10
$\begingroup$

I'm going through the book 'Introductory Time Series with R' by Cowpertwait and Metcalfe. On page 36 Its says the lines are at: $-1/n \pm 2/\sqrt{n}$. I've read here R forum that the lines are at $\pm 1.96/\sqrt{n}$.

I ran the following code :

b = c(3,1,4,1) acf(b) 

and I see that the lines look to appear to be at $\pm 1.96/\sqrt{4}$. So, obviously the book is wrong? Or, Am I misreading what has been written? Are the authors talking about something slightly different?

*Note, I'm not interested in the 1.96 vs 2 minor detail discrepancy. I assume this was just the author using the rule of thumb of 2 sd's versus the actual 1.96 sd.

Edit: I ran this simulation:

acf1 = 0 acf2 = 0 acf3 = 0 for(i in 1:5000){ resids= runif(1000) residsacf = c(acf(resids,plot= FALSE)) acf1[i] = residsacf$acf[2,,1] acf2[i] = residsacf$acf[3,,1] acf3[i] = residsacf$acf[4,,1] } meanacf1 = mean(acf1) meanacf2 = mean(acf2) meanacf3 = mean(acf3) meanacf1 meanacf2 meanacf3 

I always seem to get values near $1/n$ for all 3.

Further edit : I'm seeing a trend of $1/n-(k-1)/n^2$

$\endgroup$
4
  • 1
    $\begingroup$ Really, $-\frac{1}{n}\pm \frac{2}{\sqrt{n}}$? Centered at $-\frac{1}{n}$? $\endgroup$ Commented Oct 31, 2011 at 9:58
  • $\begingroup$ In Enders' Applied Economic Time Series (2nd edition, pp 67-68) explains that the $2 / \sqrt{N}$ comes from Box and Jenkins (1976), Time Series Forecasting, Analysis, and Control. Enders used the following estimate of $var(r_s)$: $$var(r_s) = T^{-1} \left(1+2 \sum_{j=1}^{s-1}r_j^2\right).$$ Enders uses $T$ as the length of the series. $\endgroup$ Commented Nov 1, 2011 at 0:20
  • $\begingroup$ The usual limits are critical values under the null hypothesis of white noise, in which case the variance expression in Enders collapses to $1/T$. $\endgroup$ Commented Nov 1, 2011 at 1:18
  • $\begingroup$ Shumway and Stoffer in Time Series Analysis and Its Applications: With R Examples use $\pm 2/\sqrt{N}$ as well. See their ACF code available here. $\endgroup$ Commented Nov 1, 2011 at 2:01

1 Answer 1

9
$\begingroup$

The sample autocorrelation is negatively biased and the first sample autocorrelation coefficient has mean $-1/n$ where $n$ is the number of observations. But Metcalfe and Cowpertwait are incorrect in saying that all autocorrelation coefficients have that mean, and they are also incorrect in saying that R plots lines at $-1/n \pm 1.96/\sqrt{n}$.

Asymptotically the mean is 0 and that is what R uses in plotting the lines at $\pm 1.96/\sqrt{n}$ .

$\endgroup$
5
  • $\begingroup$ Thanks for the response Rob. Am I correct in understanding that the expectation of the ACF at lag 1 is -1/n? If so, shouln't the dashed lines then be centered there for the first lag? Also, since it seems what they wrote wasn't a typo. Do you think they mean something different, or they are simply wrong? I went to their website, and don't see it listed as errata. $\endgroup$ Commented Nov 8, 2011 at 2:42
  • 1
    $\begingroup$ For any reasonable sample size, $1/n$ is negligible compared to $2/\sqrt{n}$ so it doesn't matter much. I've corresponded with Andrew Metcalfe and he acknowledged the error with respect to R. I guess they haven't updated the errata yet. $\endgroup$ Commented Nov 8, 2011 at 9:38
  • $\begingroup$ Technically, isn't the flaw with R and the authors' assumption R was correct? $\endgroup$ Commented Nov 8, 2011 at 10:27
  • $\begingroup$ There are two problems. First, the mean of -1/n only applies to the first autocorrelation function, but the authors say it applies to all correlation functions. That is their error, not R's. Second, R uses the asymptotic result (as does every other software package I've seen) rather than the small sample result. So R is not wrong, it just uses an approximation that can be improved. $\endgroup$ Commented Nov 8, 2011 at 22:20
  • $\begingroup$ is this analogous to calculating sample variance using n in the denominator instead of n-1? $\endgroup$ Commented Nov 15, 2011 at 2:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.