| sacf | R Documentation |
Sample autocorrelation (sacf) and partial autocorrelation (spacf) functions
that highlight the lags belonging to one or more seasonal cycles, so that the
seasonal structure of a multi-seasonal series is visible at a glance.
ggsacf() and ggspacf() are the ggplot2 equivalents.
sacf(
x,
season = NULL,
lag.max = NULL,
ci = 0.95,
col = NULL,
main = NULL,
ylab = "ACF",
plot = TRUE,
...
)
spacf(x, ..., ylab = "PACF")
ggsacf(
x,
season = NULL,
lag.max = NULL,
ci = 0.95,
main = NULL,
ylab = "ACF",
...
)
ggspacf(x, ..., ylab = "PACF")
x |
A numeric vector, a |
season |
Numeric vector of seasonal periods to highlight, of any length.
If |
lag.max |
Maximum lag. Defaults to |
ci |
Coverage of the confidence bands, as a probability. Default |
col |
Colours used for the seasonal lags, one per element of |
main, ylab |
Plot title and y-axis label. |
plot |
If |
... |
Further arguments passed to stats::acf, and from |
Lags that are multiples of more than one period (lag 168 with
season = c(24, 168), say) are attributed to the longest matching period.
The series is treated as a plain numeric vector, so lags are always reported in
number of observations and not in units of time. Leading and trailing NAs,
such as those produced by differencing in msarima, are dropped
(stats::na.contiguous).
sacf() and spacf() invisibly return the stats::acf object, with
the seasonal periods in the "season" attribute and, for each lag, the index
of the period it belongs to in "season.group". ggsacf() and ggspacf()
return a ggplot object.
Okabe, M. and Ito, K. (2008). Color Universal Design (CUD): How to make figures and presentations that are friendly to colorblind people. https://jfly.uni-koeln.de/color/
stats::acf, msarima
fit <- msarima(MAD_m40, order = c(1, 0, 2),
seasonal = list(c(0, 1, 1), c(0, 1, 1)))
sacf(MAD_m40, lag.max = 200) # periods 24 and 168 taken from the msts object
spacf(fit) # residual pacf, periods taken from the model
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.