fitcensBayes: Objective Bayesian Fitting with Independent Right Censoring

View source: R/fitcensBayes.R

fitcensBayesR Documentation

Objective Bayesian Fitting with Independent Right Censoring

Description

Fits registered univariate distributions to exact and independently right-censored observations using the objective priors of the complete-data model. This is separate from the complete-data interface fitdistrBayes.

Usage

fitcensBayes(x, status, distr, prior = NULL, start = NULL, fixed = NULL,
  iter = 4000L, warmup = floor(iter / 2), thin = 1L,
  chains = 4L, seed = NULL,
  method = c("auto", "direct", "augmentation"),
  na.action = c("fail", "omit"), control = list(), ...,
  criteria = FALSE)

Arguments

x

Nonempty numeric vector of observed values: the event time when status = 1, or the lower censoring limit when status = 0. Values must satisfy the support of the selected model.

status

Numeric or logical vector of the same length as x. One (TRUE) denotes an exact event; zero (FALSE) denotes the strict event T > x. For a discrete model, a record meaning T \ge 3 must be entered as x = 2, status = 0.

distr

One of the 20 registered distribution names, ignoring case. See fitcensBayes_models and the Details section. A density function or model specification defined by the user is not supported by this censored interface.

prior

A registered prior name. It must be supplied explicitly. See fitcensBayes_models for the available names by model.

start

Optional named list or numeric vector of initial parameter values on the original scale. Missing starting values use the classical initialization of the complete-data model applied to the exact events. Starts initialize computation; they do not determine propriety.

fixed

Optional named list of fixed parameters. The negative binomial requires positive size. The usual Student-t routes require positive df; its "independence-jeffreys" route estimates df.

iter

Total iterations per chain, including warmup; at least 20.

warmup

Number of initial iterations discarded; nonnegative and smaller than iter.

thin

Retain every thin-th iteration after warmup. At least ten draws per chain must remain.

chains

Number of independently initialized chains; at least two.

seed

Optional nonnegative integer seed passed to set.seed() before posterior simulation. The RNG state advances normally.

method

Sampling method. "auto" uses the original sampler without censoring and the observed likelihood with censoring. "direct" uses the observed likelihood (not necessarily independent simulation); "augmentation" samples latent censored lifetimes and updates the parameters conditionally.

na.action

Whether to reject missing values or omit the entire x, status pair. Infinite values are always rejected.

control

Named list of controls, described below.

...

Reserved for future extensions. Unused arguments are errors.

criteria

FALSE by default: no model-comparison computation. TRUE requests WAIC, PSIS-LOO, and DIC after sampling; a character vector selects "waic", "looic", or "dic". Must be named in full. PSIS-LOO requires the optional loo package. See criteria.

Details

Censoring is assumed independent and non-informative about the lifetime parameters. The observed likelihood is proportional to

L(\theta) = \prod_{i:\delta_i=1} f(x_i\mid\theta) \prod_{i:\delta_i=0} S(x_i\mid\theta),

where S(t\mid\theta)=P(T>t\mid\theta). The censoring distribution is not estimated. Only right censoring is implemented.

The supported distributions are beta, Cauchy, chi-squared, exponential, gamma, geometric, lognormal, logistic, negative binomial, normal, Poisson, Student-t, Weibull, Frechet, Gumbel, Lomax, Nakagami-m, exponential-logarithmic, Rician, and weighted Lindley. Their parameterizations and aliases are those of fitdistrBayes. There are 56 registered model-prior routes. Not every prior is available for every model.

Interpretation of the priors. The function reuses Jeffreys, reference, and maximal data information priors derived for the complete-data sampling model, including the registered first-rule and parameter-ordered variants. It does not claim that these are the corresponding objective priors derived from the information matrix of a particular censoring design.

Posterior propriety and moments. Since every survival factor is at most one, a proper posterior based on the exact-event subset implies a proper censored posterior. The complete-data sufficient conditions are therefore applied to this subset, not to the total or imputed sample size. A finite nonnegative posterior moment also transfers by the same bound. Failure of this sufficient criterion is not claimed to prove impropriety; the function stops without sampling. Uncertified moments are labelled NA and are not estimated from a finite chain. Known infinite moments are distinguished by FALSE. In particular, positive moments of the Weibull scale diverge under the registered priors, even though medians and credible intervals exist.

