Autocorrelation of a time series can be plotted in R with use of acf function. For example:

acf(ldeaths) # built-in series

enter image description here

I couldn't find any information about the blue dashed line in function's docs but after watching some videos about time series I came to conclussion that it must be the cut-off point of critical region for testing the hypothesis

$$H_0: \forall_{h \in \{1...T-1\}} \rho(h) = 0, \text{ vs } H_1: \exists h \in \{1...T-1\} \quad \rho(h) \neq 0,$$

i.e. autocorrelation is zero for all lags $h$ vs for some lag the autocorrelation is non-zero. $T$ denotes the length of the series.

I don't remember where I found it but the formula $2/\sqrt{T}$ popped up in my mind and I tried to test it:

t = length(mdeaths)
abline(h = 2/sqrt(t), col = "red")

enter image description here

It seems to be right, but I'm not sure how to derive it. I guess it has something to do with the distribution of $\hat \rho$ estimator. If it was normal with zero mean and $\sigma = 1$ and we took $z_{\alpha} \approx 2$ and $n = T$, then the term $\frac{2}{\sqrt(T)}$ would be $z_{\alpha}\frac{\sigma}{\sqrt{n}}$ used in construction of 95% confidence interval for a normally distributed variable. But the information I found about the distribution of $\hat \rho$ is inconsistent with that https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Standard_error. Can anyone help?

Edit: I've changed the value of 2 in the formula to 1.96 and the new line fits even better to the dashed one, which suits my theory.

Edit 2: I've found this: https://otexts.com/fpp2/wn.html#wn

For white noise series, we expect each autocorrelation to be close to zero. Of course, they will not be exactly equal to zero as there is some random variation. For a white noise series, we expect 95% of the spikes in the ACF to lie within ±2/√Twhere T is the length of the time series.

  • $\begingroup$ In any useful time series, $n$ is sufficiently large that one needn't fuss about the difference between $n$ and $n-2$ -- especially because the effective value of $n$ decreases as the lag increases, anyway. You don't have to reverse-engineer R code: simply inspect stats:::plot.acf (which is written in R itself), where you can verify your theory. $\endgroup$
    – whuber
    Apr 11 at 17:01
  • $\begingroup$ There have been other questions (at least one) about the same thing here on Cross Validated. You may try to find them and see if they contain any useful information. $\endgroup$ Apr 11 at 19:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.