reapply
function generates the parameters based on the values in the provided
object and then reapplies the same model with those parameters to the data, getting
the fitted paths and updated states. reforecast
function uses those values
in order to produce forecasts for the h
steps ahead.
reapply(object, nsim = 1000, bootstrap = FALSE, heuristics = NULL, ...)reforecast(object, h = 10, newdata = NULL, occurrence = NULL,
interval = c("prediction", "confidence", "none"), level = 0.95,
side = c("both", "upper", "lower"), cumulative = FALSE, nsim = 100,
...)
reapply()
returns object of the class "reapply", which contains:
timeElapsed
- Time elapsed for the code execution;
y
- The actual values;
states
- The array of states of the model;
refitted
- The matrix with fitted values, where columns correspond
to different paths;
fitted
- The vector of fitted values (conditional mean);
model
- The name of the constructed model;
transition
- The array of transition matrices;
measurement
- The array of measurement matrices;
persistence
- The matrix of persistence vectors (paths in columns);
profile
- The array of profiles obtained by the end of each fit.
reforecast()
returns the object of the class forecast.smooth,
which contains in addition to the standard list the variable paths
- all
simulated trajectories with h in rows, simulated future paths for each state in
columns and different states (obtained from reapply()
function) in the
third dimension.
Model estimated using one of the functions of smooth package.
Number of paths to generate (number of simulations to do).
The logical, which determines, whether to use bootstrap for the covariance matrix of parameters or not.
The value for proportion to use for heuristic estimation of the
standard deviation of parameters. If NULL
, it is not used.
Other parameters passed to reapply()
and mean()
functions in case of
reforecast
(trim
parameter in mean()
is set to
0.01 by default) and to vcov
in case of reapply
.
Forecast horizon.
The new data needed in order to produce forecasts.
The vector containing the future occurrence variable (values in [0,1]), if it is known.
What type of mechanism to use for interval construction. The options
include interval="none"
, interval="prediction"
(prediction intervals)
and interval="confidence"
(intervals for the point forecast). The other options
are not supported and do not make much sense for the refitted model.
Confidence level. Defines width of prediction interval.
Defines, whether to provide "both"
sides of prediction
interval or only "upper"
, or "lower"
.
If TRUE
, then the cumulative forecast and prediction
interval are produced instead of the normal ones. This is useful for
inventory control systems.
Ivan Svetunkov, ivan@svetunkov.com
The main motivation of the function is to take the randomness due to the in-sample estimation of parameters into account when fitting the model and to propagate this randomness to the forecasts. The methods can be considered as a special case of recursive bootstrap.
forecast.smooth
x <- rnorm(100,0,1)
# Just as example. orders and lags do not return anything for ces() and es(). But modelType() does.
ourModel <- adam(x, "ANN")
refittedModel <- reapply(ourModel, nsim=50)
plot(refittedModel)
ourForecast <- reforecast(ourModel, nsim=50)
Run the code above in your browser using DataLab