The official command ttest tests that a single variable has the same mean within thetwo groups defined by groupvar, while another official command median do similar things for group medians.ttable3 performs ttest for a group of variables specified in varlist with formatted table output.When median option is specified, it performs median test.
范例:
* t-test sysuse auto,clear ttable3 price wei len mpg, by(foreign) ttable3 price wei len mpg, by(foreign) f(%8.2f) Two-sample t test with equal variances--------------------------------------------------------------------------Variables G1(Domestic) Mean1 G2(Foreign) Mean2 MeanDiff--------------------------------------------------------------------------price 52 6072.42 22 6384.68 -312.26weight 52 3317.12 22 2315.91 1001.21***length 52 196.13 22 168.55 27.59***mpg 52 19.83 22 24.77 -4.95***-------------------------------------------------------------------------- * Median test ttable3 price wei len mpg, by(foreign) medianNonparametric equality-of-medians test--------------------------------------------------------------------------Variables G1(Domestic) Median1 G2(Foreign) Median2 Chi2--------------------------------------------------------------------------price 52 4782.500 22 5759.000 2.329weight 52 3360.000 22 2180.000 25.874***length 52 200.000 22 170.000 25.874***mpg 52 19.000 22 24.500 10.268***--------------------------------------------------------------------------* Restrict to two-groups tab rep78 ttable3 price wei len mpg if rep78==3|rep78==4, by(rep78)使用方法: