0

I need to include one more random effect in my lme model. However, these 2 random effects are not related, therefore cannot be nested.

I am not sure how to write the code for this. I've tried the following:

modelA <- lme(FT~ Init.Age + Sex + Status, random= (1|Patient) + (1|Site), data = data, na.action = na.omit)

modelB <- lme(FT~ Init.Age + Sex + Status, random= list (~1|Patient, ~1|Site), data = data, na.action = na.omit)

only model B works. But it gives me exactly the same results as random= ~1|Patient and I think that cannot be correct. The results are the following: enter image description here

Thanks for your help! lil

Andrew
  • 5,028
  • 2
  • 11
  • 21
Lili
  • 547
  • 6
  • 19
  • 1
    `random = ~ (1|Patient) + (1|Site)`. Also for this kind of simple structure it might be beneficial to use `lme4` (for speed) for which the random effects are directly included in the `formula` term: `formula = FT ~Init.age + Sex + Status + (1|Patient) + (1|Site)` other than that used in exactly the same manner. – Oliver Oct 03 '19 at 20:24
  • Dear Oliver, thanks! The problem is that I need p values, and lme4 does not provide me with them. The thing is: I need to control by Site (patients can belong to site1 or site2). As I think Site has an influence in FT. Could I convert site (Factor) into an integer and put it as a fixed effect, rather than put it as a random effect? would that be right? Thanks! – Lili Oct 03 '19 at 21:01
  • `random = ~ (1|Patient) + (1|Site)` gives me the following error: Error in getGroups.data.frame(dataMix, groups) : invalid formula for groups – Lili Oct 03 '19 at 21:11
  • 2
    Alrighty i took a bit of time, and checked up. [This sigma question](https://stat.ethz.ch/pipermail/r-sig-mixed-models/2018q2/026750.html) [and this SE question](https://stats.stackexchange.com/questions/58669/specifying-multiple-separate-random-effects-in-lme) talks about the same problem. Basically it seems you are forced to use a nested structure `random = list(Patient = ~ 1, Site = ~1)`. For `lme4` Sattertwaithe (spelling?) approximations can be obtained by loading the `lmerTest` package. – Oliver Oct 04 '19 at 06:20
  • oops! I have forgotten to reply but this actually worked!! Thanks very much! – Lili Oct 09 '19 at 10:48
  • 1
    No problem, i am glad i could help. – Oliver Oct 09 '19 at 11:47

0 Answers0