knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(conmat)
conmat
supports parallelisation via the future
and furrr
R packages. The functions that will be impacted by this are:
First we set the future plan, saying "multisession", with 4 workers.
library(future) plan(multisession, workers = 4)
Then we run our code as normal to get the parallelisation! (note that you must specify the plan, otherwise it does not know how to parallelise. See the future package documentation for more details).
Note that these functions will run about 3 times faster than normal, they might still take some time. They are able to run in parallel as we are fitting a model to each setting, which is a task that is embarrasingly parallel.
perth <- abs_age_lga("Perth (C)") perth_contacts <- extrapolate_polymod( population = perth )
settings_estimated_contacts <- estimate_setting_contacts( contact_data_list = get_polymod_setting_data(), survey_population = get_polymod_population(), prediction_population = get_polymod_population(), age_breaks = c(seq(0, 75, by = 5), Inf), per_capita_household_size = NULL )
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 )
synthetic_settings_5y_perth <- predict_setting_contacts( population = perth, contact_model = contact_model, age_breaks = c(seq(0, 85, by = 5), Inf) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.