For the exponential model, let m=\sum_i\delta_i and A=\sum_i x_i. The rate posterior is \mathrm{Gamma}(m,A) under Jeffreys/reference and \mathrm{Gamma}(m+2,A) under MDI, using the shape-rate convention. It requires A>0 finite and positive shape. Thus all-censored exponential data are accepted under MDI; other all-censored routes are not certified. For geometric Jeffreys/reference, the probability posterior is \mathrm{Beta}(m,\sum_i x_i+n_c+1/2), where n_c is the number censored and counts start at zero.

Computation. Observed-likelihood sampling uses exact simulation for the analytic cases, marginal slice sampling with conditional scale simulation for Weibull, and preconditioned slice sampling otherwise. Augmentation generates T_i\mid T_i>x_i,\theta and uses conditional parameter updates; normal and lognormal models have exact blocked updates. Initial values use classical estimates from the exact events, optional optimization of the observed log posterior, and dispersed chain starts. The geometry is fixed during retained simulation. Imputed data are never used to certify propriety. Difficult tails and heavy censoring can require longer runs; inspect diagnostics rather than relying on default iteration counts.

Controls.

rhat_threshold, ess_threshold

Diagnostic targets, default 1.01 and 400 for rank-normalized split/folded R-hat and bulk/tail ESS.

slice_width, slice_steps, max_shrink

Slice width (1), maximum stepping-out budget (40), and shrinkage budget (1000).

init_jitter, max_init_tries

Initial dispersion (2) and maximum attempts to find a finite initial target (100).

optimize_start

Use observed-posterior optimization for automatic starts (default TRUE). A supplied start keeps its center.

warn_convergence

Warn if MCMC diagnostic targets fail (default TRUE). Turning off the warning does not alter diagnostics.

store_callables

Store callbacks for prediction and log-likelihood extraction (default TRUE).

entropy_tol, entropy_exact_limit

Tolerance (1e-10) and exact-sum limit (2000) for applicable MDI calculations.

Unknown controls are errors. No new mandatory packages are required.

Value

A list of class "fitcensBayes", separate from "fitdistrBayes":

call, model, prior

The matched call; model name, parameter names, fixed values and sample size; and prior label, kernel, complete-data origin and posterior-propriety justification.

censoring

Censoring type, exact/censored counts, censored fraction and the non-informative censoring assumption.

initialization, engine

Starting procedure and values when applicable; selected algorithm, iteration settings and seed.

estimates

Named numeric vector of posterior medians.

summary

Data frame with one row per parameter: justified posterior mean and standard deviation, median, equal-tail 95 percent limits, R-hat, ESS, mean Monte Carlo standard error, and moment status.

moment_status

Data frame recording whether each mean and variance is finite (TRUE), infinite (FALSE), or not certified (NA), with explanations. Uncertified or infinite means, standard deviations and associated MCSEs are suppressed in the summary.

diagnostics

Diagnostic targets, extrema, explanatory messages and a converged flag. This flag denotes meeting the diagnostic targets, not a mathematical proof of convergence. exact_or_independent identifies independent posterior simulation, for which MCMC convergence checks do not apply.

chains

List of numeric matrices, one per chain, with retained iterations in rows and model parameters in columns.

draws

Combined data frame with columns .chain, .iteration, .draw, and the parameter values.

data, status, omitted

Observed values and indicators after missing-pair removal, and omitted original indices.

control

Validated computational settings.

criteria

Present only when requested: a "fitdistrBayes_criteria" object based on the observed likelihood, not the density of imputed lifetimes. Does not change the chains.

When store_callables = TRUE, internal callbacks are stored for the observed log likelihood, predictive sampling, survival and imputation. See fitcensBayes-methods for extraction and prediction methods.

See Also

fitdistrBayes, fitcensBayes_models, fitcensBayes-methods.

Examples

set.seed(42)
lifetime <- rexp(80, rate = 0.7)
censoring <- rexp(80, rate = 0.3)
x <- pmin(lifetime, censoring)
status <- as.integer(lifetime <= censoring)
fit <- fitcensBayes(x, status, "exponential", "reference", seed = 43)
fit
confint(fit)

# Discrete censoring means strictly greater than the reported count.
fit_geom <- fitcensBayes(c(0, 1, 2, 3, 4, 5), c(1, 1, 0, 1, 0, 0),
                        "geometric", "jeffreys", seed = 44)
coef(fit_geom)

# Inspect the installed tutorial without executing long MCMC runs.
system.file("examples", "tutorial_fitcensBayes.R", package = "fitdistrBayes")

fitdistrBayes documentation built on Sept. 21, 2026, 5:08 p.m.