Learn R Programming

smooth (version 1.6.3)

sim.ces:

Description

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

Usage

sim.ces(seasonality=c("none","simple","partial","full"),
        frequency=1, A=NULL, B=NULL,
        initial=NULL,
        obs=10, nsim=1,
        randomizer=c("rnorm","runif","rbeta","rt"),
        iprob=1, ...)

Arguments

seasonality
The type of seasonality used in CES. Can be: none - No seasonality; simple - Simple seasonality, using lagged CES (based on t-m observation, where m is the seasonality lag); partial - Partial seasonality with real seasonal components (equivalent to additive seasonality); full - Full seasonality with complex seasonal components (can do both multiplicative and additive seasonality, depending on the data). First letter can be used instead of full words. Any seasonal CES can only be constructed for time series vectors.
frequency
Frequency of generated data. In cases of seasonal models must be greater than 1.
A
First complex smoothing parameter. Should be a complex number.

NOTE! CES is very sensitive to A and B values so it is advised to use values from previously estimated model.

B
Second complex smoothing parameter. Can be real if seasonality="partial". In case of seasonality="full" must be complex number.
initial
A matrix with initial values for CES. In case with seasonality="partial" and seasonality="full" first two columns should contain initial values for non-seasonal components, repeated frequency times.
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 CES model.
A
Value of complex smoothing parameter A. If nsim>1, then this is a vector.
B
Value of complex smoothing parameter B. If seasonality="n" or seasonality="s", then this is equal to NULL. If nsim>1, then this is a vector.
initial
Initial values of CES 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., Kourentzes, N. (February 2015). Complex exponential smoothing. Working Paper of Department of Management Science, Lancaster University 2015:1, 1-31.

See Also

sim.es, sim.ssarima, ces, Distributions

Examples

Run this code
# Create 120 observations from CES(n). Generate 100 time series of this kind.
x <- sim.ces("n",obs=120,nsim=100)

# Generate similar thing for seasonal series of CES(s)_4
x <- sim.ces("s",frequency=4,obs=80,nsim=100)

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

Run the code above in your browser using DataLab