sim.es | R Documentation |
Function generates data using ETS with Single Source of Error as a data generating process.
sim.es(model = "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, ...)
model |
Type of ETS model according to [Hyndman et. al., 2008]
taxonomy. Can consist of 3 or 4 chars: |
obs |
Number of observations in each generated time series. |
nsim |
Number of series to generate (number of simulations to do). |
frequency |
Frequency of generated data. In cases of seasonal models must be greater than 1. |
persistence |
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 |
phi |
Value of damping parameter. If trend is not chosen in the model, the parameter is ignored. |
initial |
Vector of initial states of level and trend. The maximum
length is 2. If |
initialSeason |
Vector of initial states for seasonal coefficients.
Should have length equal to |
bounds |
Type of bounds to use for persistence vector if values are
generated. |
randomizer |
Type of random number generator function used for error
term. Defaults are: |
probability |
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 |
For the information about the function, see the vignette:
vignette("simulate","smooth")
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.
Ivan Svetunkov, ivan@svetunkov.ru
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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-540-71918-2")}.
es, ts, Distributions
# Create 40 observations of quarterly data using AAA model with errors from normal distribution
ETSAAA <- sim.es(model="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 <- sim.es(model="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 <- sim.es(model="AAA",phi=0.9,frequency=4,obs=40,bounds="admissible",
randomizer="rnorm",mean=0,sd=100,nsim=50)
# Create 60 observations of monthly data using ANN model
# with errors from beta distribution
ETSANN <- sim.es(model="ANN",persistence=c(1.5),frequency=12,obs=60,
randomizer="rbeta",shape1=1.5,shape2=1.5)
plot(ETSANN$states)
# Create 60 observations of monthly data using MAM model
# with errors from uniform distribution
ETSMAM <- sim.es(model="MAM",persistence=c(0.3,0.2,0.1),initial=c(2000,50),
phi=0.8,frequency=12,obs=60,randomizer="runif",min=-0.5,max=0.5)
# Create 80 observations of quarterly data using MMM model
# with predefined initial values and errors from the normal distribution
ETSMMM <- sim.es(model="MMM",persistence=c(0.1,0.1,0.1),initial=c(2000,1),
initialSeason=c(1.1,1.05,0.9,.95),frequency=4,obs=80,mean=0,sd=0.01)
# Generate intermittent data using AAdN
iETSAAdN <- sim.es("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,
randomizer="rlnorm",meanlog=0,sdlog=0.3)
iETSMNN <- sim.es("MNN",obs=50,frequency=12,persistence=0.2,initial=4,
probability=oETSMNN$probability)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.