mean_test {quest} | R Documentation |
Test for Sample Mean Against Mu (one-sample t-test)
Description
mean_test
computes the sample mean and compares it against a specified
population mu
value. This is sometimes referred to as a one-sample
t-test. It provides the same results as t.test
, but
provides the confidence interval for the mean difference from mu rather than
the mean itself. The function also calculates the descriptive statistics and
the standardized mean difference (i.e., Cohen's d) based on the sample
standard deviation.
Usage
mean_test(x, mu = 0, d.ci.type = "tdist", ci.level = 0.95, check = TRUE)
Arguments
x |
numeric vector. |
mu |
numeric vector of length 1 specifying the population mean value to compare the sample mean against. |
d.ci.type |
character vector with length 1 specifying the type of
confidence interval to compute for the standardized mean difference (i.e.,
Cohen's d). There are currently two options: 1. "tdist" which calculates
the confidence intervals based on the t-distribution using the function
|
ci.level |
numeric vector of length 1 specifying the confidence level. It must be between 0 and 1. |
check |
logical vector of length 1 specifying whether the input
arguments should be checked for errors. For example, checking whether
|
Value
list of numeric vectors containing statistical information about the sample mean: 1) nhst = one-sample t-test stat info in a numeric vector, 2) desc = descriptive statistics stat info in a numeric vector, 3) std = standardized mean difference stat info in a numeric vector
1) nhst = one-sample t-test stat info in a numeric vector
- est
mean - mu estimate
- se
standard error
- t
t-value
- df
degrees of freedom
- p
two-sided p-value
- lwr
lower bound of the confidence interval
- upr
upper bound of the confidence interval
2) desc = descriptive statistics stat info in a numeric vector
- mean
mean of
x
- mu
population value of comparison
- sd
standard deviation of
x
- n
sample size of
x
3) std = standardized mean difference stat info in a numeric vector
- d_est
Cohen's d estimate
- d_se
Cohen's d standard error
- d_lwr
Cohen's d lower bound of the confidence interval
- d_upr
Cohen's d upper bound of the confidence interval
See Also
means_test
one-sample t-tests for multiple variables,
t.test
same results,
mean_diff
independent two-sample t-test,
mean_change
dependent two-sample t-test,
Examples
# one-sample t-test
mean_test(x = mtcars$"mpg")
mean_test(x = attitude$"rating", mu = 50)
mean_test(x = attitude$"rating", mu = 50, d.ci.type = "classic")
# compare to t.test()
mean_test(x = attitude$"rating", mu = 50, ci.level = .99)
t.test(attitude$"rating", mu = 50, conf.level = .99)
# same as intercept-only regression when mu = 0
mean_test(x = mtcars$"mpg")
lm_obj <- lm(mpg ~ 1, data = mtcars)
coef(summary(lm_obj))