[R-sig-ME] lme4 and calculating QAICc

Andrew Close a.j.close at newcastle.ac.uk
Tue Oct 13 16:08:25 CEST 2009


Dear all,

I am trying to calculate QAICc using to compare two Poisson models. Unfortunately all I seem to get as printed values is NaN.

Is there something I'm missing? Even though I am able to generate model output, I do receive "convergence errors". Would these warning message have anything to do with this?

Incidentally, I'm using the methodology extracted from Bolker et al (2009)

Here is the code I have used.

######
library(lme4)
######
mp1=lmer(abundance~year+controlA+(year|groupC:sitecode),family="poisson",data=testData)

######
mq1=lmer(abundance~year+controlA+(year|groupC:sitecode),family="quasipoisson",data=testData)

######
QAICc <- function(mod, scale, QAICc = TRUE) {
LL <- logLik(mod)
ll <- as.numeric(LL)
df <- attr(LL, "df")
n <- length(mod at y)
if (QAICc)
qaic = as.numeric(-2 * ll/scale + 2 * df + 2 * df * (df +
1)/(n - df - 1))
else qaic = as.numeric(-2 * ll/scale + 2 * df)
qaic
}
#######
QAICc(mq1,scale=phi)

....and this is what I generate...

[1] NaN

Thank you.


Andrew


Andrew Close
Research Associate
Institute for Research on Environment and Sustainability (IRES)
School of Biology
4th Floor Devonshire Building
Newcastle University
NE1 7RU
+44 (0)191 2464840




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