Subset GHRmodels Objects
Description
This function subsets selected models from a GHRmodels object into a new reduced GHRmodels object.
subset_models(models, mod_id, new_name = NULL)Arguments
models: AGHRmodelsobject.mod_id: A character vector of model IDs indicating which model(s) to keep. These must matchmodels$mod_gof$model_id.new_name:NULL(default) or a character used to build the new model IDs.
Returns
A new GHRmodels object containing only the specified model(s).
See Also
stack_models for combining GHRmodels objects, fit_models for fitting INLA models.
Examples
# Load example dataset
data(dengue_MS)
dengue_MS <- dengue_MS[dengue_MS$year %in% 2010:2012, ]
# Formulas
formulas <- c(
"dengue_cases ~ tmin + f(month, model='rw2')",
"dengue_cases ~ pdsi + f(month, model='rw2')"
)
# Fit
fitmod <- fit_models(
formulas = formulas,
data = dengue_MS,
family = "nbinomial",
offset_var = "pop100000"
)
# Subset a single model
sub1 <- subset_models(fitmod, mod_id = "mod1")