Learn R Programming

tssim (version 0.2.7)

sim_daily_hs: Simulate a daily time series based on the HS model

Description

This function simulates a daily time series with a Monte Carlo simulation based on an STS model based on Harvey and Shephard (1993) (HS model). The daily data consists of a trend, weekly seasonal, annual seasonal and irregular component. The components are each simulated by a transition process with daily random shocks. At the end of the simulation the components are combined and normalized to form the complete time series.

Usage

sim_daily_hs(
  N,
  multiplicative = TRUE,
  sizeWeeklySeas = 100,
  sizeAnnualSeas = 100,
  sizeTrend = 100,
  sizeDrift = 100,
  varIrregularity = 100,
  sizeWeeklySeasAux = 100,
  sizeAnnualSeasAux = 100,
  start = 2020,
  sizeBurnIn = 730,
  shockLevel = 1,
  shockDrift = 1,
  shockWeeklySeas = 1,
  shockAnnualSeas = 1,
  index = 100
)

Value

Multiple simulated daily time series of class xts including:

original

The original series

seas_adj

The original series seasonal effects

sfac7

The day-of-the-week effect

sfac365

The day-of-the-year effect

Arguments

N

Length of the simulated time series in years.

multiplicative

If TRUE, a multiplicative model is simulated, an additive model if FALSE.

sizeWeeklySeas

Size and stability of the weekly seasonal factor.

sizeAnnualSeas

Size and stability of the annual seasonal factor.

sizeTrend

Size of the trend component.

sizeDrift

Size of the drift of the trend component.

varIrregularity

Variance of the random irregular component.

sizeWeeklySeasAux

Size of the auxiliary variable for the weekly seasonal factor.

sizeAnnualSeasAux

size of the auxiliary variable for the annual seasonal factor.

start

The initial date or year.

sizeBurnIn

Size of burn-in sample in days.

shockLevel

Variance of the shock to the level (trend).

shockDrift

Variance of the shock to the drift (trend).

shockWeeklySeas

Variance of the shock to the weekly seasonal.

shockAnnualSeas

Variance of the shock to the annual seasonal.

index

A value to which the mean of the base year (first effective year) of the time series is normalized.

Author

Nikolas Fritz , Daniel Ollech, based on code provided by Ángel Cuevas and Enrique M Quilis

Details

The size of the components and the variance of the irregular component are defaulted to 100 each and the variances of the shocks are defaulted to 1.

The first effective year serves as base year for the time series

The impact of a seasonal factor on the time series depends on its ratio to the other components. To increase (decrease) a factor's impact, the value of the size needs to be increased (decreased) while the other components need to be kept constant. Therefore, the stability of the seasonal factor also grows as the shocks on the given component have less impact. In order to increase the impact without increasing the stability, the variance of the shock also needs to be raised accordingly.

References

Cuevas, Ángel and Quilis, Enrique M., Seasonal Adjustment Methods for Daily Time Series. A Comparison by a Monte Carlo Experiment (December 20, 2023). Available at SSRN: https://ssrn.com/abstract=4670922 or http://dx.doi.org/10.2139/ssrn.4670922

Structural Time Series (STS) Monte Carlo simulation Z = trend + seasonal_weekly + seasonal_annual + irregular, according to Harvey and Shephard (1993): "Structural Time Series Models", in Maddala, G.S., Rao, C.R. and Vinod, H.D. (Eds.) Handbook of Statistics, vol. 11, Elsevier Science Publishers.

Examples

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

Run the code above in your browser using DataLab