Re: [R] lmer and mixed effects logistic regression

From: Spencer Graves <>
Date: Tue 27 Jun 2006 - 01:51:20 EST

<see inline>

Rick Bilonick wrote:

> 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. 

SG: If lmer gave me small estimated variances for the random effects, I would check very carefully my model, as I would believe I probably have specified something incorrectly.

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.

______________________________________________ mailing list PLEASE do read the posting guide! Received on Tue Jun 27 01:55:49 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 27 Jun 2006 - 04:12:30 EST.

Mailing list information is available at Please read the posting guide before posting to the list.