Skip to content

Instantly share code, notes, and snippets.

@dspm dspm/covid10hr_prevalence

Last active Apr 26, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.