Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Cumulative Risk - life table problem?


From   "David Winter" <[email protected]>
To   <[email protected]>
Subject   st: Cumulative Risk - life table problem?
Date   Mon, 24 Apr 2006 17:24:02 +0100

Hello,

I have run some cumulative risk estimates and produced some life tables,
using -stset- and -sts list-.  I wanted to look at the period between
entry at risk and exit from risk for a cancer cohort where failure
(flagged by a variable: censvar) was developing a cancer.

I -stset- the data and calculated the interval between entry and exit in
years (generated variable: intvlexit).  I then tabulated this variable
and found the maximum interval (entry to exit to be 48 years).  When I
ran -sts list- on this data I set the time range from 0 - 65 as I don't
know in advance what the maximum interval is). I expected that, after
time value = 49, there would be 0 persons entering risk, but in the life
table all Time values from 49 to 65 have 1 record apparently "still at
risk".

The log file is as follows:

------------------------------------------------------------------------
----
       log:  M:\DaveW\wilms\LifeTable.log
  log type:  text
 opened on:  24 Apr 2006, 16:26:33

. do "C:\DOCUME~1\WINTER~1.INT\LOCALS~1\Temp\STD04000000.tmp"

. /* STATA .do file to produce Life tables & Cum Risk */
. /* version 1 (APR 2006)                             */
. /* Dave Winter                                      */
. 
. 
. display "RUNNING CUM-RISK USING TAB-Separated DATA..."
RUNNING CUM-RISK USING TAB-Separated DATA...

