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.
Best,
Dimitris
----
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/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- 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)
changes
over time in different treatments (2 Temp & 2 Light levels). Within
each
treatment combination, there are two replicate tanks (each with unique
TankID) with coral fragments in them. All tanks are subject to the
same
environment until Time=0, when treatments are imposed, and Chla is
measured
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 |
TankID,
method="ML")
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
that
the trend in Chla over time may vary among treatment combinations.
Based
on the help files, two separate threads from the archives, and the
Pinheiro
and Bates nlme 3.0 manual, I became confused about which of two ways
to
check for a first-order temporal autocorrelation:
Chla.1b <- lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 |
TankID,
corr = corCAR1(form = ~Time | TankID), method="ML")
Chla.1c <- lme(Chla ~ Temp*Light* Time - Temp*Light, random = ~1 |
TankID,
corr = corCAR1(form = ~1 | TankID), method="ML")
Comparing these fits with inspection of
plot(ACF(chla.model1),alpha=0.05)
suggests to me that there are problems with both of my attempts. For
the
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
days
apart), and I gather than ACF assumes they are, but my troubleshooting
(summarized below) suggests to me that my problem is bigger than this.
I
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
due
entirely to the unequal spacing of measurements, I created a bogus
time
variable (Time2) that was equally spaced (running from 0 to 5 in steps
of
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
model
fits, while ACF plot suggests a negative correlation at lag 1).
2. Still using the bogus equally-spaced time variable, I replaced
corCAR1
with corAR1. Now, the two different specifications of ?form? yield
identical parameter estimates and MLLs; the estimates of phi agree
with
those from the ACF plot; and the models actually do fit better than
the
equivalent model without autocorrelation.
Any advice would be greatly appreciated.
Sincerely,
Sean Connolly
[[alternative HTML version deleted]]
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html