Bayesian Prevalence-Incidence Mixture Model

Models time-to-event data from interval-censored screening studies. It accounts for latent prevalence at baseline and incorporates misclassification due to imperfect test sensitivity. For usage details, see the package vignette "BayesPIM_intro". Further details can be found in Klausch, Lissenberg-Witte and Coupé (2026) .


BayesPIM: Bayesian prevalence-incidence mixture model

BayesPIM fits prevalence-incidence mixture (PIM) models to screening and surveillance data, as described in Klausch et al. (2026). It models time to incidence with an accelerated failure time specification, latent prevalence at baseline with a probit model, and imperfect test sensitivity, using a Bayesian Gibbs sampler. For full usage see vignette("BayesPIM_intro").

Installation

install.packages("BayesPIM")

Or the development version from GitHub:

# install.packages("devtools")
devtools::install_github("thomasklausch2/BayesPIM", build_vignettes = TRUE)

Example

Simulate screening data and fit the model. The default sampler is the collapsed slice sampler, which augments only the latent screening interval.

library(BayesPIM)

set.seed(2025)
dat <- gen_data(
  kappa = 0.7,            # test sensitivity
  n = 1e3, theta = 0.2,   # sample size and baseline prevalence
  p = 1, p_discrete = 1,
  beta_t = c(0.2, 0.2), beta_g = c(0.2, 0.2),
  v_min = 20, v_max = 30, mean_rc = 80,
  sigma_t = 0.2, mu_t = 5, dist = "weibull", prob_r = 1
)

mod <- bayespim(
  v_obs = dat$v_obs,
  x_t = dat$x, x_g = dat$x, r = dat$r,
  kappa = 0.7, update_kappa = FALSE,
  dist = "weibull",             # also lognormal, loglog, gamma, gengamma
  sampler = "slice_collapsed",  # also "slice" and "mh"
  ndraws = 1e3, warmup = 5e2,
  chains = 4, seed_chains = 1:4,
  update_till_converge = TRUE   # extend sampling until R-hat and ESS are met
)

Convergence diagnostics are printed while fitting and stored in mod$convergence. Posterior summaries and trace plots come from the summary() and plot() methods:

summary(mod)              # posterior quantiles, R-hat and ESS per block
plot(mod, thinning = 5)   # trace and density plots

Compare incidence distributions with information criteria, and obtain posterior predictive cumulative incidence functions:

get_ic(mod, samples = 1e3, cores = 2)   # WAIC-1, WAIC-2 and DIC

cif <- ppCIF(mod, pst_samples = 1e3, quant = seq(0, 300, length.out = 601))
plot(cif, type = "both")   # mixture and non-prevalent CIF

References

T. Klausch, B. I. Lissenberg-Witte, and V. M. H. Coupé (2026). “A Bayesian prevalence-incidence mixture model for screening outcomes with misclassification.”, Statistics in Medicine, 45(8-9), e70433. doi:10.1002/sim.70433

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("BayesPIM")

2.0 by Thomas Klausch, 2 months ago


https://github.com/thomasklausch2/BayesPIM


Report a bug at https://github.com/thomasklausch2/BayesPIM/issues


Browse source code at https://github.com/cran/BayesPIM


Authors: Thomas Klausch [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp, MASS, doParallel, foreach, parallel, actuar, posterior, survival, flexsurv, graphics, grDevices, stats, utils

Depends on coda

Suggests knitr, rmarkdown, bookdown

Linking to Rcpp


See at CRAN