Section author: Ravi Selker, Jonathon Love, Damian Dropmann
One Sample T-Test
(ttestOneS)
Description
The Student’s One-sample t-test is used to test the null hypothesis that the true mean is equal to a particular value (typically zero). A low p-value suggests that the null hypothesis is not true, and therefore the true mean must be different from the test value.
Usage
ttestOneS(
data,
vars,
students = TRUE,
bf = FALSE,
bfPrior = 0.707,
wilcoxon = FALSE,
testValue = 0,
hypothesis = "dt",
norm = FALSE,
qq = FALSE,
meanDiff = FALSE,
ci = FALSE,
ciWidth = 95,
effectSize = FALSE,
ciES = FALSE,
ciWidthES = 95,
desc = FALSE,
plots = FALSE,
miss = "perAnalysis",
mann = FALSE
)
Arguments
|
the data as a data frame |
|
a vector of strings naming the variables of interest in |
|
|
|
|
|
a number between 0.5 and 2.0 (default 0.707), the prior width to use in calculating Bayes factors |
|
|
|
a number specifying the value of the null hypothesis |
|
|
|
|
|
|
|
|
|
|
|
a number between 50 and 99.9 (default: 95), the width of confidence intervals |
|
|
|
|
|
a number between 50 and 99.9 (default: 95), the width of confidence intervals for the effect sizes |
|
|
|
|
|
|
Details
The Student’s One-sample t-test assumes that the data are from a normal distribution – in the case that one is unwilling to assume this, the non-parametric Wilcoxon signed-rank can be used in it’s place (however, note that the Wilcoxon signed-rank has a slightly different null hypothesis; that the median is equal to the test value).
Output
A results object containing:
|
a table containing the t-test results |
|
a table containing the normality test results |
|
a table containing the descriptives |
|
an image of the descriptive plots |
|
an array of Q-Q plots |
Tables can be converted to data frames with asDF or as.data.frame(). For example:
results$ttest$asDF
as.data.frame(results$ttest)
Examples
data('ToothGrowth')
ttestOneS(ToothGrowth, vars = vars(len, dose))
#
# ONE SAMPLE T-TEST
#
# One Sample T-Test
# ------------------------------------------------------
# statistic df p
# ------------------------------------------------------
# len Student's t 19.1 59.0 < .001
# dose Student's t 14.4 59.0 < .001
# ------------------------------------------------------
#