[R] lme4 model with no fixed effects?

Douglas Bates bates at stat.wisc.edu
Tue Nov 21 20:42:40 CET 2006


On 11/21/06, Frank Samuelson <gmane0806.13.cudgel at neverbox.com> wrote:
> Crossed random effects:
>
>    > lmer( y ~  (1 | i1) + (1|i2)  ,data=dta)
>    Linear mixed-effects model fit by REML
>    Formula: y ~ (1 | i1) + (1 | i2)
>       Data: dta
>       AIC   BIC logLik MLdeviance REMLdeviance
>     91.18 94.84 -42.59       85.2        85.18
>    Random effects:
>     Groups   Name        Variance Std.Dev.
>     i1       (Intercept) 0.068224 0.26120
>     i2       (Intercept) 0.463112 0.68052
>     Residual             1.469250 1.21213
>    number of obs: 25, groups: i1, 5; i2, 5
>
>    Fixed effects:
>                Estimate Std. Error t value
>    (Intercept)  0.09806    0.40625  0.2414
>
> Crossed random effects with no fixed effects?
>
>    >  lmer( y ~ -1 + (1 | i1) + (1|i2)  ,data=dta)
>    Error in lmer(y ~ -1 + (1 | i1) + (1 | i2), data = dta) :
>            Xp must be a real matrix
>
> If this isn't possible, it is easy enough to throw
> together a slow ML estimator myself.

I think you may need to do that.  I see that model.matrix(~ -1,
mydata) does produce a model matrix with 0 columns and the correct
number of rows so that part will work.  The error message that you see
comes from internal code that checks the type of the matrix before
checking the dimension.  It may happen that if I check for the
dimension before the type I can make it work with a fixed-effects
model matrix with 0 columns but I would not be optimistic.  I suspect
that in several other places I will need to modify code to check for
the 0 columns case.  (IIRC, Lapack code doesn't like dimensions of 0
so I will need to trap that case before every call to an Lapack
subroutine.)

I'll put it on the "To Do" list but, given the state of that list, you
would be well advised to throw your own version together for the
interim.



More information about the R-help mailing list