We present tables 9.2 and 9.3 below. The rest of the chapter has been skipped for now. We will complete it as time permits.
Table 9.2 on page 293 using the psrecur2 data.
/* AG */
use https://stats.idre.ucla.edu/stat/examples/asa2/psrecur2, clear
keep id time2 status tape light yrspsor
duplicates drop
stset time2, id(id) failure(status) exit(time .)
stcox tape light yrspsor, nolog nohr robust
failure _d: status
analysis time _t: time2
exit on or before: time .
id: id
Cox regression -- Breslow method for ties
No. of subjects = 32 Number of obs = 110
No. of failures = 96
Time at risk = 2118
Wald chi2(3) = 16.09
Log pseudolikelihood = -299.16672 Prob > chi2 = 0.0011
(Std. Err. adjusted for 32 clusters in id)
------------------------------------------------------------------------------
| Robust
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tape | .3901378 .1264466 3.09 0.002 .1423071 .6379685
light | .4014043 .1231209 3.26 0.001 .1600917 .642717
yrspsor | .008993 .0056691 1.59 0.113 -.0021182 .0201042
------------------------------------------------------------------------------
/* PWP-CP */
use https://stats.idre.ucla.edu/stat/examples/asa2/psrecur2, clear
keep id time2 status tape light yrspsor
duplicates drop
sort id
by id: gen enum = _n
stset time2, id(id) failure(status) exit(time .)
stcox tape light yrspsor, nolog nohr robust strata(enum)
failure _d: status
analysis time _t: time2
exit on or before: time .
id: id
Stratified Cox regr. -- Breslow method for ties
No. of subjects = 32 Number of obs = 110
No. of failures = 96
Time at risk = 2118
Wald chi2(3) = 21.83
Log pseudolikelihood = -199.17431 Prob > chi2 = 0.0001
(Std. Err. adjusted for 32 clusters in id)
------------------------------------------------------------------------------
| Robust
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tape | .8383151 .2538524 3.30 0.001 .3407735 1.335857
light | 1.117665 .2723576 4.10 0.000 .583854 1.651476
yrspsor | .0210228 .0138743 1.52 0.130 -.0061703 .0482159
------------------------------------------------------------------------------
Stratified by enum
/* PWP-GT */
use https://stats.idre.ucla.edu/stat/examples/asa2/psrecur2, clear
keep id time2 status tape light yrspsor
duplicates drop
sort id
by id: gen t_dif = time2-time2[_n-1] if _n>1
by id: replace t_dif = time2 if _n ==1
by id: gen enum = _n
stset t_dif, fail(status) exit(time .)
stcox tape light yrspsor, nolog nohr robust strata(enum) cluster(id)
failure _d: status
analysis time _t: t_dif
exit on or before: time .
Stratified Cox regr. -- Breslow method for ties
No. of subjects = 110 Number of obs = 110
No. of failures = 96
Time at risk = 2118
Wald chi2(3) = 18.69
Log pseudolikelihood = -232.73287 Prob > chi2 = 0.0003
(Std. Err. adjusted for 32 clusters in id)
------------------------------------------------------------------------------
| Robust
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tape | .6162981 .2490209 2.47 0.013 .1282262 1.10437
light | .811226 .227078 3.57 0.000 .3661614 1.256291
yrspsor | .0158291 .0125377 1.26 0.207 -.0087443 .0404024
------------------------------------------------------------------------------
Stratified by enum
/* WLW */
use https://stats.idre.ucla.edu/stat/examples/asa2/psrecur2.dta, clear
stset time2, fail(status)
stcox tape light yrspsor, nolog nohr robust strata(enum) cluster(id)
failure _d: status
analysis time _t: time2
Stratified Cox regr. -- Breslow method for ties
No. of subjects = 128 Number of obs = 128
No. of failures = 96
Time at risk = 4735
Wald chi2(3) = 29.35
Log pseudolikelihood = -222.02194 Prob > chi2 = 0.0000
(Std. Err. adjusted for 32 clusters in id)
------------------------------------------------------------------------------
| Robust
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tape | 1.029952 .3245314 3.17 0.002 .3938819 1.666022
light | 1.540215 .3117584 4.94 0.000 .9291797 2.15125
yrspsor | .0277804 .0189626 1.47 0.143 -.0093856 .0649465
------------------------------------------------------------------------------
Stratified by enum
/* TT-R */
use https://stats.idre.ucla.edu/stat/examples/asa2/psrecur2, clear
sort id
quietly by id: drop if time2[_n]==time2[_n-1]
sort id enum
stset time2, fail(status)
stcox tape light yrspsor, nolog nohr robust strata(enum) cluster(id)
failure _d: status
analysis time _t: time2
Stratified Cox regr. -- Breslow method for ties
No. of subjects = 110 Number of obs = 110
No. of failures = 96
Time at risk = 4153
Wald chi2(3) = 26.89
Log pseudolikelihood = -219.51963 Prob > chi2 = 0.0000
(Std. Err. adjusted for 32 clusters in id)
------------------------------------------------------------------------------
| Robust
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tape | .9553304 .3195125 2.99 0.003 .3290975 1.581563
light | 1.447917 .3039228 4.76 0.000 .8522388 2.043594
yrspsor | .0258127 .0181875 1.42 0.156 -.0098342 .0614596
------------------------------------------------------------------------------
Stratified by enum
Table 9.3 on page 305 using the whas500 data.
use https://stats.idre.ucla.edu/stat/examples/asa2/whas500, clear
set matsize 600
/* 500 groups of size 1, shared and Cox fit */
stcox bmi hr diasbp chf, nolog nohr shared(id) /* frailty model */
failure _d: fstat
analysis time _t: lenfol
Cox regression --
Breslow method for ties Number of obs = 500
Gamma shared frailty Number of groups = 500
Group variable: id
No. of subjects = 500 Obs per group: min = 1
No. of failures = 215 avg = 1
Time at risk = 441218 max = 1
Wald chi2(4) = 136.69
Log likelihood = -1155.999 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0833684 .0158002 -5.28 0.000 -.1143362 -.0524005
hr | .0126112 .0030273 4.17 0.000 .0066779 .0185445
diasbp | -.0164228 .0035707 -4.60 0.000 -.0234211 -.0094244
chf | .9935692 .1497136 6.64 0.000 .700136 1.287002
-------------+----------------------------------------------------------------
theta | .0941106 .2419855
------------------------------------------------------------------------------
Likelihood-ratio test of theta=0: chibar2(01) = 0.16 Prob>=chibar2 = 0.344
Note: standard errors of regression parameters are conditional on theta.
stcox bmi hr diasbp chf, nolog nohr /* standard cox model */
failure _d: fstat
analysis time _t: lenfol
Cox regression -- Breslow method for ties
No. of subjects = 500 Number of obs = 500
No. of failures = 215
Time at risk = 441218
LR chi2(4) = 143.00
Log likelihood = -1156.0802 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0807504 .0153472 -5.26 0.000 -.1108304 -.0506704
hr | .0121129 .0029192 4.15 0.000 .0063914 .0178343
diasbp | -.0158408 .0034591 -4.58 0.000 -.0226205 -.0090611
chf | .9533591 .1444589 6.60 0.000 .6702248 1.236493
------------------------------------------------------------------------------
/* 250 groups of size 2, shared and strata fit */
sort age id
generate r_grp=group(250)
stcox bmi hr diasbp chf, nolog nohr shared(r_grp) /* frailty model */
failure _d: fstat
analysis time _t: lenfol
Cox regression --
Breslow method for ties Number of obs = 500
Gamma shared frailty Number of groups = 250
Group variable: r_grp
No. of subjects = 500 Obs per group: min = 2
No. of failures = 215 avg = 2
Time at risk = 441218 max = 2
Wald chi2(4) = 126.62
Log likelihood = -1155.0221 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0824762 .0163449 -5.05 0.000 -.1145116 -.0504408
hr | .0132518 .0031305 4.23 0.000 .0071162 .0193875
diasbp | -.0172585 .0037107 -4.65 0.000 -.0245313 -.0099857
chf | .993616 .1554692 6.39 0.000 .6889018 1.29833
-------------+----------------------------------------------------------------
theta | .2086416 .1594293
------------------------------------------------------------------------------
Likelihood-ratio test of theta=0: chibar2(01) = 2.12 Prob>=chibar2 = 0.073
Note: standard errors of regression parameters are conditional on theta.
stcox bmi hr diasbp chf, nolog nohr strata(r_grp) /* stratified model */
failure _d: fstat
analysis time _t: lenfol
Stratified Cox regr. -- no ties
No. of subjects = 500 Number of obs = 500
No. of failures = 215
Time at risk = 441218
LR chi2(4) = 15.86
Log likelihood = -92.575874 Prob > chi2 = 0.0032
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0343006 .0252864 -1.36 0.175 -.083861 .0152598
hr | .0156723 .0057792 2.71 0.007 .0043453 .0269993
diasbp | -.0062124 .0061181 -1.02 0.310 -.0182037 .0057788
chf | .4399418 .2534272 1.74 0.083 -.0567665 .93665
------------------------------------------------------------------------------
Stratified by r_grp
/* 100 groups of size 5, shared and strata fit */
sort age id
replace r_grp=group(100)
stcox bmi hr diasbp chf, nolog nohr shared(r_grp) /* frailty model */
failure _d: fstat
analysis time _t: lenfol
Cox regression --
Breslow method for ties Number of obs = 500
Gamma shared frailty Number of groups = 100
Group variable: r_grp
No. of subjects = 500 Obs per group: min = 5
No. of failures = 215 avg = 5
Time at risk = 441218 max = 5
Wald chi2(4) = 104.03
Log likelihood = -1151.3743 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0705542 .0161995 -4.36 0.000 -.1023045 -.0388038
hr | .0125951 .0031502 4.00 0.000 .0064209 .0187692
diasbp | -.0155517 .0037323 -4.17 0.000 -.0228669 -.0082365
chf | .9646334 .1562119 6.18 0.000 .6584637 1.270803
-------------+----------------------------------------------------------------
theta | .3111222 .1383324
------------------------------------------------------------------------------
Likelihood-ratio test of theta=0: chibar2(01) = 9.41 Prob>=chibar2 = 0.001
Note: standard errors of regression parameters are conditional on theta.
stcox bmi hr diasbp chf, nolog nohr strata(r_grp) /* stratified model */
failure _d: fstat
analysis time _t: lenfol
Stratified Cox regr. -- no ties
No. of subjects = 500 Number of obs = 500
No. of failures = 215
Time at risk = 441218
LR chi2(4) = 47.18
Log likelihood = -226.60723 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.049731 .0195673 -2.54 0.011 -.0880822 -.0113798
hr | .0114746 .0038267 3.00 0.003 .0039745 .0189748
diasbp | -.0084375 .0045927 -1.84 0.066 -.0174391 .0005641
chf | .9309663 .1943245 4.79 0.000 .5500972 1.311835
------------------------------------------------------------------------------
Stratified by r_grp
/* 50 groups of size 10, shared and strata fit */
sort age id
replace r_grp=group(50)
stcox bmi hr diasbp chf, nolog nohr shared(r_grp) /* frailty model */
stcox bmi hr diasbp chf, nolog nohr shared(r_grp)
failure _d: fstat
analysis time _t: lenfol
Cox regression --
Breslow method for ties Number of obs = 500
Gamma shared frailty Number of groups = 50
Group variable: r_grp
No. of subjects = 500 Obs per group: min = 10
No. of failures = 215 avg = 10
Time at risk = 441218 max = 10
Wald chi2(4) = 86.42
Log likelihood = -1147.7267 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0617675 .0162284 -3.81 0.000 -.0935745 -.0299604
hr | .011002 .0030884 3.56 0.000 .0049487 .0170552
diasbp | -.0140457 .003652 -3.85 0.000 -.0212036 -.0068879
chf | .8835463 .1536326 5.75 0.000 .582432 1.184661
-------------+----------------------------------------------------------------
theta | .3522475 .1401259
------------------------------------------------------------------------------
Likelihood-ratio test of theta=0: chibar2(01) = 16.71 Prob>=chibar2 = 0.000
Note: standard errors of regression parameters are conditional on theta.
stcox bmi hr diasbp chf, nolog nohr strata(r_grp) /* stratified model */
failure _d: fstat
analysis time _t: lenfol
Stratified Cox regr. -- Breslow method for ties
No. of subjects = 500 Number of obs = 500
No. of failures = 215
Time at risk = 441218
LR chi2(4) = 52.26
Log likelihood = -356.27794 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
bmi | -.0400207 .0176953 -2.26 0.024 -.0747028 -.0053387
hr | .0098473 .0033082 2.98 0.003 .0033634 .0163313
diasbp | -.0106283 .0039806 -2.67 0.008 -.0184302 -.0028265
chf | .8293564 .1671912 4.96 0.000 .5016677 1.157045
------------------------------------------------------------------------------
Stratified by r_grp
