fiber.lm <- lm(strength ~ diameter + machine, data = fiber)
emm <- emmeans(fiber.lm, "machine")
eff_size(emm, sigma = sigma(fiber.lm), edf = df.residual(fiber.lm))
# or equivalently:
eff_size(pairs(emm), sigma(fiber.lm), df.residual(fiber.lm), method = "identity")
### Mixed model example:
if (require(nlme)) withAutoprint({
Oats.lme <- lme(yield ~ Variety + factor(nitro),
random = ~ 1 | Block / Variety,
data = Oats)
# Combine variance estimates
VarCorr(Oats.lme)
(totSD <- sqrt(214.4724 + 109.6931 + 162.5590))
# I figure edf is somewhere between 5 (Blocks df) and 51 (Resid df)
emmV <- emmeans(Oats.lme, ~ Variety)
eff_size(emmV, sigma = totSD, edf = 5)
eff_size(emmV, sigma = totSD, edf = 51)
}, spaced = TRUE)
# Multivariate model for the same data:
MOats.lm <- lm(yield ~ Variety, data = MOats)
eff_size(emmeans(MOats.lm, "Variety"),
sigma = sqrt(mean(sigma(MOats.lm)^2)), # RMS of sigma()
edf = df.residual(MOats.lm))
Run the code above in your browser using DataLab