Decompose a time series into trend, cyclical, seasonal and irregular components. Deals with additive or multiplicative components.
tsdecomp(
x,
type = c("additive", "multiplicative"),
trend.method = c("lm", "loess"),
tcc.order = 3,
x.name = NULL,
show.plot = TRUE,
...
)# S3 method for tsdecomp
print(
x,
decomp.incl = c("all", "tc", "tcc", "cc", "detrend", "ic", "scadj", "sc", "sceffect"),
...
)
# S3 method for tsdecomp
plot(
x,
plot.incl = c("all", "tc", "tcc", "cc", "detrend", "ic", "scadj", "sc", "sceffect"),
...
)
An object of class "tsdecomp" with following components:
original series data
list of time in which the series values were observed.
time gap between the series and forecasted values.
name of the time series for which forecasts was requested.
value of the trend component for each observation.
value of the cyclical component for each observation.
trend-cyclical component value of each observation.
value of each observation after removing the trend component.
value of the seasonal component for each observation.
value of each observation after removing the seasonal component
value of the irregular component for each observation.
value expressing the estimated overall effect of each season in the time series.
type of the time series decomposition.
a time series for which decomposition is required or a `tsdecomp` object.
type of the time series components. Available options are `additive` and `multiplicative`. Can be abbreviated. Default is `additive`.
estimating method of the trend. Available options are `lm` (linear) and `loess` (non-linear). Default is `lm`.
moving average order for the estimation of the trend-cycle component.
name of the series. If omitted here, the series name found by tsname() will be taken over here. If tsname() is NULL, the variable name will be used instead. Default is NULL.
logical. If TRUE, forecasting plot will be displayed directly. Default is TRUE.
parameter values that can affect the time series decomposition plots.
time series components that should be printed. Available options are `all` (default), `tc` (trend), `tcc` (trend-cycles), `tcc` (cycles), `detrend`, `ic` (irregular), `scadj` (seasonally adjusted), `sc` (seasonality), and `sceffect` (seasonal effects).
time series components that should be plotted. Available options are `all` (default), `tc` (trend), `tcc` (trend-cycles), `tcc` (cycles), `detrend`, `ic` (irregular), `scadj` (seasonally adjusted), `sc` (seasonality), and `sceffect` (seasonal effects). Ignored if show.plot = FALSE.
Ka Yui Karl Wu
The additive model used is:
$$Y_t = T_t + C_t + S_t + I_t$$
The multiplicative model used is:
$$Y_t = T_t \cdot C_t \cdot S_t \cdot I_t$$
The function first determines the trend-cycle component using a moving average, and removes it from the time series. Then, the seasonal figure is computed by averaging, for each time unit, over all periods. The seasonal figure is then centred. Finally, the error component is determined by removing trend and seasonal figure (recycled as needed) from the original time series.
This only works well if `x` covers an integer number of complete periods.
The function `plot` generates the following plots:
Trend | a time series line plot together with a trend line. | |
Trend-Cycles | a time series line plot together with the trend-cycle component (moving averages). | |
Cycles | a line plot of the trend-cycle component (moving averages). | |
Detrended | a line plot of the time series after removing the trend component. | |
Irregular | a line plot of the irregular component. | |
Seasonally Adjusted | a line plot of the time series after removing the seasonal component. | |
Seasonal | a line plot of the seasonal component. | |
Seasonal Effect | a line plot of the overall estimated effect of each season in the time series. |
Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts.
https://otexts.com/fpp3/
Kendall, M., & Stuart, A. (1983) The Advanced Theory of Statistics, Vol.3, Griffin. pp. 410-414.
tsdecomp(airport$Travellers, type = "multiplicative")
Run the code above in your browser using DataLab