[R] loglikelihood and lmer
Marco Geraci
marcodoc75 at yahoo.com
Fri Mar 31 21:56:31 CEST 2006
Dear R users,
I am estimating Poisson mixed models using glmmPQL
(MASS) and lmer (lme4). We know that glmmPQL do not
provide the correct loglikelihood for such models (it
gives the loglike of a 'pseudo' or working linear
mixed model). I would like to know how the loglike is
calculated by lmer.
A minor question is: why do glmmPQL and lmer give
different degrees-of-freedom for the same estimated
model? Does glmmPQL consider the scale parameter 'phi'
as a degree of freedom?
A toy example
set.seed(100)
m <- 5
n <- 100
N <- n*m
X <- cbind(1,runif(N))
Z <- kronecker(diag(n),rep(1,m))
z <- rpois(N, exp(X%*%matrix(c(1,2)) +
Z%*%matrix(rnorm(n))))
id <- rep(1:n,each=m)
fit.glmm <- glmmPQL(z ~ X-1, random = ~1|id,
family="poisson",verbose=F)
fit.lmer <- lmer(z ~ X-1 + (1|id),
family="poisson",verbose=F)
> logLik(fit.glmm)
'log Lik.' -386.4373 (df=4)
> logLik(fit.lmer)
'log Lik.' -458.1203 (df=3)
Thanks,
Marco
> sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices"
"utils"
[6] "datasets" "base"
other attached packages:
mvtnorm SemiPar cluster lme4 lattice
Matrix
"0.7-2" "1.0-1" "1.10.4" "0.995-2" "0.12-11"
"0.995-5"
nlme MASS
"3.1-68.1" "7.2-24"
>
More information about the R-help
mailing list