Section 9.2: Time-Dependent Covariates
Table 9.1 on page 273 based on data set bone_marrow. This table is done with three different models. We first have to create centered variables in a data step. The time-varying covariates are created on-the-fly in proc phreg.
data bone_marrow1; set bone_marrow; z11 = z1 - 28; z22 = z2 - 28; z1xz2 = z11 * z22; g1 = ( g = 1 ); g2 = ( g = 2 ); g3 = ( g = 3 ); run; proc phreg data= bone_marrow1; model t2*dfree(0) = za g2 g3 ; if ( t2 >= ta &a=1) then za = 1; else za = 0; run; proc phreg data= bone_marrow1; model t2*dfree(0)= zc g2 g3; if ( t2 >= tc & c = 1) then zc = 1; else zc = 0; run; proc phreg data= bone_marrow1; model t2*dfree(0)= zp g2 g3; if (t2 >= tp & p=1) then zp = 1; else zp = 0; run; Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio za 1 0.31836 0.28514 1.2466 0.2642 1.375 g2 1 -0.55164 0.28799 3.6690 0.0554 0.576 g3 1 0.43381 0.27222 2.5396 0.1110 1.543 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio zc 1 -0.19478 0.28757 0.4587 0.4982 0.823 g2 1 -0.62251 0.29622 4.4163 0.0356 0.537 g3 1 0.36567 0.26850 1.8548 0.1732 1.441 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio zp 1 -1.12986 0.32800 11.8658 0.0006 0.323 g2 1 -0.49624 0.28924 2.9435 0.0862 0.609 g3 1 0.38134 0.26761 2.0306 0.1542 1.464
Table 9.2 on page 274 based on three models.
/*Table 9.2 Fixed Factors Only*/ proc phreg data= bone_marrow1; model t2*dfree(0) = g2 g3 z8 z11 z22 z1xz2; run; /*Table 9.2 Time-Dependent Factor*/ proc phreg data= bone_marrow1; model t2*dfree(0)= zp g2 g3; if (t2 >= tp & p=1) then zp = 1; else zp = 0; run; /*Table 9.2 All Factor*/ proc phreg data= bone_marrow1; model t2*dfree(0) = g2 g3 z8 z11 z22 z1xz2 zp; if (t2 >= tp & p=1) then zp = 1; else zp = 0; run;
First model: Model Fit Statistics Without With Criterion Covariates Covariates -2 LOG L 746.719 713.982 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio g2 1 -1.09058 0.35430 9.4752 0.0021 0.336 g3 1 -0.40439 0.36278 1.2425 0.2650 0.667 z8 1 0.83687 0.27853 9.0276 0.0027 2.309 z11 1 0.00686 0.01968 0.1214 0.7276 1.007 z22 1 0.00391 0.01826 0.0458 0.8305 1.004 z1xz2 1 0.00315 0.0009498 11.0074 0.0009 1.003 Second model: Model Fit Statistics Without With Criterion Covariates Covariates -2 LOG L 746.719 723.647 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio zp 1 -1.12986 0.32800 11.8658 0.0006 0.323 g2 1 -0.49624 0.28924 2.9435 0.0862 0.609 g3 1 0.38134 0.26761 2.0306 0.1542 1.464 Third model: Model Fit Statistics Without With Criterion Covariates Covariates -2 LOG L 746.719 706.611 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio g2 1 -1.03234 0.35317 8.5444 0.0035 0.356 g3 1 -0.41538 0.36526 1.2932 0.2555 0.660 z8 1 0.81302 0.28339 8.2309 0.0041 2.255 z11 1 0.00950 0.01947 0.2379 0.6258 1.010 z22 1 0.00448 0.01795 0.0623 0.8029 1.004 z1xz2 1 0.00286 0.0009346 9.3528 0.0022 1.003 zp 1 -0.99618 0.33651 8.7638 0.0031 0.369
Table 9.3 on page 275. The log likelihood statistics is contained in each of the SAS output. We omit them here to save some space. We will only show the output from the test statement. SAS performs Wald test on each one and it gives very similar results.
proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 zpg2 zpg3; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; zpg2 = zp*g2; zpg3 =zp*g3; model1: test zpg2, zpg3; run; proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 z8zp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; z8zp = z8*zp; model2: test z8zp; run; proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 z1zp z2zp zxzp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; z1zp = z11*zp; z2zp = z22*zp; zxzp = z1xz2*zp; model3: test z1zp, z2zp, zxzp; run; proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 zpg2 zpg3 z8zp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; zpg2 = zp*g2; zpg3 =zp*g3; z8zp = z8*zp; model4: test z8zp; run; proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 zpg2 zpg3 z1zp z2zp zxzp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; zpg2 = zp*g2; zpg3 =zp*g3; z1zp = z11*zp; z2zp = z22*zp; zxzp = z1xz2*zp; model5: test z1zp, z2zp, zxzp; run; proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 zpg2 zpg3 z1zp z2zp zxzp z8zp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; zpg2 = zp*g2; zpg3 =zp*g3; z1zp = z11*zp; z2zp = z22*zp; zxzp = z1xz2*zp; z8zp = z8*zp; model6: test z8zp; run; Linear Hypotheses Testing Results Wald Label Chi-Square DF Pr > ChiSq model1 7.4997 2 0.0235 model2 3.1518 1 0.0758 model3 7.8877 3 0.0484 model4 4.1729 1 0.0411 model5 12.5410 3 0.0057 model6 4.4670 1 0.0346
Table 9.4 on page 276.
proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8 zpg2 zpg3 z1zp z2zp zxzp z8zp; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; zpg2 = zp*g2; zpg3 =zp*g3; z1zp = z11*zp; z2zp = z22*zp; zxzp = z1xz2*zp; z8zp = z8*zp; run; Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio zp 1 -0.30621 0.69362 0.1949 0.6589 0.736 g2 1 1.30734 0.81864 2.5503 0.1103 3.696 g3 1 1.10712 1.22422 0.8178 0.3658 3.026 z11 1 -0.15375 0.05454 7.9486 0.0048 0.857 z22 1 0.11660 0.04337 7.2286 0.0072 1.124 z1xz2 1 0.00260 0.00195 1.7863 0.1814 1.003 z8 1 -1.23479 1.11389 1.2288 0.2676 0.291 zpg2 1 -3.03742 0.92574 10.7653 0.0010 0.048 zpg3 1 -1.86753 1.29076 2.0934 0.1479 0.155 z1zp 1 0.19335 0.05878 10.8208 0.0010 1.213 z2zp 1 -0.14705 0.04800 9.3831 0.0022 0.863 zxzp 1 0.0001265 0.00230 0.0030 0.9561 1.000 z8zp 1 2.45353 1.16086 4.4670 0.0346 11.629
Example 9.2 on page 277 based on data set kidney.
proc phreg data=kidney; model time*infect(0)= z1 z2; z1 = placement-1; z2 = log(time)*z1; run;
The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 14.6737 2 0.0007 Score 12.7062 2 0.0017 Wald 8.0705 2 0.0177 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio z1 1 1.42235 1.03145 1.9016 0.1679 4.147 z2 1 -1.46217 0.58748 6.1944 0.0128 0.232
Table 9.5 on page 278 based on data set bone_marrow1 that is created in the previous Section 9.2. We have included the code to create the table and will only show the output from each of the test statement.
/*Factor of group*/ proc phreg data = bone_marrow1; model t2*dfree(0) = g1 g2 g1p g2p; g1p = log(t2) * g1; g2p = log(t2) * g2; group: test g1p=g2p=0; run; /*Effect of Waiting time*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z7 z7p; z7p = log(t2)*z7; Waiting_time: test z7p; run; /*Factor of Fab status*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z8 z8p; z8p = log(t2)*z8; Fab: test z8p; run; /*Factor of MTX*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z10 z10p; z10p = log(t2)*z10; MTX: test z10p; run; /*Factor of Sex*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z3 z4 z3z4 z3p z4p z3z4p; z3z4 = z3*z4; z3p = log(t2)*z3; z4p = log(t2)*z4; z3z4p = log(t2)*z3z4; Sex: test z3p, z4p, z3z4p; run; /*Factor of CMV status*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z5 z6 z5z6 z5p z6p z5z6p; z5z6 = z5*z6; z5p = log(t2)*z5; z6p = log(t2)*z6; z5z6p = log(t2)*z5z6; CMV: test z5p, z6p, z5z6p; run; /*Factor of Age*/ proc phreg data = bone_marrow1; model t2*dfree(0) = z11 z22 z1xz2 z1p z2p z1z2p; z1p = log(t2)*z11; z2p = log(t2)*z22; z1z2p = log(t2)*z1xz2; Age: test z1p, z2p, z1z2p; run;
Linear Hypotheses Testing Results Wald Label Chi-Square DF Pr > ChiSq group 1.7349 2 0.4200 Waiting_time 0.0049 1 0.9442 Fab 0.4441 1 0.5051 MTX 4.3226 1 0.0376 Sex 0.2203 3 0.9742 CMV 1.6870 3 0.6398 Age 4.7593 3 0.1903
Table 9.6 on page 280 based on the data set kidney.
/*to extract the event time*/ proc sql noprint; select distinct time into :event_time separated by ' ' from kidney where infect = 1; quit; %put &event_time; %macro event_lpl(data, time, censor, var, delta_list); %let k=1; %let whole =; %let dep = %scan(&delta_list, &k, ' '); %do %while(&dep NE ); ods listing close; proc phreg data=&data; model &time*&censor(0) = &var z2; if &time > &dep then z2 = &var; else z2 = 0; ods output FitStatistics = _temp&k; run; ods output close; ods listing; %let whole= &whole%str( _temp&k); %let k = %eval(&k + 1); %let dep = %scan(&delta_list, &k, ' '); %end; data whole; set &whole; if Criterion = "-2 LOG L" ; run; data whole; set whole; e_time = scan("&delta_list", _n_, ' '); logp = - withcovariates/2; run; proc print data = whole noobs; var e_time logp; run; %mend; data kidney1; set kidney; z1 = placement - 1; run; %event_lpl(kidney1, time, infect, z1, &event_time) e_time logp 0.5 -97.878 1.5 -100.224 2.5 -97.630 3.5 -97.501 4.5 -99.683 5.5 -100.493 6.5 -98.856 8.5 -100.428 9.5 -101.084 10.5 -101.668 11.5 -102.168 15.5 -100.829 16.5 -101.477 18.5 -102.059 23.5 -102.620 26.5 -103.229
The anova table on page 280.
proc phreg data = kidney1; model time*infect(0) = z2 z3 ; if time > 3.5 then do z2=z1; z3=0; end; else do z2=0; z3=z1; end; run;
The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 13.9049 2 0.0010 Score 12.8330 2 0.0016 Wald 9.4677 2 0.0088 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio z2 1 -2.08891 0.75973 7.5600 0.0060 0.124 z3 1 1.08175 0.78320 1.9077 0.1672 2.950
Section 9.3: Stratified Proportional Hazards Models
Table 9.7 on page 283.
proc phreg data=bone_marrow1; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; strata z10; run; The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 38.2728 7 <.0001 Score 44.6457 7 <.0001 Wald 40.3675 7 <.0001 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio zp 1 -1.00334 0.34453 8.4810 0.0036 0.367 g2 1 -0.99030 0.36658 7.2980 0.0069 0.371 g3 1 -0.36327 0.37138 0.9568 0.3280 0.695 z11 1 0.00954 0.01984 0.2314 0.6305 1.010 z22 1 -0.00141 0.01791 0.0062 0.9373 0.999 z1xz2 1 0.00255 0.0009364 7.4245 0.0064 1.003 z8 1 0.89203 0.28347 9.9024 0.0017 2.440
Table 9.8 on page 284.
proc phreg data=bone_marrow1; by z10; model t2*dfree(0) = zp g2 g3 z11 z22 z1xz2 z8; if ( t2 >= tp & p = 1) then zp = 1; else zp = 0; ods output ParameterEstimates=table9_8; run; proc sort data=table9_8; by variable; run; proc transpose data = table9_8 prefix=g out=table9_8a (where=(_name_="Estimate" or _name_="StdErr")) ; by variable; id z10; run; data table9_8b; set table9_8a; num = lag(gno)-lag(gyes); if _name_="StdErr" then do; chisq = num**2/(gno**2 + gyes**2); pvalue=1 - probchi(chisq, 1); end; drop num; run; proc print data = table9_8b noobs; run; Variable _NAME_ gNo gYes chisq pvalue g2 Estimate -1.19819 -0.56257 . . g2 StdErr 0.45851 0.63852 0.65380 0.41876 g3 Estimate -0.29627 -0.85960 . . g3 StdErr 0.44541 0.91752 0.30506 0.58073 z11 Estimate 0.02765 0.01141 . . z11 StdErr 0.02587 0.03909 0.12005 0.72898 z1xz2 Estimate 0.00225 0.00139 . . z1xz2 StdErr 0.00140 0.00227 0.10247 0.74889 z22 Estimate -0.02027 0.03433 . . z22 StdErr 0.02533 0.03104 1.85815 0.17284 z8 Estimate 1.08877 0.34588 . . z8 StdErr 0.33846 0.65111 1.02484 0.31137 zp Estimate -0.88294 -1.00895 . . zp StdErr 0.47591 0.55113 0.02995 0.86261
Section 9.4: Left Truncation
Table 9.9 on page 288.
proc phreg data=bone_marrow1; model t2*dfree(0) = g2 g3 z11 z22 z1xz2 z8 /entry=tp; strata z10; run;
The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 37.1792 6 <.0001 Score 36.0545 6 <.0001 Wald 32.1483 6 <.0001 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio g2 1 -1.75212 0.43761 16.0307 <.0001 0.173 g3 1 -0.75036 0.40769 3.3874 0.0657 0.472 z11 1 0.04174 0.02229 3.5066 0.0611 1.043 z22 1 -0.03460 0.02068 2.7986 0.0943 0.966 z1xz2 1 0.00228 0.00122 3.4931 0.0616 1.002 z8 1 1.27753 0.32494 15.4571 <.0001 3.588
Section 9.5: Synthesis of Time-varying Effects (Multistate Modeling)
Table 9.10 on page 291 based on data bone_marrow1 created in Section 9.1.
proc phreg data=bone_marrow1; model tp*p(0) = z11 z22 z1xz2 z10; run; The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 30.7549 4 <.0001 Score 27.4464 4 <.0001 Wald 25.9884 4 <.0001 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio z11 1 0.03606 0.01626 4.9175 0.0266 1.037 z22 1 -0.02616 0.01477 3.1367 0.0766 0.974 z1xz2 1 -0.00272 0.0009715 7.8217 0.0052 0.997 z10 1 -1.04226 0.22329 21.7882 <.0001 0.353
The first model in Table 9.11 on page 292 based on the models specified on page 291.
code here.
The left-truncated model before platelet recovery. We need to modify our data set by censoring any individual whose platelets recover prior to death or relapse at their platelet recovery time. This is done in the data step below.
data bone_marrow2; set bone_marrow1; m2 = dfree; myt = t2; if tp <= t2 and p = 1 then do; m2= 0; myt = tp; end; run; proc phreg data=bone_marrow2; model myt*m2(0) = g2 g3 z8 z11 z22 z1xz2 ; run; The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 14.2991 6 0.0265 Score 13.4770 6 0.0361 Wald 12.1243 6 0.0593 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio g2 1 1.46620 0.91746 2.5539 0.1100 4.333 g3 1 1.44752 1.33334 1.1786 0.2776 4.253 z8 1 -1.75629 1.32144 1.7664 0.1838 0.173 z11 1 -0.16154 0.06198 6.7936 0.0091 0.851 z22 1 0.12580 0.04755 7.0003 0.0081 1.134 z1xz2 1 0.00318 0.00210 2.2880 0.1304 1.003
The left-truncated model after platelet recovery. This is done using the entry= option in proc phreg.
proc phreg data=bone_marrow2; model t2*dfree(0) = g2 g3 z8 z11 z22 z1xz2 /entry = tp; run;
The PHREG Procedure Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 37.7176 6 <.0001 Score 36.9965 6 <.0001 Wald 32.9733 6 <.0001 Analysis of Maximum Likelihood Estimates Parameter Standard Hazard Variable DF Estimate Error Chi-Square Pr > ChiSq Ratio g2 1 -1.71600 0.42554 16.2616 <.0001 0.180 g3 1 -0.75650 0.40752 3.4460 0.0634 0.469 z8 1 1.21153 0.32231 14.1291 0.0002 3.359 z11 1 0.03872 0.02177 3.1625 0.0753 1.039 z22 1 -0.02923 0.02051 2.0321 0.1540 0.971 z1xz2 1 0.00266 0.00123 4.6829 0.0305 1.003