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.

rcens Package

Hits

This package provides functions to generate censored samples of type I, II and III, from any random sample generator. It also provides 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.

Installation

You can install rcens from CRAN via:

install.packages("rcens")

Or install the latest development version (on GitHub) via {devtools}:

devtools::install_github("dlsaavedra/rcens")

Getting Started

Create easily a new censored data set establishment the percentage of censoring and the original distribution of random variable.

Right Censored Data, type III (Random)

In this example create a right censored data type III and fit Kaplan Meier (survival library).

#Example Exponential - Uniform

devtools::install_github("dlsaavedra/rcens")
library(rcens)
library(survival)

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

S = Surv(Data$sample_censored,Data$censored_indicator, type = "right")
s1 = survfit(S ~ 1)

CDF_censored = ecdf(Data$sample_censored)
Survival_CDF = Vectorize(function(x){ 1 - CDF_censored(x)})
CDF_original= ecdf(Data$sample_uncensored)
Survival_CDF_original = Vectorize(function(x){ 1 - CDF_original(x)})

plot(Survival_CDF, col = "blue", xlim = c(0,2))
title("Survival Curve")
plot(Survival_CDF_original, col = "red", add= TRUE, xlim = c(0,2))
lines(s1$time, s1$surv, col = "green", xlim = c(0,2))
legend("topright",c("original","censured", "Survival_KM"),
       col = c("red", "blue", "green"), lty = 1)
https://github.com/dlsaavedra/rcens/blob/main/image/Survival_Curve_Example_rcensT3.png
https://github.com/dlsaavedra/rcens/blob/main/image/Survival_Curve_Example_rcensT3.png

Other Examples

In the folder examples_plot you can find example for each function in this packages.

Citation

To cite rcens in publication use:

Saavedra D, Ramos PL (2024). rcens: Generate Sample Censoring. R package version 0.1.0, https://github.com/dlsaavedra/rcens.

A BibTeX entry for LaTeX users is:

  @Manual{,
    title = {rcens: Generate Sample Censoring},
    author = {Daniel Saavedra and Pedro L Ramos},
    year = {2024},
    note = {R package version 0.1.1},
    url = {https://github.com/dlsaavedra/rcens},
  }

Future Work

We are currently working to generate data with interval right censoring, both with fixed and random interval length. Soon we will propose a function to generate data with double interval censoring. All this while maintaining the possibility of using any distribution for the original data.

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.