classical.decomposition: Decompose a time series into trend, seasonal and remainder...

Description Usage Arguments Details Value Functions Note See Also Examples

View source: R/classical_decomposition.R

Description

The model is assumed to be additive, i.e. the time series is of the form: y(t) = trend(t) + seasonal(t) + remainder(t)

Usage

1
2
3
classical.decomposition(ts, period, robust = T)

plot_decomposition(decomposition, main = "Time series decomposition")

Arguments

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.

Details

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.

Value

a 3xn numeric matrix, with column trend, season and remainder

Functions

Note

Good explanation of the decomposition at https://www.otexts.org/fpp/6/3

See Also

decompose

Examples

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)

majpark21/TSexploreR documentation built on Oct. 16, 2019, 2:46 p.m.