suraj keshri
2018-Feb-21 04:06 UTC
[R] Specify multiple nested random effects in lme with heteroskedastic variance across group
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 with 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. I hope someone can figure this out. [1]: https://stats.stackexchange.com/questions/58669/specifying-multiple-separate-random-effects-in-lme [[alternative HTML version deleted]]
Bert Gunter
2018-Feb-21 11:36 UTC
[R] Specify multiple nested random effects in lme with heteroskedastic variance across group
You should post this on the r-sig-mixed-models list. You are more likely to get a helpful response there. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Feb 20, 2018 at 8:06 PM, suraj keshri <surajkeshri at gmail.com> wrote:> 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 with 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. I hope someone > can figure this out. > > > [1]: > https://stats.stackexchange.com/questions/58669/ > specifying-multiple-separate-random-effects-in-lme > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Apparently Analagous Threads
- using lmer weights argument to represent heteroskedasticity
- Heteroskedastic Time Series
- USING TOBIT OR WHAT ALTERNATIVE WHEN DATA ARE PANEL AND HETEROSKEDASTIC AND PROBABLY AUTOCORRELATED?
- testing equality of variances across groups in lme?
- Fixed variance structure for lme