Stata commands to test equality of mean and median

DataCommand to Test Equality of MeanCommand to Test Equality of Median
Paired or matchedPaired t test:
ttest var1 = var2
Wilcoxon matched-pairs signed-rank test:
signrank var1 = var2

Sign test of matched pairs:
signtest var1 = var2
Unpaired or unmatchedTwo-sample t test:
ttest var, by(groupvar)
Wilcoxon rank-sum test or Mann_Whitney test:
ranksum var, by(groupvar)

K-sample equality-of-medians test:
median var, by(groupvar)

Please read this post for how to display the results in a ready-for-use format.

UCLA IDRE has posted an article (link) that may provide a bit more explanation. UCLA IDRE is a great resource for learning statistical analysis. A big thank you to them.

This entry was posted in Stata. Bookmark the permalink.

2 Responses to Stata commands to test equality of mean and median

  1. Helen says:

    Hi Kai, I am currently using the following code to compare the statistical difference for the coefficient between two subsamples.

    qui reg DepVar IndVar if LOSS==1
    est store m1

    qui reg DepVar IndVar if LOSS==0
    est store m2

    suest m1 m2, cluster(firm)
    test [m1_mean]IndVar-[m2_mean]IndVar=0

    Is there a way that I can include both fixed effects (year fixed and industry fixed effects) and firm cluster in this setting? Since in other full sample tests, I use reghdfe DepVar IndVar, absorb (industry year) cluster(firm).

    Thank you in advance!

Leave a Reply to Helen Cancel reply

Your email address will not be published. Required fields are marked *