Description Usage Arguments Details Value Null Hypothesis Test Assumptions Confidence Intervals Author(s) References See Also Examples
Performs a onesample, twosample, or a Welch modified twosample
ttest based on user supplied summary information. Output is identical to that
produced with t.test
.
1 2 3 
mean.x 
a single number representing the sample mean of 
s.x 
a single number representing the sample standard deviation for 
n.x 
a single number representing the sample size for 
mean.y 
a single number representing the sample mean of 
s.y 
a single number representing the sample standard deviation for 
n.y 
a single number representing the sample size for 
alternative 
is a character string, one of 
mu 
is a single number representing the value of the mean or difference in means specified by the null hypothesis. 
var.equal 
logical flag: if 
conf.level 
is the confidence level for the returned confidence interval; it must lie between zero and one. 
If y
is NULL
, a onesample ttest is
carried out with x
. If y is not NULL
, either a standard or
Welch modified twosample ttest is performed, depending on whether var.equal
is TRUE
or FALSE
.
A list of class htest
, containing the following components:
statistic 
the tstatistic, with names attribute 
parameters 
is the degrees of freedom of the tdistribution
associated with statistic.
Component 
p.value 
the pvalue for the test. 
conf.int 
is a confidence interval (vector of length 2)
for the true mean or difference in means. The confidence level
is recorded in the attribute 
estimate 
vector of length 1 or 2, giving the sample mean(s)
or mean of differences; these estimate the corresponding population
parameters. Component 
null.value 
the value of the mean or difference in means specified by
the null hypothesis. This equals the input argument 
alternative 
records the value of the input argument alternative:

data.name 
a character string (vector of length 1) containing the names x and y for the two summarized samples. 
For the onesample ttest, the null hypothesis is that the mean of
the population from which x
is drawn is mu
. For the standard and Welch modified
twosample ttests, the null hypothesis is that the population mean for x
less that for
y
is mu
.
The alternative hypothesis in each case indicates the direction of divergence of the population
mean for x
(or difference of means for x
and y
) from mu
(i.e., "greater"
, "less"
, or "two.sided"
).
The assumption of equal population variances is central to the standard twosample ttest. This test can be misleading when population variances are not equal, as the null distribution of the test statistic is no longer a tdistribution. If the assumption of equal variances is doubtful with respect to a particular dataset, the Welch modification of the ttest should be used.
The ttest and the associated confidence interval are quite robust with respect to level toward heavytailed nonGaussian distributions (e.g., data with outliers). However, the ttest is nonrobust with respect to power, and the confidence interval is nonrobust with respect to average length, toward these same types of distributions.
For each of the above tests, an expression for the
related confidence interval (returned component conf.int
) can be obtained in the usual
way by inverting the expression for the test statistic. Note that, as explained
under the description of conf.int
, the confidence interval will be halfinfinite when
alternative is not "two.sided"
; infinity will be represented by Inf
.
Alan T. Arnholt
Kitchens, L.J. (2003). Basic Statistics and Data Analysis. Duxbury.
Hogg, R. V. and Craig, A. T. (1970). Introduction to Mathematical Statistics, 3rd ed. Toronto, Canada: Macmillan.
Mood, A. M., Graybill, F. A. and Boes, D. C. (1974). Introduction to the Theory of Statistics, 3rd ed. New York: McGrawHill.
Snedecor, G. W. and Cochran, W. G. (1980). Statistical Methods, 7th ed. Ames, Iowa: Iowa State University Press.
1 2 3 4 5 
Loading required package: e1071
Loading required package: MASS
Loading required package: lattice
[1] 4.72 2.22
attr(,"conf.level")
[1] 0.95
Onesample tTest
data: Summarized x
t = 2.5952, df = 24, pvalue = 0.01588
alternative hypothesis: true mean is not equal to 2.5
95 percent confidence interval:
2.807067 5.192933
sample estimates:
mean of x
4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.