ind_ttest compares the means of two independent groups in order to determine whether there is statistical evidence that the associated population means are significantly different.

ind_ttest(data, x, y, confint = 0.95, alternative = c("both", "less",
  "greater", "all"), ...)

Arguments

data
a data frame
x
grouping variable; object of type factor
y
a numeric vector
confint
confidence level
alternative
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

ind_ttest returns an object of class "ind_ttest". An object of class "ind_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

# data hsb2 <- inferr::hsb hsb2$female <- as.factor(hsb2$female) # lower tail ind_ttest(hsb2, 'female', 'write', alternative = 'less')
#> Group Statistics #> ----------------------------------------------------------------------------- #> Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> ----------------------------------------------------------------------------- #> 0 91 50.121 1.080 10.305 47.975 52.267 #> 1 109 54.991 0.779 8.134 53.447 56.535 #> ----------------------------------------------------------------------------- #> combined 200 52.775 0.67 9.479 51.454 54.096 #> ----------------------------------------------------------------------------- #> diff 200 -4.87 1.304 9.231 -7.426 -2.314 #> ----------------------------------------------------------------------------- #> #> Independent Samples Test #> ------------------------ #> #> Ho: mean(0) - mean(1) = diff = 0 #> Ha: diff < 0 #> #> --------------------------------------------------------------------- #> Variable Method Variances DF t Value P < t #> --------------------------------------------------------------------- #> write Pooled Equal 198 -3.7347 0.0001 #> write Satterthwaite Unequal 170 -3.6564 0.0002 #> --------------------------------------------------------------------- #> #> Test for Equality of Variances #> --------------------------------------------------------------- #> Variable Method Num DF Den DF F Value P > F #> --------------------------------------------------------------- #> write Folded F 90 108 1.605 0.0188 #> ---------------------------------------------------------------
# upper tail ind_ttest(hsb2, 'female', 'write', alternative = 'greater')
#> Group Statistics #> ----------------------------------------------------------------------------- #> Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> ----------------------------------------------------------------------------- #> 0 91 50.121 1.080 10.305 47.975 52.267 #> 1 109 54.991 0.779 8.134 53.447 56.535 #> ----------------------------------------------------------------------------- #> combined 200 52.775 0.67 9.479 51.454 54.096 #> ----------------------------------------------------------------------------- #> diff 200 -4.87 1.304 9.231 -7.426 -2.314 #> ----------------------------------------------------------------------------- #> #> Independent Samples Test #> ------------------------ #> #> Ho: mean(0) - mean(1) = diff = 0 #> Ha: diff > 0 #> #> --------------------------------------------------------------------- #> Variable Method Variances DF t Value P > t #> --------------------------------------------------------------------- #> write Pooled Equal 198 -3.7347 0.9999 #> write Satterthwaite Unequal 170 -3.6564 0.9998 #> --------------------------------------------------------------------- #> #> Test for Equality of Variances #> --------------------------------------------------------------- #> Variable Method Num DF Den DF F Value P > F #> --------------------------------------------------------------- #> write Folded F 90 108 1.605 0.0188 #> ---------------------------------------------------------------
# both tails ind_ttest(hsb2, 'female', 'write', alternative = 'both')
#> Group Statistics #> ----------------------------------------------------------------------------- #> Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> ----------------------------------------------------------------------------- #> 0 91 50.121 1.080 10.305 47.975 52.267 #> 1 109 54.991 0.779 8.134 53.447 56.535 #> ----------------------------------------------------------------------------- #> combined 200 52.775 0.67 9.479 51.454 54.096 #> ----------------------------------------------------------------------------- #> diff 200 -4.87 1.304 9.231 -7.426 -2.314 #> ----------------------------------------------------------------------------- #> #> Independent Samples Test #> ------------------------ #> #> Ho: mean(0) - mean(1) = diff = 0 #> Ha: diff ~= 0 #> #> --------------------------------------------------------------------- #> Variable Method Variances DF t Value P > |t| #> --------------------------------------------------------------------- #> write Pooled Equal 198 -3.7347 0.0002 #> write Satterthwaite Unequal 170 -3.6564 0.0003 #> --------------------------------------------------------------------- #> #> Test for Equality of Variances #> --------------------------------------------------------------- #> Variable Method Num DF Den DF F Value P > F #> --------------------------------------------------------------- #> write Folded F 90 108 1.605 0.0188 #> ---------------------------------------------------------------
# all tails ind_ttest(hsb2, 'female', 'write', alternative = 'all')
#> Group Statistics #> ----------------------------------------------------------------------------- #> Group Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] #> ----------------------------------------------------------------------------- #> 0 91 50.121 1.080 10.305 47.975 52.267 #> 1 109 54.991 0.779 8.134 53.447 56.535 #> ----------------------------------------------------------------------------- #> combined 200 52.775 0.67 9.479 51.454 54.096 #> ----------------------------------------------------------------------------- #> diff 200 -4.87 1.304 9.231 -7.426 -2.314 #> ----------------------------------------------------------------------------- #> #> Independent Samples Test #> ------------------------ #> #> Ho: mean(0) - mean(1) = diff = 0 #> #> Ha: diff < 0 Ha: diff ~= 0 Ha: diff > 0 #> #> Pooled #> ------------------------------------------------------------------------ #> t = -3.7347 t = -3.7347 t = -3.7347 #> P < t = 0.0001 P > |t| = 0.0002 P > t = 0.9999 #> #> Satterthwaite #> ------------------------------------------------------------------------ #> t = -3.6564 t = -3.6564 t = -3.6564 #> P < t = 0.0002 P > |t| = 0.0003 P > t = 0.9998 #> #> #> Test for Equality of Variances #> --------------------------------------------------------------- #> Variable Method Num DF Den DF F Value P > F #> --------------------------------------------------------------- #> write Folded F 90 108 1.605 0.0188 #> ---------------------------------------------------------------