Learn R Programming

perARMA (version 1.3)

acfpacf: Plotting usual ACF and PACF

Description

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.

Usage

acfpacf(x, nac, npac, datastr,...)
acfpacf.acf(x, normflg)
acfpacf.pacf(x, m)

Arguments

x
input time series, missing values are not permitted.
nac
number of ACF values to return (typically much less than length of x).
npac
number of PACF values to return (typically much less than length of x).
datastr
string name of data to be printed on the plot.
normflg
computing parameter for ACF values. These values are returned as a series acf(k) for k = 0, ..., nr, where nr is length of x. Parameter normflg can be equal to: 0 - acf(k) val
m
maximum lag to compute PACF values. Value for the first lag (pacf(1)) is equal to acf(2) and then for computing values for k = 2, ..., m the Toeplitz structure of the projection equations is used (see Brockwell, P.
...
other arguments: plfg, acalpha, pacacalpha, valcol, thrcol, thrmhcol, where plfg is plotting flag, this parameter should be positive number to plot computed

Details

Function 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.

References

Box, G. E. P., Jenkins, G. M., Reinsel, G. (1994), Time Series Analysis, 3rd Ed., Prentice-Hall, Englewood Cliffs, NJ. 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.

See Also

peracf, perpacf

Examples

Run this code
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