# Autocorrelation *across* random effects in nlme:lme?

I have response data measured at the site and month level. I wish to fit a year trend to the data and month to remove the seasonal trend. However, to avoid pseudoreplication, I have fitted year also as a random effect. My model using the lme function in R (package nlme) looks like:

lme(Response ~ Year + Month, method="REML", random = ~ 1|Year/Site, data=data1)


I then wish to fit an AR(1) function to look at the correlation between months. The lme function demands that the correlation structure be nested within the random effects structure, such that the model now looks like:

lme(Response ~ Year + Month, method="REML", random = ~ 1|Year/Site, correlation=corAR1(value=0.1,form=~autor|Year/Site), data=data1)


The term 'autor' is used as a running month term. However, given that the correlation structure is nested within the random effects structure, the correlation between the first response in year i and the last response in year (i-1) is not taken into account in the autocorrelation estimation. My questions are as follows:

1) Is there a specific reason why the correlation structure cannot be fitted across the random effects (ie years in this case) and must be nested within its structure? Would this conflict with the random effects standard deviation estimation?

2) Is there a way to fit an AR(1) with crossed random effects? I have not been able to fit such a model with lme so far.

## 1 Answer

You're fitting both a random and fixed effect for the year variable. This is not very likely. Chances are that either fixed effect is measured near zero or that std of random effect is near zero. Than use one of these formulas (which i suspect you actually want):

Measuring continuous yearly trend:

lme(Response ~ autor + Month, method="REML", random = ~ 1|Site, correlation=corAR1(value=0.1,form=~autor|Site), data=data1)


Measuring a separate response for each year:

lme(Response ~ Year + Month, method="REML", random = ~ 1|Site, correlation=corAR1(value=0.1,form=~autor|Site), data=data1)

1. Since Year will not be a random effect problem should be solved.
2. Not in R as much as I know. (lme4 - supports crossed random effects but not AR, nlme - does not support crossed random-efffects). You could use SAS/SPSS. But first you could try fitting results with lme4 and see whether there's any autocorrelation. You try could and use plm (http://cran.r-project.org/web/packages/plm/index.html), I don't have any experience with this package myself... BTW - I don't see any crossed random effects in your data...