[R-sig-ME] Variance of random effects in binomial lmer

Geir H Bolstad geir.bolstad at bio.ntnu.no
Thu May 20 11:01:21 CEST 2010


Dear all,

Why is the estimated variance of a random effect different from the
variance of the predicted random effects in a lmer with logit link and
binomially distributed errors?

> mod <- lmer(y~(1|x), family=binomial)

Random effects:
 Groups Name        Variance Std.Dev.
 x      (Intercept) 7.1227   2.6688  
Number of obs: 10000, groups: x, 500

> var(ranef(mod)$x)
            (Intercept)
(Intercept)    5.126217

These two (variance of random effects and var(ranef(mod)$x)) are the
same in a lmer with normally distributed errors and identity link. So
what is the difference?

Syntax to generate data:
n1 <- 500
n2 <- 20
sd1 <- 3
sd2 <- 1
AA <- rnorm(n1, 0, sd1)
BB <- list()
for(i in 1:length(AA)) BB[[i]] <- AA[i]+rnorm(n2, 0, sd2)
BB2 <- unlist(BB)
y1 <- exp(BB2)/(1+exp(BB2))
y <- rbinom(length(y1), 1, y1)
x <- factor(rep(1:n1, each=n2))

Thanks for your help
Geir H. Bolstad
PhD candidate, Biology
Norwegian University of Science and Technology




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