Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • New Package -tteir- at the SSC

    Thanks to Kit Baum there is a new package -tteir- on the SSC

    Description
    The command tteir is a wrapper for the use of stset, stsplit, and collapse as described in sections 4.3 to 4.5 in Royston and Lambert (2011) to prepare time-to-event datasets for poisson regressions with piecewise constant incidence rates. A piecewise constant incidence rate for an interval can be interpreted as the average hazard rate for that same interval. The main idea is to get a minimal but sufficient dataset for analysis.

    Examples
    The command tteir generates
    Code:
    . webuse diet, clear
    . tteir dox, failure(fail) origin(time doe) scale(365.25) at(0(2)18)
    five variables summarizing the original dataset:
    Code:
    . list
    
         +--------------------------------------------+
         | _start       _stop   _total   _x     _futm |
         |--------------------------------------------|
      1. |      0           2      337    8   665.775 |
      2. |      2           4      329    9   649.929 |
      3. |      4           6      319   14   618.721 |
      4. |      6           8      302   10   594.716 |
      5. |      8          10      292    7   566.991 |
         |--------------------------------------------|
      6. |     10          12      269   13   491.916 |
      7. |     12          14      220    7   414.802 |
      8. |     14          16      199    7   361.907 |
      9. |     16          18      144    5   177.780 |
     10. |     18   20.041068       44    0    61.131 |
         +--------------------------------------------+
    The list is a summary of number of events and total follow-up time for each group.

    Instead of the Kaplan-Meyer failure curve,
    Code:
    . webuse diet, clear
    . stset dox, failure(fail) origin(time doe) scale(365.25) id(id)
    . sts graph, by(hienergy) failure name(km, replace)
    one can use the tteir command and the predicted incidence rates from the post estimation of the poisson regression
    Code:
    . tteir dox, failure(fail) origin(time doe) scale(365.25) at(0(2)18) by(hienergy)
    . qui poisson _x bn._start#i.hienergy, irr exposure(_futm) nocons vce(robust)
    . predict ir, it
    . format ir %6.4f
    to get a piece-wice constant Nelson-Aalen failure curve, i.e., the cummulative incidence rates
    Code:
    . generate dt = _stop - _start
    . bysort hienergy (_stop): generate cir = 1 - exp(-sum(ir*dt))
    . format cir %6.4f
    The simplest way to compare is to use (if installed) addplot
    Code:
    . addplot km: (line cir _stop if !hienergy,sort) (line cir _stop if hienergy,sort)
    Click image for larger version

Name:	image_30618.png
Views:	1
Size:	58.3 KB
ID:	1708170

    To reproduce a cox regression like
    Code:
    . webuse diet, clear
    . stset dox, failure(fail) origin(time doe) scale(365.25) id(id)
    . stcox i.hienergy
    
            Failure _d: fail
      Analysis time _t: (dox-origin)/365.25
                Origin: time doe
           ID variable: id
    
    Iteration 0:   log likelihood = -442.59555
    Iteration 1:   log likelihood = -441.65468
    Iteration 2:   log likelihood = -441.65462
    Refining estimates:
    Iteration 0:   log likelihood = -441.65462
    
    Cox regression with no ties
    
    No. of subjects =        337                            Number of obs =    337
    No. of failures =         80
    Time at risk    = 4,603.6687
                                                            LR chi2(1)    =   1.88
    Log likelihood = -441.65462                             Prob > chi2   = 0.1701
    
    ------------------------------------------------------------------------------
              _t | Haz. ratio   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
      1.hienergy |      0.736      0.165    -1.37    0.17        0.474       1.141
    ------------------------------------------------------------------------------
    can be done simple by
    Code:
    . tteir dox, failure(fail) origin(time doe) scale(365.25) every(.) by(hienergy)
    . qui poisson _x bn._start i.hienergy, irr exposure(_futm) nocons vce(robust)
    . lincom _b[1.hienergy], eform
    
     ( 1)  [_x]1.hienergy = 0
    
    ------------------------------------------------------------------------------
              _x |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             (1) |      0.736      0.117    -1.93    0.05        0.539       1.004
    ------------------------------------------------------------------------------
    To handle non-proportional hazards or time-dependent effects is simple
    Code:
    . webuse diet, clear
    . generate bmi = weight / height / height * 10000
    . egen bmi_grp = cut(bmi), at(15 18.5 25 30 200) label
    . tteir dox, failure(fail) origin(time dob) enter(time doe) scale(365.25) id(id) at(30(10)70) by(bmi_grp)
    . qui poisson _x i.bmi_grp#bn._start, irr exposure(_futm) nocons vce(robust)
    Visualizing the time-dependent effects by BMI groups on CHD
    Code:
    . quietly margins _start#bmi_grp, predict(ir)
    . marginsplot, xtitle(Age (years)) title("") ytitle("Incidence rates and 95% CI")
    Click image for larger version

Name:	marginsplot.png
Views:	1
Size:	65.1 KB
ID:	1708174


    To secure better estimates, it would often be better to chose that events are evenly distributed into the time intervals. Here 5 intervals are chosen.
    Code:
    . webuse diet, clear
    . tteir dox, failure(fail) origin(time doe) scale(365.25) nintervals(5)
    . list, sep(0) noobs
    
      +------------------------------------------------+
      |    _start       _stop   _total   _x      _futm |
      |------------------------------------------------|
      |         0   3.5687885      337   16   1178.097 |
      | 3.5687885   6.2642026      320   16    836.090 |
      | 6.2642026   9.9794661      301   16   1076.422 |
      | 9.9794661   12.583162      269   16    622.070 |
      | 12.583162   20.041068      209   16    890.990 |
      +------------------------------------------------+
    Or one can chose intervals with a minimum number of 20 events in each interval.
    Code:
    . webuse diet, clear
    . tteir dox, failure(fail) origin(time doe) scale(365.25) mininterval(20)
    . list, sep(0) noobs
    
      +------------------------------------------------+
      |    _start       _stop   _total   _x      _futm |
      |------------------------------------------------|
      |         0   4.4147844      337   20   1447.696 |
      | 4.4147844   7.8097194      316   20   1025.819 |
      | 7.8097194   11.868583      293   20   1085.313 |
      | 11.868583   20.041068      225   20   1044.841 |
      +------------------------------------------------+
    Last edited by Niels Henrik Bruun; 02 Apr 2023, 14:32.
    Kind regards

    nhb

  • #2
    Thanks to Kit Baum, there is an update of -tteir-. A bug when using the option every(.), i.e., at failures is fixed.
    Kind regards

    nhb

    Comment

    Working...
    X