-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Adjusted) Cohen's d for contrasts in linear models #351
Comments
Ok, some Qs:
|
Compared to the current functions to compute standardized regression coefficients for continuous covariates but leaving factors alone (which yields a d-like metric for the factor predictors), this would yield proper Cohen's d values by removing the between-groups variance from the response SD used to standardize. |
(could in be loosely related to... *pulling it out from under the rug* this? As in that it could be used as some of standardized index of effect size 😅) |
@bwiernik If I understand correctly, this is similar to what mod <- lm(mpg ~ factor(cyl, levels = c(4, 6, 8)) + hp, data = mtcars)
r2_cov <- summary(lm(mpg ~ hp, data = mtcars))$r.squared
print.es(
smd_stats(diff = summary(mod)$coef[2,1],
se_diff = summary(mod)$coef[2,2],
t_ncp = summary(mod)$coef[2,3],
df = mod$df.residual,
sigma = summary(mod)$sigma,
R2_cov = r2_cov,
n1 = table(model.frame(mod)[,2])[1],
n2 = table(model.frame(mod)[,2])[2],
conf.int = TRUE
)
)
#> Standardized mean difference (Hedges' g)
#> ========================================
#>
#> es df se se_var ci.lb ci.ub
#> -1.2 28 0.364 0.133 -1.9 -0.472
emmeans::emmeans(mod, ~cyl) |>
emmeans::eff_size(sigma = sigma(mod), edf = df.residual(mod))
#> contrast effect.size SE df lower.CL upper.CL
#> 4 - 6 1.897 0.579 28 0.710 3.08
#> 4 - 8 2.708 0.823 28 1.022 4.39
#> 6 - 8 0.812 0.638 28 -0.496 2.12
#>
#> sigma used for effect sizes: 3.146
#> Confidence level used: 0.95 Where would this go?I think this can either be implemented in What do you think? |
It is similar to There are three broad approaches to computing a d value from a linear model:
We should write this function to handle arbitrary contrasts like emmeans, but standardize using the correct SD. This should work with arbitrary contrasts I think: I think |
(Not sure I've ever seen opt1 called a d-value 👀) If I understand correctly: Correct?
Sounds good, but think of expandability - if we add more supported models, we might need a |
Sure, conditional/marginal is a good way to describe it. But given that the choice of standardizer is primarily about interpretability, I'm not sure that the conditional SD is very useful in most cases. There is some discussion here |
And so what do you think? |
It's not pretty, but... cohens_d <- function(x, ...) {
if (insight::is_model(x) && inherits(x, <models that this function should work with>)) {
.cohens_d_models(x, ...)
} else {
.cohens_d(x, ...)
}
} I'm open to any other ideas (: I invite you to build the skeleton of the |
Would it be possible to extend this brilliant idea also to more generalized models, like the MMRM fit via GLS (2 implementations in R: nlme::gls() and mmrm:mmrm()) and GEE (geeglm and maybe geeM, geesmv)? The MMRM (rather than mixed models) make the core tool in clinical trials, it would be great to have the effect sizes automated to use appropriate part of the estimated variance-covariance matrix at the given contrasts. |
Some code I wrote a while back for computing SMDs from lm output. Could be useful to report effect sizes in terms of standardized betas and Cohen's ds. Most important bit is the comment at the end.
The text was updated successfully, but these errors were encountered: