sim_campaigns: Simulated vaccination campaigns

Description Usage Arguments Details Value Examples

View source: R/vaccinate.R

Description

sim_campaigns simulates annual vaccination campaigns across locations & time.

Usage

1
2
3
4
5
6
7
8
9
sim_campaigns(
  locs,
  campaign_prob = 0.5,
  coverage = 0.5,
  sim_years = 10,
  burn_in_years = 5,
  steps_in_year = 52,
  sample_tstep = function(n) {     sample.int(52, n, replace = TRUE) }
)

Arguments

locs

numeric or character vector of ids of locations

campaign_prob

either a single numeric probability 0, 1 or vector of probabilities of the same length as locs which specifies the probability that a campaign occurs in a given location in a given year

coverage

either a function that returns a coverage estimate 0, 1, a single numeric value of coverage

sim_years

the number of years to simulate campaigns over

burn_in_years

the number of years to start without any vaccination

steps_in_year

timestep to allocate campaigns across, defaults to weekly

sample_tstep

function to sample the timestep during which a campaign occurs in a given location

Details

This function simulates annual vaccination campaigns for a givens et of locations (locs) over a certain time frame. Optionally, you can include a burn-in period where no campaigns occur (in addition to the imeframe you specify). You can flexibly pass simulated coverage and the timestep which campaigns occur using custom functions which accept a single parameter (n = the number of values to return). Defaults to using a weekly time step, but this can be changed through the steps_in_year parameter. See examples for more details.

To Do:

Value

a data.table with three columns: vacc_times (timestep of campaign), vacc_est (coverage/number vaccinated estimate), vacc_locs (location of campaign)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
ex_campaign <- sim_campaigns(locs = 1:10) # with defaults
ex_campaign <- sim_campaigns(locs = 1:10, burn_in_years = 10) # longer burn in

# with a beta distribution around coverage (takes n as only parameter)
cov_fun <- function(n) rbeta(n, shape1 = 2, shape2 = 2)
ex_campaign <- sim_campaigns(locs = 1:10, coverage = cov_fun)

# with a different sample_tstep function (takes n as only parameter)
only half of year do campaigns occur
sample_half <- function(n) sample.int(26, n, replace = TRUE)
ex_campaign <- sim_campaigns(locs = 1:10, sample_tstep = sample_half)
hist(ex_campaign$vacc_times)

# three month gaps between campaigns
sample_threemos <- function(n) sample(seq(0, 52, 12), n, replace = TRUE)
ex_campaign <- sim_campaigns(locs = 1:10, sample_tstep = sample_threemos)
hist(ex_campaign$vacc_times)

# simulate on monthly timestep
ex_campaign <- sim_campaigns(locs = 1:10, steps_in_year = 12,
sample_tstep = function(n) {sample.int(12, n, replace = TRUE)})

mrajeev08/simrabid documentation built on May 7, 2021, 11:47 a.m.