|
|
|
||||
|
|
|||||
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 WinZip 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.)
Partial likelihood ratio test from Table 5.1, page 166.
Note: Much of the output is omitted since only the p-value for the likelihood ratio chi-square is needed.
use uis, clear
stset time, failure(censor)
xi: stcox i.hercoc, nohr
LR chi2(3) = 7.76
Log likelihood = -2855.2457 Prob > chi2 = 0.0513
stci, by(hercoc)
| no. of
hercoc | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
1 | 111 150 10.19877 106 196
2 | 114 142 8.867892 110 184
3 | 178 183 11.40735 147 226
4 | 207 181 8.826439 153 220
-------------+-------------------------------------------------------------
total | 610 168 9.223978 153 186
xi: stcox i.ivhx, nohr
LR chi2(2) = 14.64
Log likelihood = -2851.8054 Prob > chi2 = 0.0007
stci, by(ivhx)
| no. of
ivhx | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
1 | 233 194 8.682577 171 228
2 | 115 170 13.43096 129 226
3 | 262 147 9.493609 113 168
-------------+-------------------------------------------------------------
total | 610 168 9.223978 153 186
xi: stcox i.race, nohr
LR chi2(1) = 7.57
Log likelihood = -2927.6972 Prob > chi2 = 0.0059
stci, by(race)
| no. of
race | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
0 | 467 152 10.46316 124 174
1 | 155 193 9.202173 162 232
-------------+-------------------------------------------------------------
total | 622 166 9.025591 147 183
xi: stcox i.treat, nohr
LR chi2(1) = 6.75
Log likelihood = -2957.1293 Prob > chi2 = 0.0094
stci, by(treat)
| no. of
treat | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
0 | 320 131 7.477745 113 154
1 | 308 190 8.618466 175 224
-------------+-------------------------------------------------------------
total | 628 166 9.112655 144 183
xi: stcox i.site, nohr
LR chi2(1) = 2.40
Log likelihood = -2959.3033 Prob > chi2 = 0.1211
stci, by(site)
| no. of
site | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
0 | 444 156 9.039492 130 174
1 | 184 198 10.03484 159 228
-------------+-------------------------------------------------------------
total | 628 166 9.112655 144 183
generate age2 = recode(age,27,32,37,56)
recode age2 27=1 32=2 37=3 56=4
xi: stcox i.age2, nohr
LR chi2(3) = 3.81
Log likelihood = -2931.2058 Prob > chi2 = 0.2823
stci, by(age2)
| no. of
age2 | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
1 | 158 159 11.22693 121 194
2 | 158 148 8.254827 123 177
3 | 184 162 10.46207 121 200
4 | 123 189 9.008079 162 237
-------------+-------------------------------------------------------------
total | 623 167 9.075607 148 184
generate beckt2 = recode(becktota,9.99,14.9,24.9,55)
recode beckt2 9.99=1 14.9=2 24.9=3 55=4
xi: stcox i.beckt2, nohr
LR chi2(3) = 4.41
Log likelihood = -2760.8369 Prob > chi2 = 0.2208
stci, by(beckt2)
| no. of
beckt2 | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
1 | 135 211 9.888823 166 246
2 | 102 169 8.607335 124 220
3 | 226 168 9.391813 136 199
4 | 132 144 8.051 110 187
-------------+-------------------------------------------------------------
total | 595 170 8.557824 156 189
generate ndrugt2 = ndrugtx
recode ndrugt2 0/1=1 2/3=2 4/6=3 7/40=4
xi: stcox i.ndrugtx2, nohr
LR chi2(3) = 14.50
Log likelihood = -2867.7232 Prob > chi2 = 0.0023
stci, by(ndrugt2)
| no. of
ndrugt2 | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
1 | 183 170 12.6755 140 227
2 | 165 177 5.798958 161 207
3 | 138 127 9.139421 106 183
4 | 125 123 10.21114 106 184
-------------+-------------------------------------------------------------
total | 611 166 8.952557 144 182
Table 5.2, page 167.
generate age3 = qge/5
stcox age
Cox regression -- Breslow method for ties
No. of subjects = 623 Number of obs = 623
No. of failures = 504
Time at risk = 146816
LR chi2(1) = 3.24
Log likelihood = -2931.4929 Prob > chi2 = 0.0719
------------------------------------------------------------------------------
_t |
_d | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age3 | .9377044 .0337048 -1.79 0.074 .8739175 1.006147
------------------------------------------------------------------------------
generate beckt3 = becktota/10
stcox beckt3
Cox regression -- Breslow method for ties
No. of subjects = 595 Number of obs = 595
No. of failures = 478
Time at risk = 144013
LR chi2(1) = 5.32
Log likelihood = -2760.3812 Prob > chi2 = 0.0211
------------------------------------------------------------------------------
_t |
_d | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
beckt3 | 1.115852 .0526159 2.32 0.020 1.017348 1.223892
------------------------------------------------------------------------------
generate ndrugt3 = ndrugtx/5
stcox ndrugt3
Cox regression -- Breslow method for ties
No. of subjects = 611 Number of obs = 611
No. of failures = 496
Time at risk = 143002
LR chi2(1) = 13.35
Log likelihood = -2868.299 Prob > chi2 = 0.0003
------------------------------------------------------------------------------
_t |
_d | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
ndrugt3 | 1.158192 .04342 3.92 0.000 1.076141 1.246498
------------------------------------------------------------------------------
Table 5.3, page 168.
xi: stcox age becktota ndrugtx i.hercoc i.ivhx race treat site, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(11) = 47.91
Log likelihood = -2640.0305 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0288716 .0081716 -3.53 0.000 -.0448876 -.0128556
becktota | .008342 .0049756 1.68 0.094 -.00141 .0180939
ndrugtx | .0283735 .0083064 3.42 0.001 .0120934 .0446537
_Ihercoc_2 | .0653182 .1500091 0.44 0.663 -.2286942 .3593307
_Ihercoc_3 | -.0936223 .1654656 -0.57 0.572 -.4179288 .2306843
_Ihercoc_4 | .0279784 .1602768 0.17 0.861 -.2861584 .3421152
_Iivhx_2 | .1743865 .1386377 1.26 0.208 -.0973384 .4461115
_Iivhx_3 | .2807122 .1469297 1.91 0.056 -.0072648 .5686891
race | -.2028896 .1166875 -1.74 0.082 -.4315929 .0258137
treat | -.2399473 .0943704 -2.54 0.011 -.4249099 -.0549847
site | -.1024875 .1092668 -0.94 0.348 -.3166465 .1116716
------------------------------------------------------------------------------
Table 5.4, page 168.
lrtest, saving(0)
xi: stcox age becktota ndrugtx i.ivhx race treat site, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(8) = 46.51
Log likelihood = -2640.7278 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.028217 .00817 -3.45 0.000 -.0442298 -.0122042
becktota | .0079385 .0049673 1.60 0.110 -.0017972 .0176741
ndrugtx | .0277628 .0082863 3.35 0.001 .011522 .0440035
_Iivhx_2 | .1959922 .1372134 1.43 0.153 -.0729412 .4649255
_Iivhx_3 | .3327979 .119912 2.78 0.006 .0977746 .5678212
race | -.2092451 .1158944 -1.81 0.071 -.4363939 .0179037
treat | -.2317746 .093713 -2.47 0.013 -.4154487 -.0481006
site | -.0994619 .1085414 -0.92 0.359 -.3121991 .1132753
------------------------------------------------------------------------------
lrtest /* shown on page 167 */
Cox: likelihood-ratio test chi2(3) = 1.39
Prob > chi2 = 0.7068
Table 5.5, page 169.
lrtest, saving(0)
rename _livhx_3 ivhx3
stcox age becktota ndrugtx ivhx3 race treat site, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(7) = 44.51
Log likelihood = -2641.7294 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0261517 .0080491 -3.25 0.001 -.0419276 -.0103758
becktota | .0083976 .0049516 1.70 0.090 -.0013074 .0181025
ndrugtx | .0290737 .0082126 3.54 0.000 .0129773 .04517
ivhx3 | .2561209 .1062996 2.41 0.016 .0477776 .4644642
race | -.224462 .1152656 -1.95 0.051 -.4503784 .0014544
treat | -.2324266 .0937326 -2.48 0.013 -.4161392 -.048714
site | -.0866855 .1078637 -0.80 0.422 -.2980944 .1247233
------------------------------------------------------------------------------
lrtest
Cox: likelihood-ratio test chi2(1) = 2.00
Prob > chi2 = 0.1570
Table 5.6, page 170.
xi: stcox i.age2 i.beckt2 i.ndrugt2 ivhx3 race treat site, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(13) = 47.24
Log likelihood = -2640.3652 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Iage2_2 | .0374926 .1316518 0.28 0.776 -.2205402 .2955254
_Iage2_3 | -.2408561 .1312281 -1.84 0.066 -.4980584 .0163462
_Iage2_4 | -.4002157 .1506788 -2.66 0.008 -.6955408 -.1048906
_Ibeckt2_2 | .0464099 .1526759 0.30 0.761 -.2528293 .3456491
_Ibeckt2_3 | .1077921 .124958 0.86 0.388 -.137121 .3527052
_Ibeckt2_4 | .2096867 .1402925 1.49 0.135 -.0652817 .484655
_Indrugt2_2 | -.0914484 .1294441 -0.71 0.480 -.3451542 .1622575
_Indrugt2_3 | .2427763 .1336843 1.82 0.069 -.0192401 .5047927
_Indrugt2_4 | .3704249 .1404316 2.64 0.008 .095184 .6456657
ivhx3 | .2417153 .1067796 2.26 0.024 .0324311 .4509995
race | -.2511075 .1163678 -2.16 0.031 -.4791841 -.0230309
treat | -.2173453 .0941389 -2.31 0.021 -.4018541 -.0328365
site | -.0835198 .1084607 -0.77 0.441 -.2960989 .1290593
------------------------------------------------------------------------------
Figure 5.1, page 171.
preserve input mp1 c1 mp2 c2 mp3 c3 24 0 5 0 .5 0 30.5 .037 12.5 .046 2.5 -.091 35.5 -.241 20 .108 5 .243 47.5 -.400 40 .210 23.5 .370 end
Figure 5.1a, page 171.
graph twoway scatter c1 mp1, connect(l) xlabel(24 30.5 35.5 47.5)
Figure 5.1b, page 171.
graph twoway scatter c2 mp2, connect(l) ylabel(0 .25) xlabel(5 12.5 20 40)
Figure 5.1c, page 171.
graph twoway scatter c3 mp3, connect(l) ylabel(-.07 .4) xlabel(.5 2.5 5 23.5)
Table 5.7, page 172 and Table 5.8, page 173.
restore
fracpoly cox time ndrugtx age becktota ivhx3 race treat site, dead(censor) nohr degree(2) compare
Cox regression -- Breslow method for ties
Entry time 0 Number of obs = 575
LR chi2(8) = 51.43
Prob > chi2 = 0.0000
Log likelihood = -2638.2717 Pseudo R2 = 0.0097
------------------------------------------------------------------------------
time |
censor | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Indru__1 | -.5226671 .1244122 -4.20 0.000 -.7665105 -.2788238
Indru__2 | -.1947183 .0482466 -4.04 0.000 -.2892799 -.1001566
Iage__1 | -.0281541 .0081328 -3.46 0.000 -.044094 -.0122141
Ibeck__1 | .0091589 .004987 1.84 0.066 -.0006154 .0189333
ivhx3 | .2585973 .1080215 2.39 0.017 .046879 .4703156
race | -.2421462 .1154647 -2.10 0.036 -.4684528 -.0158396
treat | -.2108924 .0936877 -2.25 0.024 -.394517 -.0272678
site | -.1053157 .109154 -0.96 0.335 -.3192536 .1086223
------------------------------------------------------------------------------
Deviance: 5276.543. Best powers of ndrugtx among 44 models fit: -1 -1.
Fractional polynomial model comparisons:
---------------------------------------------------------------
ndrugtx df Deviance Gain P(term) Powers
---------------------------------------------------------------
Not in model 0 5294.497 -- --
Linear 1 5283.459 0.000 0.001 1
m = 1 2 5283.088 0.371 0.543 .5
m = 2 4 5276.543 6.915 0.038 -1 -1
---------------------------------------------------------------
fracgen ndrugtx -1 -1
Figure 5.1d, page 171.
fracpred fp, for(ndrugtx) graph twoway scatter fp ndrugtx, msymbol(i) connect(l) sort
Figure 5.2a, page 175.
stcox becktota ndrugtx ivhx3 race treat site, nohr mgale(mgale) [...output omitted...] graph twoway (lowess mgale age) (scatter mgale age), ylabel(-2.642 .997) xlabel(20 56)
Figure 5.3a, page 176.
drop mgale stcox age ndrugtx ivhx3 race treat site, nohr mgale(mgale) [...output omitted...] graph twoway (lowess mgale becktota) (scatter mgale becktota), /// ylabel(-3.211 .998) xlabel(0 54)
Figure 5.4a, page 177.
drop mgale stcox age becktota ivhx3 race treat site, nohr mgale(mgale) [...output omitted...] graph twoway (lowess mgale ndrugtx) (scatter mgale ndrugtx), /// ylabel(-3.201 1) xlabel(0 40)
Figure 5.2b, page 175; Figure 53b, page 176; Figure 5.4b, page 177.
drop mgale
stcox age becktota ndrugtx ivhx3 race treat site, nohr mgale(mgale)
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(7) = 44.51
Log likelihood = -2641.7294 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0261517 .0080491 -3.25 0.001 -.0419276 -.0103758
becktota | .0083976 .0049516 1.70 0.090 -.0013074 .0181025
ndrugtx | .0290737 .0082126 3.54 0.000 .0129773 .04517
ivhx3 | .2561209 .1062996 2.41 0.016 .0477776 .4644642
race | -.224462 .1152656 -1.95 0.051 -.4503784 .0014544
treat | -.2324266 .0937326 -2.48 0.013 -.4161392 -.048714
site | -.0866855 .1078637 -0.80 0.422 -.2980944 .1247233
------------------------------------------------------------------------------
lowess censor age, gen(cism) nodraw
generate hi = censor - mgale
lowess hi age, gen(hism) nodraw
generate fi = log(cism/hism) -.0261517*age
graph twoway scatter fi age, msymbol(i) connect(l) sort ylabel(-.499 -2.003) xlabel(20 56)
drop cism hism fi lowess censor becktota, gen(cism) nodraw lowess hi becktota, gen(hism) nodraw generate fi = log(cism/hism) + .0083976*becktota graph twoway scatter fi becktota, msymbol(i) connect(l) sort ylabel(-.077 .389) xlabel(0 54)
drop cism hism fi lowess censor ndrugtx, gen(cism) nodraw lowess hi ndrugtx, gen(hism) nodraw generate fi = log(cism/hism) + .0290737*ndrugtx graph twoway scatter fi ndrugtx, msymbol(i) connect(l) sort ylabel(-.034 1.001) xlabel(0 40)
Table 5.10, page 179.
generate agexsite = age*site
generate racexsite = race*site
generate agexndrugfp1=age*ndrugt_1
generate agexndrugfp2=age*ndrugt_2
stcox age becktota ndrugt_1 ndrugt_2 ivhx3 race treat site agexsite racexsite agexndrugfp1 agexndrugfp2, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(12) = 73.12
Log likelihood = -2627.4236 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0543081 .028035 -1.94 0.053 -.1092556 .0006395
becktota | .0100496 .0049925 2.01 0.044 .0002644 .0198347
ndrugt_1 | -.6743511 .6444652 -1.05 0.295 -1.93748 .5887775
ndrugt_2 | -.1721687 .2523393 -0.68 0.495 -.6667447 .3224072
ivhx3 | .22935 .1079297 2.12 0.034 .0178116 .4408884
race | -.4877383 .1346109 -3.62 0.000 -.7515709 -.2239057
treat | -.2420527 .0945533 -2.56 0.010 -.4273738 -.0567316
site | -1.119396 .5460698 -2.05 0.040 -2.189674 -.0491192
agexsite | .026438 .0165766 1.59 0.111 -.0060515 .0589275
racexsite | .8627388 .2481027 3.48 0.000 .3764666 1.349011
agexndrugfp1 | .0016289 .0194482 0.08 0.933 -.0364889 .0397467
agexndrugfp2 | -.0019831 .0076598 -0.26 0.796 -.0169961 .01303
------------------------------------------------------------------------------
Table 5.11, page 179.
stcox age becktota ndrugt_1 ndrugt_2 ivhx3 race treat site agexsite racexsite, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(10) = 67.13
Log likelihood = -2630.4179 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0413963 .0099128 -4.18 0.000 -.060825 -.0219676
becktota | .008738 .0049654 1.76 0.078 -.000994 .0184701
ndrugt_1 | -.5744565 .1251879 -4.59 0.000 -.8198202 -.3290928
ndrugt_2 | -.2145783 .048587 -4.42 0.000 -.3098071 -.1193495
ivhx3 | .227748 .108563 2.10 0.036 .0149684 .4405276
race | -.4668853 .1347564 -3.46 0.000 -.7310029 -.2027677
treat | -.2467592 .09434 -2.62 0.009 -.4316621 -.0618562
site | -1.316987 .5314407 -2.48 0.013 -2.358592 -.2753827
agexsite | .0324002 .0160807 2.01 0.044 .0008827 .0639178
racexsite | .8502773 .2477582 3.43 0.000 .3646801 1.335875
------------------------------------------------------------------------------
Table 5.13, page 186.
stcox age becktota race treat site ivhx3 ndrugt_1 ndrugt_2 racexsite agexndrugfp1, nohr
Cox regression -- Breslow method for ties
No. of subjects = 575 Number of obs = 575
No. of failures = 464
Time at risk = 138900
LR chi2(10) = 70.49
Log likelihood = -2628.739 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t |
_d | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0538471 .0118803 -4.53 0.000 -.077132 -.0305622
becktota | .0103485 .0049966 2.07 0.038 .0005554 .0201417
race | -.4829437 .1344923 -3.59 0.000 -.7465438 -.2193435
treat | -.2223822 .0937517 -2.37 0.018 -.4061322 -.0386321
site | -.2781853 .1220049 -2.28 0.023 -.5173106 -.03906
ivhx3 | .2339795 .1077173 2.17 0.030 .0228575 .4451015
ndrugt_1 | -.8377904 .1595497 -5.25 0.000 -1.150502 -.5250788
ndrugt_2 | -.229083 .0487574 -4.70 0.000 -.3246458 -.1335202
racexsite | .8968524 .2473127 3.63 0.000 .4121284 1.381576
agexndrugfp1 | .0072271 .0026092 2.77 0.006 .0021131 .012341
------------------------------------------------------------------------------
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services