OneTestOnePopBMM: 1 test and 1 population binomial mixture model

Description Usage Arguments Value References Examples

Description

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

Usage

1
2
OneTestOnePopBMM(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 within infected herds, the sensitivity, the specificity and the herd prevalence. The names of these values must be "true_prev_wph", "se", "sp" and "prev_h" respectively.

priors

vector with the parameters a and b (Beta distribution) for the true prevalence within infected herds, the sensitivity and the specificity; and with the parameter p (Bernoulli distribution) for the herd prevalence. The names of these values must be: "true_prev_wph_a", "true_prev_wph_b", "se_a", "se_b", "sp_a", "sp_b" and "prev_h".

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, the true prevalence, and the positive and negative predictive values can be monitored if specified in pars as "app_prev", "true_prev", "ppv" and "npv", respectively.

thin

thinning interval for monitors. It is passed to the thin 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.

n.iter

number of iterations to monitor. It is passed to the n.iter 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
# Data (initial values for chains automatically generated).
dataset <- list(pop_size = 91, positives = 1)

# Priors
priors <- list(true_prev_wph_a = 1.8, true_prev_wph_b = 26.74, se_a = 6.28,
               se_b = 13.32, sp_a = 212.12, sp_b = 3.13, prev_h = 0.1)
               

# Prevalence estimates
prev_est <- OneTestOnePopBMM(dataset = dataset, priors = priors, n_iter = 3e3,
                             pars = c('true_prev', 'true_prev_wph', 'prev_h'))
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)

leb-fmvz-usp/ptb documentation built on May 30, 2019, 3:43 p.m.