[R-sig-ME] Temporal Autocorrelation

Viechtbauer Wolfgang (STAT) wolfgang.viechtbauer at maastrichtuniversity.nl
Fri Jan 29 22:07:12 CET 2016


I believe the problem is not related to what you suspect. As the error indicates, your dataset appears to include insects that were measured more than once during the same week (the 'covariate' is the week variable, whose values are not all unique within some insects). Quoting from Pinheiro & Bates (2000): "The position variable must evaluate to an integer vector, with nonrepeated values per group [...]" (p. 235).

I think this will help you find the IDs of those insects:

apply(table(data$ID, data$week_checked) > 1, 1, sum) > 0

By the way, while it probably doesn't matter, the correct syntax should be: corAR1(form = ~ week_checked|ID). No need for the '1 +' part.

Best,
Wolfgang

-- 
Wolfgang Viechtbauer, Ph.D., Statistician | Department of Psychiatry and    
Neuropsychology | Maastricht University | P.O. Box 616 (VIJV1) | 6200 MD    
Maastricht, The Netherlands | +31 (43) 388-4170 | http://www.wvbauer.com    

> -----Original Message-----
> From: R-sig-mixed-models [mailto:r-sig-mixed-models-bounces at r-
> project.org] On Behalf Of Katie Murray
> Sent: Wednesday, January 27, 2016 16:02
> To: 'r-sig-mixed-models at r-project.org'
> Subject: [R-sig-ME] Temporal Autocorrelation
> 
> Good afternoon,
> 
> I was wondering if anyone would be able to give me some guidance with the
> following:
> 
> We have a dataset that investigates the senescence of insect body weight.
> Observations span several months with measurements of weight taken for
> individuals on a weekly basis until they die. Each individual has a
> unique ID; every week we collected weight data and measured some other
> parameters. We would like to test for and account for temporal
> autocorrelation in the data set.
> 
> We are trying to run a model in lme of this form:
> 
> m1<-lme(weight ~ week + var 1 + var 2,  random = ~ 1 + week_checked|ID,
>              correlation = corAR1(form = ~ 1 + week_checked|ID),
>              data = data)
> 
> lme delivers the following error message:
> 
> "Error in Initialize.corAR1(X[[i]], ...) :
>   covariate must have unique values within groups for "corAR1" objects "
> 
> We believe this is caused by the fact that individuals disappear from the
> dataset as they die, and therefore their ID is no longer represented in
> the weeks following death. If we truncate the data set before the first
> individual dies, the model runs fine.
> 
> Is there any way to account for temporal autocorrelation in a data set
> where the number of individuals progressively declines over time due to
> mortality?
> 
> Many thanks in advance,
> 
> Katie
> 
> Katie Murray
> PhD Research Student
> Biological and Environmental Sciences
> Stirling University
> Stirling
> FK9 4LA
> 
> Katie.murray at stir.ac.uk



More information about the R-sig-mixed-models mailing list