Stata 15 help for ranksum

[R] ranksum -- Equality tests on unmatched data

Syntax

Wilcoxon rank-sum test

ranksum varname [if] [in], by(groupvar) [porder]

Nonparametric equality-of-medians test

median varname [if] [in] [weight] , by(groupvar) [median_options]

ranksum_options Description ------------------------------------------------------------------------- Main * by(groupvar) grouping variable porder probability that variable for first group is larger than variable for second group -------------------------------------------------------------------------

median_options Description ------------------------------------------------------------------------- Main * by(groupvar) grouping variable exact performs Fisher's exact test medianties(below) assign values equal to the median to below group medianties(above) assign values equal to the median to above group medianties(drop) drop values equal to the median from the analysis medianties(split) split values equal to the median equally between the two groups ------------------------------------------------------------------------- * by(groupvar) is required. by is allowed with ranksum and median; see [D] by. fweights are allowed with median; see weight.

Menu

ranksum

Statistics > Nonparametric analysis > Tests of hypotheses > Wilcoxon rank-sum test

median

Statistics > Nonparametric analysis > Tests of hypotheses > K-sample equality-of-medians test

Description

ranksum tests the hypothesis that two independent samples (that is, unmatched data) are from populations with the same distribution by using the Wilcoxon rank-sum test, which is also known as the Mann-Whitney two-sample statistic (Wilcoxon 1945; Mann and Whitney 1947).

median performs a nonparametric K-sample test on the equality of medians. It tests the null hypothesis that the K samples were drawn from populations with the same median. For two samples, the chi-squared test statistic is computed both with and without a continuity correction.

ranksum and median are for use with unmatched data. For equality tests on matched data, see [R] signrank.

Options for ranksum

+------+ ----+ Main +-------------------------------------------------------------

by(groupvar) is required. It specifies the name of the grouping variable.

porder displays an estimate of the probability that a random draw from the first population is larger than a random draw from the second population.

Options for median

+------+ ----+ Main +-------------------------------------------------------------

by(groupvar) is required. It specifies the name of the grouping variable.

exact displays the significance calculated by Fisher's exact test. For two samples, both one- and two-sided probabilities are displayed.

medianties(below|above|drop|split) specifies how values equal to the overall median are to be handled. The median test computes the median for varname by using all observations and then divides the observations into those falling above the median and those falling below the median. When values for an observation are equal to the sample median, they can be dropped from the analysis by specifying medianties(drop); added to the group above or below the median by specifying medianties(above) or medianties(below), respectively; or if there is more than 1 observation with values equal to the median, they can be equally divided into the two groups by specifying medianties(split). If this option is not specified, medianties(below) is assumed.

Examples

--------------------------------------------------------------------------- Setup . webuse fuel2

Perform rank-sum test on mpg by using the two groups defined by treat . ranksum mpg, by(treat)

Same as above, but include estimate of probability that the value of mpg for an observation with treat = 0 is greater than the value of mpg for an observation with treat = 1 . ranksum mpg, by(treat) porder

Perform Pearson chi-squared test of the equality of the medians of mpg between the two groups defined by treat . median mpg, by(treat)

Perform Fisher's exact test of the equality of the medians of mpg between the two groups defined by treat . median mpg, by(treat) exact

--------------------------------------------------------------------------- Setup . webuse medianxmpl

Perform Pearson chi-squared test of the equality of the medians of age between the two groups defined by gender . median age, by(gender)

Same as above command . median age, by(gender) medianties(below)

Same as above command, but for observations with values of age equal to the median, put them in the group above the median . median age, by(gender) medianties(above)

Same as above command, but drop observations with values of age equal to the median . median age, by(gender) medianties(drop)

Same as above command, but for observations with values of age equal to the median, divide them equally between the two groups . median age, by(gender) medianties(split) ---------------------------------------------------------------------------

Stored results

ranksum stores the following in r():

Scalars r(N_1) sample size n_1 r(N_2) sample size n_2 r(z) z statistic r(Var_a) adjusted variance r(group1) value of variable for first group r(sum_obs) actual sum of ranks for first group r(sum_exp) expected sum of ranks for first group r(porder) probability that draw from first population is larger than draw from second population

median stores the following in r():

Scalars r(N) sample size r(chi2) Pearson's chi-squared test r(p) p-value for Pearson's chi-squared test r(p_exact) Fisher's exact p r(groups) number of groups compared r(chi2_cc) continuity-corrected Pearson's chi-squared r(p_cc) continuity-corrected p-value r(p1_exact) one-sided Fisher's exact p

References

Mann, H. B., and D. R. Whitney. 1947. On a test whether one of two random variables is stochastically larger than the other. Annals of Mathematical Statistics 18: 50-60.

Wilcoxon, F. 1945. Individual comparisons by ranking methods. Biometrics 1: 80-83.


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index