1

i want to fit a mixed model but with variance structure.

I create my data frame

DTF <- data.frame(Y = rnorm(7*4, 0, 1),
                  TIME = rep(1:7, 4),
                  GROUP = c(rep(1,7), rep(2,7), rep(3,7), rep(4,7)),
                  X = rep(rnorm(7, 20, 5), 4))

and than i run this command

model <- lmer(Y ~ TIME:GROUP + X + (1 | GROUP), DTF, REML = FALSE,
              varWeights(varFixed(~ TIME)))

and i have

Error in lmer(...): 'control' is not a list; use lmerControl()

I don't know what i have to change. Thanks for your help!

Nouman Ch
  • 4,023
  • 4
  • 29
  • 42
  • To the best of my knowledge, you can't use nlme variance structures within lme4 models. You'll have to switch to nlme entirely. (Also, the fourth parameter of `lmer` is `control` and not `weights`.) – Roland May 25 '18 at 08:44
  • I think that i can do it. But thanks, the problem was in the order or parameters. model <- lmer(Y ~ TIME:GROUP + X + (1|GROUP), data=DTF, REML=FALSE, control = lmerControl(), varWeights(varFixed(~ TIME))) – Emiliano Traini May 25 '18 at 09:11
  • I can only reiterate: I don't believe this fits a variance structure. Compare models with and without `weights` specified like this. They will have exactly the same fit. – Roland May 25 '18 at 09:13
  • touche! you're right. but also with nlmer i have the same thing. – Emiliano Traini May 25 '18 at 09:17
  • `nlme::lme` is the function you should use! NOT `lme4::nlmer`! – Roland May 25 '18 at 09:18

0 Answers0