sim.ves: Simulate Vector Exponential Smoothing

View source: R/simves.R

sim.vesR Documentation

Simulate Vector Exponential Smoothing

Description

Function generates data using VES model as a data generating process.

Usage

sim.ves(model = "ANN", obs = 10, nsim = 1, nvariate = 2,
  frequency = 1, persistence = NULL, phi = 1, transition = NULL,
  initial = NULL, initialSeason = NULL,
  seasonal = c("individual, common"), weights = rep(1/nvariate, nvariate),
  bounds = c("usual", "admissible", "restricted"), randomizer = c("rnorm",
  "rt", "rlaplace", "rs"), ...)

Arguments

model

Type of ETS model. This can consist of 3 or 4 chars: ANN, AAN, AAdN, AAA, AAdA etc. Only pure additive models are supported. If you want to have multiplicative one, then just take exponent of the generated data.

obs

Number of observations in each generated time series.

nsim

Number of series to generate (number of simulations to do).

nvariate

Number of series in each generated group of series.

frequency

Frequency of generated data. In cases of seasonal models must be greater than 1.

persistence

Matrix of smoothing parameters for all the components of all the generated time series.

phi

Value of damping parameter. If trend is not chosen in the model, the parameter is ignored. If vector is provided, then several parameters are used for different series.

transition

Transition matrix. This should have the size appropriate to the selected model and nvariate. e.g. if ETS(A,A,N) is selected and nvariate=3, then the transition matrix should be 6 x 6. In case of damped trend, the phi parameter should be placed in the matrix manually. if NULL, then the default transition matrix for the selected type of model is used. If both phi and transition are provided, then the value of phi is ignored.

initial

Vector of initial states of level and trend. The minimum length is one (in case of ETS(A,N,N), the initial is used for all the series), the maximum length is 2 x nvariate. If NULL, values are generated for each series.

initialSeason

Vector or matrix of initial states for seasonal coefficients. Should have number of rows equal to frequency parameter. If NULL, values are generated for each series.

seasonal

The type of seasonal component across the series. Can be "individual", so that each series has its own component or "common", so that the component is shared across the series.

weights

The weights for the errors between the series with the common seasonal component. Ignored if seasonal="individual".

bounds

Type of bounds to use for persistence vector if values are generated. "usual" - bounds from p.156 by Hyndman et. al., 2008. "restricted" - similar to "usual" but with upper bound equal to 0.3. "admissible" - bounds from tables 10.1 and 10.2 of Hyndman et. al., 2008. Using first letter of the type of bounds also works.

randomizer

Type of random number generator function used for error term. Defaults are: rnorm, rt, rlaplace, rs. But any function from Distributions will do the trick if the appropriate parameters are passed. mvrnorm from MASS package can also be used.

...

Additional parameters passed to the chosen randomizer. All the parameters should be passed in the order they are used in chosen randomizer. For example, passing just sd=0.5 to rnorm function will lead to the call rnorm(obs, mean=0.5, sd=1). ATTENTION! When generating the multiplicative errors some tuning might be needed to obtain meaningful data. sd=0.1 is usually already a high value for such models.

Value

List of the following values is returned:

  • model - Name of ETS model.

  • data - The matrix (or an array if nsim>1) of the generated series.

  • states - The matrix (or array if nsim>1) of states. States are in columns, time is in rows.

  • persistence - The matrix (or array if nsim>1) of smoothing parameters used in the simulation.

  • transition - The transition matrix (or array if nsim>1).

  • initial - Vector (or matrix) of initial values.

  • initialSeason - Vector (or matrix) of initial seasonal coefficients.

  • residuals - Error terms used in the simulation. Either matrix or array, depending on nsim.

Author(s)

Ivan Svetunkov, ivan@svetunkov.ru

References

  • de Silva A., Hyndman R.J. and Snyder, R.D. (2010). The vector innovations structural time series framework: a simple approach to multivariate forecasting. Statistical Modelling, 10 (4), pp.353-374

  • Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with exponential smoothing: the state space approach, Springer-Verlag.

  • Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. New introduction to Multiple Time Series Analysis. Berlin, Heidelberg: Springer Berlin Heidelberg. doi: 10.1007/978-3-540-27752-1

  • Chen H., Svetunkov I., Boylan J. (2021). A New Taxonomy for Vector Exponential Smoothing and Its Application to Seasonal Time Series.

See Also

ves, Distributions

Examples


# Create 40 observations of quarterly data using AAA model with errors
# from normal distribution
VESAAA <- sim.ves(model="AAA",frequency=4,obs=40,nvariate=3,
                   randomizer="rnorm",mean=0,sd=100)

# You can also use mvrnorm function from MASS package as randomizer,
# but you need to provide mu and Sigma explicitly
## Not run: VESANN <- sim.ves(model="ANN",frequency=4,obs=40,nvariate=2,
                   randomizer="mvrnorm",mu=c(100,50),sigma=matrix(c(40,20,20,30),2,2))
## End(Not run)

# When generating the data with multiplicative model a more diligent definitiion
# of parameters is needed. Here's an example with MMM model:

VESMMM <- sim.ves("AAA", obs=120, nvariate=2, frequency=12, initial=c(10,0),
          initialSeason=runif(12,-1,1), persistence=c(0.06,0.05,0.2), mean=0, sd=0.03)
VESMMM$data <- exp(VESMMM$data)

# Note that smoothing parameters should be low and the standard diviation should
# definitely be less than 0.1. Otherwise you might face the explosions.


legion documentation built on Feb. 16, 2023, 5:34 p.m.