Extract confidence interval values ​​from an ACF correlogram

In R, we can run the ACF time series correlate, and the confidence interval bands will be plotted in light blue. But when I pull out the structure of the ACF object, I cannot find these values. Does anyone know how to extract confidence interval range values?

eg.

List of 6 $ acf : num [1:27, 1, 1] 1 0.06453 -0.06354 0.00213 -0.01324 ... $ type : chr "correlation" $ n.used: int 501 $ lag : num [1:27, 1, 1] 0 1 2 3 4 5 6 7 8 9 ... $ series: chr "tser[i:(i + 500)]" $ snames: NULL - attr(*, "class")= chr "acf" 

enter image description here

+6
source share
2 answers

I looked at the function and I don't see an easy way to extract the confidence interval. The area is calculated in the plot.acf function. To see this function, use

 getS3method("plot", "acf") 

There is a clim variable in this function, this is the one you need. The easiest way is to copy plot.acf to myplot.acf , but return clim .

+7
source

I know this question is super old, but if someone wants the value of the confidence interval to mean, it's just the value of the confidence level z divided by the sqrt of the number of observations used. In the plot.acf function plot.acf this is calculated here:

 clim0 <- if (with.ci) qnorm((1 + ci)/2)/sqrt(x$n.used) 

where with.ci is a logical value indicating whether the user wants to build confidence intervals or not, and ci is the desired level of confidence (for example, .95, .9, etc.)

EDIT: this is a confidence interval, if you think that the delayed values ​​are white noise, if it is not, there is a correction that you can apply

 clim <- clim0 * sqrt(cumsum(c(1, 2 * x$acf[-1, i, j]^2))) 

You can read more about it here.

+1
source

All Articles