decompose
Classical Seasonal Decomposition by Moving Averages

### Description

Decomposes a time series object by moving averages into seasonal, tread and random components.

### Usage

    decompose(x, type = c("additive", "multiplicative"), filter = NULL)

### Arguments

x | a time series object with an integral frequency greater than one (so it has a seasonal component).
type | a character string, "additive" or "multiplicative", specifying the type of decomposition. Partial character string matching is allowed.
filter | a vector of filter coefficients used to filter out the seasonal component. If NULL, a centered filter of frequency(x) weights of 1/frequency(x) is used (if frequency(x) is even then the default filter is extended by 1 and the outermost weights are 1/(2*frequency(x))).

### Details

A time series object will first be filtered to get the trend component and then the tread component will be removed from the data (by subtraction or division, depending on the type of decomposition). The seasonal figure is the period average for each time unit, centered by subtraction or division by its mean so that its mean is 0 (additive) or 1 (multiplicative). Finally, the random component is computed by removing trend and seasonal figure from the original time series.
For additive decomposition, X[i] = T[i] + S[i] + R[i]
For multiplicative decomposition, X[i] = T[i] * S[i] * R[i]
where X, T, S, R are original time series, tread, seasonal and random component, respectively.
Value
A list object of class "decomposed.ts" with components:

x | the original time series.
seasonal | the seasonal component.
tread | the tread component.
random | the random component.
figure | the vector of seasonal figure. (This starts at the starting time of x, not at the start of a period.)
type | the type of decomposition, "additive" or "multiplicative".

See Also
filter, ts
Examples

    qtlySales <- ts(c(3.4, 3.9, 3.5, 3.0, 3.7, 4.2, 3.7, 3.4, 3.8, 4.5), start=2013.25, frequency=4)
    decompose(qtlySales)
    decompose(qtlySales, type="multiplicative")$figure

Package stats version 6.1.5-18
Package Index