In a mixed effect model where the intercept is random effect and the slope is fixed effect (see the code below), I understand the output of summary(glmer(...))
. But I do not understand coef(glmer(...))
; it will output the intercept for each sample. In the example, how are those 100 intercepts estimated?
n <- 100
x <- runif(n,2,6)
a <- -3
b <- 1.5
s <- 1
N <- 8
id <- 1:n
r <- rnorm(length(x),0,s) # random factor
p <- function(x,a,b) exp(a+b*x)/(1+exp(a+b*x))
y <- rbinom(length(x), N, prob = p(x,a+r,b))
library(lme4)
model <- glmer(cbind(y,N-y)~x+(1|id),family=binomial)
summary(model)
coef(model) # output here is what I do not understand
# are they estimates for r?
rr <- coef(model)$id[,1]-summary(model)$coefficients[1,1]
plot(r,rr)
The likelihood of the model, I think, is:
\begin{align} L_{i} &= \int_{-\infty}^{\infty}f(y_i|N,a,b,r_{i})g(r_{i}|s)dr_{i} \\[5pt] L &= \prod_{i=1}^{n} L_{i} \end{align}
where f is binomial pmf and g is normal pdf. So r should be integrated out. The number of the parameters of this model is 3 (a, b, and s). Although it seems there are 100 intercepts estimated, they are not really considered the parameters of the model, I think. AIC(model)
is -2*logLik(model)+3*2
. I would like to know what method will give those 100 intercepts.