lifeTable: Life Table Construction and Estimates

Description Usage Arguments Value Author(s) References Examples

View source: R/DiscSurvLifeTable.R

Description

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

Usage

1
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

Author(s)

Thomas Welchowski [email protected]

Matthias Schmid [email protected]

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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")

Example output

Loading required package: Ecfun

Attaching package: 'Ecfun'

The following object is masked from 'package:base':

    sign


Attaching package: 'Ecdat'

The following object is masked from 'package:datasets':

    Orange

            n events dropouts atRisk hazard seHazard      S    seS cumHazard
[0, 1)   1742    148      154 1665.0 0.0889   0.0070 0.9111 0.0070    0.0889
[1, 2)   1440    107      183 1348.5 0.0793   0.0074 0.8388 0.0093    0.1682
[2, 3)   1150     59      178 1061.0 0.0556   0.0070 0.7922 0.0106    0.2238
[3, 4)    913     28       87  869.5 0.0322   0.0060 0.7667 0.0113    0.2560
[4, 5)    798     62      126  735.0 0.0844   0.0103 0.7020 0.0130    0.3404
[5, 6)    610     19       57  581.5 0.0327   0.0074 0.6791 0.0136    0.3731
[6, 7)    534     43       92  488.0 0.0881   0.0128 0.6192 0.0151    0.4612
[7, 8)    399      5       31  383.5 0.0130   0.0058 0.6111 0.0154    0.4742
[8, 9)    363     19       54  336.0 0.0565   0.0126 0.5766 0.0164    0.5308
[9, 10)   290      3       23  278.5 0.0108   0.0062 0.5704 0.0166    0.5415
[10, 11)  264      9       35  246.5 0.0365   0.0119 0.5496 0.0174    0.5781
[11, 12)  220      4       12  214.0 0.0187   0.0093 0.5393 0.0178    0.5967
[12, 13)  204     10       31  188.5 0.0531   0.0163 0.5107 0.0190    0.6498
[13, 14)  163     15       21  152.5 0.0984   0.0241 0.4604 0.0211    0.7482
[14, 15)  127      5       20  117.0 0.0427   0.0187 0.4408 0.0220    0.7909
[15, 16)  102      7       17   93.5 0.0749   0.0272 0.4078 0.0236    0.8658
[16, 17)   78      3       11   72.5 0.0414   0.0234 0.3909 0.0246    0.9071
[17, 18)   64      5        4   62.0 0.0806   0.0346 0.3594 0.0263    0.9878
[18, 19)   55      1        5   52.5 0.0190   0.0189 0.3525 0.0267    1.0068
[19, 20)   49      2        7   45.5 0.0440   0.0304 0.3370 0.0277    1.0508
[20, 21)   40      2       12   34.0 0.0588   0.0404 0.3172 0.0294    1.1096
[21, 22)   26      0        0   26.0 0.0000   0.0000 0.3172 0.0294    1.1096
[22, 23)   26      0        4   24.0 0.0000   0.0000 0.3172 0.0294    1.1096
[23, 24)   22      0        0   22.0 0.0000   0.0000 0.3172 0.0294    1.1096
[24, 25)   22      0        1   21.5 0.0000   0.0000 0.3172 0.0294    1.1096
[25, 26)   21      1        5   18.5 0.0541   0.0526 0.3001 0.0324    1.1637
[26, 27)   15      0       12    9.0 0.0000   0.0000 0.3001 0.0324    1.1637
[27, 28)    3      0        3    1.5 0.0000   0.0000 0.3001 0.0324    1.1637
         seCumHazard
[0, 1)        0.0073
[1, 2)        0.0106
[2, 3)        0.0128
[3, 4)        0.0142
[4, 5)        0.0178
[5, 6)        0.0193
[6, 7)        0.0235
[7, 8)        0.0242
[8, 9)        0.0275
[9, 10)       0.0282
[10, 11)      0.0307
[11, 12)      0.0321
[12, 13)      0.0362
[13, 14)      0.0442
[14, 15)      0.0482
[15, 16)      0.0559
[16, 17)      0.0608
[17, 18)      0.0707
[18, 19)      0.0732
[19, 20)      0.0795
[20, 21)      0.0897
[21, 22)      0.0897
[22, 23)      0.0897
[23, 24)      0.0897
[24, 25)      0.0897
[25, 26)      0.1048
[26, 27)      0.1048
[27, 28)      0.1048
  id age    sex dxyr pcdx pctime futime death alb creat  hgb mspike
