Skip to content

Instantly share code, notes, and snippets.

@statwonk
Created March 1, 2020 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statwonk/b70a2ce292a92df85aa045ea08ab8b8a to your computer and use it in GitHub Desktop.
Save statwonk/b70a2ce292a92df85aa045ea08ab8b8a to your computer and use it in GitHub Desktop.
Coronavirus estimates
set.seed(0)
N <- 1e7 # sims
quantiles_of_interest <- function(x) { quantile(x, c(0.0001, 0.25, 0.5, 0.75, 0.9999)) }
death_rate <- function() { pmin(pmax(rlnorm(N, log(0.02), 0.35), 0.001), 0.06) }
# Statwonk's belief of final US death rate
quantiles_of_interest(death_rate())
# 0.01% 25% 50% 75% 99.99%
# 0.005470864 0.015791803 0.019996466 0.025320353 0.060000000
# between 0.1% and 6% with half probability between 1.5% and 2.5%.
# 50-50 over/under at 2%
susceptible_cases <- function() { rlnorm(N, log(0.3), 1.3) }
quantiles_of_interest(susceptible_cases())
# assuming,
# between 2.4k and 40M cases
# over/under 300k cases
# most likely between 12.4k and 720k cases.
# 0.01% 25% 50% 75% 99.99%
# 0.002404616 0.124863118 0.300184578 0.721304764 37.522636870
death_rate()*susceptible_cases() -> cases
quantiles_of_interest(cases)
# 0.01% 25% 50% 75% 99.99%
# 4.025394e-05 2.419324e-03 5.999486e-03 1.487905e-02 9.048770e-01
# I'd be shocked if less than 40 die in the US.
# over/under 6k.
# 1 in 4 chance more than 14k die.
# I'd be shocked if more than 900k die in the US.
# I wouldn't be surprised by anything in between, highly uncertain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment