0
$\begingroup$

I know this is a subject of controversy, but I'm not interested in why p-values and effect sizes are bad but how I can calculate the latter based on the lmer() function. In psychology literally every supervisor wants to have $\eta^2$ or $\eta^2_{partial}$ reported in ANOVA results. So no room for idealism here.

I'm aware of calculating the effect size with the help of the car and heplots package, but calling this way beginner-unfriendly would be the understatement of the year.

Is there any way to calculate $\eta^2$ or $\eta^2_{partial}$ for a lmer() anova (not the overall $R^2$ like one could get with sjstats::r2()) or the residuals sum of squares to write a short function to calculate it myself?

For example, if anova(lmer(...)) returns an ANOVA output like this

          Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
A       1090549  1090549   1   175    25.7756   9.747e-07 ***
B       36119    36119     1   175    0.8537    0.3568    

I'd like to get something like this

                 eta^2
(Intercept) 0.95813226
A           0.16879768
B           0.03596987
$\endgroup$
3
  • $\begingroup$ There are functions in sjstats that also calculate omega or eta squared, but these require an object of class aov or similar, but if I recall right, anova() returns a data frame, which is not consistent across different models. I think here is the problem why it's rather difficult to calculate eta squared from these objects. $\endgroup$ – Daniel Mar 22 '19 at 8:27
  • $\begingroup$ I know, one can calculate eta squared for aov objects, but I also need it for repeated measure ANOVAs. I really like the syntax of lme4 but if theres no way to calculate eta squared I'll have to switch to ez::ezANOVA(). $\endgroup$ – j3ypi Mar 22 '19 at 8:58
  • 1
    $\begingroup$ I'm not sure, but maybe the afex package may help you? $\endgroup$ – Daniel Mar 22 '19 at 9:00
0
$\begingroup$

@Daniel gave me the right hint with the afex package. The syntax is quiet similar to the one in lme4. Assuming you have IQ as the dependend variable, A as a between subject factor and B and C as within subject factors, one could write

afex::aov_4(IQ ~ A + (B * C|id), data = df, anova_table = "pes") 

with id as the persons identification and pes to calculate $\eta^2_{partial}$ instead of the generalized $\eta^2$. One would obtain a table like this

Effect    df      MSE         F    pes p.value
 A       1, 28 32954.92   9.91 **  .26    .004
 B       1, 28  3002.32 15.25 ***  .35   .0005
 A:B     1, 28  3002.32      1.49  .05     .23
 C       1, 28  8583.84      1.21  .04     .28
 A:C     1, 28  8583.84      0.18 .006     .68
 B:C     1, 28   821.29      0.63  .02     .43
 A:B:C   1, 28   821.29      0.47  .02     .50
$\endgroup$
2
  • $\begingroup$ The documentation doesn't indicate how it would be calculated for a mixed model. I wonder . $\endgroup$ – Sal Mangiafico Mar 24 '19 at 13:04
  • $\begingroup$ @SalMangiafico Take a look at afex::mixed(). But since the package developers make use of lme4::lmer(), I doubt that effect sizes are calculated. $\endgroup$ – j3ypi Mar 24 '19 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.