Forecast: Forecast

Description Fields Methods See Also Examples

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.

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.

Arguments
cutoffs - A numeric vector with elements to use as the dividing values for the bins.
include.lowest - logical, indicating if an x[i] equal to the lowest (or highest, for right = FALSE) breaks value should be included.
right - logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
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.

Arguments
string - The name(s) of methods to debug as a character vector

initialize(...)

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

Arguments
... - This function should take in any arguments just in case.

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.

Arguments
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.

Arguments
Value

a MatrixData.

quantile(alphas,na.rm=FALSE)

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

Arguments
alphas - A numeric vector with elements between 0 and 1 of percentiles to find cutoffs for.
na.rm - A boolean regarding whether to remove NA values before computing the quantiles.
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.

Arguments
string - The name(s) of the methods to stop debugging.

See Also

Is inherited by : SimpleForecast, SimulatedForecast

Examples

 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
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(
  )
)

ForecastFramework documentation built on April 14, 2020, 7:39 p.m.