Learn R Programming

discSurv (version 1.1.2)

lifeTable: Life Table Construction and Estimates

Description

Constructs a life table and estimates discrete hazard rates, survival functions, cumulative hazard rates and their standard errors without covariates.

Usage

lifeTable(dataSet, timeColumn, censColumn, intervalBorders = NULL)

Arguments

dataSet
Original data in short format. Must be of class "data.frame".
timeColumn
Name of the column with discrete survival times. Must be a scalar character vector.
censColumn
Gives the column name of the event indicator (1=observed, 0=censored). Must be of type "character".
intervalBorders
Optional names of the intervals for each row, e. g. [a_0, a_1), [a_1, a_2), ..., [a_{q-1}, a_q)

Value

  • List containing an object of class "data.frame" with following columns
    • n:
    {Number of individuals at risk in a given time interval (integer)}
  • events:
  • {Observed number of events in a given time interval (integer)}
  • dropouts:
  • {Observed number of dropouts in a given time interval (integer)}
  • atRisk:
  • {Estimated number of individuals at risk, corrected by dropouts (numeric)}
  • hazard:
  • {Estimated risk of death (without covariates) in a given time interval}
  • seHazard:
  • {Estimated standard deviation of estimated hazard}
  • S:
  • {Estimated survival curve}
  • seS:
  • {Estimated standard deviation of estimated survival function}
  • cumHazard:
  • {Estimated cumulative hazard function}
  • seCumHazard:
  • {Estimated standard deviation of the estimated cumulative hazard function}

References

Jerald F. Lawless, (2000), Statistical Models and Methods for Lifetime Data, 2nd edition, Wiley series in probability and statistics

Examples

Run this code
# Example with unemployment data
library(Ecdat)
data(UnempDur)

# Extract subset of all persons smaller or equal the median of age
UnempDurSubset <- subset(UnempDur, age<=median(UnempDur$age))
LifeTabUnempDur <- lifeTable (dataSet=UnempDurSubset, timeColumn="spell", censColumn="censor1")
LifeTabUnempDur

# Example with monoclonal gammapothy data
library(survival)
head(mgus)
# Extract subset of mgus
subMgus <- mgus [mgus$futime<=median(mgus$futime), ]
# Transform time in days to intervals [0, 1), [1, 2), [2, 3), ... , [12460, 12461)
mgusInt <- subMgus
mgusInt$futime <- mgusInt$futime + 1
LifeTabGamma <- lifeTable (dataSet=mgusInt, timeColumn="futime", censColumn="death")
head(LifeTabGamma$Output, 25)
plot(x=1:dim(LifeTabGamma$Output)[1], y=LifeTabGamma$Output$hazard, type="l", 
xlab="Time interval", ylab="Hazard", las=1, 
main="Life table estimated marginal hazard rates")

Run the code above in your browser using DataLab