[R-sig-ME] Multiple independent random effects

Ben Bolker bbolker at gmail.com
Fri Sep 12 22:00:30 CEST 2014


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



More information about the R-sig-mixed-models mailing list