Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation


Description

The function Acf computes (and by default plots) an estimate of the autocorrelation function of a (possibly multivariate) time series. Function Pacf computes (and by default plots) an estimate of the partial autocorrelation function of a (possibly multivariate) time series. 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 = na.contiguous,
  demean = TRUE,
  ...
)

Pacf(
  x,
  lag.max = NULL,
  plot = TRUE,
  na.action = na.contiguous,
  demean = TRUE,
  ...
)

Ccf(
  x,
  y,
  lag.max = NULL,
  type = c("correlation", "covariance"),
  plot = TRUE,
  na.action = na.contiguous,
  ...
)

taperedacf(
  x,
  lag.max = NULL,
  type = c("correlation", "partial"),
  plot = TRUE,
  calc.ci = TRUE,
  level = 95,
  nsim = 100,
  ...
)

taperedpacf(x, ...)

Arguments

x

a univariate or multivariate (not Ccf) numeric time series object or a numeric vector or matrix.

lag.max

maximum lag at which to calculate the acf. Default is $10*log10(N/m)$ where $N$ is the number of observations and $m$ the number of series. Will be automatically limited to one less than the number of observations in the series.

type

character string giving the type of acf to be computed. Allowed values are “correlation” (the default), “covariance” or “partial”.

plot

logical. If TRUE (the default) the resulting acf, pacf or ccf is plotted.

na.action

function to handle missing values. Default is na.contiguous. Useful alternatives are na.pass and na.interp.

demean

Should covariances be about the sample means?

...

Additional arguments passed to the plotting function.

y

a univariate numeric time series object or a numeric vector.

calc.ci

If TRUE, confidence intervals for the ACF/PACF estimates are calculated.

level

Percentage level used for the confidence intervals.

nsim

The number of bootstrap samples used in estimating the confidence intervals.

Details

The functions improve the acf, pacf and ccf functions. The main differences are that Acf does not plot a spike at lag 0 when type=="correlation" (which is redundant) and the horizontal axes show lags in time units rather than seasonal units.

The tapered versions implement the ACF and PACF estimates and plots described in Hyndman (2015), based on the banded and tapered estimates of autocovariance proposed by McMurry and Politis (2010).

Value

The Acf, Pacf and Ccf functions return objects of class "acf" as described in acf from the stats package. The taperedacf and taperedpacf functions return objects of class "mpacf".

Author(s)

Rob J Hyndman

References

Hyndman, R.J. (2015). Discussion of “High-dimensional autocovariance matrices and optimal linear prediction”. Electronic Journal of Statistics, 9, 792-796.

McMurry, T. L., & Politis, D. N. (2010). Banded and tapered estimates for autocovariance matrices and the linear process bootstrap. Journal of Time Series Analysis, 31(6), 471-482.

See Also

Examples

Acf(wineind)
Pacf(wineind)
## Not run: 
taperedacf(wineind, nsim=50)
taperedpacf(wineind, nsim=50)

## End(Not run)

forecast

Forecasting Functions for Time Series and Linear Models

v8.14
GPL-3
Authors
Rob Hyndman [aut, cre, cph] (<https://orcid.org/0000-0002-2140-5352>), George Athanasopoulos [aut], Christoph Bergmeir [aut] (<https://orcid.org/0000-0002-3665-9021>), Gabriel Caceres [aut], Leanne Chhay [aut], Mitchell O'Hara-Wild [aut] (<https://orcid.org/0000-0001-6729-7695>), Fotios Petropoulos [aut] (<https://orcid.org/0000-0003-3039-4955>), Slava Razbash [aut], Earo Wang [aut], Farah Yasmeen [aut] (<https://orcid.org/0000-0002-1479-5401>), R Core Team [ctb, cph], Ross Ihaka [ctb, cph], Daniel Reid [ctb], David Shaub [ctb], Yuan Tang [ctb] (<https://orcid.org/0000-0001-5243-233X>), Zhenyu Zhou [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.