True prevalence from apparent prevalence with uncertainty
Source:R/uncertain_rogan_gladen.R
uncertain_rogan_gladen.Rd
Uses resampling to incorporate uncertainty of sensitivity and specificity into an estimate of true prevalence from a given value of apparent prevalence.
Usage
uncertain_rogan_gladen(
pos_obs,
n_obs,
false_pos_controls = NULL,
n_controls = NULL,
false_neg_diseased = NULL,
n_diseased = NULL,
...,
spec = spec_prior(),
sens = sens_prior(),
samples = 1000,
confint = 0.95,
fmt = "%1.2f%% [%1.2f%% — %1.2f%%]",
seed = NA
)
Arguments
- pos_obs
the number of positive observations for a given test
- n_obs
the number of observations for a given test
- false_pos_controls
the number of positives that appeared in the specificity disease-free control group. These are by definition false positives. This is (1-specificity)*n_controls
- n_controls
the number of controls in the specificity disease-free control group.
- false_neg_diseased
the number of negatives that appeared in the sensitivity confirmed disease group. These are by definition false negatives. This is (1-sensitivity)*n_diseased
- n_diseased
the number of confirmed disease cases in the sensitivity control group.
- ...
not used
- spec
the prior specificity of the test as a
beta_dist
.- sens
the prior sensitivity of the test as a
beta_dist
.- samples
number fo random draws of sensitivity and specificity
- confint
confidence interval limits
- fmt
a
sprintf
formatting string accepting 3 numbers- seed
set seed for reproducibility
Examples
uncertain_rogan_gladen(
pos_obs = 20, n_obs = 1000,
false_pos_controls = 10, n_controls = 800,
false_neg_diseased = 20, n_diseased = 100)
#> # A tibble: 1 × 13
#> prevalence.median prevalence.lower prevalence.upper prevalence.label
#> <dbl> <dbl> <dbl> <chr>
#> 1 0.0101 0 0.0180 1.01% [0.00% — 1.80%]
#> # ℹ 9 more variables: spec.median <dbl>, spec.lower <dbl>, spec.upper <dbl>,
#> # spec.label <chr>, sens.median <dbl>, sens.lower <dbl>, sens.upper <dbl>,
#> # sens.label <chr>, prevalence.method <chr>
uncertain_rogan_gladen(
pos_obs = 5, n_obs = 1000,
sens = beta_dist(p=0.75,n=200),
spec = beta_dist(p=0.9975, n=800))
#> # A tibble: 1 × 13
#> prevalence.median prevalence.lower prevalence.upper prevalence.label
#> <dbl> <dbl> <dbl> <chr>
#> 1 0.00394 0 0.00625 0.39% [0.00% — 0.62%]
#> # ℹ 9 more variables: spec.median <dbl>, spec.lower <dbl>, spec.upper <dbl>,
#> # spec.label <chr>, sens.median <dbl>, sens.lower <dbl>, sens.upper <dbl>,
#> # sens.label <chr>, prevalence.method <chr>
uncertain_rogan_gladen(
pos_obs = c(5,10), n_obs = c(1000,1000),
false_pos_controls = c(2,1), n_controls = c(800,800),
false_neg_diseased = c(25,20),n_diseased = c(100,100))
#> # A tibble: 2 × 13
#> prevalence.median prevalence.lower prevalence.upper prevalence.label
#> <dbl> <dbl> <dbl> <chr>
#> 1 0.00382 0 0.00658 0.38% [0.00% — 0.66%]
#> 2 0.0113 0.00694 0.0132 1.13% [0.69% — 1.32%]
#> # ℹ 9 more variables: spec.median <dbl>, spec.lower <dbl>, spec.upper <dbl>,
#> # spec.label <chr>, sens.median <dbl>, sens.lower <dbl>, sens.upper <dbl>,
#> # sens.label <chr>, prevalence.method <chr>