Skip to content

Instantly share code, notes, and snippets.

@slodge
Created December 22, 2021 18:20
Show Gist options
  • Save slodge/99905f9877d26a4c47c72e61b7e29d5c to your computer and use it in GitHub Desktop.
Save slodge/99905f9877d26a4c47c72e61b7e29d5c to your computer and use it in GitHub Desktop.
percent_covid <- 0.01
sensitivity <- 0.67
specificity <- 0.9995
pop <- 10000
num_with_covid <- pop * percent_covid
num_without_covid <- pop * (1 - percent_covid)
lat_flow_positive_with_covid <- sensitivity * num_with_covid
lat_flow_positive_without_covid <- (1 - specificity) * num_without_covid
lat_flow_negative_with_covid <- (1 - sensitivity) * num_with_covid
lat_flow_negative_without_covid <- specificity * num_without_covid
prob_positive_given_lat_flow_positive <- lat_flow_positive_with_covid / (lat_flow_positive_with_covid + lat_flow_positive_without_covid)
prob_positive_given_lat_flow_negative <- lat_flow_negative_with_covid / (lat_flow_negative_with_covid + lat_flow_negative_without_covid)
prob_positive_given_lat_flow_positive
prob_positive_given_lat_flow_negative
percent_covid <- 0.001
sensitivity <- 0.67
specificity <- 0.9995
pop <- 10000
num_with_covid <- pop * percent_covid
num_without_covid <- pop * (1 - percent_covid)
lat_flow_positive_with_covid <- sensitivity * num_with_covid
lat_flow_positive_without_covid <- (1 - specificity) * num_without_covid
lat_flow_negative_with_covid <- (1 - sensitivity) * num_with_covid
lat_flow_negative_without_covid <- specificity * num_without_covid
prob_positive_given_lat_flow_positive <- lat_flow_positive_with_covid / (lat_flow_positive_with_covid + lat_flow_positive_without_covid)
prob_positive_given_lat_flow_negative <- lat_flow_negative_with_covid / (lat_flow_negative_with_covid + lat_flow_negative_without_covid)
prob_positive_given_lat_flow_positive
prob_positive_given_lat_flow_negative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment