[R] question: corCAR1 in lme

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Wed May 25 12:49:29 CEST 2005

Hi Sean,

As you already guessed and as also the help-page ACF.lme() indicates: 
"The autocorrelation function is useful for investigating serial 
correlation models for equally spaced data."

Since you don't have equally spaced time points, you should use: 
"corCAR1(form = ~ Time | TankID)", which would indicate that "Time" is 
the position variable and *not* the order of the observations (i.e., 
when you use "form = ~ 1 | TankID").

Since you assume continuous time and you also fit a random-intercepts 
model, I think that the correct tool to use is the semi-variogram 
(i.e., look at "?Variogram()") and maybe you could also consider other 
correlation structures such as corExp() or corGaus().

I hope it helps.


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/

----- Original Message ----- 
From: "Sean Connolly" <sean.connolly at jcu.edu.au>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, May 25, 2005 11:07 AM
Subject: [R] question: corCAR1 in lme

Hello all,

I am trying to use lme to examine how a response variable (Chla) 
over time in different treatments (2 Temp & 2 Light levels).  Within 
treatment combination, there are two replicate tanks (each with unique
TankID) with coral fragments in them.  All tanks are subject to the 
environment until Time=0, when treatments are imposed, and Chla is 
for each tank at six times, including Time 0 just as the experiment
commences. The model is:

Chla.1 <- lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 

The reasoning here is that each tank’s intercept (Chla at Time 0) is a
random draw from a common distribution regardless of treatment, but 
the trend in Chla over time may vary among treatment combinations. 
on the help files, two separate threads from the archives, and the 
and Bates nlme 3.0 manual, I became confused about which of two ways 
check for a first-order temporal autocorrelation:

Chla.1b <- lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 
corr = corCAR1(form = ~Time | TankID), method="ML")

Chla.1c <- lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 | 
corr = corCAR1(form = ~1 | TankID), method="ML")

Comparing these fits with inspection of 
suggests to me that there are problems with both of my attempts.  For 
ACF plot, the correlation at lag 1 is about –0.3, and sticks out 
beyond the
confidence limits.  By contrast, the two models' correlation 
parameters are
not negative (phi = +0.13 and ~0 respectively), and the log-likelihood
values are identical to the original model, suggesting no evidence of
autocorrelation.  Our times are not equally spaced (they vary from 5-8 
apart), and I gather than ACF assumes they are, but my troubleshooting
(summarized below) suggests to me that my problem is bigger than this. 
think I have not used corCAR1 properly, and am hoping someone can 
point me
in the right direction.

Attempted troubleshooting:

1.  To check whether the discrepancy between ACF and the lme fits was 
entirely to the unequal spacing of measurements, I created a bogus 
variable (Time2) that was equally spaced (running from 0 to 5 in steps 
1).  I then re-fit all of the above models with Time2 replacing Time 
in the
function calls, and get the same kinds of problems (phi ~ 0 in the 
fits, while ACF plot suggests a negative correlation at lag 1).

2.  Still using the bogus equally-spaced time variable, I replaced 
with corAR1.  Now, the two different specifications of “form” yield
identical parameter estimates and MLLs; the estimates of phi agree 
those from the ACF plot; and the models actually do fit better than 
equivalent model without autocorrelation.

Any advice would be greatly appreciated.

Sean Connolly
[[alternative HTML version deleted]]

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide! 

More information about the R-help mailing list