[R-sig-ME] GAMM4: temporal autocorrelation? (GAM, binomial data, random effect)

Tagmarie Ramgad82 at gmx.net
Wed Mar 14 10:50:58 CET 2018


Dear all,

I am not a statistican but a biologist and I have a problem that I 
cannot solve. I guess more people must have that problem but I didn't 
find a solution online.

I want to to do a gam with random effects and my response variable has a 
binomial error structure. Reading through literature I found that gamm() 
doesn't perform very good with binomial error structures and gamm4 would 
be better.

So I did a gam using gamm4. My code is like this:

Mod1 <- gamm4(grooming ~s(time,bs = 
"cr"),random=~(1|animalID),data=mydata, family=binomial)

The result looks perfect! Unfortunately, when testing for temporal 
autocorrelation with

pacf(resid(Mod1$gam))

I do clearly have temporal autocorrelation in my data. I had also 
expected that because time is of course always leading to 
autocorrelation structures.
My problem:

How do I incorporate the temporal autocorrelation into my model? The 
usual part which works in gams (correlation=corAR1(0.71, form = ~ 1 | 
animalID) won't work in GAMM4 I know.

I followed an example from "?magic" (after loading mgcv) but that 
resulted in a crap looking result.

Does anyone know how to deal with that data structure? Help would be 
terribly much appreciated!



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