The DiseasyModel
module implements common functionality that all models have available beyond that provided by
DiseasyBaseModule
.
Most notably, the model module facilitates:
Module interfaces: The module contains the functional modules via its active bindings:
$activity
:DiseasyActivity
$observables
:DiseasyObservables
$season
:DiseasySeason
$variant
:DiseasyVariant
Configured instances of these modules can be provided during initialisation. Alternatively, default instances of these modules can optionally be created.
Model interface: The module defines the functions
$get_results()
,$get_training_data()
and the$parameters
binding. These functions define the "API" of the models and ensure the models can take part in the ensemble.
Value
A new instance of the DiseasyModel
R6 class.
Super class
diseasy::DiseasyBaseModule
-> DiseasyModel
Active bindings
activity
(
diseasy::activity
)
The local copy of an activity module. Read-only.observables
(
diseasy::DiseasyObservables
)
The local copy of a DiseasyObservables module. Read-only.season
(
diseasy::season
)
The local copy of a season module. Read-only.variant
(
diseasy::variant
)
The local copy of a variant module. Read-only.parameters
(
list()
)
The parameters used in the model. Read-only.
Methods
Method new()
Creates a new instance of the DiseasyModel
R6 class.
This module is typically not constructed directly but rather through DiseasyModel*
classes.
Usage
DiseasyModel$new(
activity = FALSE,
observables = FALSE,
season = FALSE,
variant = FALSE,
parameters = NULL,
label = NULL,
...
)
Arguments
activity, observables, season, variant
(
boolean
orR6::R6Class instance
)
If a boolean is given, it dictates whether to load a new instance module of this class.If an instance of the module is provided instead, a copy of this instance is added to the
DiseasyModel
instance. This copy is a "clone" of the instance at the time it is added and any subsequent changes to the instance will not reflect in the copy that is added toDiseasyModel
.parameters
(
named list()
)
List of parameters to set for the model during initialization.Each model has their own parameters.
Common parameters are:
training_length
(named numeric
)
The number of days that should be included in the training splits of the data for the model. Allowed splits are: "training", "testing", and "validation".
label
(
character
)
A human readable label for the model instance....
Parameters sent to
DiseasyBaseModule
R6 constructor
Details
The DiseasyModel
is the main template that the individual models should inherit from since this defines the
set of methods the later framework expects from each model. In addition, it provides the main interface with
the other modules of the framework.
Returns
A new instance of the DiseasyModel
R6 class.
Method get_results()
The primary method used to request model results of a given observable at a given stratification
Usage
DiseasyModel$get_results(
observable,
prediction_length,
quantiles = NULL,
stratification = NULL
)
Arguments
observable
(
character
)
The observable to provide data or prediction for.prediction_length
(
numeric
)
The number of days to predict. The prediction start is defined bylast_queryable_date
of theDiseasyObservables
R6 class.quantiles
(
list
(numeric
))
Default NULL. If given, results are returned at the quantiles given.stratification
(
list
(quosures
))
Default NULL. Userlang::quos(...)
to specify stratification. If given, expressions in stratification evaluated to give the stratification level.
Returns
A tibble
tibble::tibble with predictions at the level specified by stratification level. In addition to stratification columns, the output has the columns:
date (Date
) specifying the date of the prediction
realization_id (character
) giving a unique id for each realization in the ensemble
model (character
) the name (classname) of the model used to provide the prediction.
Method get_training_data()
A method that returns training data for the models based on the model value of training_length
and
the last_queryable_date
of the DiseasyObservables
module.
Examples
# Normally, one would not want to create this module directly, but it is possible.
Model_module <- DiseasyModel$new()
rm(Model_module)