Dear list,

I have a data frame like this:

set.seed(5)
mydata <- data.frame(var = rnorm(100,20,1),
                     temp = sin(sort(rep(c(1:10),10))),
                     subj = as.factor(rep(c(1:10),5)),
                     time = sort(rep(c(1:10),10)),
                     trt = rep(c("A","B"), 50))


I need to model the response of var as a function of temp*trt
and to do so I'm using the following model:

model <- lme(var~temp*trt,random=~1|subj,mydata)

however, since i have repeated measurement of the same subject, i.e. I measured var in subj1 at time1,2,3..
I must consider the non independence of the residuals.
moreover, temp is also a function of time, but i'm not sure how to include this in my model.

I'm following the approach in Zuur et al 2009, so I checked for temporal auto-correlation using the function afc()
In fact the residuals follow the temporal patter of temperature with time.
However, here I'm not interested in the temporal dependence of temperature and consequently the effect of this on var.
Instead what i need to do is to account for the correlation between consecutive measures (made on the same subject) in the error term of the model. 

here is my attempt to do so:

model1 <- lme(var~temp*trt,random=~1|subj,correlation=corAR1(form=~1|subj/time),mydata)

but, actually gives:
Correlation Structure: AR(1)
 Formula: ~1 | subj/time 
 Parameter estimate(s):
Phi 
  0

What io don't know is, am I doing something wrong?
or effectively there is no correlation between observation made on the same subject.

Hope, I've been clear enough.
Any suggestions?

cheers
matteo
	[[alternative HTML version deleted]]


