View source: R/describes_functions.R
mean_change | R Documentation |
mean_change
tests for mean change across two timepoints with a
dependent two-samples t-test. The function also calculates the descriptive
statistics for the timepoints and the standardized mean difference (i.e.,
Cohen's d) based on either the standard deviation of the pre-timepoint,
pooled standard deviation of the pre-timepoint and post-timepoint, or the
standard deviation of the change score (post - pre). mean_change
is
simply a wrapper for t.test
plus some extra
calculations.
mean_change(
pre,
post,
standardizer = "pre",
d.ci.type = "unbiased",
ci.level = 0.95,
check = TRUE
)
pre |
numeric vector of the variable at the pre-timepoint. |
post |
numeric vector of the variable at the post-timepoint. The
elements must correspond to the same cases in |
standardizer |
chararacter vector of length 1 specifying what to use for standardization when computing the standardized mean difference (i.e., Cohen's d). There are three options: 1. "pre" for the standard deviation of the pre-timepoint, 2. "pooled" for the pooled standard deviation of the pre-timepoint and post-timepoint, 3. "change" for the standard deviation of the change score (post - pre). The default is "pre", which I believe makes the most theoretical sense (see Cumming, 2012); however, "change" is the traditional choice originally proposed by Jacob Cohen (Cohen, 1988). |
d.ci.type |
character vector of lenth 1 specifying how to compute the
confidence interval (and standard error) of the standardized mean
difference. There are currently two options: 1. "unbiased" which calculates
the unbiased standard error of Cohen's d based on the formulas in
Viechtbauer (2007). If |
ci.level |
double vector of length 1 specifying the confidence level.
|
check |
logical vector of length 1 specifying whether the input
arguments should be checked for errors. For example, checking whether
|
mean_change
calculates the mean change as post
- pre
such that increases over time have a positive mean change estimate and
decreases over time have a negative mean change estimate. This would be as if
the post-timepoint was x
and the pre-timepoint was y
in
t.test(paired = TRUE)
.
list of numeric vectors containing statistical information about the mean change: 1) nhst = dependent two-samples 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 = dependent two-samples t-test stat info in a numeric vector
mean change estimate (i.e., post - pre)
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 the post variable
mean of the pre variable
standard deviation of of the post variable
standard deviation of the pre variable
sample size of the change score
Pearson correlation between the pre and post variables
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
Cohen, J. (1988). Statistical power analysis for the behavioral sciences, 2nd ed. Hillsdale, NJ: Erlbaum.
Cumming, G. (2012). Understanding the new statistics: Effect sizes, confidence intervals, and meta-analysis. New York, NY: Rouledge.
Viechtbauer, W. (2007). Approximate confidence intervals for standardized effect sizes in the two-independent and two-dependent samples design. Journal of Educational and Behavioral Statistics, 32(1), 39-60.
means_change
for multiple sets of prepost pairs of variables,
t.test
the workhorse for mean_change
,
mean_diff
for a independent two-samples t-test,
mean_test
for a one-sample t-test,
# dependent two-sample t-test
mean_change(pre = mtcars$"disp", post = mtcars$"hp") # standardizer = "pre"
mean_change(pre = mtcars$"disp", post = mtcars$"hp", d.ci.type = "classic")
mean_change(pre = mtcars$"disp", post = mtcars$"hp", standardizer = "pooled")
mean_change(pre = mtcars$"disp", post = mtcars$"hp", ci.level = 0.99)
mean_change(pre = mtcars$"hp", post = mtcars$"disp",
ci.level = 0.99) # note, when flipping pre and post, the cohen's d estimate
# changes with standardizer = "pre" because the "pre" variable is different.
# This does not happen for standardizer = "pooled" or "change". For example...
mean_change(pre = mtcars$"disp", post = mtcars$"hp", standardizer = "pooled")
mean_change(pre = mtcars$"hp", post = mtcars$"disp", standardizer = "pooled")
mean_change(pre = mtcars$"disp", post = mtcars$"hp", standardizer = "change")
mean_change(pre = mtcars$"hp", post = mtcars$"disp", standardizer = "change")
# same as intercept-only regression with the change score
mean_change(pre = mtcars$"disp", post = mtcars$"hp")
lm_obj <- lm(hp - disp ~ 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.