acf {ts} | R Documentation |
Autocovariance and Autocorrelation Function Estimation
Description
The function acf
computes (and by default plots) estimates of
the autocovariance or autocorrelation function. Function pacf
is the function used for the partial autocorrelations. Function
ccf
computes the cross-correlation or cross-covariance of two
univariate series.
Usage
acf(x, lag.max = NULL,
type = c("correlation", "covariance", "partial"),
plot = TRUE, na.action, demean = TRUE, ...)
pacf(x, lag.max = NULL, plot = TRUE, na.action, ...)
ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"),
plot = TRUE, na.action, ...)
Arguments
x , y |
a univariate or multivariate (not |
lag.max |
maximum lag at which to calculate the acf. Default
is |
type |
character string giving the type of acf to be computed.
Allowed values are
|
plot |
logical. If |
na.action |
function to be called to handle missing values. |
demean |
logical. Should the covariances be about the sample means? |
... |
further arguments to be passed to |
Details
For type
= "correlation"
and "covariance"
, the
estimates are based on the sample covariance.
The partial correlation coefficient is estimated by fitting
autoregressive models of successively higher orders up to
lag.max
.
The generic function plot
has a method for objects of class
"acf"
.
Value
An object of class "acf"
, which is a list with the following
elements:
lag |
A three dimensional array containing the lags at which the acf is estimated. |
acf |
An array with the same dimensions as |
type |
The type of correlation (same as the |
n.used |
The number of observations in the time series. |
series |
The name of the series |
snames |
The series names for a multivariate time series. |
The result is returned invisibly if plot
is TRUE
.
Author(s)
Original: Paul Gilbert, Martyn Plummer.
Extensive modifications and univariate case of pacf
by
B.D. Ripley.
See Also
plot.acf
Examples
## Examples from Venables & Ripley
data(lh)
acf(lh)
acf(lh, type="covariance")
pacf(lh)
data(UKLungDeaths)
acf(ldeaths)
acf(ldeaths, ci.type="ma")
acf(ts.union(mdeaths, fdeaths))
ccf(mdeaths, fdeaths) # just the cross-correlations.