Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimating effect size with emmenas for post hoc

Tags:

r

emmeans

Is there a way to have effect size (such as Cohen's d or the most appropriate) directly using emmeans()?

I cannot find anything for obtaining effect size by using emmeans()

post <- emmeans(fit, pairwise~  favorite.pirate | sex)
emmip(fit, ~ favorite.pirate | sex)
like image 236
atnplab Avatar asked Oct 11 '25 21:10

atnplab


1 Answers

There is not a built-in provision for effect-size calculations, but you can cobble one together by defining a custom contrast function that divides each pairwise comparison by a value of sigma:

mypw.emmc = function(..., sigma = 1) {
  result = emmeans:::pairwise.emmc (...)
  for (i in seq_along(result[1, ]))
    result[[i]] = result[[i]] / sigma
  result
}

Here's a test run:

> mypw.emmc(1:3, sigma = 4)
  1 - 2 1 - 3 2 - 3
1  0.25  0.25  0.00
2 -0.25  0.00  0.25
3  0.00 -0.25 -0.25

With your model, the error SD is 9.246 (look at summary(fit); so, ...

> emmeans(fit, mypw ~ sex, sigma = 9.246, name = "effect.size")
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean    SE     df lower.CL upper.CL
 female   63.8 0.434   3.03     62.4     65.2
 male     74.5 0.809  15.82     72.8     76.2
 other    68.8 1.439 187.08     65.9     71.6

Results are averaged over the levels of: favorite.pirate 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 effect.size    estimate     SE  df t.ratio p.value
 female - male    -1.158 0.0996 399 -11.624 <.0001 
 female - other   -0.537 0.1627 888  -3.299 0.0029 
 male - other      0.621 0.1717 981   3.617 0.0009 

Results are averaged over the levels of: favorite.pirate 
Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 3 estimates 

Some words of caution though:

  1. The SEs of the effect sizes are misleading because they don't account for the variation in sigma.
  2. This is not a very good example because

    a. The factors interact (Edward Low is different in his profile). Also, see the warning message.

    b. The model is singular (as warned when the model was fitted), yielding an estimated variance of zero for college)

like image 75
Russ Lenth Avatar answered Oct 14 '25 16:10

Russ Lenth