help for ttable3 (blog)

Title

ttable3 -- Mean or Median Comparison for a lot of variables between two groups with formatted table output

Syntax

ttable3 varlist [if] [in], by(varlist:groupvar)
[
format:(%fmt)
unequal
welch
median
rowname
notitle
nostar
tvalue
pvalue
]

Description

The official command ttest tests that a single variable has the same mean
within the two 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 is specified, it performs median test.

Options

by(varlist:groupvar) specifies the groupvar that defines the two
groups that ttable3 will use to test the hypothesis that their means (medians) are
equal. Specifying by(groupvar) implies an unpaired (two sample) t test or median test.

format(%fmt)
specify the display format for group means and their difference; default format is %8.3f.

unequal specifies that the unpaired data not be assumed to have equal
variances.

welch specifies that the approximate degrees of freedom for the test
be obtained from Welch's formula
(1947) rather than Satterthwaite's approximation
formula (1946), which is the default when unequal
is specified. Specifying welch implies unequal.

median causes ttable3 to perform a nonparametric 2-sample test on the equality of medians.
It tests the null hypothesis that the two 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. see [R] median

notitle suppress title in the table header. It is helpful when logout is used to export results to Excel or Word format.

nostar will not display stars(*) on the screen if it is specified

tvalue/pvalue specifies whether Stata will report the t-value/p-value or not

Examples

The auto data

* t-test

. sysuse auto,clear

. ttable3 price wei len mpg, by(foreign)

. ttable3 price wei len mpg, by(foreign) f(%8.2f)

* Median test

. ttable3 price wei len mpg, by(foreign) median

* Restrict to two-groups

. tab rep78

. ttable3 price wei len mpg if rep78==3|rep78==4, by(rep78)

* Report t-value and ommit the satrs

. ttable3 price wei len mpg, by(foreign) nostar tvalue

Save in Excel or Word

you can use the user-written logout command to export the results into Excel or Word:

. logout, save(Tab2_corr) excel replace: ttable3 price wei len mpg, by(foreign) notitle

Acknowledgements

codes from ttable2 by Xuan Zhang and Chuntao Li have been incorporated for t-test.

Any comments will be appreciated

Author

Yujun,Lian (arlionn) Department of Finance, Lingnan College, Sun Yat-Sen University.

E-mail: arlionn@163.com.

Blog: https://www.lianxh.cn

Also see

Online: [R] ttest [R] median

Also see

Online:
ttest,
median,
ttable2 (if installed),
covbal (if installed),
dmout (if installed),
t2docx (if installed),
baselinetable (if installed)