MyNixOS website logo
Description

Generate Sample Censoring.

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.

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)

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.

Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows