sample_posterior_r_mcmc_hyperR.Rd
one or sub population - known test performance - posterior distribution of prevalence. source here
sample_posterior_r_mcmc_hyperR(samps, posi, ni, se, sp, gam0)
samps | number of MCMC samples desired |
---|---|
posi | number of positive tests population |
ni | number of total tests in population |
se | known sensitivity of test |
sp | known specificity of test |
gam0 | hyperprior variance parameter |
Prevalence posterior distribution
sample_posterior_r_mcmc_hyperR
: sub population - known test performance - posterior distribution of prevalence. source here
Larremore, D. B., Fosdick, B. K., Bubar, K. M., Zhang, S., Kissler, S. M., Metcalf, C. J. E., ... & Grad, Y. (2020). Estimating SARS-CoV-2 seroprevalence and epidemiological parameters with uncertainty from serological surveys. medRxiv. doi: https://doi.org/10.1101/2020.04.15.20067066
if (FALSE) { library(tidyverse) library(skimr) sensitivity = 0.93 specificity = 0.975 positive_pop <- c(321, 123, 100, 10) negative_pop <- c(1234, 500, 375, 30) # __ ONE-POP --------------------------------------------------------------- # reproduce this # https://github.com/LarremoreLab/covid_serological_sampling/ # codebase/prevalence_onepopulation_workbook.ipynb # input for reproducible examples result_one <- sample_posterior_r_mcmc_hyperR(samps = 10000, posi = positive_pop[1], ni = negative_pop[1], # se = sensitivity, # sp = specificity, se = 0.977, sp = 0.986, gam0 = 150 ) # reproducible example 00 result_one %>% as_tibble() result_one %>% skim() result_one %>% as_tibble() %>% ggplot(aes(x = r1)) + geom_histogram(aes(y=..density..),binwidth = 0.005) # __ SUB-POPS -------------------------------------------------------------- # reproduce this # https://github.com/LarremoreLab/covid_serological_sampling/ # codebase/prevalence_subpopulations_workbook.ipynb result_sub <- sample_posterior_r_mcmc_hyperR(samps = 10000, posi = positive_pop, ni = positive_pop+negative_pop, se = sensitivity, sp = specificity, # se = 0.977, # sp = 0.986, gam0 = 150 ) # reproducible example result_sub %>% as_tibble() result_sub %>% skim() result_sub %>% as_tibble() %>% rownames_to_column() %>% select(-gam) %>% pivot_longer(cols = -rowname,names_to = "estimates",values_to = "values") %>% ggplot(aes(x = values, color = estimates)) + geom_density() }