Package 'rcens'

Title: Generate Sample Censoring
Description: Provides functions to generate censored samples of type I, II and III, from any random sample generator. It also supplies the option to create left and right censorship. Along with this, the generation of samples with interval censoring is in the testing phase, with two options of fixed length intervals and random lengths.
Authors: Daniel Saavedra [aut, cre, cph] , Pedro L Ramos [aut]
Maintainer: Daniel Saavedra <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2025-02-12 03:54:51 UTC
Source: https://github.com/dlsaavedra/rcens

Help Index


Generate interval censoring sample

Description

Generator of interval censored samples where the length of interval is random, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. Generator sample of distribution C (censoring) with parameters appended by the list param_C In which, you can control the desired censorship percentage.

Usage

rcensI(
  rdistrX,
  rdistrC,
  param_X,
  param_C,
  n = 10000,
  epsilon = 0.5,
  n_mc = 10000,
  theta = 1,
  verbose = FALSE
)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

rdistrC

sample generator of distribution C.
First argument number of samples, next arguments in param_C.

param_X

list with parameters of rdistrX function.

param_C

list with parameters of rdistrC function, one of these parameters
should be "lambda", this wil be the searched parameter.

n

number of sample to create.

epsilon

Parameter to estimate the number of visit (in [0,1]), shrink it only if the algorithm takes too long

n_mc

number of sample use to estimate the moments of C, greater n_mc more accuracy.

theta

Desired censoring percentage

verbose

if TRUE print a censoring percentage of new created database.

Value

A list with sample data information:

sample_censored vector of censored sample
sample_uncensored vector of uncensored sample (original)
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored
1:= no censored, 0:= censored
n_censored number of censored samples

Author(s)

Daniel Saavedra Morales

See Also

rcensT1 for generate censorship sample type I.
rcensT2 for generate censorship sample type II.
rcensT3 for generate censorship sample type III
rcensIfix for generate interval censoring sample with fix length interval

Examples

#Example Exponential - Uniform

Data_I = rcensI(rdistrX = rexp, rdistrC = runif,
               param_X = list("rate" = 2),
              param_C = list("min" = 0, "max" = 1),
             n = 1e02, theta = .9)

## Example with plot in examples_plot/Example_rcensI_plot.R

Generate interval censoring sample (Fix)

Description

Generator of interval censored samples where the length of interval is fixed, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. In which, you can control the desired censorship percentage.

Usage

rcensIfix(
  rdistrX,
  param_X,
  interval_length,
  n = 10000,
  theta = 1,
  verbose = FALSE
)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

param_X

list with parameters of rdistrX function.

interval_length

length of interval

n

number of sample to create.

theta

Desired censoring percentage

verbose

if TRUE print a censoring percentage of new created database.

Value

A list with sample data information:

sample_censored vector of censored sample
sample_uncensored vector of uncensored sample (original)
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored
1:= no censored, 0:= censored
n_censored number of censored samples

Author(s)

Daniel Saavedra Morales

See Also

rcensT1 for generate censorship sample type I.
rcensT2 for generate censorship sample type II.
rcensT3 for generate censorship sample type III
rcensI for generate interval censoring sample with random length interval

Examples

#Example Exponential - Uniform

Data_Ifix = rcensIfix(rdistrX = rexp, interval_length = 2,
                   param_X = list("rate" = .5),
                   n = 1e02, theta = .9)

## Example with plot in examples_plot/Example_rcensIfix_plot.R

Generate Censoring Sample, Type I

Description

Generator of censored samples type I with right or left censoring, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. In which, you can control the censorship time or the desired censorship percentage.

Usage

rcensT1(
  rdistrX,
  param_X,
  qdistrX = NULL,
  n = 10000,
  t_censored = -1,
  theta = 0.5,
  verbose = FALSE,
  right = TRUE
)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

param_X

list with parameters of rdistrX function.

qdistrX

quantile function of X.

n

number of sample to create.

t_censored

time level censored.

theta

Desired censoring percentage.

verbose

if TRUE print a censoring percentage of new created database.

right

if TRUE create right-censored data, else create left-censored

