I'm learning more about the lme4 package and have appreciated both Bodo Winter's tutorial and this guide on Tufts. However, the two guides differ when suggesting a method to determine the significance of a fixed effect.
Winters suggests using R's anova
function to compare one model with the fixed effect in question and one without.
In contrast, Tufts first suggests using the car
package's Anova
function (they also suggest the anova
method).
However, as can be seen in the play example below, the two methods return different chi-squared and p values.
library(lme4)
# meaningless models
lmer_wt_null = lmer(mpg ~ (1 + wt | cyl), data = mtcars, REML = FALSE)
lmer_wt_full = lmer(mpg ~ wt + (1 + wt | cyl), data = mtcars, REML = FALSE)
# stats::anova output (Winters)
anova(lmer_wt_null, lmer_wt_full)
# Data: mtcars
# Models:
# lmer_wt_null: mpg ~ (1 + wt | cyl)
# lmer_wt_full: mpg ~ wt + (1 + wt | cyl)
# Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
# lmer_wt_null 5 167.29 174.62 -78.647 157.29
# lmer_wt_full 6 163.14 171.93 -75.568 151.14 6.1563 1 0.01309 *
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
library(car)
# car::anova output (Tufts)
Anova(lmer_wt_full)
# Analysis of Deviance Table (Type II Wald chisquare tests)
#
# Response: mpg
# Chisq Df Pr(>Chisq)
# wt 19.213 1 1.169e-05 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
What are the two methods doing differently and what is the meaning of the difference between these p values?
I'm almost certain that I'm missing something basic. Thanks.