[R-sig-ME] Autocorrelation in a GAMM for nightly time series

Ben Bolker bbolker at gmail.com
Wed Jun 5 03:35:51 CEST 2013


Andrew Digby <andrewdigby at ...> writes:

> I'm analysing call counts of a nocturnal species in 
> response to temporal and environmental effects. Over a
> period of 3 years I divide each night into 10 equal-length blocks, 
> and count the calls of each sex in each
> block. 

 [snip]

> gam(ncalls ~ sex + year + s(month) + s(time of night) +
>  s(moon) + s(temperature) + s(rain) +
> offset(blocklength), family=negbin(c(1,5)), data=dc)
 
> Where 'time of night' = 1-10 = the block number during the night,
> and blocklength = the length of that block (this changes throughout
> the year; hence the offset).
 
> Not surprisingly, the acf shows significant correlation between
> adjacent time blocks, with a periodicity of 10. This is because
> counts in a particular block will be similar to those in the blocks
> immediately before and after, and also to the same block on other
> nights (the species has a quite regular pattern of decreasing call
> rates as the night progresses).
 
> To address these autocorrelation problems, I've tried various 
> ARMA correlations, with correlation
> between time of night blocks, grouped by day (or week) and sex:
> 
> gamm( .., correlation=corARMA(form=~TimeofNight | DayofYearSex), p, q) 
>  (p=1:3, q=0:3)
> gamm( .., correlation=corARMA(form=~TimeofNight | WeekofYearSex), p, q)
 
> This improves the ACF, but there are still correlations between
> residuals at same time of night - e.g. peaks every 10 lags.
 
> 1) Can I rely on the ACF when my time series isn't actually
> consecutive time bins, since it only includes each night (not full
> days). This means, for example, that the time lag between
> observations 9 & 10 (~1 hour) is much longer than that between 10 &
> 11 (~12 hours = daytime)?

> 2) (if yes to the above) How can I construct a correlation structure
> in a GAMM which allows for correlation between adjacent time bins
> within each night, and between the same time bin on different
> nights?

  I think you can use corCAR1, which is intended for continuous-time
models, but it's limited -- it does only exponential correlations
in time (analogous to corAR1). 

  If you have enough data/computational power, you might try 
a 2D spline (tensor product? I don't quite remember) to allow
for a gradually changing nocturnal time pattern over the course
of the year (i.e something like s(timeofnight,dayofyear)) --
not entirely clear to me why you're fitting s(month) rather than
s(dayofyear), unless you only have one observation per month?

In general my experience is that when I find myself fitting
high-order ARMA models (i.e. more than a couple of lags in total),
it's because there's some systematic pattern that I failed to
capture in the fixed-effects part of the model. Your mileage may
of course vary.

  Ben Bolker



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