Plots values of usual ACF and PACF functions with confidence
intervals. Function acfpacf uses procedures acfpacf.acf and
acfpacf.pacf, which computes values of ACF and PACF function, respectively.
acfpacf(x, nac, npac, datastr,...)
acfpacf.acf(x, normflg)
acfpacf.pacf(x, m)x).
x).
acf(k) for k = 0, ..., nr, where nr
is length of x. Parameter normflg can be equal to:
0 - acf(k) values will be normalized by nr,
1 - acf(k) values will be normalized by nr multiplied by sample variance (to obtain correlations),
2 - acf(k) values will be divided by nr-k, thus normalized by number of samples at each lag,
3 - acf(k) values will be divided by nr-k multiplied by sample variance.
In acfpacf procedure normflg=3 is used.
pacf(1)) is equal to acf(2), which is the lag 1 acf
value, and then for computing values for k = 2, ..., m the Toeplitz structure
of the projection equations is used (see Brockwell, P. J., Davis, R. A., 1991, Time Series: Theory and Methods, example 4.4.2).
plfg, acalpha, pacacalpha, valcol, thrcol, thrmhcol, where
plfg is plotting flag, this parameter should be positive number to plot computed acfpacf values,
acalpha and pacalpha are p-values (or alpha is I type error) thresholds for ACF and PACF plots based on independent normal values,
valcol,thrcol,thrmhcol are colors of function values, confidence interval markers on the ACF/PACF and confidence interval markers on the ACF/PACF
for multiple hypothesis alpha correction on the plot.
By default parameters are fixed to plfg=1, acalpha=.05, pacacalpha=.05, valcol="red", thrcol="green", thrmhcol="blue".
acfpacf returns plot of ACF and PACF values with two types of
thresholds for input acalpha and pacalpha, respectively. The first one
denoted by thr is given for ACF values by $ Pr[acf(j)>thr] = \alpha/2$ and $Pr[acf(j)<-thr] = \alpha/2$
where acf(k) is the ACF value at lag k. This threshold corresponds to type I
error for null hypothesis that acf(k) = 0. The plot allows to check if any of
the ACF values are significantly non-zero. Actual
threshold calculations are based on the following asymptotic result:
if $X_t$ is $IID (0,\sigma^2)$, then for large $n$, $\hat{\rho}(k)$ for
$k << n$ are $IID N(0,1/n)$ (see Brockwell, P. J., Davis, R. A., 1991, Time Series: Theory and Methods, example 7.2.1, p. 222).
Thus, under the null hypothesis, the plots for thr = qnorm(1-acalpha/2,0,1/sqrt(nr))
should exhibit a proportion of roughly acalpha points that lie outside
the interval [-thr, thr]. Threshold for PACF is based on the same results.
On the other hand we can also interpret the plots as a multiple hypothesis testing problem to compute second
threshold thrm. Suppose, we decided to plot some number of nonzero lags (equal to nac)
of the ACF function. If the estimated acf values estimates
are IID then we have nac independent tests of acf(k) = 0. The probability that at least one of values
lies outside the interval [-thr, thr] is equal to 1-Pr[all lie inside], which is [1-(1-acalpha)]^nac.
Finally, the last expression is approximately
equal to nac*acalpha. To get a threshold thrmh such that 1-Pr[all lie inside] = acalpha we
take the threshold as
thrmh = qnorm (1-(acalpha/2)/nac, 0, 1/sqrt(nr)) (for more details check the Bonferroni correction).
For the PACF, the threshold thrm calculation is based on Theorem 8.1.2
of Time Series: Theory and Methods, p. 241, which states that the PACF values for an AR sequence are
asymptotically normal.Brockwell, P. J., Davis, R. A. (1991), Time Series: Theory and Methods, 2nd Ed., Springer: New York.
Bretz, F., Hothorn, T., Westfall, P. (2010), Multiple Comparisons Using R, CRC Press.
Westfall, P. H., Young, S. S. (1993), Resampling-Based Multiple Testing: Examples and Methods for p-Value Adjustment, Wiley Series in Probability and Statistics.
peracf, perpacf
data(volumes)
# for original data
dev.set(which=1)
acfpacf(volumes,24,24,'volumes')
# for data after removing periodic mean
pmean_out<-permest(t(volumes),24, 0.05, NaN,'volumes',pp=0)
xd=pmean_out$xd
dev.set(which=1)
acfpacf(xd,24,24,'volumes')
Run the code above in your browser using DataLab