Hello

I'm analyzing a dichotomous dependent variable (dv) with more than 100  
measurements (within-subjects variable: hours24) per subject and more  
than 100 subjects. The high number of measurements allows me to model  
more complex temporal trends.
I would like to compare different models using GLM, GLMM, GAM and  
GAMM, basically do demonstrate the added value of GAMs/GAMMs relative  
to GLMs/GLMMs, by fitting splines. GLMMs/GAMMs are used to possibly  
improve fits from GLMs/GAMs by accounting for serial dependence.
My idea is to use AIC to compare the different models. I’ve noticed  
that when setting up two seemingly identical models using the two  
functions gam (of the package mgcv) and gamm4 (of the package with  
same name), the AIC turns out to be different:

 > gam.0<-gam(dv ~  
s(hours24,fx=F,k=-1,bs=“cc“),method="ML",data=sdata, family=binomial)

 > gamm.0<-gamm4(dv ~  
s(hours24,fx=F,k=-1,bs=“cc“),method="ML",data=sdata, family=binomial)

Fit indices using the commands as shown are:
 > logLik(gam.0)[1];deviance(gam.0);AIC(gam.0)
 > logLik(gamm.0$mer);deviance(gamm.0$mer);attributes(summary(gamm. 
0$mer))$AICtab[1]

gam.0: logLik=1149.6, deviance=2299.3, AIC=2316.0
gamm.0: logLik=1169.0, deviance=2338.0, AIC=2342.0

The differences between the two AIC values seem to be based on two  
factors. First, gam uses the effective degrees of freedom
 > sum(gam.0$edf)
[1] 8.372517
whereas gamm4 uses the value 2. Second the two log-likelihood values  
already differ, probably because different estimation methods are used  
but here is were my understanding ends. In any case from gamm4 I can  
get the same value for the deviance as for gam by referring to the  
deviance slot:

 > gamm.0$...@deviance["disc"], which returns the value 2299.3, which  
is the deviance without compensation for the null deviance.

My questions are:
- Is my suggested method of comparing fits among GLM, GLMM, GAM and  
GAMM using AIC legitimate? Of course I will do additional model  
plotting using residuals etc. as well but it seems important to me to  
have a more direct method of comparing these models (I’m aware of the  
fact that AIC is a rough estimate when it comes to generalized mixed  
models).
- If so, how can I compute the AICs using gam and gamm4 such that they  
can be compared A) with each other and B) with AICs obtained from GLM/ 
GLMM?

Any suggestions are welcome

Andrea









        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to