[R-sig-ME] Specify multiple nested random effects in lme with heteroskedastic variance across group
suraj keshri
surajkeshri at gmail.com
Wed Feb 21 19:25:48 CET 2018
I want to fit a random effects model with two separate nested random
effects. I can easily do this using the `lmer` package in R. Here's how:
model<-lmer(y ~ 1 + x + (1 | oid/gid) + (1 | did/gid), data=data)
Here, I'm fitting a random intercept for `oid` nested within `gid` and
`did` nested within `gid`. This works well. However, I want to fit a model
where the variance of the intercept changes across the `gid` for both the
random effects. `nlme` package is capable of doing that. However, it's not
clear how. The best I could do is like so:
model <- lme(y ~ 1 + x, random=list(gid=~1, oid=~1, did=~1),
weights=varIdent(form=~1|gid), data = data)
but this nests the `did` within `oid` and `gid` nested together. I tried to
use the idea from a similar [question][1], which seems like a close problem
but the answer has not been explained well in that question. Thank you!
[1]: https://stats.stackexchange.com/questions/58669/
specifying-multiple-separate-random-effects-in-lme
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list