RecursiveForecastModel: RecursiveForecastModel

Description Fields Methods See Also

Description

A model for recursively predicting multiple timesteps into the future. This class implements a particular type of forecasting, where a predict method is called to predict each successive time step in order. Extend this class if you have a predict method, but not a special forecast method.

Fields

data

A MatrixData containing the data used in fitting of the model.

maxPredCol

The farthest back column from the output value used in prediction.

predCols

An array of which columns are used in prediction. 1 means the column before the prediction, 2 the one before that etc.

stochastic

A string with the family of stochastic noise to apply to the recursive process. Currently only accepts 'Deterministic' and 'Poisson' as values.

Methods

fit(data)

Fit the model for predicting. This method breaks down the fitting process into two parts, data preparation, and the model fitting.

Arguments
data - The data to use to fit the model. This object should be a MatrixData object.

fit_()

This method must be extended. Fit the model for predicting all of the rows. Assumes the data has been put into place.

Arguments

forecast(newdata = private$.data,steps=1)

Using a model previously fit with fit to predict the next steps columns. This function assumes that all of the data preprocessing has already been taken care of. This function is similar to predict, except that it can predict multiple time steps into the future instead of a single timestep.

Arguments
newdata - The data to forecast from.
steps - The number of timesteps into the future to predict.
Value

private$output This function should both modify and return private$output.

predict(newdata)

Use a model previously fit with fit to predict. This function does not assume any data preprocessing. This function should not, in general need to be overwritten by the user. The main prediction function is predict_, so please modify that function instead if possible.

Arguments
newdata - Optional. The data used to predict. This data should be a MatrixData object.

predictRow(newdata,row,col)

Using a model previously fit with fitRow to predict the rowth row of the next column. This function does not assume any data preprocessing. Since the predict method predicts every row at the the same time, we include this method for predicting only a single row.

Arguments
newdata - Optional. The data use to predict. This can either be a matrix, appropriately formatted lag vector, or NULL to predict based on the data used to fit.
row - The row to predict the value of.
col - This is for internal use only.

predictRow_(row)

This method must be extended. Using a model previously fit with fitRow to predict the rowth row of the next column. This function assumes that all of the data preprocessing has already been taken care of.

Arguments
row - The row to predict the value of.
Value

private$output The return value should be both stored in private$output and returned using return. This should contain the results of the prediction in a Forecast object with dimensions similar to private$newdata.

predict_(col=0)

This method must be extended. Using a model previously fit with fit to predict each row of the next column. This function assumes that all of the data preprocessing has already been taken care of.

Arguments
col - Which columns of private$output should be modified. This parameter is mainly used in forecast, but could be used to store repeated predict_ calls in a single matrix.
Value

private$output The return value should be both stored in private$output and returned using return. This should contain the results of the prediction in a Forecast object with dimensions similar to private$newdata.

prepareFitData(data)

This method must be extended. Take data and store it in the object. This allows the data to be referenced later in predict() where newdata is NULL. It may also be helpful to put other data preparation steps in this method, so that the fit function runs more smoothly.

Arguments
data - The data to prepare.

prepareForecastData(data)

This method must be extended. This function takes input data and prepares it to forecast. It should in principle, be similar to preparePredictData, but sometimes forecasting requires different preparation from prediction.

Arguments
data - The data to prepare for forecasting from.
Value

private$newdata Store the processed value here, so that forecast can access it.

prepareOutputData(inputData,steps=0)

This method must be extended. This function takes the input data and constructs an appropriate container for the output of the model.

Arguments
inputData - The input to the model. Used to determine properties of the container.
steps - If the input data is used as part of a forecast, the number of steps is passed in case the output size depends on the number of time steps.

preparePredictData(newdata)

This method must be extended. Take newdata and use it to prepare the model, so that predicting doesn't need to directly reference it. This allows the model to make multiple predict_, predictRow_, or forecast calls without re-allocating the data every time.

Arguments
newdata - The data to prepare.

See Also

Is inherited by : MoveAheadModel


HopkinsIDD/ForecastFramework documentation built on Nov. 10, 2019, 2:15 a.m.