### Stata Textbook Examples Applied Survival Analysis by Hosmer and Lemeshow Chapter 3: Regression Models for Survival Data

The data files used for the examples in this text can be downloaded in a .zip file from the Wiley FTP website or the Stata Web site.  You can then use a program such as zip to unzip the data files.  If you need assistance getting data into Stata, please see our Stata Class Notes, especially the unit on Entering Data.  (NOTE:  The *.dat files are the data files, and the *.txt files contain the codebook information.)
Table 3.1, page 98.
use hmohiv, clear

stset time, failure(censor)
stcox age, nohr

Cox regression -- Breslow method for ties

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(1)      =     21.35
Log likelihood  =   -288.51804                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |   .0814042   .0174352     4.67   0.000     .0472317    .1155766
------------------------------------------------------------------------------
Table 3.2, page 103.
generate ad = age*drug
lrtest, saving(0)

Cox regression -- Breslow method for ties

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(3)      =     35.02
Log likelihood  =   -281.68438                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |   .0942309   .0229261     4.11   0.000     .0492965    .1391653
drug |   1.185909   1.256515     0.94   0.345    -1.276816    3.648634
ad |  -.0067029   .0337407    -0.20   0.843    -.0728334    .0594276
------------------------------------------------------------------------------
Table 3.3, page 105.
stcox age drug, nohr

Cox regression -- Breslow method for ties

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(2)      =     34.98
Log likelihood  =   -281.70404                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |   1.095852     .02026     4.95   0.000     1.056854    1.136289
drug |   2.563531   .6550089     3.68   0.000      1.55363    4.229893
------------------------------------------------------------------------------
Compute G, page 105.
lrtest

Cox:  likelihood-ratio test                           chi2(1)     =       0.04
Prob > chi2 =     0.8428
Table 3.4, page 108.
stcox age drug, nohr

Cox regression -- Breslow method for ties

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(2)      =     34.98
Log likelihood  =   -281.70404                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |   .0915319   .0184879     4.95   0.000     .0552963    .1277675
drug |   .9413856   .2555104     3.68   0.000     .4405943    1.442177
------------------------------------------------------------------------------

stcox age drug, exactm nohr

Cox regression -- exact marginal likelihood

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(2)      =     39.27
Log likelihood  =   -199.57935                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |    .097677    .018738     5.21   0.000     .0609512    .1344027
drug |   1.022633   .2571643     3.98   0.000     .5186006    1.526666
------------------------------------------------------------------------------

stcox age drug, efron nohr

Cox regression -- Efron method for ties

No. of subjects =          100                     Number of obs   =       100
No. of failures =           80
Time at risk    =         1136
LR chi2(2)      =     39.13
Log likelihood  =   -276.35726                     Prob > chi2     =    0.0000

------------------------------------------------------------------------------
_t |
_d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |   .0971408   .0186397     5.21   0.000     .0606077     .133674
drug |   1.016698    .256217     3.97   0.000     .5145222    1.518875
------------------------------------------------------------------------------

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.