smooth (version 3.1.4) Simulate Exponential Smoothing


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

Usage = "ANN", obs = 10, nsim = 1, frequency = 1,
  persistence = NULL, phi = 1, initial = NULL, initialSeason = NULL,
  bounds = c("usual", "admissible", "restricted"), randomizer = c("rnorm",
  "rlnorm", "rt", "rlaplace", "rs"), probability = 1, ...)



Type of ETS model according to [Hyndman et. al., 2008] taxonomy. Can consist of 3 or 4 chars: ANN, AAN, AAdN, AAA, AAdA, MAdM etc.


Number of observations in each generated time series.


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


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


Persistence vector, which includes all the smoothing parameters. Must correspond to the chosen model. The maximum length is 3: level, trend and seasonal smoothing parameters. If NULL, values are generated.


Value of damping parameter. If trend is not chosen in the model, the parameter is ignored.


Vector of initial states of level and trend. The maximum length is 2. If NULL, values are generated.


Vector of initial states for seasonal coefficients. Should have length equal to frequency parameter. If NULL, values are generated.


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. These bounds are also used for multiplicative models, but the models are much more restrictive, so weird results might be obtained. Be careful!


Type of random number generator function used for error term. Defaults are: rnorm, rt, rlaplace and rs. rlnorm should be used for multiplicative models (e.g. ETS(M,N,N)). 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, but might result in weird values.


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). 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. ALSO NOTE: In case of multiplicative error model, the randomizer will generate 1+e_t error, not e_t. This means that the mean should typically be equal to 1, not zero.


List of the following values is returned:

  • model - Name of ETS model.

  • 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.

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

  • phi - Value of damping parameter used in time series generation.

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

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

  • probability - vector of probabilities used in the simulation.

  • intermittent - type of the intermittent model used.

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

  • occurrence - Values of occurrence variable. Once again, can be either a vector or a matrix...

  • logLik - Log-likelihood of the constructed model.


For the information about the function, see the vignette: vignette("simulate","smooth")


  • Snyder, R. D., 1985. Recursive Estimation of Dynamic Linear Models. Journal of the Royal Statistical Society, Series B (Methodological) 47 (2), 272-276.

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

See Also

es, ts, Distributions


Run this code
# Create 40 observations of quarterly data using AAA model with errors from normal distribution
ETSAAA <-"AAA",frequency=4,obs=40,randomizer="rnorm",mean=0,sd=100)

# Create 50 series of quarterly data using AAA model
# with 40 observations each with errors from normal distribution
ETSAAA <-"AAA",frequency=4,obs=40,randomizer="rnorm",mean=0,sd=100,nsim=50)

# Create 50 series of quarterly data using AAdA model
# with 40 observations each with errors from normal distribution
# and smoothing parameters lying in the "admissible" range.
ETSAAA <-"AAA",phi=0.9,frequency=4,obs=40,bounds="admissible",

# Create 60 observations of monthly data using ANN model
# with errors from beta distribution
ETSANN <-"ANN",persistence=c(1.5),frequency=12,obs=60,

# Create 60 observations of monthly data using MAM model
# with errors from uniform distribution
ETSMAM <-"MAM",persistence=c(0.3,0.2,0.1),initial=c(2000,50),

# Create 80 observations of quarterly data using MMM model
# with predefined initial values and errors from the normal distribution
ETSMMM <-"MMM",persistence=c(0.1,0.1,0.1),initial=c(2000,1),

# Generate intermittent data using AAdN
iETSAAdN <-"AAdN",obs=30,frequency=1,probability=0.1,initial=c(3,0),phi=0.8)

# Generate iETS(MNN) with TSB style probabilities
oETSMNN <- sim.oes("MNN",obs=50,occurrence="d",persistence=0.2,initial=1,
iETSMNN <-"MNN",obs=50,frequency=12,persistence=0.2,initial=4,

# }

Run the code above in your browser using DataCamp Workspace