IncidenceForecast: IncidenceForecast

Description Fields Methods See Also Examples

Description

A basic concrete SimulatedForecast class.

Fields

data

The prediction this model is responsible for. The data should be of class SimulatedIncidenceMatrix

forecastMadeTime

When the forecast was created.

forecastTimes

The times the forecast is about.

model

The model used to create the forecast.

nsim

The number of simulations.

sample

Draw a random sample from the possible model predictions. Please see implementation of the data for the properties of the sampling.

Methods

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

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. -Inf, and Inf will be added automatically.
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(data=SimulatedIncidenceMatrix$new(),forecastTimes=c())

Create a new IncidenceForecast.

Arguments
data - The data to initialize with

mean(trim = 0,na.rm = FALSE)

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
trim - the fraction (0 to 0.5) of observations to be trimmed from each end of ‘x’ before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.
na.rm - a logical value indicating whether ‘NA’ values should be stripped before the computation proceeds.
Value

An IncidenceMatrix with the mean over all simulations.

median(na.rm=FALSE)

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
na.rm - a logical value indicating whether ‘NA’ values should be stripped before the computation proceeds.
Value

a MatrixData.

quantile(probs,na.rm=FALSE,names=TRUE,type=7)

Get the cutoffs for each percentile in probs.

Arguments
probs - A numeric vector with elements between 0 and 1 of percentiles to find cutoffs for. (Values up to ‘2e-14’ outside that range are accepted and moved to the nearby endpoint.)
na.rm - logical; if true, any 'NA' and 'NaN''s are removed from 'x' before the quantiles are computed.
names - logical; if true, the result has a 'names' attribute. Set to 'FALSE' for speedup with many 'probs'.
type - an integer between 1 and 9 selecting one of the nine quantile algorithms detailed below to be used.
Value

an ArrayData where the rows and columns correspond to the .

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

Inherits from : SimulatedForecast

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data = SimulatedIncidenceMatrix$new(
  IncidenceMatrix$new(matrix(1:9,3,3)),
  nsim=3
)
data$addError(cols = 3,type='Poisson')
forecast = IncidenceForecast$new(data,forecastTimes=c(FALSE,FALSE,TRUE))
forecast
forecast$forecastTimes
forecast$forecastMadeTime
forecast$data$mat
forecast$nsim
forecast$sample$mat
forecast$sample$mat
forecast$mean()$mat
forecast$median()$mat
forecast$binDist(1:4*4)$arr
forecast$quantile(c(.05,.5,.95))$arr

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