[R-sig-ME] lme4 and calculating QAICc
David Atkins
datkins at u.washington.edu
Tue Oct 13 20:04:27 CEST 2009
Andrew--
Your code worked fine for me using an lmer() fit on some of my own data,
and setting scale = 1.
Is phi defined somewhere that we can't see, or might that be causing
your problems? I think it should work if scale is passed a numeric value.
cheers, Dave
--
Dave Atkins, PhD
Research Associate Professor
Center for the Study of Health and Risk Behaviors
Department of Psychiatry and Behavioral Science
University of Washington
1100 NE 45th Street, Suite 300
Seattle, WA 98105
206-616-3879
datkins at u.washington.edu
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