Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

tssim (version 0.2.7)

sim_monthly_mstl: Monthly time series simulation for the MSTL-algorithm

Description

This function simulates a monthly time series according to the simulation model of Bandara, Hyndman and Bergmeir (2021) about the MSTL-algorithm for seasonal-trend decomposition. The simulated time series consists of a trend, annual seasonal and irregular component which are each simulated independently from each other. After the simulation process they are normalized and then combined to form the complete time series. As in the paper, this simulation function has the option to distinguish between a deterministic and a stochastic data generation process.

Usage

sim_monthly_mstl(
  N,
  multiplicative = TRUE,
  start = 2020,
  sizeSeasonality = 100,
  sizeIrregularity = 100,
  sizeTrend = 100,
  shockSeasonality = 1,
  deterministic = FALSE
)

Value

Multiple simulated monthly time series of class xts including:

original

The original series

seas_adj

The original series without seasonal effects

sfac

The seasonal effect

Arguments

N

length in years

multiplicative

If TRUE, a multiplicative model is simulated, if FALSE, the model is additive

start

Start year or start date of the simulation.

sizeSeasonality

Size of the annual seasonal factor.

sizeIrregularity

Size of the irregular component.

sizeTrend

Size of trend component.

shockSeasonality

Variance of the shock to the annual seasonal coefficient, defaulted to 1.

deterministic

If TRUE, the seasonal coefficients are deterministic, meaning they do not change after a seasonal cycle. If FALSE, the coefficients are stochastic, meaning they change by random shocks after a seasonal cycle.

Author

Nikolas Fritz, Daniel Ollech

References

Bandara, K., Hyndman, R. J., & Bergmeir, C. (2021). MSTL: A seasonal-trend decomposition algorithm for time series with multiple seasonal patterns. arXiv preprint arXiv:2107.13462.

Examples

Run this code
x <- sim_monthly_mstl(4)
ts.plot(x[,1])

Run the code above in your browser using DataLab