Skip to contents

Expand Survival Data into Long Format for Discrete-Time Models

Usage

dataLong(
  dataSet,
  timeColumn,
  censColumn,
  timeAsFactor = TRUE,
  remLastInt = FALSE,
  aggTimeFormat = FALSE,
  lastTheoInt = NULL
)

Arguments

dataSet

A data.frame containing the survival data.

timeColumn

A character string giving the name of the column with observed survival times.

censColumn

A character string giving the name of the column with the event indicator (0 = censored, 1 = event).

timeAsFactor

Logical; if TRUE, the time intervals are returned as a factor, otherwise as numeric values.

remLastInt

Logical; if TRUE, removes observations in the final interval where hazard is always 1.

aggTimeFormat

Logical; if TRUE, expands to a fixed number of intervals given by lastTheoInt, regardless of observed time.

lastTheoInt

Integer; the maximum theoretical number of intervals. Required if aggTimeFormat = TRUE.

Value

A data.frame in long format with columns:

  • obj: subject index

  • timeInt: discrete time interval

  • y: binary event indicator at each interval

  • all original variables from dataSet