[R-sig-ME] lme4 and calculating QAICc
Dr. Christoph Scherber
Christoph.Scherber at agr.uni-goettingen.de
Tue Oct 13 18:28:00 CEST 2009
Dear Andrew,
You might want to check if you can extract a log-Likelihood from your models
logLik(mq1)
If you get an NaN here, there may be something wrong with your model(s).
Best wishes
Christoph
> 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
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list