View source: R/describes_functions.R
mean_test | R Documentation |
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.
mean_test(x, mu = 0, d.ci.type = "tdist", ci.level = 0.95, check = TRUE)
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
|
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
mean - mu estimate
standard error
t-value
degrees of freedom
two-sided p-value
lower bound of the confidence interval
upper bound of the confidence interval
2) desc = descriptive statistics stat info in a numeric vector
mean of x
population value of comparison
standard deviation of x
sample size of x
3) std = standardized mean difference stat info in a numeric vector
Cohen's d estimate
Cohen's d standard error
Cohen's d lower bound of the confidence interval
Cohen's d upper bound of the confidence interval
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,
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.