[R-sig-ME] GAMM4: temporal autocorrelation?
Highland Statistics Ltd
highstat at highstat.com
Wed Mar 14 12:36:38 CET 2018
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
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.
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"
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
So I did a gam using gamm4. My code is like this:
Mod1 <- gamm4(grooming ~s(time,bs =
The result looks perfect! Unfortunately, when testing for temporal
I do clearly have temporal autocorrelation in my data. I had also
expected that because time is of course always leading to
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
End of R-sig-mixed-models Digest, Vol 135, Issue 17
Dr. Alain F. Zuur
Highland Statistics Ltd.
9 St Clair Wynd
AB41 6DZ Newburgh, UK
Email: highstat at highstat.com
NIOZ Royal Netherlands Institute for Sea Research,
Department of Coastal Systems, and Utrecht University,
P.O. Box 59, 1790 AB Den Burg,
Texel, The Netherlands
1. Beginner's Guide to Spatial, Temporal and Spatial-Temporal Ecological Data Analysis with R-INLA. (2017).
2. Beginner's Guide to Zero-Inflated Models with R (2016).
3. Beginner's Guide to Data Exploration and Visualisation with R (2015).
4. Beginner's Guide to GAMM with R (2014).
5. Beginner's Guide to GLM and GLMM with R (2013).
6. Beginner's Guide to GAM with R (2012).
7. Zero Inflated Models and GLMM with R (2012).
8. A Beginner's Guide to R (2009).
9. Mixed effects models and extensions in ecology with R (2009).
10. Analysing Ecological Data (2007).
More information about the R-sig-mixed-models