ACF | R Documentation |
The function ACF
computes an estimate of the autocorrelation function
of a (possibly multivariate) tsibble. Function PACF
computes an estimate
of the partial autocorrelation function of a (possibly multivariate) tsibble.
Function CCF
computes the cross-correlation or cross-covariance of two columns
from a tsibble.
ACF(
.data,
y,
...,
lag_max = NULL,
type = c("correlation", "covariance", "partial"),
na.action = na.contiguous,
demean = TRUE,
tapered = FALSE
)
PACF(.data, y, ..., lag_max = NULL, na.action = na.contiguous, tapered = FALSE)
CCF(
.data,
y,
x,
...,
lag_max = NULL,
type = c("correlation", "covariance"),
na.action = na.contiguous
)
.data |
A tsibble |
... |
The column(s) from the tsibble used to compute the ACF, PACF or CCF. |
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 |
na.action |
function to be called to handle missing
values. |
demean |
logical. Should the covariances be about the sample means? |
tapered |
Produces banded and tapered estimates of the (partial) autocorrelation. |
x , y |
a univariate or multivariate (not |
The functions improve the stats::acf()
, stats::pacf()
and
stats::ccf()
functions. The main differences are that ACF
does not plot
the exact correlation at lag 0 when type=="correlation"
and
the horizontal axes show lags in time units rather than seasonal units.
The resulting tables from these functions can also be plotted using
autoplot.tbl_cf()
.
The ACF
, PACF
and CCF
functions return objects
of class "tbl_cf", which is a tsibble containing the correlations computed.
Mitchell O'Hara-Wild and Rob J Hyndman
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.
stats::acf()
, stats::pacf()
, stats::ccf()
library(tsibble)
library(tsibbledata)
library(dplyr)
vic_elec %>% ACF(Temperature)
vic_elec %>% ACF(Temperature) %>% autoplot()
vic_elec %>% PACF(Temperature)
vic_elec %>% PACF(Temperature) %>% autoplot()
global_economy %>%
filter(Country == "Australia") %>%
CCF(GDP, Population)
global_economy %>%
filter(Country == "Australia") %>%
CCF(GDP, Population) %>%
autoplot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.