Last active
May 12, 2020 15:17
-
-
Save crsh/44a44dee90cba1198288b8c766835809 to your computer and use it in GitHub Desktop.
Calculate Cohen's d_r and mean differences in measurement scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mean_difference_r <- function(x, object) UseMethod("mean_difference_r", object) | |
mean_difference_r.lm <- function(x, object) { | |
x * sigma(object) | |
} | |
mean_difference_r.mlm <- function(x, object) { | |
x * sqrt(mean(sigma(object)^2)) | |
} | |
mean_difference_r.afex_aov <- function(x, object) { | |
mean_difference_r.mlm(x, object$lm) | |
} | |
mean_difference_r.merMod <- function(x, object) { | |
x * sigma(object) | |
} | |
mean_difference_r.merModLmerTest <- function(x, object) { | |
mean_difference_r.merMod(x, object) | |
} | |
mean_difference_r.mixed <- function(x, object) { | |
mean_difference_r.merMod(x, object$full_model) | |
} | |
mean_difference_r.gam <- function(x, object) { | |
x * sqrt(object$scale) | |
} | |
cohens_d_r <- function(x, object) { | |
1 / mean_difference_r(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These functions can be used to specify an equivalence threshold Δ in units of dr (see this blog post by Jake Westfall) for two one-sided equivalence tests (Lakens, 2017) in the R-package
lsmeans
. The following example is adapted from theafex
vignette ANOVA and Post-Hoc Contrasts: Reanalysis of Singmann and Klauer (2011).