[R-sig-ME] How to calculate proportion of deviance explained from GAMM?

Mari Lyly mari.s.lyly at utu.fi
Tue Dec 3 08:42:51 CET 2013


Hello all,

I'm using GAMM (mgcv::gamm) to fit non-Gaussian models with several fixed factors and smooth terms, and also a temporal structure. I have correlated main effect candidates, and I would like to compare their GAMMs to see, which one of the models best fits the data. The random structure is the same in all of the models.

I came across a thesis on Additive Mixed Models (http://eio.usc.es/pub/mte/descargas/ProyectosFinMaster/Proyecto_393.pdf). Following that example, I plan to use the proportion of deviance explained as a tool for model comparison and tuning the models in GAMM. The DE% is defined as:
(null deviance - residual deviance ) / null deviance

I have tried using the following script, but I end up having residual deviance (DR) slightly larger than the null deviance (DN):
DN <- deviance(gam(model0 ~ 1, data=data, family=poisson))
model1 <-gamm(response ~ s(cov1, by=factor1) + s(cov2) + s(cov3) + s(cov4) + cov5,
     random=list(factor2= ~ 1), correlation= corAR1(form= ~ factor3 | factor2), data=data, family=poisson)
DR <- sum(residuals(model1$gam, type="pearson")^2)

Would someone be able to tell if I am using the correct code to extract DN from the null model (GAM) and DR from the model to be compared (GAMM)? To my understanding, DR values should be clearly smaller than DN (unless it's overparameterization, which should not be the case here). If I'm not using the right functions, then please give advice on how to acquire the correct values.

With best regards,
   Mari Lyly
__________________________________
Mari Lyly, PhD student
University of Turku
e-mail: mari.s.lyly at utu.fi



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