ttest performs t tests on the equality of means. It tests the hypothesis that a sample has a mean equal to a hypothesized value.

ttest(x, mu = 0, alpha = 0.05, type = c("both", "less", "greater", "all"),
  ...)

Arguments

x
a numeric vector
mu
a number indicating the true value of the mean
alpha
acceptable tolerance for type I error
type
a character string specifying the alternative hypothesis, must be one of "both" (default), "greater", "less" or "all". You can specify just the initial letter
...
additional arguments passed to or from other methods

Value

ttest returns an object of class "ttest". An object of class "ttest" is a list containing the following components:

References

Sheskin, D. J. 2007. Handbook of Parametric and Nonparametric Statistical Procedures, 4th edition. : Chapman & Hall/CRC.

See also

t.test

Examples

# lower tail ttest(hsb$write, mu = 50, type = 'less')
#> One-Sample Statistics #> --------------------------------------------------------------------------------- #> Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> --------------------------------------------------------------------------------- #> write 200 52.775 0.6702 9.4786 -Inf 53.8828 #> --------------------------------------------------------------------------------- #> #> Lower Tail Test #> --------------- #> #> Ho: mean(write) >=50 #> Ha: mean(write) <50 #> -------------------------------------------------------------------------------- #> Variable t DF Sig Mean Diff. [95% Conf. Interval] #> -------------------------------------------------------------------------------- #> write 4.141 199 0.99997 2.775 -Inf 3.8828 #> --------------------------------------------------------------------------------
# upper tail ttest(hsb$write, mu = 50, type = 'greater')
#> One-Sample Statistics #> --------------------------------------------------------------------------------- #> Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> --------------------------------------------------------------------------------- #> write 200 52.775 0.6702 9.4786 51.6678 Inf #> --------------------------------------------------------------------------------- #> #> Upper Tail Test #> --------------- #> #> Ho: mean(write) <=50 #> Ha: mean(write) >50 #> -------------------------------------------------------------------------------- #> Variable t DF Sig Mean Diff. [95% Conf. Interval] #> -------------------------------------------------------------------------------- #> write 4.141 199 0.99997 2.775 1.6678 Inf #> --------------------------------------------------------------------------------
# both tails ttest(hsb$write, mu = 50, type = 'both')
#> One-Sample Statistics #> --------------------------------------------------------------------------------- #> Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> --------------------------------------------------------------------------------- #> write 200 52.775 0.6702 9.4786 51.4537 54.0969 #> --------------------------------------------------------------------------------- #> #> Two Tail Test #> --------------- #> #> Ho: mean(write) ~=50 #> Ha: mean(write) !=50 #> -------------------------------------------------------------------------------- #> Variable t DF Sig Mean Diff. [95% Conf. Interval] #> -------------------------------------------------------------------------------- #> write 4.141 199 0.99997 2.775 1.4537 4.0969 #> --------------------------------------------------------------------------------
# all tails ttest(hsb$write, mu = 50, type = 'all')
#> One-Sample Statistics #> --------------------------------------------------------------------------------- #> Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> --------------------------------------------------------------------------------- #> write 200 52.775 0.6702 9.4786 51.4537 54.0969 #> --------------------------------------------------------------------------------- #> #> Ho: mean(write) ~=50 #> #> Ha: mean < 50 Ha: mean ~= 50 Ha: mean > 50 #> t = 4.141 t = 4.141 t = 4.141 #> P < t = 1.0000 P > |t| = 0.0001 P > t = 0.0000