dataCensoring: Data Censoring Transformation

View source: R/DiscSurvDataTransform.R

dataCensoringR Documentation

Data Censoring Transformation

Description

Function for transformation of discrete survival times in censoring encoding. The original data is expanded to include the censoring process. Alternatively the long data format can also be augmented. With the new generated variable "yCens", the discrete censoring process can be analyzed instead of the discrete survival process. In discrete survival analysis this information is used to constructs weights for predictive evaluation measures. It is applicable in single event survival analysis.

Usage

dataCensoring(
  dataShort,
  eventColumns,
  eventColumnsAsFactor = FALSE,
  timeColumn,
  shortFormat = TRUE
)

Arguments

dataShort

Original data set in short format (class "data.frame"). Descriptions of data formats are available in discSurv-package.

eventColumns

Name of event columns (class "character"). The event columns have to be in binary format. If the sum of all events equals zero in a row, then this observation is interpreted as censored.

eventColumnsAsFactor

Should the argument eventColumns be interpreted as column name of a factor variable (class "logical")? Default is FALSE.

timeColumn

Name of column with discrete time intervals (class "character").

shortFormat

Is the supplied data set dataShort not preprocessed with function dataLong (class "logical")? Default is TRUE. If shortFormat=FALSE then it is assumed that the data set was augmented with function dataLong.

Value

Original data set as argument dataShort, but with added censoring process as first variable in column "yCens".

Note

Arguments to this function have to be specified in the required formats. Other objects are not supported. For example a common mistake is the usage of tibble data formats, that are not of class "data.frame".

Author(s)

Thomas Welchowski t.welchowski@psychologie.uzh.ch

References

\insertRef

fahrmeirDiscSurvdiscSurv

\insertRefthompsonTreatmentdiscSurv

\insertReftutzModelDiscdiscSurv

See Also

contToDisc, dataLong, dataLongTimeDep, dataLongCompRisks

Examples


library(pec)
data(cost)
head(cost)
IntBorders <- 1:ceiling(max(cost$time)/30)*30
subCost <- cost [1:100, ]

# Convert from days to months
CostMonths <- contToDisc(dataShort=subCost, timeColumn="time", intervalLimits=IntBorders)
head(CostMonths)

# Generate censoring process variable in short format
CostMonthsCensorShort <- dataCensoring (dataShort = CostMonths, 
eventColumns = "status", timeColumn = "time", shortFormat = TRUE)
head(CostMonthsCensorShort)

################################
# Example with long data format
library(pec)
data(cost)
head(cost)
IntBorders <- 1:ceiling(max(cost$time)/30)*30
subCost <- cost [1:100, ]

# Convert from days to months
CostMonths <- contToDisc(dataShort = subCost, timeColumn = "time", intervalLimits = IntBorders)
head(CostMonths)

# Convert to long format based on months
CostMonthsLong <- dataLong(dataShort = CostMonths, timeColumn = "timeDisc", eventColumn = "status")
head(CostMonthsLong, 20)

# Generate censoring process variable
CostMonthsCensor <- dataCensoring (dataShort = CostMonthsLong, timeColumn = "timeInt", 
shortFormat = FALSE)
head(CostMonthsCensor)
tail(CostMonthsCensor [CostMonthsCensor$obj==1, ], 10)
tail(CostMonthsCensor [CostMonthsCensor$obj==3, ], 10)


discSurv documentation built on April 29, 2026, 9:07 a.m.