tseries (version 0.1-1)

acf: Autocorrelation Function

Description

Computes the sample autocorrelation (covariance) function of x up to lag lag. If pl is TRUE, then the autocorrelation (covariance) function is plotted. For the autocorrelation function also the 95% confidence bounds for strict white noise are computed and plotted. Uses fft for efficiency reasons. Missing values are not handled.

Usage

acf (x, lag = length(x)-1, correlation = TRUE, pl = TRUE, ...)

Arguments

x
a numeric vector or time series.
lag
a scalar lag parameter.
correlation
a logical indicating whether the autocorrelation or autocovariance function is computed.
pl
a logical indicating whether the autocorrelation (covariance) function is plotted.
...
additional arguments to plot.tsparam.

Value

  • A "tsparam" object.

References

P. J. Brockwell and R. A. Davis (1991): Time Series: Theory and Methods, 2nd Edition, Springer Verlag, NY, pp. 220-225, 373-375.

See Also

tsparam

Examples

Run this code
data (sales)
acf (sales, lag = 20)
sal <- diff (sales)
acf (sal, lag = 20)
x <- rnorm (sal)
cr <- acf (x, lag = 20)
plot (cr, type = "o")

Run the code above in your browser using DataLab