Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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, timeAsFactor=TRUE)

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.

timeAsFactor

Should the time intervals be coded as factor? Default is to use factor. If the argument is false, the column is coded as numeric.

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.

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

Author(s)

References

Gerhard Tutz and Matthias Schmid, (2016), Modeling discrete time-to-event data, Springer series in statistics, Doi: 10.1007/978-3-319-28158-2

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

Examples

# 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, ]

discSurv

Discrete Time Survival Analysis

v1.4.1
GPL-3
Authors
Thomas Welchowski <welchow@imbie.meb.uni-bonn.de> and Matthias Schmid <matthias.schmid@imbie.uni-bonn.de>
Initial release
2019-12-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.