0
$\begingroup$

In one analysis, I want to use the mixed-effects model to test the fixed effect of Condition. To find out the effect, I've seen some people use anova() to compare the model to a baseline model without the fixed factor of interest, and some people use Anova(model, type = "III") from "car" package to get the effect of every fixed factor.

Here are my dataset and the code to get the effect of Condition. It looks like the two ways give slightly different results. I'm wondering, are these two ways testing the same thing? Why do they give different results and which way is more appropriate?

library(car)
library(lme4)
# order the levels of condition
df$condition <- factor(df$condition, levels = c("TreatmentA", 
"Control", "TreatmentB"))
# set orthogonal contrasts
TreatmentABvsControl <- c(1/3, -2/3, 1/3)
TreatmentAvsTreatmentB <- c(1/2, 0, -1/2)
contrasts(df$condition) <- cbind(TreatmentABvsControl, 
TreatmentAvsTreatmentB)
# build model
mod <- lmer(dv ~ condition + (1|subject) + (1|trial), data = df, 
REML = FALSE)
# build baseline model
mod_baseline <- lmer(dv ~ 1 + (1|subject) + (1|trial), data = df, 
REML = FALSE)
# compare 2 models to get the effect
anova(mod, mod_baseline)
# use Anova() to get the effect
Anova(mod, type = "III")
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.