tsutils (version 0.9.0)

decomp: Classical time series decomposition

Description

Perform classical time series decomposition.

Usage

decomp(y, m = NULL, s = NULL, trend = NULL, outplot = c(FALSE,
  TRUE), decomposition = c("multiplicative", "additive", "auto"),
  h = 0, type = c("mean", "median", "pure.seasonal"), w = NULL)

Arguments

y

input time series. Can be ts object.

m

seasonal period. If y is a ts object then the default is its frequency.

s

starting period in the season. If y is a ts object then this is picked up from y.

trend

vector of the level/trend of y. Use NULL to estimate internally.

outplot

if TRUE, then provide a plot of the decomposed components.

decomposition

type of decomposition. This can be "multiplicative", "additive" or "auto". If y contains non-positive values then this is forced to "additive".

h

forecast horizon for seasonal component.

type

calculation for seasonal component:

  • "mean": the mean of each seasonal period.

  • "median": the median of each seasonal period.

  • "pure.seasonal": estimate using a pure seasonal model.

w

percentage or number of observations to winsorise in the calculation of mean seasonal indices. If w>1 then it is the number of observations, otherwise it is a percentage. If type != "mean" then this is ignored.

Value

A list containing:

  • trend: trend component.

  • season: season component.

  • irregular: irregular component.

  • f.season: forecasted seasonal component if h>0.

  • g: pure seasonal model parameters.

References

Ord K., Fildes R., Kourentzes N. (2017) Principles of Business Forecasting, 2e. Wessex Press Publishing Co., p.106-111.

Examples

Run this code
# NOT RUN {
decomp(referrals)

# }

Run the code above in your browser using DataLab