censoringData: Adding rows with censored data points

View source: R/preprocessing.R

censoringDataR Documentation

Adding rows with censored data points

Description

Creates extra rows for indicating left- or right-censored data.

Usage

censoringData(
  dat,
  nestVars,
  timeVar,
  eventVar = "event",
  catVar = NULL,
  TimeGap = 1,
  censoring = "right",
  verbose = T
)

Arguments

dat

data.frame containing the variables to be lagged

nestVars

name(s) of the columns indicating how the data is nested (e.g., ID variable). Currently up to two nestVars are possible.

timeVar

name of the column with the time variable.

eventVar

name of the column indicating if an event (value = 1) happened or not/censored (0)

catVar

name of the event (for coxph or frailty) or event-type (for multi-state) column where the indication of the censoring is stored.

censoring

character string "right" or "left" indicating if right- or left- censored data row should be added

timeGap

time to be added (for right-censoring) or removed (for left-censoring) form timeVar

Value

data.frame with extra rows for censored data.

Examples

 dat <- data.frame(ID = c(rep(1,10), rep(2,10)),
                  day = rep(c(rep(1,5), rep(2,5)),2),
                  event = 1,
                  a = runif(20, max = 10),
                  t = rlnorm(20,1,.4),
                  cat = sample(c("X","Y","Z"), 20, replace = T))
censoringData(dat, nestVars = c("ID"), timeVar = "t")
censoringData(dat, nestVars = c("ID","day"), timeVar = "t")
censoringData(dat, nestVars = c("ID"), timeVar = "t", censoring = "left",TimeGap = 1


timonelmer/dena documentation built on April 15, 2023, 11:51 p.m.