This function simulates a daily 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, weekly, annual 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.
sim_daily_mstl(
N,
multiplicative = TRUE,
start = 2020,
sizeAnnualSeas = 100,
sizeWeeklySeas = 100,
sizeIrregularity = 100,
shockAnnualSeas = 1,
shockWeeklySeas = 1,
deterministic = FALSE
)
Multiple simulated daily time series of class xts including:
The original series
The original series without seasonal effects
The day-of-the-week effect
The day-of-the-year effect
length in years
If TRUE, a multiplicative model is simulated, if FALSE, the model is additive
Start year or start date of the simulation.
Size of the annual seasonal factor, defaulted to 100.
Size of the weekly seasonal factor, defaulted to 100.
Size of the irregular component, defaulted to 100.
Shock to the annual seasonal coefficient, defaulted to 1.
Shock to the weekly seasonal coefficient, defaulted to 1.
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 randomly after a seasonal cycle.
Nikolas Fritz, Daniel Ollech
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.
x <- sim_daily_mstl(4)
ts.plot(x[,1])
Run the code above in your browser using DataLab