rcens: Generate Censored Samples (Type I or Type II)

View source: R/functions.R

rcensR Documentation

Generate Censored Samples (Type I or Type II)

Description

This function generates censored samples from a specified distribution, using Type I (time-based) or Type II (failure-based) censoring schemes.

Usage

rcens(n, r = NULL, dist, type = c("I", "II"), cens.time = NULL, ...)

Arguments

n

total number of items in the sample

r

number of uncensored observations (only for Type II censoring).

dist

a character string specifying the name of the distribution (e.g., "norm" for the normal distribution, "exp" for the exponential distribution).

type

type of censoring: "I" for Type I (time-based) or "II" for Type II (failure-based).

cens.time

censoring time for Type I censoring.

...

further arguments to be passed to dist.

Details

This function implements two types of censoring schemes:

  1. Type I censoring: Observations are censored if they exceed a specified cens.time. The function returns all observations less than cens.time.

  2. Type II censoring: The smallest r observations are returned, simulating a situation where the experiment stops after r failures.

Value

A numeric vector of censored samples.

See Also

rpcens2

Examples

# Type I censoring: Exponential distribution with rate = 1, censored at time 2
rcens(n = 10, dist = "exp", type = "I", cens.time = 2, rate = 1)

# Type II censoring: Normal distribution, smallest 5 values
rcens(n = 10, r = 5, dist = "norm", type = "II", mean = 0, sd = 1)


mos documentation built on June 16, 2025, 5:09 p.m.