AI fails again

I was trying to fit a mixed effects model and I waned to compare the model with the same fixed effects with and without a random intercept in an ANOVA. So I wasn’t sure how to do this using lmer from the lme4 package. So I googled it:

It gave me the following answer with code:

# Example data
data <- data.frame(
  response = rnorm(100),
  fixed_effect_1 = rnorm(100),
  fixed_effect_2 = rnorm(100)
)

# Fit a linear mixed model with no random effects
model <- lmer(response ~ fixed_effect_1 + fixed_effect_2, data = data)

# Display the model summary
summary(model)
I was pretty sure this wouldn't work, but I tried it anyway.  And it doesn't work.  You can't fit an lmer model without specifying random effects.  

For the record, I’m not sure my question even makes sense. I think I should be comparing these models with AIC rather than ANOVA, now that I think about it for more than a second.

Anyway,

Cheers.

Posted on June 5, 2025, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a comment