Hi, I have a mixed-effects model in lme4 like so mdl <- lmer(T ~1 + (1|A) + (1|B),...) where the factors A and B are being modelled as independent random effects. However, there is also heteroscedasticity in the problem, where the variance of T depends on a third grouping factor, lets called it C. I can fit such a model in the nlme package, using the weights=varIdent(form=~1| C) argument, but this package doesn't seem to easily support independent random effects of the form shown above... How can I get the best of both worlds here? Mark
Multiple independent random effects
4 messages · Mark Payne, Michael Cone, Ben Bolker
Mark, I don't think that's possible with lme4/lmer right now. Michael Am 12.09.2014 12:12 schrieb Mark Payne:
Hi, I have a mixed-effects model in lme4 like so mdl <- lmer(T ~1 + (1|A) + (1|B),...) where the factors A and B are being modelled as independent random effects. However, there is also heteroscedasticity in the problem, where the variance of T depends on a third grouping factor, lets called it C. I can fit such a model in the nlme package, using the weights=varIdent(form=~1| C) argument, but this package doesn't seem to easily support independent random effects of the form shown above... How can I get the best of both worlds here? Mark [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Michael Cone <coanil at ...> writes:
Mark, I don't think that's possible with lme4/lmer right now. Michael
It's possible, but not easy. http://rpubs.com/bbolker/varfac shows how to set up formulae/model structures that allow for different RE variances, or different residual variances, across different levels of a fixed treatment factor. Basically, you have to set up an observation-level random effect and dummy variables for each level of C other than the first, then add (0+cLevel2|obs) + (0+cLevel3|obs) + (0+cLevel4|obs) ... or equivalently you can use (0+dummy(C,"level2")|obs) + (0+dummy(C,"level3")|obs) + ... This is more elegantly doable with the flexLambda development branch ...
Am 12.09.2014 12:12 schrieb Mark Payne:
Hi, I have a mixed-effects model in lme4 like so mdl <- lmer(T ~1 + (1|A) + (1|B),...) where the factors A and B are being modelled as independent random effects. However, there is also heteroscedasticity in the problem, where the variance of T depends on a third grouping factor, lets called it C. I can fit such a model in the nlme package, using the weights=varIdent(form=~1| C) argument, but this package doesn't seem to easily support independent random effects of the form shown above... How can I get the best of both worlds here? Mark
2 days later
Thanks for the replies. The quick fix of course is to just convert the random effects to fixed effects and do the rest with gls() which works in this situation quite acceptably. But I'm surprised about this - is there a technical constraint that means that the two can't be combined? Or is it just a matter of history? Mark
On 12 September 2014 22:00, Ben Bolker <bbolker at gmail.com> wrote:
Michael Cone <coanil at ...> writes:
Mark, I don't think that's possible with lme4/lmer right now. Michael
It's possible, but not easy. http://rpubs.com/bbolker/varfac shows how to set up formulae/model structures that allow for different RE variances, or different residual variances, across different levels of a fixed treatment factor. Basically, you have to set up an observation-level random effect and dummy variables for each level of C other than the first, then add (0+cLevel2|obs) + (0+cLevel3|obs) + (0+cLevel4|obs) ... or equivalently you can use (0+dummy(C,"level2")|obs) + (0+dummy(C,"level3")|obs) + ... This is more elegantly doable with the flexLambda development branch ...
Am 12.09.2014 12:12 schrieb Mark Payne:
Hi, I have a mixed-effects model in lme4 like so mdl <- lmer(T ~1 + (1|A) + (1|B),...) where the factors A and B are being modelled as independent random effects. However, there is also heteroscedasticity in the problem, where the variance of T depends on a third grouping factor, lets called it C. I can fit such a model in the nlme package, using the weights=varIdent(form=~1| C) argument, but this package doesn't seem to easily support independent random effects of the form shown above... How can I get the best of both worlds here? Mark
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models