Skip to content
Prev 16317 / 20628 Next

GAMM4: temporal autocorrelation?

Hello Ramgad82

Without providing data or/and scatterplots it is difficult to say 
anything sensible..but here are a few points to consider:

Problem 1: Applying the acf on the residuals assume that the residuals 
form a single time series. I guess you have multiple time series; one 
per animalID? In that case make an acf for each individual residual time 
series.

Problem 2. You are aiming for:? s(Time) + auto-correlated time

These two components might fight for the same information. The solution 
is to fix either the df of the smoother, or the auto-correlation parameters.

3. As to your specific question...you can either try glmmTMB or R-INLA.

Kind regards,

Alain


------------------------------

Message: 3
Date: Wed, 14 Mar 2018 10:50:58 +0100
From: Tagmarie <Ramgad82 at gmx.net>
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] GAMM4: temporal autocorrelation? (GAM, binomial
	data, random effect)
Message-ID: <1ce57e0a-80e1-9c81-3e97-ad34c8649b35 at gmx.net>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

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!




------------------------------

Subject: Digest Footer

_______________________________________________
R-sig-mixed-models mailing list
R-sig-mixed-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models


------------------------------

End of R-sig-mixed-models Digest, Vol 135, Issue 17
***************************************************
Message-ID: <1bd53924-1f8d-0959-1564-ee6dc66a6360@highstat.com>
In-Reply-To: <mailman.16221.11.1521025202.41925.r-sig-mixed-models@r-project.org>