The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Censoring Schemes

Your Name

2026-07-31

Introduction

TKApprox supports a wide range of censoring schemes commonly encountered in reliability, survival analysis, and lifetime data analysis. This vignette demonstrates how to use each censoring scheme with the package.

Complete (Uncensored) Data

The simplest case is complete data with no censoring.

# Define exponential distribution
pdf_exp <- function(x, param) dexp(x, rate = param)
cdf_exp <- function(x, param) pexp(x, rate = param)

# Prior specification
prior_spec <- list(rate = list(family = "gamma", hyperparameters = list(shape = 2, rate = 1)))

# Generate complete data
set.seed(123)
data <- rexp(20, rate = 1.5)

# Fit with complete data
fit_complete <- tk_fit(
  data = data,
  censoring_scheme = "complete",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel"
)

summary(fit_complete)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: complete 
## Sample size: 20 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 7 
## Gradient norm: 0 
## Execution time: 0.0782 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error CI_Lower CI_Upper
##       rate       1.777306       1.862275   0.38784 1.102123 2.622428
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -0.4461 
## Log-likelihood at mode: -7.7207 
## Prior contribution: -1.2022 
## 
## Posterior Covariance Matrix:
## ---------------------------
##         rate
## rate 0.15042

Right-Censored Data

Right censoring occurs when we only know that an event occurred after a certain time.

# Create right-censored data
# status = 1: observed, status = 0: right-censored
data <- c(1.2, 2.3, 1.8, 3.1, 0.9, 2.5, 1.5, 3.8, 2.0, 1.7)
status <- c(1, 1, 0, 1, 0, 1, 1, 0, 1, 1)

fit_right <- tk_fit(
  data = data,
  censoring_scheme = "right-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  status = status
)

summary(fit_right)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: right-censored 
## Sample size: 10 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 9 
## Gradient norm: 0 
## Execution time: 0.0546 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error  CI_Lower  CI_Upper
##       rate      0.3669725      0.4133215 0.1297444 0.1590272 0.6676158
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -1.602 
## Log-likelihood at mode: -14.6503 
## Prior contribution: -1.3694 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.016834

Left-Censored Data

Left censoring occurs when we only know that an event occurred before a certain time.

# Create left-censored data
# status = 1: observed, status = 0: left-censored
data <- c(1.2, 2.3, 1.8, 3.1, 0.9, 2.5, 1.5, 3.8, 2.0, 1.7)
status <- c(1, 0, 1, 1, 0, 1, 1, 0, 1, 1)

fit_left <- tk_fit(
  data = data,
  censoring_scheme = "left-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  status = status
)

summary(fit_left)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: left-censored 
## Sample size: 10 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 8 
## Gradient norm: 0 
## Execution time: 0.0418 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error  CI_Lower CI_Upper
##       rate      0.6363492      0.7008036  0.196945 0.3147985 1.086809
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -1.4221 
## Log-likelihood at mode: -13.1323 
## Prior contribution: -1.0884 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.038787

Interval-Censored Data

Interval censoring occurs when we only know that an event occurred within a time interval.

# Create interval-censored data
# Each row: [lower, upper]
# If lower == upper, it's an exact observation
data <- cbind(
  lower = c(1.0, 2.0, 1.5, 2.5, 1.2, 2.0, 1.8, 3.0, 1.5, 2.2),
  upper = c(1.5, 2.5, 1.5, 3.0, 1.8, 2.5, 2.2, 3.5, 2.0, 2.5)
)

fit_interval <- tk_fit(
  data = data,
  censoring_scheme = "interval-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel"
)

summary(fit_interval)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: interval-censored 
## Sample size: 10 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 8 
## Gradient norm: 0 
## Execution time: 0.0593 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error CI_Lower  CI_Upper
##       rate      0.5054865      0.5521979 0.1527211  0.25287 0.8515257
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -2.5317 
## Log-likelihood at mode: -24.1293 
## Prior contribution: -1.1877 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.023324

