Description Usage Arguments Details Value Functions Note See Also Examples
View source: R/classical_decomposition.R
The model is assumed to be additive, i.e. the time series is of the form: y(t) = trend(t) + seasonal(t) + remainder(t)
1 2 3 | classical.decomposition(ts, period, robust = T)
plot_decomposition(decomposition, main = "Time series decomposition")
|
ts: |
a time series or numerical vector |
period: |
number of time points in one cycle |
robust: |
if T, the median of all points of a cycle are used to determined seasonal component; if F, the mean is used instead. |
Trends is determined using a rolling mean with window width corresponding to the signal period, extremities are padded with linear interpolation from the first and last 2 measures.
Season is determined by summarizing points "period-wise". Specifically, let's consider a signal, which has 5 periods, each composed of 15 points. The 1st point of a season is determined by taking the mean (or median if robust=TRUE) of the 1st point of each of the 5 periods. Once all 15 points have been summarized, this 'unit season' is repeated 5 times to form the seasonal component.
a 3xn numeric matrix, with column trend, season and remainder
plot_decomposition
: utility plot function
Good explanation of the decomposition at https://www.otexts.org/fpp/6/3
decompose
1 2 3 4 5 | # Regular motif of length 15 repeated 5 times + Linear Trend
x <- rep(1:15, 5)
x <- x + seq(0, 10, length.out = length(x))
x_decomp <- classical.decomposition(ts = x, period = 15)
plot_decomposition(x_decomp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.