Value

A list with sample data information:

sample_censored vector of censored sample
sample_uncensored vector of uncensored sample (original)
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored
1:= no censored, 0:= censored
censored_time vector of censorship time
n_censored number of censored samples

Author(s)

Daniel Saavedra Morales

See Also

rcensT2 for generate censorship sample type II.
rcensT3 for generate censorship sample type III
rcensI for generate interval censoring sample with random length interval
rcensIfix for generate interval censoring sample with fix length interval

Examples

## Example Exponential
## time censored

Data_T1 = rcensT1(rdistrX = rexp, param_X = list("rate" = 2),
                 n = 1e02, t_censored = 1)

## time censored estimate with desired censoring percentage.

Data_T1 = rcensT1(rdistrX = rexp, param_X = list("rate" = 2),
                 qdistrX = qexp, n = 1e02, theta = .8)

## Example with plot in examples_plot/Example_rcensT1_plot.R

Generate Censoring Sample, Type II

Description

Generator of censored samples type II with right or left censoring, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. In which, you can control the number of censored sample or the desired censorship percentage.

Usage

rcensT2(
  rdistrX,
  param_X,
  n = 10000,
  m_censored = -1,
  theta = 0.5,
  verbose = FALSE,
  right = TRUE
)

Arguments

rdistrX

sample generator of distribution X. \ First argument number of samples, next arguments in param_X.

param_X

list with parameters of rdistrX function.

n

number of sample to create.

m_censored

number of sample censored. m_censored < n. \ If m_censored <= n, m_censored is estimate with the desired censoring percentage.

theta

Desired censoring percentage.

verbose

if TRUE print a censoring percentage of new created database.

right

if TRUE create right-censored data, else create left-censored

Value

A list with sample data information:

sample_censored vector of censored sample
sample_uncensored vector of uncensored sample (original)
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored
1:= no censored, 0:= censored
censored_time vector of censorship time
n_censored number of censored samples

Author(s)

Daniel Saavedra Morales

See Also

rcensT1 for generate censorship sample type I.
rcensT3 for generate censorship sample type III
rcensI for generate interval censoring sample with random length interval
rcensIfix for generate interval censoring sample with fix length interval

Examples

##Example Exponential

## Number of sample censored
Data_T2 = rcensT2(rdistrX = rexp, param_X = list("rate" = 2), n = 1e02, m_censored = 9)

## Number of censored sample estimate with desired censoring percentage.
Data_T2 = rcensT2(rdistrX = rexp, param_X = list("rate" = 2), n = 1e02, theta = .8)


## Example with plot in examples_plot/Example_rcensT2_plot.R

Generate Censoring Sample,Type III (Random)

Description

Generator of censored samples type III with right or left censoring, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. Also accumulate function of distribution and generator sample of distribution C (censoring) with parameters appended by the list param_C In which, you can control the desired censorship percentage.

Usage

rcensT3(
  rdistrX,
  pdistrC,
  rdistrC,
  param_X,
  param_C,
  n = 10000,
  theta = 0.5,
  n_mc = 10000,
  lambda_tol = c(1e-06, 10000),
  verbose = FALSE,
  right = TRUE
)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

pdistrC

function distribution of C. First argument probabilities, next arguments in param_C.

rdistrC

sample generator of distribution C.
First argument number of samples, next arguments in param_C.

param_X

list with parameters of rdistrX function.

param_C

list with parameters of rdistrC function, one of these parameters
should be "lambda", this wil be the searched parameter.

n

number of sample to create.

theta

Desired censoring percentage

n_mc

number of sample use in Monte Carlo integration, greater n_mc more accuracy.

lambda_tol

lowest and uppest value where live the search parameter lambda.

verbose

if TRUE print a censoring percentage of new created database.

right

if TRUE create right-censored data, else create left-censored

Value

A list with sample data information:

lambda searched censoring distribution parameter.
sample_censored vector of censored sample.
sample_uncensored vector of uncensored sample (original).
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored.
1:= no censored, 0:= censored
censored_time vector of censorship time.
n_censored number of censored samples.

Author(s)

