[R-sig-ME] Using anova vs. Anova for linear mixed model
Kevin Chu
kev|n@m@chu @end|ng |rom duke@edu
Thu Sep 12 20:14:13 CEST 2019
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Anova_car.png
Type: image/png
Size: 102189 bytes
Desc: Anova_car.png
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20190912/7a584988/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: anova_stats.png
Type: image/png
Size: 125109 bytes
Desc: anova_stats.png
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20190912/7a584988/attachment-0003.png>
More information about the R-sig-mixed-models
mailing list