# The use of acf or Phi/Rho correlation coefficients to diagnose autocorrelation in lme?

I am looking for some advice on how to diagnose autocorrelation issues with when time intervals are not equally spaced? Specifically, I would like to use that diagnosing method to help choose the best correlation structure specification. I am using the lme function from the package nlme.

I am interested in knowing if there is a significant difference in my response variable across four sites. I measured the response variable over the course of 166 days at uneven intervals (ranging from 7 to 21 days apart). Because this is a temporal study, I need to make sure that there is no autocorrelation issues in the residuals.

Experimental design: I have explained the overall experimental design in a previous question here (https://stats.stackexchange.com/questions/187499/nested-random-effects-in-lme4-r).

When I look at the model without correlation structure, the residuals would suggest some pattern due to time (below), although it is not as obvious as some examples I have seen.

Model 1:

lme_lognormal_pam_noCor<-lme(fvfm_log~maintank*daypostbirth, random=~1|tank, data=pam_nona)

plot(residuals(lme_lognormal_pam_noCor, type="normalized")~pam_nona\$daypostbirth)


acf(residuals(lme_lognormal_pam_noCor,type="normalized"))


The ACF plot of the normalized residuals would suggest an autocorrelation issue. However, can the acf plot be trusted as the ACF.lme help clearly states that this is for “for investigating serial correlation models for equally spaced data?”

Assuming that we can trust the acf plot, I try three different correlation structures:

Model 2:

lme_lognormal_pam_noCor_halfinter_Cor_nograd<-lme(fvfm_log~maintank*daypostbirth, random=~1|tank, correlation=corCompSymm(form=~daypostbirth|tank), data=pam_nona)


Model 3:

lme_lognormal_pam_noCor_halfinter_Cor_nograd2<-lme(fvfm_log~maintank*daypostbirth, random=~1|tank, correlation=corCompSymm(form=~1|tank), data=pam_nona)


When using summary, the model output states that the correlation coefficient Rho=0 However, the autocorrelation plots suggest that the autocorrelation issue is not completely dealt with (I have only included one for brevity as they are the same):

acf(residuals(lme_lognormal_pam_noCor_halfinter_Cor_nograd2,type="normalized"))


Now I will try the corAR1 structure:

Model 4:

lme_lognormal_pam_noCor_halfinter_CorAR1_nograd<-lme(fvfm_log~maintank*daypostbirth, random=~1|tank, correlation=corAR1(form=~1|tank), data=pam_nona)


The summary output gives the correlation coefficient Phi=0.71, which suggests a larger autocorrelation problem, which contrasts with the acf plot for this model that suggests we have effectively eliminated it. acf(residuals(lme_lognormal_pam_noCor_halfinter_CorAR1_nograd,type="normalized"))

The AIC comparisons suggest that the best model is Model 4 as it has the lowest AIC.

Therefore my questions are:

1) Should I go by the correlation coefficients Rho and Phi or should I look to the acf plots to diagnose autocorrelation?

I haven’t been able to find much information on using either Rho or Phi to detect autocorrelation in models other information in this paper (“Alternative Tests for Time Series Dependence based on Autocorrelation Coefficients by R.M. Levich and R. C. Rizzo, December 1998”) and this comment by Gavin Simpson that suggests their use in interpreting the impacts of autocorrelation (Do autocorrelated residual patterns remain even in models with appropriate correlation structures, & how to select the best models?). Also, a similar issue was brought up on an R list here (https://stat.ethz.ch/pipermail/r-help/2005-May/072149.html).

I would be inclined to go with either Model 2 or 3 because of Rho=0 and that acf plots don’t seem appropriate for diagnosing un-equal time intervals.

2) Based on the acf plots above and the acf plot of the model without any correlation structure, does a corAR1 or corCompSym structure seem more appropriate? If I only used AIC to decide, the corAR1 performs better. Would you ever use a biological justification of choosing one correlation structure over the other instead of AIC? For example, if you think the correlation coefficient over time should be equal (corCompSym) versus a correlation coefficient that decays with time (corAR1) based on your knowledge of the experiment.

3) Would variograms be more appropriate than acf plots at diagnosing autocorrelation with un-equally spaced data? That idea was suggested here (https://stat.ethz.ch/pipermail/r-help/2005-May/072149.html). None of the models either with Rho=0 (models 2 and 3) or with an adequate autocorrelation plot (model 4) exhibit variograms that would suggest lack of autocorrelation (no horizontal asymptote). All have a very similar shape below:

plot(Variogram(lme_lognormal_pam_noCor_halfinter_Cor_nograd2))


Any advice would be helpful. This is essentially important as the model coefficients are very different based on either the corCompSym versus the corAR1 structure.