# NOT RUN {
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)) {
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)
print(eff_size(emmV, sigma = totSD, edf = 5))
print(eff_size(emmV, sigma = totSD, edf = 51))
}
# 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))
# These results illustrate a sobering message that effect sizes are often
# not nearly as accurate as you may think.
# }
Run the code above in your browser using DataLab