Within group estimate of autocorrelation
On 14-09-22 02:39 PM, PATRICK, Samantha wrote:
Hi
I have a model which fits an corAR1 autocorrelation structure and the code tells the model that time is nested within individual:
fit0<-lme(Respone~1, random=~1|indiv, correlation=corAR1(form=~time|indiv), data=Data2, method = "REML")
From this I get a Phi single estimate of the autocorrelation.
However I want to have an estimate of the autocorrelation for each individual. I have checked but can not find any code to extract this value. The model assumes that autocorrelation structure is homogeneous across individuals.
So my first question is: Is it possible to extract an estimate of autocorrelation per individual or does the model not save/calculate this?
So, the answer is: no/correct.
And second, if it isn't possible, I wondered if there is any way to
use the weights function to group individuals.
If I add the code: weights=varIdent(form=~1|group), I can fit multiple residual variance terms so I wondered if this could be used to estimate a Phi value per group, by somehow structuring the model so it fits an autocorrelation for each residual variance group?
The solution does not need to be lme necessarily - I?m open to any
suggestions! Perhaps just use acf() along with your favourite by-group tool in R (plyr, aggregate, dplyr, data.table, for loop ...) to compute/extract the first-order autocorrelation parameter for each individual? Or you could use gls(Response~1,correlation=corAR1(form~time),...) for each individual and similarly return the autocorrelation parameter per individual. I hope you have a reasonably large number of observations per individual ...