| fitcensBayes | R Documentation |
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.
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)
x |
Nonempty numeric vector of observed values: the event time when
|
status |
Numeric or logical vector of the same length as |
distr |
One of the 20 registered distribution names, ignoring case.
See |
prior |
A registered prior name. It must be supplied explicitly.
See |
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 |
iter |
Total iterations per chain, including warmup; at least 20. |
warmup |
Number of initial iterations discarded; nonnegative and
smaller than |
thin |
Retain every |
chains |
Number of independently initialized chains; at least two. |
seed |
Optional nonnegative integer seed passed to |
method |
Sampling method. |
na.action |
Whether to reject missing values or omit the entire
|
control |
Named list of controls, described below. |
... |
Reserved for future extensions. Unused arguments are errors. |
criteria |
|
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_thresholdDiagnostic targets, default 1.01 and 400 for rank-normalized split/folded R-hat and bulk/tail ESS.
slice_width, slice_steps, max_shrinkSlice width (1), maximum stepping-out budget (40), and shrinkage budget (1000).
init_jitter, max_init_triesInitial dispersion (2) and maximum attempts to find a finite initial target (100).
optimize_startUse observed-posterior optimization for
automatic starts (default TRUE). A supplied start keeps its center.
warn_convergenceWarn if MCMC diagnostic targets fail
(default TRUE). Turning off the warning does not alter diagnostics.
store_callablesStore callbacks for prediction and
log-likelihood extraction (default TRUE).
entropy_tol, entropy_exact_limitTolerance
(1e-10) and exact-sum limit (2000) for applicable MDI calculations.
Unknown controls are errors. No new mandatory packages are required.
A list of class "fitcensBayes", separate from "fitdistrBayes":
call, model, priorThe matched call; model name, parameter names, fixed values and sample size; and prior label, kernel, complete-data origin and posterior-propriety justification.
censoringCensoring type, exact/censored counts, censored fraction and the non-informative censoring assumption.
initialization, engineStarting procedure and values when applicable; selected algorithm, iteration settings and seed.
estimatesNamed numeric vector of posterior medians.
summaryData 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_statusData 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.
diagnosticsDiagnostic 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.
chainsList of numeric matrices, one per chain, with retained iterations in rows and model parameters in columns.
drawsCombined data frame with columns .chain,
.iteration, .draw, and the parameter values.
data, status, omittedObserved values and indicators after missing-pair removal, and omitted original indices.
controlValidated computational settings.
criteriaPresent 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.
fitdistrBayes, fitcensBayes_models,
fitcensBayes-methods.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.