| Type: | Package |
| Title: | Reproducible Random Samples Under Univariate Censoring Schemes |
| Version: | 0.1.0 |
| 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>. |
| License: | GPL-3 |
| Depends: | R (≥ 4.0.0) |
| Imports: | graphics, stats |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-08 23:26:00 UTC; shikhar tyagi |
| Author: | Shikhar Tyagi |
| Maintainer: | Shikhar Tyagi <shikhar1093tyagi@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-17 13:40:08 UTC |
UniCensor: Reproducible Univariate Samples Under Censoring Schemes
Description
The UniCensor package simulates censored or truncated random samples from any user-defined univariate distribution. Supply the PDF, CDF, survival function, support bounds, parameters, sample size, and a seed; identical inputs always produce identical output.
Distribution specification
Use dist_spec to define a distribution object, then pass it
to any scheme-specific generator (e.g. r_type1_censor).
Censoring schemes (one function each)
r_completeUncensored (complete) data.
r_right_truncationRight truncation.
r_left_truncationLeft truncation.
r_random_censorRandom censoring.
r_right_censorRight censoring.
r_left_censorLeft censoring.
r_interval_censorInterval censoring.
r_middle_censorMiddle censoring.
r_block_random_censorBlock random censoring.
r_bjpt2_censorBalanced joint progressive Type-II.
r_progressive_first_failureProgressive first failure.
r_joint_type1_censorJoint Type-I censoring.
r_type1_censorType-I (time-terminated).
r_type2_censorType-II (failure-terminated).
r_progressive_type2_censorProgressive Type-II.
r_progressive_hybrid_type2_censorType-II progressively hybrid.
r_joint_type2_censorJoint Type-II censoring.
r_hybrid_censorHybrid censoring.
r_hybrid_type1_censorHybrid Type-I censoring.
r_doubly_type2_censorDoubly Type-II censoring.
r_type1_hybrid_censorType-I hybrid censoring.
r_hybrid_type2_censorHybrid Type-II censoring.
Diagnostic plots
plot_censor_hist, plot_censor_dot,
plot_censor_acf, and plot_censor_diagnostics
(all three panels).
Author(s)
Shikhar Tyagi shikhar1093tyagi@gmail.com
Coerce censored sample to data frame
Description
Coerce censored sample to data frame
Usage
## S3 method for class 'censored_sample'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
Arguments
x |
a |
row.names |
ignored. |
optional |
ignored. |
... |
ignored. |
Value
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
Description
Extract observed values from a censored sample
Usage
## S3 method for class 'censored_sample'
as.vector(x, ...)
Arguments
x |
a |
... |
ignored. |
Value
Numeric vector of observed values (failures and censoring times).
Define a univariate distribution for simulation
Description
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.
Usage
dist_spec(
d = NULL,
p = NULL,
q = NULL,
surv = NULL,
lower = 0,
upper = Inf,
param = list(),
name = "custom"
)
Arguments
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 |
Value
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).
Examples
# 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)"
)
Autocorrelation function plot
Description
Plots the ACF of latent failure times to assess independence of the underlying RNG stream (should resemble white noise for valid simulation).
Usage
plot_censor_acf(samp, use_latent = TRUE, max_lag = NULL, ...)
Arguments
samp |
a |
use_latent |
logical; compute ACF on |
max_lag |
maximum lag (default |
... |
passed to |
Value
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\
Combined diagnostic panel: histogram, dot plot, and ACF
Description
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.
Usage
plot_censor_diagnostics(samp, dist = NULL, use_latent = TRUE, ...)
Arguments
samp |
a |
dist |
optional |
use_latent |
passed to individual plot functions. |
... |
ignored. |
Value
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
Description
Dot plot (index plot) of sample values
Usage
plot_censor_dot(samp, use_latent = TRUE, pch = NULL, ...)
Arguments
samp |
a |
use_latent |
logical; plot latent ( |
pch |
plotting character; censored points use |
... |
passed to |
Value
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.
Histogram of observed values with true density overlay
Description
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.
Usage
plot_censor_hist(samp, dist = NULL, use_latent = TRUE, nbreaks = 30L, ...)
Arguments
samp |
a |
dist |
optional |
use_latent |
logical; plot histogram of latent failures
( |
nbreaks |
number of histogram breaks (default |
... |
graphical parameters passed to |
Value
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
Description
Print method for censored_sample
Usage
## S3 method for class 'censored_sample'
print(x, ...)
Arguments
x |
a |
... |
ignored. |
Value
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
Description
Print method for dist_spec
Usage
## S3 method for class 'dist_spec'
print(x, ...)
Arguments
x |
a |
... |
ignored. |
Value
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.
Balanced joint progressive Type-II (BJPT-II) censoring
Description
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.
Usage
r_bjpt2_censor(n, dist, scheme = NULL, k = 2L, seed = NULL)
Arguments
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. |
Value
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.
Examples
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)
Block random censoring
Description
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.
Usage
r_block_random_censor(
n,
dist,
block_size = 5L,
prop_blocks = 0.4,
cen_rate = 0.2,
seed = NULL
)
Arguments
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. |
Value
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).
Examples
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
Description
Generate a complete (uncensored) random sample
Usage
r_complete(n, dist, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
seed |
optional integer seed for reproducibility. |
Value
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).
Examples
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)
Doubly Type-II censoring
Description
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.
Usage
r_doubly_type2_censor(n, dist, r1, r2, seed = NULL)
Arguments
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. |
Value
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).
Examples
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)
Hybrid censoring (Type-I and Type-II constraints)
Description
Stops at cen_time or when r_failures events occur, whichever
comes first.
Usage
r_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
cen_time |
fixed time limit. |
r_failures |
failure count limit. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Hybrid Type-I censoring with progressive withdrawal
Description
At each time in prog_times, scheme[j] units are withdrawn;
remaining units are Type-I censored at cen_time.
Usage
r_hybrid_type1_censor(n, dist, cen_time, prog_times, scheme, seed = NULL)
Arguments
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. |
Value
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).
Examples
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)
Hybrid Type-II censoring
Description
Progressive Type-II removals are applied, then the experiment terminates
at the r_failures-th remaining failure.
Usage
r_hybrid_type2_censor(n, dist, scheme, r_failures, seed = NULL)
Arguments
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. |
Value
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).
Examples
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)
Interval censoring
Description
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.
Usage
r_interval_censor(
n,
dist,
width,
prop_interval = 0.3,
cen_rate = 0.2,
seed = NULL
)
Arguments
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. |
Value
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).
Examples
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)
Joint Type-I censoring across multiple samples
Description
Generates k independent samples of size n each, all
censored at a common fixed time cen_time.
Usage
r_joint_type1_censor(n, dist, cen_time, k = 2L, seed = NULL)
Arguments
n |
sample size per group. |
dist |
a |
cen_time |
fixed censoring time. |
k |
number of independent samples (default |
seed |
optional integer seed. |
Value
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.
Examples
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)
Joint Type-II censoring across multiple samples
Description
All k samples share the same termination rule: stop when a total of
r_failures events have been observed across all groups combined.
Usage
r_joint_type2_censor(n, dist, r_failures, k = 2L, seed = NULL)
Arguments
n |
sample size per group. |
dist |
a |
r_failures |
total failure count across all groups. |
k |
number of groups (default |
seed |
optional integer seed. |
Value
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.
Examples
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
Description
Left censoring at a fixed threshold
Usage
r_left_censor(n, dist, threshold, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
threshold |
left-censoring threshold. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Left-truncated random sample
Description
Observations are drawn from X \mid X \ge \code{left}.
Usage
r_left_truncation(n, dist, left, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
left |
lower truncation point. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Middle censoring
Description
Observations that fall within the interval [lower, upper] are
middle-censored; observations outside this interval are observed exactly.
Usage
r_middle_censor(n, dist, lower, upper, seed = NULL)
Arguments
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. |
Value
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).
Examples
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)
Progressive first-failure censoring
Description
At each failure one surviving unit is randomly removed until only one unit remains under observation.
Usage
r_progressive_first_failure(n, dist, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
seed |
optional integer seed. |
Value
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).
Examples
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)
Type-II progressively hybrid censoring
Description
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
\min(X_{m:m:n}, T), where X_{m:m:n} is the m-th
(i.e., r_failures-th) failure among the remaining units and
T 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.
Usage
r_progressive_hybrid_type2_censor(
n,
dist,
scheme,
r_failures = NULL,
cen_time,
seed = NULL
)
Arguments
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. |
Value
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).
Examples
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)
Progressive Type-II censoring
Description
At the j-th failure time, scheme[j] surviving units are
randomly removed from the risk set.
Usage
r_progressive_type2_censor(n, dist, scheme = NULL, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
scheme |
integer vector of removals at successive failure times. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Random censoring
Description
Each subject is observed until \min(X, C) where C follows an
exponential distribution with rate cen_rate.
Usage
r_random_censor(n, dist, cen_rate = 0.2, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
cen_rate |
exponential censoring rate (default |
seed |
optional integer seed. |
Value
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).
Examples
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
Description
Right censoring at a fixed time
Usage
r_right_censor(n, dist, cen_time, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
cen_time |
fixed right-censoring time. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Right-truncated random sample
Description
Observations are drawn from X \mid X \le \code{right}.
Usage
r_right_truncation(n, dist, right, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
right |
upper truncation point. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Type-I (time-terminated) censoring
Description
All units are observed until fixed time cen_time; failures after
that time are right-censored.
Usage
r_type1_censor(n, dist, cen_time = NULL, seed = NULL)
Arguments
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. |
Value
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).
Examples
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)
Type-I hybrid censoring
Description
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.
Usage
r_type1_hybrid_censor(n, dist, cen_time, r_failures, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
cen_time |
fixed censoring time. |
r_failures |
failure count target. |
seed |
optional integer seed. |
Value
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).
Examples
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)
Type-II (failure-terminated) censoring
Description
Experiment stops at the r_failures-th observed failure; remaining
units are right-censored at that time.
Usage
r_type2_censor(n, dist, r_failures = NULL, seed = NULL)
Arguments
n |
sample size. |
dist |
a |
r_failures |
number of failures before termination (default
|
seed |
optional integer seed. |
Value
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).
Examples
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)