[R-sig-ME] Using anova vs. Anova for linear mixed model

Fox, John j|ox @end|ng |rom mcm@@ter@c@
Fri Sep 13 17:05:22 CEST 2019


Dear Kevin,

It's not entirely clear to me what you did, because as far as I know, the anova() method for merMod objects supplied by the lme4 package doesn't have a type argument and computes sequential ("type-I") tests. (You say that you're using anova() in the stats package, but while stats provides the anova() generic function, the method is coming from someplace else.)

That said, I suspect that the discrepancy is due to the empty cells in the table of the fixed-effects factors. Normally, Anova() will detect the resulting aliased coefficients in the model and report an error, but I believe that lmer() suppresses the aliased coefficients by removing redundant columns of the model matrix. Whatever anova() method you used apparently detected the empty cells directly and printed a warning.

Finally, and particularly in light of the empty cells, I wonder why you want to compute type-III tests.

I hope that this is of some help,
 John

  -----------------------------
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox

> On Sep 12, 2019, at 2:14 PM, Kevin Chu <kevin.m.chu using duke.edu> wrote:
> 
> Hello,
> 
> I built a linear mixed effects model with three fixed factors and one random factor. I want to test for statistical significance of the fixed effects using F-tests from a type III ANOVA table. Since I am using a type III ANOVA, I understand that I need to set the contrasts to contr.sum so that the sums of squares are calculated correctly.
> 
> These are the data types.
> 
>> str(mydata)
> 'data.frame': 280 obs. of  5 variables:
> $ SUBJECT  : Factor w/ 20 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
> $ CONDITION: Factor w/ 4 levels "anechoic","aula",..: 1 1 1 1 2 2 2 2 3 3 ...
> $ CHANNEL  : Factor w/ 2 levels "0","1": 1 1 2 2 1 1 2 2 1 1 ...
> $ STRATEGY : Factor w/ 2 levels "0","1": 1 2 1 2 1 2 1 2 1 2 ...
> $ SCORE    : num  107.4 57 90.1 96.1 -16.4 ...
> 
> Below is the code I used to generated the model.
> 
> lmm <- lmer(SCORE ~ CONDITION * CHANNEL * STRATEGY + (1 | SUBJECT), data=mydata, contrasts=list(CONDITION=contr.sum, CHANNEL=contr.sum, STRATEGY=contr.sum))
> 
> I tried passing lmm through anova from the stats package and Anova from the car package, but I obtained different results (screenshots are attached).
> 
> My questions:
> 1) Why do anova and Anova give different results even though I specified type III ANOVA?
> 2) Why is the Sum Sq equal to 0 in the table produced by anova?
> 
> I would prefer not to release the data as I plan to publish a paper based on my results, but if it helps I can create dummy data.
> 
> Thank you,
> Kevin Chu
> <Anova_car.png><anova_stats.png>_______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list