Learn R Programming

ForecastFramework (version 0.10.3)

Forecast: Forecast

Description

An abstract class for storing the results of forecasting. These classes do not contain any data directly, but instead contain a data object. Extend this class when you want to store the results of a model, and none of the convenience classes are applicable.

Arguments

Fields

data

The data used to create the forecast.

forecastMadeTime

When the forecast was created.

forecastTimes

The times the forecast is about.

model

The model used to create the forecast.

Methods

binDist(cutoffs,include.lowest = FALSE,right = TRUE)

This must be extended. Get the distribution of simulations of the data within fixed bins.

Value

an ArrayData.

debug(string)

A function for debugging the methods of this class. It calls the browser command. In order for methods to opt into to debugging, they need to implement the following code at the beginning: if(<method_name> %in% private$.debug){browser()}. This method exists, because the debugger is not always intuitive when it comes to debugging R6 methods.

initialize(...)

This function should be extended. Create a new instance of this class.

mean()

This must be extended. This method extracts the elementwise mean of the forecast. This function will not change the number of rows or columns in the data, but will convert probabilistic estimates into deterministic ones.

Value

a MatrixData.

median()

This must be extended. This method extracts the elementwise median of the forecast. This function will not change the number of rows or columns in the data, but will convert probabilistic estimates into deterministic ones.

Value

a MatrixData.

quantile(alphas,na.rm=FALSE)

This must be extended. Get the cutoffs for each percentile in alphas.

Value

an ArrayData.

undebug(string)

A function for ceasing to debug methods. Normally a method will call the browser command every time it is run. This command will stop it from doing so.

See Also

Is inherited by : SimpleForecast, SimulatedForecast

Examples

Run this code
# NOT RUN {

SimpleForecast <- R6Class(
  classname = "SimpleForecast",
  inherit = Forecast,
  private = list(
    .data = MatrixData$new()
  ),
  public = list(
    binDist = function(cutoffs){
      stop("This doesn't really make sense.")
    },
    mean = function(){
      return(self$data)
    },
    median = function(){
      return(self$data)
    },
    quantile = function(alphas){
      stop("This doesn't really make sense.")
    },
    initialize = function(data,forecastTimes){
    	if(missing(data) && missing(forecastTimes)){
    		return()
    	}
      if(data$ncol != length(forecastTimes)){
        stop("The number of columns should be the number of times forecasted.")
      }
      private$.forecastMadeTime = now()
      private$.forecastTimes = forecastTimes
      private$.data = data
    }
  ),
  active = list(
  )
)
# }

Run the code above in your browser using DataLab