Calculates Cohen's d for two sample comparisons.
effect_size_t( data, response, group, absolute = FALSE, paired = FALSE, na.rm = TRUE )
A data.frame.
data.frame
The response variable (dependent).
The group variable, usually a factor.
factor
If set to TRUE, the absolute effect size is returned.
TRUE
Whether the effect should be calculated for a paired t-test, default is FALSE.
FALSE
If TRUE (default), missing values are dropped.
numeric of length 1.
numeric
The effect size here is Cohen's d as calculated by \(d = \frac{m_{diff}}{S_p}\), where \(m_{diff} = \bar{x}_1 - \bar{x}_2\) and \(S_p = \sqrt{ \frac{n_1 - 1 \cdot {s_{x_1}}^2 + n_2 - 1 \cdot {s_{x_2}}^2} {n_1 + n_2 - 2} } \).
For paired = TRUE, \(S_p\) is substituted by \(S_D = S_{x_1 - x_2}\) via sd(x1 - x2).
paired = TRUE
sd(x1 - x2)
# NOT RUN { set.seed(42) df <- data.frame(x = runif(100), group = sample(c("A", "B"), 100, TRUE)) effect_size_t(df, "x", "group") # }
Run the code above in your browser using DataLab