Type-I Censoring

Type-I censoring (time censoring) occurs when the experiment is terminated at a fixed time T.

# Generate Type-I censored data
set.seed(123)
true_rate <- 1.5
censoring_time <- 2.0

# Simulate failure times
failure_times <- rexp(20, rate = true_rate)

# Apply Type-I censoring
data <- pmin(failure_times, censoring_time)

fit_type1 <- tk_fit(
  data = data,
  censoring_scheme = "type-i",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  censoring_time = censoring_time
)

summary(fit_type1)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: type-i 
## Sample size: 20 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 7 
## Gradient norm: 0 
## Execution time: 0.051 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error CI_Lower CI_Upper
##       rate       1.798298       1.888587 0.4021117 1.100463 2.676712
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -0.4132 
## Log-likelihood at mode: -7.0517 
## Prior contribution: -1.2115 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.161694

Type-II Censoring

Type-II censoring occurs when the experiment ends after a specified number of failures r.

# Generate Type-II censored data
set.seed(123)
n <- 20  # total items
r <- 10  # number of failures to observe

# Simulate failure times
failure_times <- sort(rexp(n, rate = 1.5))

# Observe only first r failures
data <- failure_times[1:r]

fit_type2 <- tk_fit(
  data = data,
  censoring_scheme = "type-ii",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  n = n,
  r = r
)

summary(fit_type2)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: type-ii 
## Sample size: 20 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: L-BFGS-B 
## Convergence code: 0 
## Iterations: 6 
## Gradient norm: 0 
## Execution time: 0.0399 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error  CI_Lower CI_Upper
##       rate       1.939872       2.117559 0.5848934 0.9711889 3.263929
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -0.1856 
## Log-likelihood at mode: -2.4339 
## Prior contribution: -1.2772 
## 
## Posterior Covariance Matrix:
## ---------------------------
##        rate
## rate 0.3421

Progressive Type-II Censoring

Progressive Type-II censoring involves removing surviving items at each failure time.

# Generate progressive Type-II censored data
set.seed(123)
n <- 20
m <- 10  # number of observed failures

# Simulate failure times
failure_times <- sort(rexp(n, rate = 1.5))

# Specify removal scheme (remove 1 item at each failure)
removals <- rep(1, m)

# Adjust for remaining items
data <- failure_times[1:m]

fit_progressive <- tk_fit(
  data = data,
  censoring_scheme = "progressive-type2",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  removals = removals,
  n = n
)

summary(fit_progressive)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: progressive-type2 
## Sample size: 20 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: BFGS 
## Convergence code: 0 
## Iterations: 14 
## Gradient norm: 0 
## Execution time: 0.0607 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error CI_Lower CI_Upper
##       rate       2.779544       3.034143  0.838064 1.391568 4.676718
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: 0.0123 
## Log-likelihood at mode: 2.0024 
## Prior contribution: -1.7573 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.702351

Hybrid Censoring

Hybrid censoring combines Type-I and Type-II: the experiment ends at min(T, r-th failure).

# Generate hybrid censored data
set.seed(123)
n <- 20
r <- 10
censoring_time <- 2.0

# Simulate failure times
failure_times <- sort(rexp(n, rate = 1.5))

# Apply hybrid censoring
if (failure_times[r] < censoring_time) {
  # Type-II censoring (r failures occur before T)
  data <- failure_times[1:r]
} else {
  # Type-I censoring (experiment ends at T)
  data <- failure_times[failure_times < censoring_time]
}

fit_hybrid <- tk_fit(
  data = data,
  censoring_scheme = "hybrid",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  censoring_time = censoring_time,
  r = r,
  n = n
)

