This page contains the solutions to the scenarios requested in the random walk IBM tutorial. It starts by presenting the base case, and then changes one (or more) parameter(s) at a time. Results are collapsed by default, but you can expand them to interpret the new dynamics. Good luck!
To start, please load the IBM functions we prepared on the GitHub repository.
If the curl packages is not installed yet, you can do so
by:
# load package 'curl'
library('curl')
# download R file with IBM function
curl_download("https://github.com/lwillem/modelling-intro/raw/master/lib/ibm_functions.R",
destfile = "ibm_functions.R")
# load the IBM functions
source('ibm_functions.R')# you can run the random walk IBM with default parameters (see console)
run_ibm_random_walk(rng_seed = 2000)## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90%"
## [1] "Peak prevalence: 31%"
## [1] "Peak day: 22"
## [1] "Total run time: 1s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 10"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 46% [baseline: 31%]"
## [1] "Peak day: 12 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 50"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 89% [baseline: 90%]"
## [1] "Peak prevalence: 47% [baseline: 31%]"
## [1] "Peak day: 8 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 3"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 84% [baseline: 90%]"
## [1] "Peak prevalence: 13% [baseline: 31%]"
## [1] "Peak day: 29 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 10"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 42% [baseline: 31%]"
## [1] "Peak day: 23 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 100"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 17% [baseline: 90%]"
## [1] "Peak prevalence: 6% [baseline: 31%]"
## [1] "Peak day: 19 [baseline: 22]"
## [1] "Total run time: 1s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 2000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 39% [baseline: 31%]"
## [1] "Peak day: 18 [baseline: 22]"
## [1] "Total run time: 4s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 10"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 38% [baseline: 31%]"
## [1] "Peak day: 18 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 40"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 53% [baseline: 90%]"
## [1] "Peak prevalence: 13% [baseline: 31%]"
## [1] "Peak day: 44 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 1"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 85% [baseline: 90%]"
## [1] "Peak prevalence: 24% [baseline: 31%]"
## [1] "Peak day: 25 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 4"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 41% [baseline: 31%]"
## [1] "Peak day: 14 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 0"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 24% [baseline: 31%]"
## [1] "Peak day: 16 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 4"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 46% [baseline: 31%]"
## [1] "Peak day: 13 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.05"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 53% [baseline: 90%]"
## [1] "Peak prevalence: 13% [baseline: 31%]"
## [1] "Peak day: 39 [baseline: 22]"
## [1] "Total run time: 2s"
## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.1"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 1"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.4"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 90% [baseline: 90%]"
## [1] "Peak prevalence: 45% [baseline: 31%]"
## [1] "Peak day: 11 [baseline: 22]"
## [1] "Total run time: 2s"
run_ibm_random_walk(vaccine_coverage = 0.5,
apply_spatial_vaccine_refusal = F,
max_velocity = 0,
rng_seed = 2000,
add_baseline = T)## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.5"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 0"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 30% [baseline: 90%]"
## [1] "Peak prevalence: 5% [baseline: 31%]"
## [1] "Peak day: 20 [baseline: 22]"
## [1] "Total run time: 2s"
run_ibm_random_walk(vaccine_coverage = 0.5,
apply_spatial_vaccine_refusal = T,
max_velocity = 0,
rng_seed = 2000,
add_baseline = T)## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.5"
## [1] "apply_spatial_vaccine_refusal: TRUE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 0"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 22% [baseline: 90%]"
## [1] "Peak prevalence: 10% [baseline: 31%]"
## [1] "Peak day: 15 [baseline: 22]"
## [1] "Total run time: 2s"
run_ibm_random_walk(vaccine_coverage = 0.8,
apply_spatial_vaccine_refusal = F,
max_velocity = 0,
rng_seed = 2000,
add_baseline = T)## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.8"
## [1] "apply_spatial_vaccine_refusal: FALSE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 0"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 1% [baseline: 90%]"
## [1] "Peak prevalence: 0% [baseline: 31%]"
## [1] "Peak day: 1 [baseline: 22]"
## [1] "Total run time: 2s"
run_ibm_random_walk(vaccine_coverage = 0.8,
apply_spatial_vaccine_refusal = T,
max_velocity = 0,
rng_seed = 2000,
add_baseline = T)## [1] "MODEL PARAMETERS"
## [1] "pop_size: 1000"
## [1] "num_days: 50"
## [1] "num_infected_seeds: 3"
## [1] "vaccine_coverage: 0.8"
## [1] "apply_spatial_vaccine_refusal: TRUE"
## [1] "rng_seed: 2000"
## [1] "area_size: 20"
## [1] "max_velocity: 0"
## [1] "target_num_contacts_day: 10"
## [1] "max_contact_distance: 2"
## [1] "num_days_infected: 7"
## [1] "transmission_prob: 0.1"
## [1] "plot_time_delay: 0"
## [1] "-------------"
## [1] "MODEL RESULTS"
## [1] "total incidence: 3% [baseline: 90%]"
## [1] "Peak prevalence: 2% [baseline: 31%]"
## [1] "Peak day: 10 [baseline: 22]"
## [1] "Total run time: 2s"