Daniel Saavedra Morales

See Also

rcensT1 for generate censorship sample type I.
rcensT2 for generate censorship sample type II
rcensI for generate interval censoring sample with random length interval
rcensIfix for generate interval censoring sample with fix length interval

Examples

#Example Exponential - Uniform


Data_T3 = rcensT3(rdistrX = rexp, pdistrC = punif, rdistrC = runif,
              param_X = list("rate" = 2),
             param_C = list("min" = 0, "max" = "lambda"),
            n = 1e02, theta = .9, right = TRUE)


Data_T3 = rcensT3(rdistrX = rexp, pdistrC = punif, rdistrC = runif,
                 param_X = list("rate" = 2),
                 param_C = list("min" = 0, "max" = "lambda"),
                 n = 1e02, theta = .1, right = FALSE)


## Example with plot in examples_plot/Example_rcensT3_plot.R

Title Generate Sample with Cure Fraction

Description

Generator Sample with Cure Fraction, given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. Also the proportion of cure desired p.

Usage

rcuref(rdistrX, param_X, n = 10000, p = 0.5)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

param_X

list with parameters of rdistrX function.

n

number of sample to create.

p

cure fraction

Value

A list with sample data information:

data_cf vector of cure fraction sample.
cure_list vector of 1 and 0 indicating whether the i-th sample is cured.
1:= cure , 0:= no cure
cure_fraction cure fraction used to create de sample.

Author(s)

Daniel Saavedra Morales

Examples

#Example Exponential Cure Fraction p = 0.5

Data = rcuref(rdistrX = rexp, param_X = list("rate" = 1),
              n = 1000, p = 0.5)

Title Generate Sample with Cure Fraction and Random Censoring

Description

Generator Sample with Cure Fraction, Random Censoring. Given a generator of samples of the distribution X (rdistrX) with parameters appended by the list param_X. Also accumulate function of distribution and generator sample of distribution C (censoring) with parameters appended by the list param_C In which, you can control the desired censorship percentage.
Note: cure fraction (p) must be less than desired censorship percentage.

Usage

rcurefT3(
  rdistrX,
  pdistrC,
  rdistrC,
  param_X,
  param_C,
  p = 0.1,
  n = 10000,
  theta = 0.5,
  n_mc = 10000,
  lambda_tol = c(1e-06, 10000),
  verbose = FALSE,
  right = TRUE
)

Arguments

rdistrX

sample generator of distribution X.
First argument number of samples, next arguments in param_X.

pdistrC

function distribution of C. First argument probabilities, next arguments in param_C.

rdistrC

sample generator of distribution C.
First argument number of samples, next arguments in param_C.

param_X

list with parameters of rdistrX function.

param_C

list with parameters of rdistrC function, one of these parameters
should be "lambda", this wil be the searched parameter.

p

cure fraction

n

number of sample to create.

theta

Desired censoring percentage

n_mc

number of sample use in Monte Carlo integration, greater n_mc more accuracy.

lambda_tol

lowest and uppest value where live the search parameter lambda.

verbose

if TRUE print a censoring percentage of new created database.

right

if TRUE create right-censored data, else create left-censored

Value

A list with sample data information:

lambda searched censoring distribution parameter.
sample_censored vector of censored sample.
sample_uncensored vector of uncensored sample (original).
censored_indicator vector of 1 and 0 indicating whether the i-th sample is censored.
1:= no censored, 0:= censored
censored_time vector of censorship time.
n_censored number of censored samples.
cure_list vector of 1 and 0 indicating whether the i-th sample is cured.
1:= cure , 0:= no cure
cure_fraction cure fraction used to create de sample.

Author(s)

Daniel Saavedra Morales

See Also

rcuref Generate Sample with Cure Fraction.

Examples

#Example Exponential - Uniform


Data_T3 = rcurefT3(rdistrX = rexp, pdistrC = punif, rdistrC = runif,
                   param_X = list("rate" = 2),
                   param_C = list("min" = 0, "max" = "lambda"),
                   n = 1e02, theta = .9, p = 0.2)




## Example with plot in examples_plot/Example_rcurefT3_plot.R