summary(fit_hybrid)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: hybrid 
## Sample size: 20 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: L-BFGS-B 
## Convergence code: 0 
## Iterations: 6 
## Gradient norm: 0 
## Execution time: 0.0467 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error  CI_Lower CI_Upper
##       rate       1.939872       2.117559 0.5848934 0.9711889 3.263929
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -0.1856 
## Log-likelihood at mode: -2.4339 
## Prior contribution: -1.2772 
## 
## Posterior Covariance Matrix:
## ---------------------------
##        rate
## rate 0.3421

Doubly Censored Data

Doubly censored data involves both left and right censoring.

# Create doubly censored data
# status = -1: left-censored, status = 0: observed, status = 1: right-censored
data <- c(1.2, 2.3, 1.8, 3.1, 0.9, 2.5, 1.5, 3.8, 2.0, 1.7)
status <- c(-1, 1, 0, 1, -1, 1, 0, 1, 0, 1)

fit_doubly <- tk_fit(
  data = data,
  censoring_scheme = "doubly-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  status = status
)

summary(fit_doubly)
## 
## === Tierney-Kadane Bayesian Estimation Summary ===
## 
## Model Information:
## -----------------
## Censoring scheme: doubly-censored 
## Sample size: 10 
## Number of parameters: 1 
## Loss function: sel 
## 
## Optimization Results:
## --------------------
## Method: nlminb 
## Convergence code: 0 
## Iterations: 9 
## Gradient norm: 1e-06 
## Execution time: 0.0496 seconds
## 
## Parameter Estimates:
## --------------------
##  Parameter Posterior_Mode Bayes_Estimate Std_Error  CI_Lower  CI_Upper
##       rate      0.2899146      0.3392002 0.1185121 0.1069207 0.5714796
## 
## Model Fit Statistics:
## ---------------------
## Log-posterior at mode: -1.336 
## Log-likelihood at mode: -11.8318 
## Prior contribution: -1.5281 
## 
## Posterior Covariance Matrix:
## ---------------------------
##          rate
## rate 0.014045

Comparing Censoring Schemes

Let’s compare estimates from different censoring schemes using simulated data:

set.seed(123)
true_rate <- 1.5
n <- 30

# Generate complete data
complete_data <- rexp(n, rate = true_rate)

# Fit complete data
fit_complete <- tk_fit(
  data = complete_data,
  censoring_scheme = "complete",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel"
)

# Create right-censored data
status_right <- c(rep(1, 20), rep(0, 10))
fit_right <- tk_fit(
  data = complete_data,
  censoring_scheme = "right-censored",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  status = status_right
)

# Create Type-I censored data
censoring_time <- median(complete_data)
data_type1 <- pmin(complete_data, censoring_time)
fit_type1 <- tk_fit(
  data = data_type1,
  censoring_scheme = "type-i",
  pdf = pdf_exp,
  cdf = cdf_exp,
  prior_spec = prior_spec,
  initial_values = c(rate = 1),
  loss_function = "sel",
  censoring_time = censoring_time
)

# Compare estimates
comparison <- data.frame(
  Scheme = c("Complete", "Right-Censored", "Type-I"),
  Estimate = c(coef(fit_complete), coef(fit_right), coef(fit_type1)),
  SE = c(fit_complete$standard_errors, fit_right$standard_errors, fit_type1$standard_errors),
  True = true_rate
)

print(comparison)
##           Scheme Estimate        SE True
## 1       Complete 1.664657 0.2896138  1.5
## 2 Right-Censored 1.144562 0.2383680  1.5
## 3         Type-I 1.518052 0.3570795  1.5

Tips for Working with Censored Data

  1. CDF is required: For all censored schemes, you must provide a CDF function
  2. Status coding: Be careful with status coding conventions
    • Right-censored: 1 = observed, 0 = censored
    • Left-censored: 1 = observed, 0 = censored
    • Doubly-censored: -1 = left-censored, 0 = observed, 1 = right-censored
  3. Interval data: Use a matrix/data.frame with columns lower and upper
  4. Initial values: Good initial values are especially important for censored data
  5. Sample size: Censoring reduces effective sample size; consider this when interpreting results

Next Steps

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.