Learn R Programming

discSurv (version 1.1.2)

dataLongTimeDep: Data Long Time Dependent Covariates

Description

Transforms short data format to long format for discrete survival modelling of single event analysis with right censoring. Covariates may vary over time.

Usage

dataLongTimeDep(dataSet, timeColumn, censColumn, idColumn)

Arguments

dataSet
Original data in short format. Must be of class "data.frame".
timeColumn
Character giving the column name of the observed times. It is required that the observed times are discrete (integer).
censColumn
Character giving the column name of the event indicator. It is required that this is a binary variable with 1=="event" and 0=="censored".
idColumn
Name of column of identification number of persons as character.

Value

  • Original data.frame with three additional columns:
    • obj:
    {Index of persons as integer vector}
  • timeInt:
  • {Index of time intervals (factor)}
  • y:
  • {Response in long format as binary vector. 1=="event happens in period timeInt" and 0 otherwise}

Details

There may be some intervals, where no additional information on the covariates is observed (e. g. observed values in interval one and three but two is missing). In this case it is assumed, that the values from the last observation stay constant over time until a new measurement was done.

References

Ludwig Fahrmeir, (1997), Discrete failure time models, LMU Sonderforschungsbereich 386, Paper 91, http://epub.ub.uni-muenchen.de/ W. A. Thompson Jr., (1977), On the Treatment of Grouped Observations in Life Studies, Biometrics, Vol. 33, No. 3

See Also

contToDisc, dataLong, dataLongCompRisks

Examples

Run this code
# Example Primary Biliary Cirrhosis data
library(survival)
dataSet1 <- pbcseq

# Only event death is of interest
dataSet1$status [dataSet1$status==1] <- 0
dataSet1$status [dataSet1$status==2] <- 1
table(dataSet1$status)

# Convert to months
dataSet1$day <- ceiling(dataSet1$day/30)+1
names(dataSet1) [7] <- "month"

# Convert to long format for time varying effects
pbcseqLong <- dataLongTimeDep (dataSet=dataSet1, timeColumn="month", 
censColumn="status", idColumn="id")
pbcseqLong [pbcseqLong$obj==1, ]

Run the code above in your browser using DataLab