Skip to content

Instantly share code, notes, and snippets.

@sbfnk
Last active January 24, 2020 13:33
Show Gist options
  • Save sbfnk/3b27eca3bfcc2244f5bbb13e13e57525 to your computer and use it in GitHub Desktop.
Save sbfnk/3b27eca3bfcc2244f5bbb13e13e57525 to your computer and use it in GitHub Desktop.
Simulate outbreak sizes
## devtools::install_github("sbfnk/bpmodels")
library('bpmodels')
## 41 initial exposure events
n <- 41
## exposure events distributed over `nexp` days
nexp <- 26 ## 8 Dec - 2 Jan according to http://virological.org/t/epidemiological-data-from-the-ncov-2019-outbreak-early-descriptions-from-publicly-available-data/337/1
## randomly sample exposure events
t0 <- sample(seq(1, 26), n, replace = TRUE)
## mean of serial interval distribution
mean_si <- 8.4 ## from Lispsitch et al. (2003)
## sd of serial interval distribution
sd_si <- 3.8 ## from Lispsitch et al. (2003)
## R0
R0 <- 2 ## to test
## k
k <- 0.16 ## from Lloyd-Smith (2005).
## end time
tf <- 37 ## 37 days from 8 Dec (see nexp)
## simulate chains
sim <- chain_sim(n, "nbinom", serial = function(x) rnorm(x, mean_si, sd_si),
mu = R0, size = k, t0 = t0, tf = tf)
## add reporting delays
times <- sim$time + 6.17 ## should use empirical distribution from linelist via the virological link
times <- times[times < tf]
## outbreak size
size <- length(times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment