Last active
April 26, 2020 11:41
-
-
Save dspm/3a87f18a1438badc573c99b200e1511e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(purrr) | |
set.seed(123) | |
nsim <- 10000 | |
df <- data.frame( | |
num_cases = 2000, | |
prop_underreporting = rnorm(nsim, .3, .05), | |
prop_asymptomatic = rnorm(nsim, .6, .05) | |
) | |
fun <- function(num_cases, prop_underreporting, prop_asymptomatic){ | |
num_symptomatic <- num_cases * (1/prop_underreporting) | |
num_positive <- num_symptomatic + (num_symptomatic * prop_asymptomatic) | |
return(num_positive) | |
} | |
df <- df %>% mutate(num_positive = pmap_dbl(df, fun)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment