4.1 A unified interface for linear models
In this section, we outline the general principle of model generation for ASMODEE. All models used in ASMODEE use trending (Schumacher and Jombart 2021b), which provides a general interface for different types of statistical models, including:
lm_model
: linear regression, wrapper forlm
glm_model
: generalized linear models (GLM), wrapper forglm
glm_nb_model
: negative binomial GLM, wrapper forMASS:glm.nb
The advantage of this interface is consitency of behaviours for various operations, e.g. fitting, predictions, confidence intervals and prediction intervals.
The formula syntax of these models is the same as in regular models, so the user should not have new difficulties specifying models with trending. For more information on the package, see the dedicated website.
To use asmodee
, the user needs to provide a list
of trending models. An
example of such a list is provided by models
in the code below, which
implements different models of cases over time:
- a constant model with Gaussian error
- a linear temporal trend with Gaussian error
- a log-linear temporal trend with Poisson distribution
- a log-linear temporal trend with Negative Binomial distribution
library(trending)
models <- list(
cst = lm_model(cases ~ 1),
linear = lm_model(cases ~ date),
poisson = glm_model(cases ~ date, family = poisson),
nb = glm_nb_model(cases ~ date)
)
This assumes the data we will fit these models to will have a cases
and a
date
column containing, respectively, the daily case incidence and the
corresponding date as a Date
object. However, these models would capture only
simple trends (constant, linear, or exponential), and data are typically more
complicated. The following sections illustrate how more flexible models can be
added to the list of candidate models.