Bayesian estimation of true prevalence from apparent prevalence obtained by testing individual samples.
truePrev(x, n, SE = 1, SP = 1, prior = c(1, 1),
nchains = 2, burnin = 10000, update = 10000,
verbose = FALSE)
x
|
The apparent number of positive samples |
n
|
The sample size |
SE, SP
|
The prior distribution for sensitivity (SE) and specificity (SP); see details for specification of these distributions |
prior
|
The parameters of the prior Beta distribution for true prevalence; defaults to c(1, 1)
|
nchains
|
The number of chains used in the estimation process; must be 2 |
burnin
|
The number of discarded model iterations; defaults to 10,000 |
update
|
The number of withheld model iterations; defaults to 10,000 |
verbose
|
Logical flag, indicating if JAGS process output should be printed to the R console; defaults to FALSE
|
truePrev
calls on JAGS via the rjags package to estimate the true prevalence from the apparent prevalence in a Bayesian framework. The default model, in BUGS language, is given below. To see the actual fitted model, see the model slot of the prev
-object.
model {
x ~ dbin(AP, n)
AP <- SE * TP + (1 - SP) * (1 - TP)
# SE ~ user-defined
# SP ~ user-defined
TP ~ dbeta(prior[1], prior[2])
}
The test sensitivity (SE
) and specificity (SP
) can be specified, independently, as one of fixed
(default), uniform
, beta
, pert
, or beta-expert
.
More info on specifying distributions is available here.
A prev-class
object.
Markov chain Monte Carlo sampling in truePrev
is performed by JAGS (Just Another Gibbs Sampler) through the rjags package. JAGS can be downloaded from http://sourceforge.net/projects/mcmc-jags/.
coda for various functions that can be applied to the prev@mcmc
object
truePrevPools
: estimate true prevalence from apparent prevalence obtained by testing pooled samples with a single test
truePrevMulti
: estimate true prevalence from apparent prevalence obtained by testing individual samples with multiple tests, using a conditional probability scheme
truePrevMulti2
: estimate true prevalence from apparent prevalence obtained by testing individual samples with multiple tests, using a covariance scheme
betaPERT
: calculate the parameters of a Beta-PERT distribution
betaExpert
: calculate the parameters of a Beta distribution based on expert opinion
## Taenia solium cysticercosis in Nepal
## 142 positives out of 742 pigs sampled
## Model SE and SP based on literature data
## Sensitivity ranges uniformly between 60% and 100%
## Specificity ranges uniformly between 75% and 100%
## .. BUGS-style
truePrev(x = 142, n = 742,
SE = ~dunif(0.60, 1.00), SP = ~dunif(0.75, 1.00))
#> mean median mode sd 2.5% 97.5%
#> TP 0.129 0.126 0.169 0.078 0.006 0.282
#> SE 0.780 0.770 0.632 0.114 0.608 0.986
#> SP 0.895 0.892 0.837 0.057 0.804 0.994
#>
#> Multivariate BGR statistic = 1.0007
#> BGR values substantially above 1 indicate lack of convergence
## .. list-style
SE <- list(dist = "uniform", min = 0.60, max = 1.00)
SP <- list(dist = "uniform", min = 0.75, max = 1.00)
truePrev(x = 142, n = 742, SE = SE, SP = SP)
#> mean median mode sd 2.5% 97.5%
#> TP 0.134 0.132 0.138 0.078 0.008 0.284
#> SE 0.778 0.765 0.634 0.116 0.607 0.986
#> SP 0.899 0.896 0.879 0.056 0.804 0.995
#>
#> Multivariate BGR statistic = 1.0031
#> BGR values substantially above 1 indicate lack of convergence
## Model SE and SP based on expert opinion
## .. SE lies in between 60% and 100%; most likely value is 90%
## .. SP is with 95% confidence larger than 75%; most likely value is 90%
SE <- list(dist = "pert", a = 0.60, m = 0.90, b = 1.00)
SP <- list(dist = "beta-expert", mode = 0.90, lower = 0.75, p = 0.95)
truePrev(x = 142, n = 742, SE = SE, SP = SP)
#> mean median mode sd 2.5% 97.5%
#> TP 0.107 0.108 0.109 0.055 0.008 0.209
#> SE 0.860 0.867 0.888 0.068 0.715 0.972
#> SP 0.889 0.889 0.881 0.043 0.809 0.968
#>
#> Multivariate BGR statistic = 1.001
#> BGR values substantially above 1 indicate lack of convergence
## Model SE and SP as fixed values (each 90%)
truePrev(x = 142, n = 742, SE = 0.90, SP = 0.90)
#> mean median mode sd 2.5% 97.5%
#> TP 0.115 0.115 0.115 0.018 0.081 0.151
#> SE 0.900 0.900 0.900 0.000 0.900 0.900
#> SP 0.900 0.900 0.900 0.000 0.900 0.900
#>
#> BGR statistic = 1.0001 (upper CL = 1.0001)
#> BGR values substantially above 1 indicate lack of convergence