lsr (version 0.5)

oneSampleTTest: One sample t-test

Description

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

Usage

oneSampleTTest( 
	x, mu, one.sided=FALSE, conf.level=.95 
)

Arguments

x

The variable to be tested (required).

mu

The value against which the mean should be tested (required).

one.sided

One sided or two sided hypothesis test (default = FALSE)

conf.level

The confidence level for the confidence interval (default = .95).

Value

An object of class 'TTest'. When printed, the output is organised into five short sections. The first section lists the name of the test and the variables included. The second provides means and standard deviations. The third states explicitly what the null and alternative hypotheses were. The fourth contains the test results: t-statistic, degrees of freedom and p-value. The final section includes the relevant confidence interval and an estimate of the effect size (i.e., Cohen's d).

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.

Details

The oneSampleTTest function runs a one-sample t-test on the data in x, 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.

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 in which the alternative hypothesis is that x is larger than mu, the input must be one.sided = "greater". Similarly, if one.sided="less", then the alternative hypothesis is that the mean of x is smaller than mu.

See Also

t.test, pairedSamplesTTest, independentSamplesTTest, cohensD

Examples

Run this code
# NOT RUN {
likert <- c(3,1,4,1,4,6,7,2,6,6,7)

oneSampleTTest( x = likert, mu = 4 ) 
oneSampleTTest( x = likert, mu = 4, one.sided = "greater" ) 
oneSampleTTest( x = likert, mu = 4, conf.level=.99 ) 

likert <- c(3,NA,4,NA,4,6,7,NA,6,6,7)
oneSampleTTest( x = likert, mu = 4 ) 

# }

Run the code above in your browser using DataLab