Stata 11 help for ttest

help ttest, ttesti dialogs: one-sample two-sample, paired two-sample, unpaired two-sample, by() immediate dialogs: one-sample two-sample -------------------------------------------------------------------------------

Title

[R] ttest -- Mean-comparison tests

Syntax

One-sample mean-comparison test

ttest varname == # [if] [in] [, level(#)]

Two-sample mean-comparison test (unpaired)

ttest varname1 == varname2 [if] [in], unpaired [unequal welch level(#)]

Two-sample mean-comparison test (paired)

ttest varname1 == varname2 [if] [in] [, level(#)]

Two-group mean-comparison test

ttest varname [if] [in] , by(groupvar) [options1]

Immediate form of one-sample mean-comparison test

ttesti #obs #mean #sd #val [, level(#)]

Immediate form of two-sample mean-comparison test

ttesti #obs1 #mean1 #sd1 #obs2 #mean2 #sd2 [, options2]

options1 description ------------------------------------------------------------------------- Main * by(groupvar) variable defining the groups unequal unpaired data have unequal variances welch use Welch's approximation level(#) set confidence level; default is level(95) ------------------------------------------------------------------------- * by(groupvar) is required.

options2 description ------------------------------------------------------------------------- Main unequal unpaired data have unequal variances welch use Welch's approximation level(#) set confidence level; default is level(95) -------------------------------------------------------------------------

Menu

one-sample

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > One-sample mean-comparison test

two-sample, unpaired

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > Two-sample mean-comparison test

two-sample, paired

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > Mean-comparison test, paired data

two-group

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > Two-group mean-comparison test

immediate command: one-sample

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > One-sample mean-comparison calculator

immediate command: two-sample

Statistics > Summaries, tables, and tests > Classical tests of hypotheses > Two-sample mean-comparison calculator

Description

ttest performs t tests on the equality of means. In the first form, ttest tests that varname has a mean of #. In the second form, ttest tests that varname1 and varname2 have the same mean, assuming unpaired data. In the third form, ttest tests that varname1 and varname2 have the same mean, assuming paired data. In the fourth form, ttest tests that varname has the same mean within the two groups defined by groupvar.

ttesti is the immediate form of ttest; see immed.

For the equivalent of a two-sample t test with sampling weights (pweights), use the svy: mean command with the over() option, and then use lincom; also see [SVY] svy postestimation.

Options

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

by(groupvar) specifies the groupvar that defines the two groups that ttest will use to test the hypothesis that their means are equal. Specifying groupvar implies an unpaired (two sample) t test. Do not confuse the by() option with the by prefix; you can specify both.

unpaired specifies that the data are to be treated as unpaired. The unpaired option is used when the two set of values to be compared are in different variables.

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.

level(#) specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level.

Examples

. sysuse auto (setup) . ttest mpg==20 (one-sample mean-comparison test)

. webuse fuel (setup) . ttest mpg1==mpg2 (two-sample mean-comparison test)

. webuse fuel3 (setup) . ttest mpg, by(treated) (two-group mean-comparison test)

(no setup required) . ttesti 24 62.6 15.8 75 (immediate form; n=24, m=62.6, sd=15.8; test m=75)

Saved results

ttest and ttesti save the following in r():

Scalars r(N_1) sample size n_1 r(N_2) sample size n_2 r(p_l) lower one-sided p-value r(p_u) upper one-sided p-value r(p) two-sided p-value r(se) estimate of standard error r(t) t statistic r(sd_1) standard deviation for first variable r(sd_2) standard deviation for second variable r(mu_1) x_1 bar, mean for population 1 r(mu_2) x_2 bar, mean for population 2 r(df_t) degrees of freedom

References

Satterthwaite, F. E. 1946. An approximate distribution of estimates of variance components. Biometrics Bulletin 2: 110-114.

Welch, B. L. 1947. The generalization of `student's' problem when several different population variances are involved. Biometrika 34: 28-35.

Also see

Manual: [R] ttest

Help: [R] bitest, [R] ci, [MV] hotelling, [R] mean, [R] oneway, [R] prtest, [R] sdtest


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