OneTestOnePopBM: 1 test and 1 population binomial model

Description Usage Arguments Details Value References Examples

View source: R/OneTestOnePopBM.R

Description

1 test and 1 population binomial model to estimate prevalence and diagnostic test related meassures.

Usage

1
2
OneTestOnePopBM(dataset, inits, priors, pars, n_iter = 10000,
  n_chains = 3, burn_in = 1000, thin = 1)

Arguments

dataset

list with the population size and the number of positives. The names of these values must be "pop_size" and "positives" respectively.

inits

list with initial conditions for chains. inits must define initial values for the true prevalence, the sensitivity and the specificity. The names of these values must be "true_prev", "se" and "sp" respectively.

priors

vector with the parameters a and b (Beta distribution) for the true prevalence, the sensitivity and the specificity. The names of these values must be: "true_prev_a", "true_prev_b", "se_a", "se_b", "sp_a" and "sp_b".

pars

character vector giving the names of parameters to be monitored. It is passed to the variable.names argument of the coda.samples function. In addition to the parameters specified in inits, the apparent prevalence and the positive and negative predictive values can be monitored if specified in pars as "app_prev", "ppv" and "npv", respectively.

n_iter

number of iterations to monitor. It is passed to the n.iter argument of the coda.samples function.

n_chains

the number of parallel chains for the model. It is passed to the n.chains argument of the jags.model function.

burn_in

the number of iteration to be discarded. It is passed to the n.iter argument of the update.jags function.

thin

thinning interval for monitors. It is passed to the thin argument of the coda.samples function.

Details

This function creates a text file with the model and it is saved in the working directory.

Value

A list of class mcmc.list.

References

https://dl.dropboxusercontent.com/u/49022/diagnostictests/index.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Data.
dataset <- list(pop_size = 91, positives = 1)

# Initial conditions for chains.
inits <- list(list(true_prev = 0.05, se = 0.8, sp = 0.9),
              list(true_prev = 0.02, se = 0.3, sp = 0.7),
              list(true_prev = 0.09, se = 0.1, sp = 0.5))

# Priors.
priors <- c(true_prev_a = 1, true_prev_b = 1,
            se_a = 6.28, se_b = 13.32, sp_a = 212.12, sp_b = 3.13)

# Prevalence estimate.
prev_est <- OneTestOnePopBM(dataset = dataset, inits = inits, n_iter = 3e3,
                            priors = priors, pars = 'true_prev')

summary(prev_est)

# Diagnostic plots.
library(coda); library(ggmcmc)
gelman.diag(prev_est)
gelman.plot(prev_est)
gg_res <- ggs(prev_est)
ggs_traceplot(gg_res)
ggs_density(gg_res)
ggs_histogram(gg_res, bins = 100)
ggs_compare_partial(gg_res)
ggs_running(gg_res)
ggs_autocorrelation(gg_res)

oswaldosantos/ptb documentation built on May 24, 2019, 5:13 p.m.