[R-sig-ME] design matrix for mixed effects model

Douglas Bates bates at stat.wisc.edu
Tue Jan 11 13:49:04 CET 2011


On Tue, Jan 11, 2011 at 1:59 AM, Andreas Böck <andreas.boeck at tum.de> wrote:
> Hi Wade,
> For a model y ~ x1 + x2 + (x1 + x2 | id)
> you get the random effects design matrix via
>
> model.matrix(~ 0 + id + (x1 + x2):id)

That will produce a dense model matrix for the random effects.
Depending on the number of levels of id and the number of observations
that matrix could be huge.  The lme4 package uses sparse model
matrices for the random effects terms, which is a key to the
performance on large problems.




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