| Title: | Reproducible Random Samples Under Univariate Censoring Schemes |
|---|---|
| Description: | Generates reproducible random samples from any user-specified univariate distribution under a comprehensive suite of censoring and truncation schemes. Users supply the probability density function (PDF), cumulative distribution function (CDF), survival function, support bounds, and parameters; the same seed and inputs yield identical samples across sessions. Supported schemes include right and left truncation, random, right, left, interval, and middle censoring, block random censoring, balanced joint progressive Type-II (BJPT-II), progressive first failure, joint Type-I, Type-I, Type-II, progressive Type-II, Type-II progressively hybrid, joint Type-II, hybrid, hybrid Type-I, doubly Type-II, Type-I hybrid, and hybrid Type-II censoring. Diagnostic histogram, dot plot, and autocorrelation plots are provided for each scheme to verify distributional behaviour. Methods are described in Nagar, Kumar, and Krishna (2026) <doi:10.59467/IJASS.2026.22.1>, Goel, Kumar, and Krishna (2026, "Estimation in power Lindley distributions using balanced joint progressively Type-II censored data"), Wu and Kus (2009) <doi:10.1016/j.csda.2009.03.010>, Goel and Krishna (2026) <doi:10.1007/s13198-026-03208-w>, Balakrishnan and Aggarwala (2000, ISBN:978-1-4612-1334-5), Mondal and Kundu (2020) <doi:10.1080/03610926.2018.1554128>, Ding and Gui (2023) <doi:10.3390/math11092003>, Prajapati, Mitra, and Kundu (2019) <doi:10.1007/s13571-018-0167-0>, Yadav, Jaiswal, and Yadav (2026) <doi:10.1007/s11135-026-02647-8>, Iyer, Jammalamadaka, and Kundu (2008) <doi:10.1016/j.jspi.2007.03.062>, Banerjee and Kundu (2008) <doi:10.1109/TR.2008.916890>, and Kundu and Joarder (2006) <doi:10.1016/j.csda.2005.05.002>. |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>) |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-07-17 16:54:24 UTC |
| Source: | https://github.com/cran/UniCensor |
Coerce censored sample to data frame
## S3 method for class 'censored_sample' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'censored_sample' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
a |
row.names |
ignored. |
optional |
ignored. |
... |
ignored. |
A data frame with columns x (observed values),
status (integer status code: 0 = right-censored, 1 = event,
2 = left-censored, 3 = interval-censored, 4 = middle-censored),
t_true (latent true failure times), and time2 (upper
interval bound for interval- or middle-censored observations,
NA otherwise).
Extract observed values from a censored sample
## S3 method for class 'censored_sample' as.vector(x, ...)## S3 method for class 'censored_sample' as.vector(x, ...)
x |
a |
... |
ignored. |
Numeric vector of observed values (failures and censoring times).
Creates a reusable distribution specification passed to all
UniCensor sampling functions. At least one of q,
surv, p, or d must be supplied for random
number generation via inverse transform sampling.
dist_spec( d = NULL, p = NULL, q = NULL, surv = NULL, lower = 0, upper = Inf, param = list(), name = "custom" )dist_spec( d = NULL, p = NULL, q = NULL, surv = NULL, lower = 0, upper = Inf, param = list(), name = "custom" )
d |
function; PDF |
p |
function; CDF |
q |
function; quantile function |
surv |
function; survival function |
lower |
numeric; lower support bound (default |
upper |
numeric; upper support bound (default |
param |
named list of distribution parameters (default empty). |
name |
character label for plots (default |
An object of class "dist_spec", which is a list with
elements d, p, q, surv (user-supplied
functions or NULL), lower and upper (support
bounds), param (named list of parameters), and name
(character label).
# Exponential(rate = 1) exp_dist <- dist_spec( d = function(x, p) p$rate * exp(-p$rate * x), p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, surv = function(x, p) exp(-p$rate * x), lower = 0, upper = Inf, param = list(rate = 1), name = "Exp(1)" )# Exponential(rate = 1) exp_dist <- dist_spec( d = function(x, p) p$rate * exp(-p$rate * x), p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, surv = function(x, p) exp(-p$rate * x), lower = 0, upper = Inf, param = list(rate = 1), name = "Exp(1)" )
Plots the ACF of latent failure times to assess independence of the underlying RNG stream (should resemble white noise for valid simulation).
plot_censor_acf(samp, use_latent = TRUE, max_lag = NULL, ...)plot_censor_acf(samp, use_latent = TRUE, max_lag = NULL, ...)
samp |
a |
use_latent |
logical; compute ACF on |
max_lag |
maximum lag (default |
... |
passed to |
Invisibly, an object of class "acf" as returned by
acf, containing the autocorrelation values at each
lag. Called primarily for its side effect of producing an ACF plot
with 95\
Produces a three-panel plot (histogram with PDF overlay, dot plot, and
ACF) for a censored sample. Graphical parameters are saved before
modification and restored on exit via on.exit.
plot_censor_diagnostics(samp, dist = NULL, use_latent = TRUE, ...)plot_censor_diagnostics(samp, dist = NULL, use_latent = TRUE, ...)
samp |
a |
dist |
optional |
use_latent |
passed to individual plot functions. |
... |
ignored. |
Invisibly, the input censored_sample object samp.
Called primarily for its side effect of producing a combined diagnostic
plot panel.
Dot plot (index plot) of sample values
plot_censor_dot(samp, use_latent = TRUE, pch = NULL, ...)plot_censor_dot(samp, use_latent = TRUE, pch = NULL, ...)
samp |
a |
use_latent |
logical; plot latent ( |
pch |
plotting character; censored points use |
... |
passed to |
Invisibly, a list with elements index (integer vector of
observation indices) and values (numeric vector of plotted
values). Called primarily for its side effect of producing a dot
(index) plot distinguishing events from censored observations.
For censored samples, uses latent t_true values to overlay the
target density when available; observed x values are histogrammed
with a note on censoring status.
plot_censor_hist(samp, dist = NULL, use_latent = TRUE, nbreaks = 30L, ...)plot_censor_hist(samp, dist = NULL, use_latent = TRUE, nbreaks = 30L, ...)
samp |
a |
dist |
optional |
use_latent |
logical; plot histogram of latent failures
( |
nbreaks |
number of histogram breaks (default |
... |
graphical parameters passed to |
Invisibly, an object of class "histogram" as returned by
hist, containing break points, counts, and
density values. Called primarily for its side effect of producing a
histogram plot with an optional PDF overlay.
Print method for censored_sample
## S3 method for class 'censored_sample' print(x, ...)## S3 method for class 'censored_sample' print(x, ...)
x |
a |
... |
ignored. |
Invisibly, the input censored_sample object x.
Called for its side effect of printing the censoring scheme, distribution
name, sample size, seed, and a frequency table of status codes.
Print method for dist_spec
## S3 method for class 'dist_spec' print(x, ...)## S3 method for class 'dist_spec' print(x, ...)
x |
a |
... |
ignored. |
Invisibly, the input dist_spec object x. Called
for its side effect of printing a human-readable summary of the
distribution name, support, parameters, and available functions.
k samples of size n are progressively Type-II censored with
a balanced removal scheme scheme applied jointly at each failure
time across all groups.
r_bjpt2_censor(n, dist, scheme = NULL, k = 2L, seed = NULL)r_bjpt2_censor(n, dist, scheme = NULL, k = 2L, seed = NULL)
n |
sample size per group. |
dist |
a |
scheme |
integer vector of total removals at each failure (split evenly across groups). |
k |
number of groups (default |
seed |
optional integer seed. |
A list of censored_sample objects (class
"censored_sample_list"), one per group. Each element contains
scheme, dist, n, seed, t_true,
x, status (0 = right-censored, 1 = event), time2,
and extra fields group and k.
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_bjpt2_censor(20, d, k = 2, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_bjpt2_censor(20, d, k = 2, seed = 1)
Subjects are partitioned into blocks of size block_size; entire
blocks are randomly selected for right censoring at the block maximum
observed failure time or at an exponential censoring time, whichever is
smaller.
r_block_random_censor( n, dist, block_size = 5L, prop_blocks = 0.4, cen_rate = 0.2, seed = NULL )r_block_random_censor( n, dist, block_size = 5L, prop_blocks = 0.4, cen_rate = 0.2, seed = NULL )
n |
sample size. |
dist |
a |
block_size |
block length (default |
prop_blocks |
fraction of blocks censored (default |
cen_rate |
exponential censoring rate within censored blocks. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_block_random_censor(30, d, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_block_random_censor(30, d, seed = 1)
Generate a complete (uncensored) random sample
r_complete(n, dist, seed = NULL)r_complete(n, dist, seed = NULL)
n |
sample size. |
dist |
a |
seed |
optional integer seed for reproducibility. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 1 = event for all observations in a complete
sample), and time2 (NA for all).
exp_dist <- dist_spec( q = function(u, p) -log(1 - u) / p$rate, surv = function(x, p) exp(-p$rate * x), param = list(rate = 1), name = "Exp(1)" ) samp <- r_complete(50, exp_dist, seed = 42) table(samp$status)exp_dist <- dist_spec( q = function(u, p) -log(1 - u) / p$rate, surv = function(x, p) exp(-p$rate * x), param = list(rate = 1), name = "Exp(1)" ) samp <- r_complete(50, exp_dist, seed = 42) table(samp$status)
Classical doubly Type-II censoring: the r1 smallest and r2
largest latent failure times are censored; the middle order statistics are
observed exactly. Requires r1 + r2 < n.
r_doubly_type2_censor(n, dist, r1, r2, seed = NULL)r_doubly_type2_censor(n, dist, r1, r2, seed = NULL)
n |
sample size. |
dist |
a |
r1 |
number of smallest order statistics left-censored. |
r2 |
number of largest order statistics right-censored. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_doubly_type2_censor(50, d, r1 = 5, r2 = 5, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_doubly_type2_censor(50, d, r1 = 5, r2 = 5, seed = 1)
Stops at cen_time or when r_failures events occur, whichever
comes first.
r_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)r_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)
n |
sample size. |
dist |
a |
cen_time |
fixed time limit. |
r_failures |
failure count limit. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_censor(30, d, cen_time = 2, r_failures = 15, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_censor(30, d, cen_time = 2, r_failures = 15, seed = 1)
At each time in prog_times, scheme[j] units are withdrawn;
remaining units are Type-I censored at cen_time.
r_hybrid_type1_censor(n, dist, cen_time, prog_times, scheme, seed = NULL)r_hybrid_type1_censor(n, dist, cen_time, prog_times, scheme, seed = NULL)
n |
sample size. |
dist |
a |
cen_time |
final Type-I censoring time. |
prog_times |
vector of progressive withdrawal times. |
scheme |
removals at each progressive time. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_type1_censor(30, d, cen_time = 3, prog_times = c(1, 2), scheme = c(2, 2), seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_type1_censor(30, d, cen_time = 3, prog_times = c(1, 2), scheme = c(2, 2), seed = 1)
Progressive Type-II removals are applied, then the experiment terminates
at the r_failures-th remaining failure.
r_hybrid_type2_censor(n, dist, scheme, r_failures, seed = NULL)r_hybrid_type2_censor(n, dist, scheme, r_failures, seed = NULL)
n |
sample size. |
dist |
a |
scheme |
progressive removal scheme before Type-II stop. |
r_failures |
failure count for final Type-II termination. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_type2_censor(30, d, scheme = c(1, 1), r_failures = 10, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_hybrid_type2_censor(30, d, scheme = c(1, 1), r_failures = 10, seed = 1)
A proportion prop_interval of subjects are interval-censored into
windows of width width; optional random right censoring applies to
the remainder at rate cen_rate.
r_interval_censor( n, dist, width, prop_interval = 0.3, cen_rate = 0.2, seed = NULL )r_interval_censor( n, dist, width, prop_interval = 0.3, cen_rate = 0.2, seed = NULL )
n |
sample size. |
dist |
a |
width |
interval window width. |
prop_interval |
fraction interval-censored (default |
cen_rate |
exponential rate for additional right censoring
(default |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_interval_censor(30, d, width = 0.5, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_interval_censor(30, d, width = 0.5, seed = 1)
Generates k independent samples of size n each, all
censored at a common fixed time cen_time.
r_joint_type1_censor(n, dist, cen_time, k = 2L, seed = NULL)r_joint_type1_censor(n, dist, cen_time, k = 2L, seed = NULL)
n |
sample size per group. |
dist |
a |
cen_time |
fixed censoring time. |
k |
number of independent samples (default |
seed |
optional integer seed. |
A list of censored_sample objects (class
"censored_sample_list"), one per group. Each element contains
scheme, dist, n, seed, t_true,
x, status (0 = right-censored, 1 = event), time2,
and extra fields group and k.
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_joint_type1_censor(20, d, cen_time = 2, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_joint_type1_censor(20, d, cen_time = 2, seed = 1)
All k samples share the same termination rule: stop when a total of
r_failures events have been observed across all groups combined.
r_joint_type2_censor(n, dist, r_failures, k = 2L, seed = NULL)r_joint_type2_censor(n, dist, r_failures, k = 2L, seed = NULL)
n |
sample size per group. |
dist |
a |
r_failures |
total failure count across all groups. |
k |
number of groups (default |
seed |
optional integer seed. |
A list of censored_sample objects (class
"censored_sample_list"), one per group. Each element contains
scheme, dist, n, seed, t_true,
x, status (0 = right-censored, 1 = event), time2,
and extra fields group and k.
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_joint_type2_censor(20, d, r_failures = 15, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_joint_type2_censor(20, d, r_failures = 15, seed = 1)
Left censoring at a fixed threshold
r_left_censor(n, dist, threshold, seed = NULL)r_left_censor(n, dist, threshold, seed = NULL)
n |
sample size. |
dist |
a |
threshold |
left-censoring threshold. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_left_censor(30, d, threshold = 0.5, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_left_censor(30, d, threshold = 0.5, seed = 1)
Observations are drawn from .
r_left_truncation(n, dist, left, seed = NULL)r_left_truncation(n, dist, left, seed = NULL)
n |
sample size. |
dist |
a |
left |
lower truncation point. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_left_truncation(20, d, left = 0.5, seed = 1)d <- dist_spec(p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_left_truncation(20, d, left = 0.5, seed = 1)
Observations that fall within the interval [lower, upper] are
middle-censored; observations outside this interval are observed exactly.
r_middle_censor(n, dist, lower, upper, seed = NULL)r_middle_censor(n, dist, lower, upper, seed = NULL)
n |
sample size. |
dist |
a |
lower |
lower bound of the middle censoring interval. |
upper |
upper bound of the middle censoring interval. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_middle_censor(30, d, lower = 0.5, upper = 1.5, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_middle_censor(30, d, lower = 0.5, upper = 1.5, seed = 1)
At each failure one surviving unit is randomly removed until only one unit remains under observation.
r_progressive_first_failure(n, dist, seed = NULL)r_progressive_first_failure(n, dist, seed = NULL)
n |
sample size. |
dist |
a |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_first_failure(15, d, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_first_failure(15, d, seed = 1)
Combines progressive Type-II censoring with a pre-set time limit
cen_time. Progressive removals according to scheme are
applied at each failure. The experiment terminates at
, where is the m-th
(i.e., r_failures-th) failure among the remaining units and
is cen_time. If fewer than r_failures events
occur before cen_time, all surviving units are censored at
cen_time. See Kundu and Joarder (2006)
doi:10.1016/j.csda.2005.05.002.
r_progressive_hybrid_type2_censor( n, dist, scheme, r_failures = NULL, cen_time, seed = NULL )r_progressive_hybrid_type2_censor( n, dist, scheme, r_failures = NULL, cen_time, seed = NULL )
n |
sample size. |
dist |
a |
scheme |
integer vector of removals at successive failure times. |
r_failures |
target number of failures (default
|
cen_time |
pre-set maximum experiment time. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character "progressive_hybrid_type2"), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), time2
(upper interval bound where applicable, NA otherwise), and
extra (list containing scheme, r_failures, cen_time,
and stop_time).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_hybrid_type2_censor(30, d, scheme = c(1, 1, 1), r_failures = 10, cen_time = 3, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_hybrid_type2_censor(30, d, scheme = c(1, 1, 1), r_failures = 10, cen_time = 3, seed = 1)
At the j-th failure time, scheme[j] surviving units are
randomly removed from the risk set.
r_progressive_type2_censor(n, dist, scheme = NULL, seed = NULL)r_progressive_type2_censor(n, dist, scheme = NULL, seed = NULL)
n |
sample size. |
dist |
a |
scheme |
integer vector of removals at successive failure times. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_type2_censor(30, d, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_progressive_type2_censor(30, d, seed = 1)
Each subject is observed until where follows an
exponential distribution with rate cen_rate.
r_random_censor(n, dist, cen_rate = 0.2, seed = NULL)r_random_censor(n, dist, cen_rate = 0.2, seed = NULL)
n |
sample size. |
dist |
a |
cen_rate |
exponential censoring rate (default |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_random_censor(30, d, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_random_censor(30, d, seed = 1)
Right censoring at a fixed time
r_right_censor(n, dist, cen_time, seed = NULL)r_right_censor(n, dist, cen_time, seed = NULL)
n |
sample size. |
dist |
a |
cen_time |
fixed right-censoring time. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_right_censor(30, d, cen_time = 2, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_right_censor(30, d, cen_time = 2, seed = 1)
Observations are drawn from .
r_right_truncation(n, dist, right, seed = NULL)r_right_truncation(n, dist, right, seed = NULL)
n |
sample size. |
dist |
a |
right |
upper truncation point. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_right_truncation(20, d, right = 3, seed = 1)d <- dist_spec(p = function(x, p) 1 - exp(-p$rate * x), q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_right_truncation(20, d, right = 3, seed = 1)
All units are observed until fixed time cen_time; failures after
that time are right-censored.
r_type1_censor(n, dist, cen_time = NULL, seed = NULL)r_type1_censor(n, dist, cen_time = NULL, seed = NULL)
n |
sample size. |
dist |
a |
cen_time |
fixed censoring time (default: 70th percentile of latent failure times from a pilot draw). |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type1_censor(30, d, cen_time = 2, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type1_censor(30, d, cen_time = 2, seed = 1)
Experiment terminates at cen_time or when r_failures events
occur; if r_failures is reached first, a final Type-I censoring time
cen_time still applies to remaining units.
r_type1_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)r_type1_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)
n |
sample size. |
dist |
a |
cen_time |
fixed censoring time. |
r_failures |
failure count target. |
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type1_hybrid_censor(30, d, cen_time = 2, r_failures = 15, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type1_hybrid_censor(30, d, cen_time = 2, r_failures = 15, seed = 1)
Experiment stops at the r_failures-th observed failure; remaining
units are right-censored at that time.
r_type2_censor(n, dist, r_failures = NULL, seed = NULL)r_type2_censor(n, dist, r_failures = NULL, seed = NULL)
n |
sample size. |
dist |
a |
r_failures |
number of failures before termination (default
|
seed |
optional integer seed. |
A censored_sample object (S3 class) containing:
scheme (character), dist (the dist_spec),
n (integer sample size), seed, t_true (numeric
vector of latent failure times), x (observed/censored values),
status (integer: 0 = right-censored, 1 = event, 2 = left-censored,
3 = interval-censored, 4 = middle-censored), and time2
(upper interval bound where applicable, NA otherwise).
d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type2_censor(30, d, r_failures = 20, seed = 1)d <- dist_spec(q = function(u, p) -log(1 - u) / p$rate, param = list(rate = 1), name = "Exp(1)") r_type2_censor(30, d, r_failures = 20, seed = 1)