📄 ttest.hlp
字号:
{smcl}
{* 18mar2005}{...}
{cmd:help ttest, ttesti}{...}
{right:dialogs: {bf:{dialog ttest1:one-sample}} {bf:{dialog ttestpair:one-sample, paired}}}
{right:{bf:{dialog ttest2:two-sample}} {bf:{dialog ttestby:two-sample, by()}}{space 2}}
{right:immediate dialogs: {bf:{dialog ttesti1:one-sample}} {bf:{dialog ttesti2:two-sample}}{space 8}}
{hline}
{title:Title}
{p2colset 5 18 20 2}{...}
{p2col:{hi:[R] ttest} {hline 2}}Mean comparison tests{p_end}
{p2colreset}{...}
{title:Syntax}
{pstd}
One-sample mean comparison test
{p 8 14 2}
{cmd:ttest}
{varname}
{cmd:==}
{it:#}
{ifin}
[{cmd:,} {opt l:evel(#)}]
{pstd}
Two-sample mean comparison test
{p 8 14 2}
{cmd:ttest}
{varname:1}
{cmd:==}
{varname:2}
{ifin}
[{cmd:,}
{it:{help ttest##options1:options1}}]
{pstd}
Group mean comparison test
{p 8 14 2}
{cmd:ttest}
{varname}
{ifin}
{cmd:,}
{opt by(groupvar)}
[{it:{help ttest##options2:options2}}]
{pstd}
Immediate form of one-sample mean comparison test
{p 8 14 2}
{cmd:ttesti}
{it:#obs}
{it:#mean}
{it:#sd}
{it:#val}
[{cmd:,}
{opt l:evel(#)}]
{pstd}
Immediate form of two-sample mean comparison test
{p 8 14 2}
{cmd:ttesti}
{it:#obs1}
{it:#mean1}
{it:#sd1}
{it:#obs2}
{it:#mean2}
{it:#sd2}
[{cmd:,}
{it:{help ttest##options3:options3}}]
{synoptset 16 tabbed}{...}
{marker options1}{...}
{synopthdr:options1}
{synoptline}
{syntab:Main}
{synopt:{opt unp:aired}}treat data as unpaired{p_end}
{synopt:{opt une:qual}}unpaired data have unequal variances{p_end}
{synopt:{opt w:elch}}use Welch's approximation{p_end}
{synopt:{opt l:evel(#)}}set confidence level; default is {cmd:level(95)}{p_end}
{synoptline}
{marker options2}{...}
{synopthdr:options2}
{synoptline}
{syntab:Main}
{p2coldent:* {opt by(groupvar)}}variable defining the groups{p_end}
{synopt:{opt une:qual}}unpaired data have unequal variances{p_end}
{synopt:{opt w:elch}}use Welch's approximation{p_end}
{synopt:{opt l:evel(#)}}set confidence level; default is {cmd:level(95)}{p_end}
{synoptline}
{p 4 6 2}* {opt by(groupvar)} is required.{p_end}
{marker options3}{...}
{synopthdr:options3}
{synoptline}
{syntab:Main}
{synopt:{opt une:qual}}unpaired data have unequal variances{p_end}
{synopt:{opt w:elch}}use Welch's approximation{p_end}
{synopt:{opt l:evel(#)}}set confidence level; default is {cmd:level(95)}{p_end}
{synoptline}
{p2colreset}{...}
{title:Description}
{pstd}
{opt ttest} performs t tests on the equality of means. In the first form,
{opt ttest} tests that {varname} has a mean of {it:#}.
In the second form, {opt ttest} tests that {it:varname1} and {it:varname2}
have the same mean. Data are assumed to be paired, but specifying
{opt unpaired} changes this assumption. In the third form, {opt ttest} tests
that {it:varname} has the same mean within the two groups defined by
{it:groupvar}.
{pstd}
{opt ttesti} is the immediate form of {opt ttest}; see {help immed}.
{pstd}
For the equivalent of a two-sample t test with sampling weights
({opt pweight}s), use the {helpb "svy:mean"} command with the {opt by()}
option, and then use {helpb lincom}; also see {help svy postestimation}.
{title:Options}
{dlgtab:Main}
{phang}
{opt by(groupvar)} specifies the {it:groupvar} that defines the two groups
that {opt ttest} will use to test the hypothesis that their means are
equal. Specifying {it:groupvar} implies an unpaired (two-sample) t test.
Do not confuse the {opt by()} option with the {cmd:by} prefix; you can
specify both.
{phang}
{opt unpaired} specifies that the data are to be treated as unpaired. The
{opt unpaired} option is used when the two set of values to be compared are
in different variables.
{phang}
{opt unequal} specifies that the unpaired data not be assumed to have equal
variances.
{phang}
{opt welch} specifies that the approximate degrees of freedom for the test
be obtained from Welch's formula rather than Satterthwaite's approximation
formula, which is the default when {opt unequal} is specified. Specifying
{opt welch} implies specifying {opt unequal}.
{phang}
{opt level(#)} specifies the confidence level, as a percentage, for confidence
intervals. The default is {cmd:level(95)} or as set by {helpb set level}.
{title:Examples}
{phang}{cmd:. ttest mpg == 20}{p_end}
{phang}{cmd:. ttest mpg1 == mpg2}{p_end}
{phang}{cmd:. ttest mpg1 == mpg2, unpaired}{p_end}
{phang}{cmd:. ttest mpg, by(treated)}{p_end}
{phang}{cmd:. ttest mpg, by(treated) unequal}
{phang}{cmd:. ttesti 24 62.6 15.8 75} (n=24,m=62.6,sd=15.8; test m=75){p_end}
{phang}{cmd:. ttesti 20 20 5 32 15 4} (n1=20,m1=20,sd1=5; n2=32,m2=15,sd2=4; test m1=m2)
{title:Also see}
{psee}
Manual: {bf:[R] ttest}
{psee}
Online:
{helpb bitest},
{helpb ci},
{helpb hotelling},
{helpb oneway},
{helpb prtest},
{helpb sdtest},
{helpb signrank},
{help svy postestimation},
{helpb "svy: mean"}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -