acf
Auto- and Cross- Covariance or Correlation Estimation
Description
Estimates and displays autocovariance, autocorrelation or partial
autocorrelation functions.
Usage
acf(x, lag.max=NULL, type = c("correlation", "covariance",
"partial"), plot = FALSE, na.action = na.fail, demean = TRUE,
...)
ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"),
plot = FALSE, na.action = na.fail, ...)
pacf(x, lag.max = NULL, plot = FALSE, na.action = na.fail, ...)
Arguments
x |
a numeric time series (inheriting from class "ts"),
or a numeric vector or matrix, which is converted to a "ts"
object with as.ts.
acf and pacf accept univariate and multivariate time series,
ccf only univariate.
|
y |
For ccf, a univariate numeric time series or a numeric vector.
|
lag.max |
the maximum number of lags at which to estimate the covariances.
If this value is not supplied, it is a number proportional to the logarithm of the
length of the series.
|
type |
a character string:
"covariance" to estimate the autocovariance function,
"correlation" for the autocorrelation function,
or "partial", if the partial autocorrelation function is desired.
The start of one of the strings will suffice.
|
plot |
This argument is ignored by TIBCO Enterprise Runtime for R. No plotting is done.
|
na.action |
the function to deal with missing values. na.pass will pass missing
values into the computation: the dot product will omit any term involving
a missing value and the divisor (normally the length of the series) will be
decremented by the number of missing terms in the dot product.
na.contiguous will pass in the longest run of non-missing values.
|
demean |
a logical flag. If TRUE, the column means are subtracted the columns
of the time series before computing the dot products of the columns and
their lagged values.
|
... |
Other arguments are silently ignored. (R passes these arguments to plot.acf.)
|
Value
returns a list object with the class attribute acf, and with the following components:
acf |
a three-dimensional array containing the autocovariance or autocorrelation
function estimates.
acf[i,j,k] is the covariance (or correlation) between the
j-th series at time t and the k-th series at time t+1-i.
The denominator used in each estimate is the length of the series, not the
number of entries in the sum, which diminishes as it grows.)
|
lag |
an array, the same shape as acf, containing
the lags (as fractions of the cycle length) at which acf is calculated.
If j > k and i > 1, then lag[i,j,k] is negative.
|
n.used |
the number of observations used to calculate the results.
|
type |
a character string indicating the type of function:
"covariance", "correlation", or "partial".
|
series |
the name of x, including transformations.
|
snames |
the series names for a multivariate time series whose value is
colnames of x.
|
Background
The autocorrelation function (acf) and partial autocorrelation function
(pacf) are useful tools in ARIMA model identification.
They describe the serial dependence structure of a time series and
make sense only when the series is assumed to be stationary.
See Also
Examples
acf(diff(window(Sdatasets::co2, frequency=1)))
acf(Sdatasets::lynx, lag.max=36)
pacf(Sdatasets::lynx, lag.max=36)