[R] lmer and mixed effects logistic regression

Rick Bilonick rab45+ at pitt.edu
Mon Jun 26 01:37:37 CEST 2006

On Fri, 2006-06-23 at 21:38 -0700, Spencer Graves wrote:
> 	  Permit me to try to repeat what I said earlier a little more clearly: 
>   When the outcomes are constant for each subject, either all 0's or all 
> 1's, the maximum likelihood estimate of the between-subject variance in 
> Inf.  Any software that returns a different answer is wrong. This is NOT 
> a criticism of 'lmer' or SAS NLMIXED:  This is a sufficiently rare, 
> extreme case that the software does not test for it and doesn't handle 
> it well when it occurs.  Adding other explanatory variables to the model 
> only makes this problem worse, because anything that will produce 
> complete separation for each subject will produce this kind of 
> instability.
> 	 Consider the following:
> library(lme4)
> DF <- data.frame(y=c(0,0, 0,1, 1,1),
>                   Subj=rep(letters[1:3], each=2),
>                   x=rep(c(-1, 1), 3))
> fit1 <- lmer(y~1+(1|Subj), data=DF, family=binomial)
> # 'lmer' works fine here, because the outcomes from
> # 1 of the 3 subjects is not constant.
>  > fit.x <- lmer(y~x+(1|Subj), data=DF, family=binomial)
> Warning message:
> IRLS iterations for PQL did not converge
> 	  The addition of 'x' to the model now allows complete separation for 
> each subject.  We see this in the result:
> Generalized linear mixed model fit using PQL
> <snip>
> Random effects:
>   Groups Name        Variance   Std.Dev.
>   Subj   (Intercept) 3.5357e+20 1.8803e+10
> number of obs: 6, groups: Subj, 3
> Estimated scale (compare to 1)  9.9414e-09
> Fixed effects:
>                 Estimate  Std. Error    z value Pr(>|z|)
> (Intercept) -5.4172e-05  1.0856e+10  -4.99e-15        1
> x            8.6474e+01  2.7397e+07 3.1563e-06        1
> 	  Note that the subject variance is 3.5e20, the estimate for x is 86 
> wit a standard error of 2.7e7.  All three of these numbers are reaching 
> for Inf;  lmer quit before it got there.
> 	  Does this make any sense, or are we still misunderstanding one another?
> 	  Hope this helps.
> 	  Spencer Graves
Yes, thanks, it's clear. I had created a new data set that has each
subject with just one observation and randomly sampled one observation
from each subject with two observations (they are right and left eyes).
I'm not sure why lmer gives small estimated variances for the random
effects when it should be infinite. I ran NLMIXED on the original data
set with several explanatory factors and the variance component was in
the thousands.

I guess the moral is before you do any computations you have to make
sure the procedure makes sense for the data.

Rick B.

More information about the R-help mailing list