1

Probably basic question, but I'm not aure how to do it. If one wants to estimate a multilevel model, but only with fixed effects, not random effects estimated, how one would do that? For example, here is my model:

model4 <- lmer(m ~ x + (  | id) , data = data_stacked2, REML = TRUE)

Thanks.

Sarah
  • 11
  • 2
  • Wouldn't you just use `lm` instead? – IRTFM Sep 11 '20 at 21:58
  • 1
    `lme4` can't handle models without random effects (but the likelihoods etc. of the corresponding `lm` models are comparable). I agree with @Werner that it would be helpful if you clarified your question (e.g. gave some context about why you want to do this/what you are trying to do) – Ben Bolker Sep 12 '20 at 01:14

1 Answers1

0

If I understood you correctly, you want to use:

lmer(m ~ x + (1|id), data = data_stacked2, REML = TRUE)

To be more specific, the above model has fixed (x) and random effects (id). If you don't need to estimate random effects, just use lm(m ~ x, data) instead.

But If you're trying to run a model with random slopes and a fixed intercept, you might want to try the formula

lmer(m ~ 1 + (0 + x|id), data = data_stacked2, REML = TRUE)

Please clarify your question.

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36