reapply: Reapply the model with randomly generated initial parameters...

reapplyR Documentation

Reapply the model with randomly generated initial parameters and produce forecasts

Description

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.

Usage

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,
  ...)

Arguments

object

Model estimated using one of the functions of smooth package.

nsim

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

bootstrap

The logical, which determines, whether to use bootstrap for the covariance matrix of parameters or not.

heuristics

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.

h

Forecast horizon.

newdata

The new data needed in order to produce forecasts.

occurrence

The vector containing the future occurrence variable (values in [0,1]), if it is known.

interval

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.

level

Confidence level. Defines width of prediction interval.

side

Defines, whether to provide "both" sides of prediction interval or only "upper", or "lower".

cumulative

If TRUE, then the cumulative forecast and prediction interval are produced instead of the normal ones. This is useful for inventory control systems.

Details

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.

Value

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.

Author(s)

Ivan Svetunkov, ivan@svetunkov.ru

See Also

forecast.smooth

Examples


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)


smooth documentation built on Oct. 1, 2024, 5:07 p.m.