Learn R Programming

DTEAssurance (version 1.1.0)

cens_data: Censor a survival dataset

Description

Applies administrative censoring to a survival dataset using one of three methods: fixed time, fixed number of events, or fixed information fraction. The input data must contain columns for pseudo survival time, recruitment time, and observed time.

Usage

cens_data(
  data,
  cens_method = "Time",
  cens_time = NULL,
  cens_IF = NULL,
  cens_events = NULL
)

Value

A list containing:

data

Censored dataframe with updated status and filtered rows

cens_events

Number of events used for censoring (if applicable)

cens_time

Time point used for censoring

sample_size

Number of patients remaining after censoring

Arguments

data

A dataframe containing uncensored survival data with columns: pseudo_time, rec_time, and time

cens_method

Censoring method: "Time" (default), "Events", or "IF"

cens_time

Time point for censoring (required if cens_method = "Time")

cens_IF

Information fraction for censoring (required if cens_method = "IF")

cens_events

Number of events for censoring (required if cens_method = "Events")

Examples

Run this code
set.seed(123)
df <- data.frame(
  pseudo_time = rexp(20, rate = 0.1),
  rec_time = runif(20, 0, 12),
  time = rexp(20, rate = 0.1)
)
censored <- cens_data(df, cens_method = "Time", cens_time = 10)
str(censored)

Run the code above in your browser using DataLab