Skip to contents

fits a gam model for each setting on the survey population data & the setting wise contact data. The underlying method is described in more detail in fit_single_contact_model(). The models can be fit in parallel, see the examples. Note that this function is parallelisable with future, and will be impacted by any future plans provided.

Usage

fit_setting_contacts(contact_data_list, population, symmetrical = TRUE)

Arguments

contact_data_list

A list of dataframes, each containing informatio on the setting (home, work, school, other), age_from, age_to, the number of contacts, and the number of participants. Example data can be retrieved with get_polymod_setting_data().

population

conmat_population object or dataset with columns lower.age.limit and population. Example data can be retrieved with get_polymod_population().

symmetrical

whether to enforce symmetrical terms in the model. Defaults to TRUE. See details of fit_single_contact_model for more information.

Value

list of fitted gam models - one for each setting provided

Author

Nicholas Tierney

Examples

# These aren't being  run as they take too long to fit
if (FALSE) {
contact_model <- fit_setting_contacts(
  contact_data_list = get_polymod_setting_data(),
  population = get_polymod_population()
)

# can fit the model in parallel
library(future)
plan(multisession, workers = 4)

polymod_setting_data <- get_polymod_setting_data()
polymod_population <- get_polymod_population()

contact_model <- fit_setting_contacts(
  contact_data_list = polymod_setting_data,
  population = polymod_population
)
}