# [R-sig-ME] syntax for random effects for an autocorrelated time series

Steven Orzack orzack at freshpond.org
Tue May 3 16:00:23 CEST 2016

```  I am working on an analysis with time series data. In particular, a
(simulated) population is counted at discrete time intervals. One has

N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12,......

where Ni is the number of individuals counted at time i.

From this time series, one can create another time series, say,

CV1, CV2, CV3, CV4,.....

where CVi is the coefficient of variation calculated from the first z
values of Ni. So, for example, if z = 4,

CV1 is the coefficient of variation of  N1, N2, N3, N4
CV2 is the coefficient of variation of  N2, N3, N4, N5
CV3 is the coefficient of variation of  N3, N4, N5, N6
..
CVi  is the coefficient of variation of  Ni, Ni+1 Ni+2, Ni+3
.
.

Obviously, the values in the times series of CVi do NOT have independent
errors. BTW, I have chosen z  = 4 for the example but it could take
other values. Of course, in any given analysis z is fixed.

The autocorrelation (lack of independence) among values in the CVi time
series means that I need to account for this in the fitting of a GLMM.
In this particular case, the link function would probably best be log.
The choice of the link function is secondary at the moment. What I need
to know is how to specify the random effects given the autocorrelation.

I am interested in assessing trends in the CV values so one of the
models will have time (i) as a predictor

The intercept model is going to look something like (using log)

log(CV) = 1 + (1 | random effects)

and the model with time is something like

log(CV) = 1 + time + (time | random effects)

The autocorrelation here seems simple but I am unsure about the exact
syntax needed for model fitting with glmer.

Suggestions for the syntax are welcome. I will be very appreciative.

Many thanks in advance,

S.

--
Steven Orzack
Fresh Pond Research Institute
173 Harvey Street
Cambridge, MA 02140
617 864-4307

www.freshpond.org

```