means_change {quest} | R Documentation |
Mean Changes Across Two Timepoints For Multiple PrePost Pairs of Variables (dependent two-samples t-tests)
Description
means_change
tests for mean changes across two timepoints for multiple
prepost pairs of variables via dependent two-samples t-tests. The function
also calculates the descriptive statistics for the timepoints and the
standardized mean differences (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). means_change
is simply a wrapper for
t.test
plus some extra calculations.
Usage
means_change(
data,
prepost.nm.list,
standardizer = "pre",
d.ci.type = "unbiased",
ci.level = 0.95,
check = TRUE
)
Arguments
data |
data.frame of data. |
prepost.nm.list |
list of length-2 character vectors specifying the
colnames from |
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 intervals (and standard errors) of the standardized mean
differences. 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
|
Details
For each prepost pair of variables, means_change
calculates the mean
change as data[[ prepost.nm.list[[i]][2] ]]
- data[[
prepost.nm.list[[i]][1] ]]
(which corresponds to 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 y
in
t.test(paired = TRUE)
.
Value
list of data.frames containing statistical information about the mean
change for each prepost pair of variables (the rownames of the data.frames
are the names of prepost.nm.list
): 1) nhst = dependent two-samples
t-test stat info in a data.frame, 2) desc = descriptive statistics stat info
in a data.frame, 3) std = standardized mean difference stat info in a data.frame,
1) nhst = dependent two-samples t-test stat info in a data.frame
- est
mean change estimate (i.e., post - pre)
- 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 data.frame
- mean_post
mean of the post variable
- mean_pre
mean of the pre variable
- sd_post
standard deviation of of the post variable
- sd_pre
standard deviation of the pre variable
- n
sample size of the change score
- r
Pearson correlation between the pre and post variables
3) std = standardized mean difference stat info in a data.frame
- 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
References
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.
See Also
mean_change
for a single pair of prepost variables,
t.test
fixes the table of contents for some unknown reason,
means_diff
for multiple independent two-sample t-tests,
means_test
for multiple one-sample t-tests,
Examples
# dependent two-sample t-tests
prepost_nm_list <- list("first_pair" = c("disp","hp"), "second_pair" = c("carb","gear"))
means_change(mtcars, prepost.nm.list = prepost_nm_list)
means_change(mtcars, prepost.nm.list = prepost_nm_list, d.ci.type = "classic")
means_change(mtcars, prepost.nm.list = prepost_nm_list, standardizer = "change")
means_change(mtcars, prepost.nm.list = prepost_nm_list, ci.level = 0.99)
# same as intercept-only regression with the change score
means_change(data = mtcars, prepost.nm.list = c("disp","hp"))
lm_obj <- lm(hp - disp ~ 1, data = mtcars)
coef(summary(lm_obj))