independentSamplesTTest

From lsr v0.5
0th

Percentile

Independent samples t-test

Convenience function that runs an independent samples t-test. This is a wrapper function intended to be used for pedagogical purposes only.

Usage
independentSamplesTTest(
formula, data=NULL, var.equal=FALSE,
one.sided=FALSE, conf.level=.95
)
Arguments
formula
Formula specifying the outcome and the groups (required).
data
Optional data frame containing the variables.
var.equal
Should the test assume equal variances (default = FALSE).
one.sided
One sided or two sided hypothesis test (default = FALSE)
conf.level
The confidence level for the confidence interval (default = .95).
Details

The independentSamplesTTest function runs an independent-samples t-test and prints the results in a format that is easier for novices to handle than the output of t.test. All the actual calculations are done by the t.test and cohensD functions. The formula argument must be a two-sided formula of the form outcome ~ group. When var.equal=TRUE, a Student's t-test is run and the estimate of Cohen's d uses a pooled estimate of standard deviation. When var.equal=FALSE, the Welch test is used, and the estimate of Cohen's d uses the "unequal" method.

As with the t.test function, the default test is two sided, corresponding to a default value of one.sided = FALSE. To specify a one sided test, the one.sided argument must specify the name of the factor level that is hypothesised (under the alternative) to have the larger mean. For instance, if the outcome for "group2" is expected to be higher than for "group1", then the corresponding one sided test is specified by one.sided = "group2".

Warning

This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.

t.test, oneSampleTTest, pairedSamplesTTest, cohensD
library(lsr)  df <- data.frame( rt = c(451, 562, 704, 324, 505, 600, 829), cond = factor( x=c(1,1,1,2,2,2,2), labels=c("group1","group2"))) # Welch t-test independentSamplesTTest( rt ~ cond, df ) # Student t-test independentSamplesTTest( rt ~ cond, df, var.equal=TRUE ) # one sided test independentSamplesTTest( rt ~ cond, df, one.sided="group1" ) # missing data df$rt[1] <- NA df$cond[7] <- NA independentSamplesTTest( rt ~ cond, df )