Easily combine modules and parameters to form a model ensemble
Arguments
- model_templates
(
list(DiseasyModel))
Provide a list of model templates that will be initialized with (functional) modules and parameters.- modules
(
tibble)
The combination of modules to load into the model instances (generated bytidyr::expand_grid).- parameters
(
tibble)
The combination of parameters to set in the model instances (generated bytidyr::expand_grid).
Examples
# Create a small ensemble with the `DiseasyModelG1` model template
conn <- DBI::dbConnect(duckdb::duckdb())
#> duckdb keeps downloaded extensions and secrets in a temporary directory:
#> ℹ /tmp/RtmpYEzEL8/duckdb
#> This is removed when the R session ends.
#> • Extensions are re-downloaded each session.
#> • Secrets are lost.
#> ℹ Run duckdb(shared_home = TRUE) (or create ~/.duckdb) to keep them (suitable for most users).
#> ℹ Run duckdb(shared_home = FALSE) to accept the temporary directory (and silence this message).
#> ℹ See ?duckdb_storage for details and alternatives.
observables <- DiseasyObservables$new(
diseasystore = DiseasystoreSeirExample,
conn = conn
)
ensemble <- combineasy(
model_templates = list(DiseasyModelG1),
modules = tidyr::expand_grid(
observables = list(observables)
)
)
print(ensemble)
#> DiseasyEnsemble: DiseasyModelG1 (hash: 6fcbe)
summary(ensemble)
#> DiseasyEnsemble consisting of:
#> DiseasyModelG1: 1
rm(observables)
DBI::dbDisconnect(conn)
