Description Fields Methods See Also Examples
An autoregressive model which assumes everything stays the same.
A MatrixData containing the data used in fitting of the model.
The farthest back column from the output value used in prediction.
The number of stochastic simulations to perform.
An array of which columns are used in prediction. 1 means the column before the prediction, 2 the one before that etc.
A string with the family of stochastic noise to apply to the recursive process. Currently only accepts 'Deterministic' and 'Poisson' as values.
Fit the model for predicting. This method breaks down the fitting process into two parts, data preparation, and the model fitting.
data | - | The data to use to fit the model. This object should be a MatrixData object. |
This method is included for compliance with the standard but does nothing. This model does not need to be fit.
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.
newdata | - | The data to forecast from. |
steps | - | The number of timesteps into the future to predict. |
private$output This function should both modify and return private$output.
Create a new MoveAheadModel
nsim | - | The number of stochastic simulations to use. |
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.
newdata | - | Optional. The data used to predict. This data should be a MatrixData object. |
Using a model previously fit with fitRow
to predict the row
th 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.
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. |
This method predicts a particular row.
row | - | The row to predict |
col | - | This is for internal use. |
This method predicts as much as possible about the next time step.
col | - | This is for internal use. |
This method gets data ready for fitting and stores it in the model for later use.
data | - | The data used to fit the model. |
This method gets data ready to use to forecast and stores it in the model for later use.
data | - | The data to use when forecasting. |
This method prepares the output for predict or forecast.
inputData | - | The data being used to predict/forecast. |
steps | - | The number of steps in the forecast. (0 for predict). |
This method gets data ready to use to predict and stores it in the model for later use.
newdata | - | The data to use when fitting the model. |
Inherits from : RecursiveForecastModel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | MoveAheadModel <- R6Class(
classname = 'MoveAheadModel',
inherit = RecursiveForecastModel,
private = list(
.data = IncidenceMatrix$new(),
newdata = IncidenceMatrix$new(),
output = ArrayData$new(),
.nsim = 3,
.predCols = c(as.integer(1)),
.maxPredCol = as.integer(1)
),
public = list(
initialize = function(nsim = 3){
private$.nsim = nsim
},
fit_ = function(){
if(self$data$ncol <= self$predCols){
stop("We cannot go further back than the start of the matrix.")
}
},
predictRow_ = function(row,col=0){
predict_(col)
},
predict_ = function(col=0){
if('predict_' %in% private$.debug){
browser()
}
if(col == 0){
col=1:private$output$ncol
}
private$output$mutate(
cols=col,
data = SimulatedIncidenceMatrix$new(
private$newdata,
private$.nsim
)$simulations
)
},
prepareFitData = function(data){
private$.data = data$clone(TRUE)
},
preparePredictData = function(newdata){
if('preparePredictData' %in% private$.debug){
browser()
}
private$newdata = SimulatedIncidenceMatrix$new(data=newdata,nsim=self$nsim)
private$.nrow = private$newdata$nrow
private$newdata$addColumns(min(self$predCols))
private$newdata$lag(min(self$predCols),na.rm=FALSE)
private$newdata$subset(cols=2:private$newdata$ncol)
},
prepareForecastData = function(data){
if(self$data$ncol <= self$predCols){
stop("We cannot go further back than the start of the matrix.")
}
private$newdata = data$clone(TRUE)
private$.nrow = private$newdata$nrow
private$newdata$addColumns(min(self$predCols))
private$newdata$lag(min(self$predCols),na.rm=TRUE)
},
prepareOutputData = function(inputData,steps=0){
private$output = SimulatedIncidenceMatrix$new(inputData,private$.nsim)
if(steps > 0){
private$output$addColumns(steps)
}
}
),
active = list(
nsim = function(value){
private$defaultActive(type='private',name='.nsim',val=value)
}
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.