Performs a one-sample, two-sample, or a Welch modified two-sample t-test based on user supplied summary information. Output is identical to that produced with t.test.

tsum.test(
  mean.x,
  s.x = NULL,
  n.x = NULL,
  mean.y = NULL,
  s.y = NULL,
  n.y = NULL,
  alternative = c("two.sided", "less", "greater"),
  mu = 0,
  var.equal = FALSE,
  conf.level = 0.95,
  ...
)

Arguments

mean.x

a single number representing the sample mean of x

s.x

a single number representing the sample standard deviation of x

n.x

a single number representing the sample size of x

mean.y

a single number representing the sample mean of y

s.y

a single number representing the sample standard deviation of y

n.y

a single number representing the sample size of y

alternative

is a character string, one of "greater", "less", or "two.sided", or just the initial letter of each, indicating the specification of the alternative hypothesis. For one-sample tests, alternative refers to the true mean of the parent population in relation to the hypothesized value mu. For the standard two-sample tests, alternative refers to the difference between the true population mean for x and that for y, in relation to mu. For the one-sample and paired t-tests, alternative refers to the true mean of the parent population in relation to the hypothesized value mu. For the standard and Welch modified two-sample t-tests, alternative refers to the difference between the true population mean for x and that for y, in relation to mu. For the one-sample t-tests, alternative refers to the true mean of the parent population in relation to the hypothesized value mu. For the standard and Welch modified two-sample t-tests, alternative refers to the difference between the true population mean for x and that for y, in relation to mu.

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 TRUE, the variances of the parent populations of x and y are assumed equal. Argument var.equal should be supplied only for the two-sample tests.

conf.level

is the confidence level for the returned confidence interval; it must lie between zero and one.

...

Other arguments passed onto tsum.test()

Value

A list of class htest, containing the following components:

statistic

the t-statistic, with names attribute "t"

parameters

is the degrees of freedom of the t-distribution associated with statistic. Component parameters has names attribute "df".

p.value

the p-value 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 conf.level. When alternative is not "two.sided", the confidence interval will be half-infinite, to reflect the interpretation of a confidence interval as the set of all values k for which one would not reject the null hypothesis that the true mean or difference in means is k . Here infinity will be represented by Inf.

estimate

is a vector of length 1 or 2, giving the sample mean(s) or mean of differences; these estimate the corresponding population parameters. Component estimate has a names attribute describing its elements.

null.value

is the value of the mean or difference in means specified by the null hypothesis. This equals the input argument mu. Component null.value has a names attribute describing its elements.

alternative

records the value of the input argument alternative: "greater" , "less" or "two.sided".

data.name

is a character string (vector of length 1) containing the names x and y for the two summarized samples.

Details

If y is NULL, a one-sample t-test is carried out with x. If y is not NULL, either a standard or Welch modified two-sample t-test is performed, depending on whether var.equal is TRUE or FALSE.

Null Hypothesis

For the one-sample t-test, the null hypothesis is that the mean of the population from which x is drawn is mu. For the standard and Welch modified two-sample t-tests, 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").

Test Assumptions

The assumption of equal population variances is central to the standard two-sample t-test. This test can be misleading when population variances are not equal, as the null distribution of the test statistic is no longer a t-distribution. If the assumption of equal variances is doubtful with respect to a particular dataset, the Welch modification of the t-test should be used.

The t-test and the associated confidence interval are quite robust with respect to level toward heavy-tailed non-Gaussian distributions (e.g., data with outliers). However, the t-test is non-robust with respect to power, and the confidence interval is non-robust with respect to average length, toward these same types of distributions.

Confidence Intervals

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 half-infinite when alternative is not "two.sided" ; infinity will be represented by Inf.

References

  • 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: McGraw-Hill.

  • Snedecor, G. W. and Cochran, W. G. 1980. Statistical Methods, 7th ed. Ames, Iowa: Iowa State University Press.

See also

Author

Alan T. Arnholt <arnholtat@appstate.edu>

Examples

 
# 95% Confidence Interval for mu1 - mu2, assuming equal variances
round(tsum.test(mean.x = 53/15, mean.y = 77/11, s.x=sqrt((222 - 15*(53/15)^2)/14),
s.y = sqrt((560 - 11*(77/11)^2)/10), n.x = 15, n.y = 11, var.equal = TRUE)$conf, 2)
#> [1] -4.72 -2.22
#> attr(,"conf.level")
#> [1] 0.95
# One Sample t-test
tsum.test(mean.x = 4, s.x = 2.89, n.x = 25, mu = 2.5)  
#> 
#> 	One Sample t-test
#> 
#> data:  User input summarized values for x
#> t = 2.5952, df = 24, p-value = 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 
#>