1  1  78 female   68 <NA>     NA    748     1 2.8   1.2 11.5    2.0
2  2  73 female   66   LP   1310   6751     1  NA    NA   NA    1.3
3  3  87   male   68 <NA>     NA    277     1 2.2   1.1 11.2    1.3
4  4  86   male   69 <NA>     NA   1815     1 2.8   1.3 15.3    1.8
5  5  74 female   68 <NA>     NA   2587     1 3.0   0.8  9.8    1.4
6  6  81   male   68 <NA>     NA    563     1 2.9   0.9 11.5    1.8
           n events dropouts atRisk      hazard    seHazard         S
[0, 1)   121      0        0    121 0.000000000 0.000000000 1.0000000
[1, 2)   121      0        0    121 0.000000000 0.000000000 1.0000000
[2, 3)   121      0        0    121 0.000000000 0.000000000 1.0000000
[3, 4)   121      0        0    121 0.000000000 0.000000000 1.0000000
[4, 5)   121      0        0    121 0.000000000 0.000000000 1.0000000
[5, 6)   121      0        0    121 0.000000000 0.000000000 1.0000000
[6, 7)   121      1        0    121 0.008264463 0.008230241 0.9917355
[7, 8)   120      1        0    120 0.008333333 0.008298538 0.9834711
[8, 9)   119      0        0    119 0.000000000 0.000000000 0.9834711
[9, 10)  119      0        0    119 0.000000000 0.000000000 0.9834711
[10, 11) 119      0        0    119 0.000000000 0.000000000 0.9834711
[11, 12) 119      0        0    119 0.000000000 0.000000000 0.9834711
[12, 13) 119      0        0    119 0.000000000 0.000000000 0.9834711
[13, 14) 119      0        0    119 0.000000000 0.000000000 0.9834711
[14, 15) 119      0        0    119 0.000000000 0.000000000 0.9834711
[15, 16) 119      0        0    119 0.000000000 0.000000000 0.9834711
[16, 17) 119      0        0    119 0.000000000 0.000000000 0.9834711
[17, 18) 119      0        0    119 0.000000000 0.000000000 0.9834711
[18, 19) 119      0        0    119 0.000000000 0.000000000 0.9834711
[19, 20) 119      0        0    119 0.000000000 0.000000000 0.9834711
[20, 21) 119      0        0    119 0.000000000 0.000000000 0.9834711
[21, 22) 119      0        0    119 0.000000000 0.000000000 0.9834711
[22, 23) 119      0        0    119 0.000000000 0.000000000 0.9834711
[23, 24) 119      0        0    119 0.000000000 0.000000000 0.9834711
[24, 25) 119      0        0    119 0.000000000 0.000000000 0.9834711
                 seS   cumHazard seCumHazard
[0, 1)   0.000000000 0.000000000 0.000000000
[1, 2)   0.000000000 0.000000000 0.000000000
[2, 3)   0.000000000 0.000000000 0.000000000
[3, 4)   0.000000000 0.000000000 0.000000000
[4, 5)   0.000000000 0.000000000 0.000000000
[5, 6)   0.000000000 0.000000000 0.000000000
[6, 7)   0.008230241 0.008264463 0.008264463
[7, 8)   0.011590720 0.016597796 0.011736515
[8, 9)   0.011590720 0.016597796 0.011736515
[9, 10)  0.011590720 0.016597796 0.011736515
[10, 11) 0.011590720 0.016597796 0.011736515
[11, 12) 0.011590720 0.016597796 0.011736515
[12, 13) 0.011590720 0.016597796 0.011736515
[13, 14) 0.011590720 0.016597796 0.011736515
[14, 15) 0.011590720 0.016597796 0.011736515
[15, 16) 0.011590720 0.016597796 0.011736515
[16, 17) 0.011590720 0.016597796 0.011736515
[17, 18) 0.011590720 0.016597796 0.011736515
[18, 19) 0.011590720 0.016597796 0.011736515
[19, 20) 0.011590720 0.016597796 0.011736515
[20, 21) 0.011590720 0.016597796 0.011736515
[21, 22) 0.011590720 0.016597796 0.011736515
[22, 23) 0.011590720 0.016597796 0.011736515
[23, 24) 0.011590720 0.016597796 0.011736515
[24, 25) 0.011590720 0.016597796 0.011736515

discSurv documentation built on May 29, 2017, 6:47 p.m.