Learn R Programming

smooth (version 1.9.0)

sim.ges: Simulate Generalised Exponential Smoothing

Description

Function generates data using GES with Single Source of Error as a data generating process.

Usage

sim.ges(orders = c(1), lags = c(1), frequency = 1, measurement = NULL,
  transition = NULL, persistence = NULL, initial = NULL, obs = 10,
  nsim = 1, randomizer = c("rnorm", "runif", "rbeta", "rt"), iprob = 1,
  ...)

Arguments

orders
Order of the model. Specified as vector of number of states with different lags. For example, orders=c(1,1) means that there are two states: one of the first lag type, the second of the second type.
lags
Defines lags for the corresponding orders. If, for example, orders=c(1,1) and lags are defined as lags=c(1,12), then the model will have two states: the first will have lag 1 and the second will have lag 12. The length of lags must correspond to the length of orders.
frequency
Frequency of generated data. In cases of seasonal models must be greater than 1.
measurement
Measurement vector \(w\). If NULL, then estimated.
transition
Transition matrix \(F\). Can be provided as a vector. Matrix will be formed using the default matrix(transition,nc,nc), where nc is the number of components in state vector. If NULL, then estimated.
persistence
Persistence vector \(g\), containing smoothing parameters. If NULL, then estimated.
initial
Vector of initial values for state matrix. If NULL, then generated using advanced, sophisticated technique - uniform distribution.
obs
Number of observations in each generated time series.
nsim
Number of series to generate (numeber of simulations to do).
randomizer
Type of random number generator function used for error term. Defaults are: rnorm, rt, runif, rbeta. But any function from Distributions will do the trick if the appropriate parameters are passed. For example rpois with lambda=2 can be used as well.
iprob
Probability of occurrence, used for intermittent data generation. This can be a vector, implying that probability varies in time (in TSB or Croston style).
...
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).

Value

List of the following values is returned:
  • model - Name of GES model.
  • measurement - Matrix w.
  • transition - Matrix F.
  • persistence - Persistence vector. This is the place, where smoothing parameters live.
  • initial - Initial values of GES in a form of matrix. If nsim>1, then this is an array.
  • data - Time series vector (or matrix if nsim>1) of the generated series.
  • states - Matrix (or array if nsim>1) of states. States are in columns, time is in rows.
  • residuals - Error terms used in the simulation. Either vector or matrix, depending on nsim.
  • occurrences - Values of occurrence variable. Once again, can be either a vector or a matrix...
  • logLik - Log-likelihood of the constructed model.

References

  • Svetunkov I. (2017). Statistical models underlying functions of 'smooth' package for R. Working Paper of Department of Management Science, Lancaster University 2017:1, 1-52.

See Also

sim.es, sim.ssarima, sim.ces, ges, Distributions

Examples

Run this code

# Create 120 observations from GES(1[1]). Generate 100 time series of this kind.
x <- sim.ges(orders=c(1),lags=c(1),obs=120,nsim=100)

# Generate similar thing for seasonal series of GES(1[1],1[4]])
x <- sim.ges(orders=c(1,1),lags=c(1,4),frequency=4,obs=80,nsim=100,transition=c(1,0,0.9,0.9))

# Estimate model and then generate 10 time series from it
ourModel <- ges(rnorm(100,100,5))
simulate(ourModel,nsim=10)

Run the code above in your browser using DataLab