Function generates data using SMA in a Single Source of Error state-space model as a data generating process.
sim.sma(order = NULL, obs = 10, nsim = 1, frequency = 1,
initial = NULL, randomizer = c("rnorm", "rlnorm", "runif", "rbeta", "rt"),
iprob = 1, ...)
Order of the modelled series. If omitted, then a random order from 1 to 100 is selected.
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.
Vector of initial states for the model. If NULL
,
values are generated.
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.
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)
.
List of the following values is returned:
model
- Name of SMA 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.
initial
- Vector (or matrix) of initial values.
iprob
- 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
.
occurrences
- Values of occurrence variable. Once again, can be either
a vector or a matrix...
logLik
- Log-likelihood of the constructed model.
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. http://dx.doi.org/10.1007/978-3-540-71918-2.
es, ets,
forecast, ts, Distributions
# NOT RUN {
# Create 40 observations of quarterly data using AAA model with errors from normal distribution
sma10 <- sim.sma(order=10,frequency=4,obs=40,randomizer="rnorm",mean=0,sd=100)
# }
Run the code above in your browser using DataLab