library(diseasy)
#> Loading required package: diseasystore
#>
#> Attaching package: 'diseasy'
#> The following objects are masked from 'package:diseasystore':
#>
#> %.%, diseasyoption
Introduction
The DiseasySeason
is the module responsible for the
implementation of different models for the seasonal dependency of the
disease.
Configuring the module
The module can be initialized without setting any parameters. Note
that some models require the parameter reference_date
to be
set which can be done during initialization of the module.
s <- DiseasySeason$new(reference_date = as.Date("2020-03-01"))
To see the season models that comes with the module we can query the module.
s$available_season_models
#> [1] "constant_season" "cosine_season" "covid_season_v1" "covid_season_v2"
By default, the module initializes with the
constant_season()
model. To check the current status of the
module, including which model is set, the $describe()
method can be used:
s$describe()
#> # Season model ###############################################
#> Season model: constant_season
#> Constant (no) seasonality model.
#> Risk of infection constant through year
#> Reference date: 2020-03-01
Once a season model is set, interfacing with the model happens
through the $model_t()
and $model_date()
methods.
t <- 0:365
plot(t, purrr::map_dbl(t, s$model_t),
type = "l", lwd = 2,
xlab = "Days past reference date",
ylab = "Relative effect of season",
ylim = c(0, 1.25), xaxs = "i", yaxs = "i")
d <- s$reference_date + 0:365
plot(d, purrr::map_dbl(d, s$model_date),
type = "l", lwd = 2,
xlab = "",
ylab = "Relative effect of season",
ylim = c(0, 1.25), xaxs = "i", yaxs = "i")
To use the other models for season, the module provides functions of
the form $use_*_season()
. For example, to configure the
module to use a cosine season instead we can use
$use_cosine_season()
s$use_cosine_season()
Once re-configured the models stored in $model_t
and
$model_date
change to the new model:
d <- s$reference_date + 0:365
plot(d, purrr::map_dbl(d, s$model_date),
type = "l", lwd = 2,
xlab = "",
ylab = "Relative effect of season",
ylim = c(0, 1.25), xaxs = "i", yaxs = "i")
Note that all models, other than constant_season
has a
scale
parameter. The scale parameter sets the relative
difference between minimum and maximum season effect in the model. For
example, if scale = 0.25
, the effect of season should never
drop below 25% of the maximum.
s$set_scale(0.25)
d <- s$reference_date + 0:365
plot(d, purrr::map_dbl(d, s$model_date),
type = "l", lwd = 2,
xlab = "",
ylab = "Relative effect of season",
ylim = c(0, 1.25), xaxs = "i", yaxs = "i")
The models may have additional parameters that control their shape. See the documentation of the module to learn more about the specific models.