. 
. quietly {

. 
. /* Transform dates to years since B.C.  Algorithm allows for same day
and month in year and leap years *
> /
. /* N.B. 28/2/anyyear = 59th day */
. 
. gen byte extraDOB = 0

. gen byte extraENT = 0

. gen byte extraEX = 0

. replace extraDOB = 1 if doy(mdy(12,31,birthyr)) == 366 &
doy(mdy(birthmth,birthday,birthyr)) > 59
(302 real changes made)

. replace extraENT = 1 if doy(mdy(12,31,entryyr)) == 366 &
doy(mdy(entrymth,entryday,entryyr)) > 59
(262 real changes made)

. replace extraEX = 1 if doy(mdy(12,31,exityr)) == 366 &
doy(mdy(exitmth,exitday,exityr)) > 59
(39 real changes made)

. gen begyear = ((endate - mdy(1,1,entryyr) - extraENT)/365.25)+entryyr

. gen endyear = ((exdate - mdy(1,1,exityr) - extraEX)/365.25)+exityr

. gen byear = ((bdate - mdy(1,1,birthyr) - extraDOB)/365.25)+birthyr

. 
. drop extraDOB extraENT extraEX

. 
. /* 'stset' data to enable time in study ('intvlexit') calculated */
. stset endyear, fail(censvar) enter(begyear) origin(byear) id(indexno)

                id:  indexno
     failure event:  censvar != 0 & censvar < .
obs. time interval:  (endyear[_n-1], endyear]
 enter on or after:  time begyear
 exit on or before:  failure
    t for analysis:  (time-origin)
            origin:  time byear

------------------------------------------------------------------------
------
     1341  total obs.
        0  exclusions
------------------------------------------------------------------------
------
     1341  obs. remaining, representing
     1341  subjects
       41  failures in single failure-per-subject data
 18467.25  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =        15
                                  last observed exit t =  63.19714

. gen intvlexit = int(_t - _t0)

. /* stset when time in study has been derived */
. stset intvlexit, fail(censvar)

     failure event:  censvar != 0 & censvar < .
obs. time interval:  (0, intvlexit]
 exit on or before:  failure

------------------------------------------------------------------------
------
     1341  total obs.
       21  obs. end on or before enter()
------------------------------------------------------------------------
------
     1320  obs. remaining, representing
       41  failures in single record/single failure data
    17798  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        48

. 
. /* tabulation of interval entry to exit */
. tab intvlexit

  intvlexit |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         21        1.57        1.57
          1 |         98        7.31        8.87
          2 |         44        3.28       12.16
          3 |         60        4.47       16.63
          4 |         43        3.21       19.84
          5 |         46        3.43       23.27
          6 |         54        4.03       27.29
          7 |         58        4.33       31.62
          8 |         70        5.22       36.84
          9 |         46        3.43       40.27
         10 |         42        3.13       43.40
         11 |         50        3.73       47.13
         12 |         53        3.95       51.08
         13 |         53        3.95       55.03
         14 |         49        3.65       58.69
         15 |         58        4.33       63.01
         16 |         45        3.36       66.37
         17 |         52        3.88       70.25
         18 |         47        3.50       73.75
         19 |         41        3.06       76.81
         20 |         32        2.39       79.19
         21 |         34        2.54       81.73
         22 |         24        1.79       83.52
         23 |         35        2.61       86.13
         24 |         17        1.27       87.40
         25 |         28        2.09       89.49
         26 |         14        1.04       90.53
         27 |         15        1.12       91.65
         28 |         17        1.27       92.92
         29 |         17        1.27       94.18
         30 |         11        0.82       95.00
         31 |          9        0.67       95.67
         32 |          6        0.45       96.12
         33 |          9        0.67       96.79
         34 |         11        0.82       97.61
         35 |          4        0.30       97.91
         36 |          4        0.30       98.21
         37 |          8        0.60       98.81
         38 |          4        0.30       99.11
         39 |          3        0.22       99.33
         41 |          2        0.15       99.48
         42 |          3        0.22       99.70
         44 |          1        0.07       99.78
         45 |          1        0.07       99.85
         47 |          1        0.07       99.93
         48 |          1        0.07      100.00
------------+-----------------------------------
      Total |      1,341      100.00

. 
. /* produce life table */
. sts list, failure at (0(1)65)

         failure _d:  censvar
   analysis time _t:  intvlexit

            Beg.                    Failure       Std.
    Time   Total     Fail           Function     Error     [95% Conf.
Int.]
------------------------------------------------------------------------
----
       0         0        0            0.0000         .          .
.
       1      1320        0            0.0000         .          .
.
       2      1222        1            0.0008    0.0008     0.0001
0.0058
       3      1178        0            0.0008    0.0008     0.0001
0.0058
       4      1118        2            0.0026    0.0015     0.0008
0.0081
       5      1075        4            0.0063    0.0024     0.0030
0.0132
       6      1029        0            0.0063    0.0024     0.0030
0.0132
       7       975        3            0.0094    0.0030     0.0050
0.0174
       8       917        2            0.0115    0.0033     0.0066
0.0203
       9       847        0            0.0115    0.0033     0.0066
0.0203
      10       801        3            0.0152    0.0039     0.0092
0.0253
      11       759        2            0.0178    0.0043     0.0111
0.0287
      12       709        1            0.0192    0.0045     0.0121
0.0305
      13       656        1            0.0207    0.0048     0.0132
0.0325
      14       603        1            0.0223    0.0050     0.0143
0.0347
      15       554        1            0.0241    0.0053     0.0156
0.0371
      16       496        2            0.0280    0.0060     0.0184
0.0426
      17       451        1            0.0302    0.0064     0.0200
0.0455
      18       399        3            0.0375    0.0076     0.0252
0.0556
      19       352        0            0.0375    0.0076     0.0252
0.0556
      20       311        1            0.0406    0.0082     0.0273
0.0601
      21       279        3            0.0509    0.0100     0.0346
0.0747
      22       245        1            0.0548    0.0107     0.0373
0.0801
      23       221        1            0.0590    0.0115     0.0403
0.0862
      24       186        0            0.0590    0.0115     0.0403
0.0862
      25       169        1            0.0646    0.0127     0.0439
0.0946
      26       141        0            0.0646    0.0127     0.0439
0.0946
      27       127        1            0.0720    0.0146     0.0483
0.1066
      28       112        0            0.0720    0.0146     0.0483
0.1066
      29        95        1            0.0817    0.0174     0.0537
0.1234
      30        78        0            0.0817    0.0174     0.0537
0.1234
      31        67        0            0.0817    0.0174     0.0537
0.1234
      32        58        1            0.0976    0.0232     0.0609
0.1544
      33        52        1            0.1149    0.0285     0.0702
0.1852
      34        43        0            0.1149    0.0285     0.0702
0.1852
      35        32        0            0.1149    0.0285     0.0702
0.1852
      36        28        0            0.1149    0.0285     0.0702
0.1852
      37        24        1            0.1518    0.0453     0.0835
0.2672
      38        16        2            0.2578    0.0805     0.1359
0.4559
      39        12        0            0.2578    0.0805     0.1359
0.4559
      40        12        0            0.2578    0.0805     0.1359
0.4559
      41         9        0            0.2578    0.0805     0.1359
0.4559
      42         7        0            0.2578    0.0805     0.1359
0.4559
      43         7        0            0.2578    0.0805     0.1359
0.4559
      44         4        0            0.2578    0.0805     0.1359
0.4559
      45         3        0            0.2578    0.0805     0.1359
0.4559
      46         3        0            0.2578    0.0805     0.1359
0.4559
      47         2        0            0.2578    0.0805     0.1359
0.4559
      48         1        0            0.2578    0.0805     0.1359
0.4559
      49         1        0                 .         .          .
.
      50         1        0                 .         .          .
.
      51         1        0                 .         .          .
.
      52         1        0                 .         .          .
.
      53         1        0                 .         .          .
.
      54         1        0                 .         .          .
.
      55         1        0                 .         .          .
.
      56         1        0                 .         .          .
.
      57         1        0                 .         .          .
.
      58         1        0                 .         .          .
.
      59         1        0                 .         .          .
.
      60         1        0                 .         .          .
.
      61         1        0                 .         .          .
.
      62         1        0                 .         .          .
.
      63         1        0                 .         .          .
.
      64         1        0                 .         .          .
.
      65         1        0                 .         .          .
.
------------------------------------------------------------------------
----
Note:  Failure function is calculated over full data and evaluated at
       indicated times; it is not calculated from aggregates shown at
left.

. 
. /* sts graph */ 
. 
. 
. display "ANALYSIS COMPLETED SUCCESSFULLY!"
ANALYSIS COMPLETED SUCCESSFULLY!

. 
. 
. 
end of do-file

. log close
       log:  M:\DaveW\wilms\LifeTable.log
  log type:  text
 closed on:  24 Apr 2006, 16:26:48
------------------------------------------------------------------------
----

Have I missed something very straight-forward (and potentially
embarrassing) here?

Best wishes, 

Dave

****************************************************
Mr David L. Winter, HNC
I.T. Manager (BCCSS Study)
Department of Public Health & Epidemiology
Room 105, Public Health Building
University of Birmingham
Edgbaston
Birmingham
B15 2TT
UK
tel.: +44 (0)121 414 6766
fax.: +44 (0)121 414 7923
****************************************************


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index