/* --------------------------------------------------------- program: PBC2-v92.SAS input: pbc.sas7bdat does: Plots residuals from Cox regression ------------------------------------------------------------ */; libname out 'H:\bios180\coursepack\SAS-unc-workshop-2008\'; **************************************************; DATA A; SET out.PBC; * transform some of the analysis variabels; logalb = log(albumin); logproth = log(proth); logbili = log(bili); trt=(trt1=1); label bili="Serum Bilirubin, mg/dl"; run; **************************************************; *** plot martingale and deviance resids by the linear predictor (xbeta); proc phreg data=A ; model time*delta(0) = logbili logalb age logproth edema; output out=B1 resmart=mart resdev=dev xbeta=linpred; run; data B1; set B1; label mart='Martingale Residuals' dev ='Deviance Residuals' linpred='Linear Predictor'; run; title h=1.2 'Martingale Residuals for Mayo Model'; proc sgplot data=B1 ; yaxis label='Martingale Residuals'; REFLINE 0; scatter y=mart x=linpred/ markerattrs=(symbol=circlefilled); run; quit; title h=1.2 'Deviance Residuals for Mayo Model'; proc sgplot data=B1; yaxis label='Deviance Residuals' max=4 min=-3; REFLINE 0; scatter y=dev x=linpred/ markerattrs=(symbol=circlefilled); run; quit; *************************************************; **** Martingal Residuals from a Null Model; **** Trick into fitting null model; **** by setting max iterations= 0; proc phreg data=A; model time*delta(0) = logbili logalb age logproth edema / maxiter=0; id bili albumin proth n; output out=B3 resmart=mart ; run; *********** vs. Non-transformed Covariates; title1 h=1.2 'Martingale Residuals '; title2 'Null Model vs. Non-transformed covars'; proc sgscatter data=B3 ; plot mart*(bili albumin age proth edema)/markerattrs=(symbol=circlefilled) loess=(smooth=0.5); run; quit; *********** vs. Transformed Coveriates; title1 h=1.2 'Martingale Residuals '; title2 'Null Model vs. Transformed covars'; proc sgscatter data=B3 ; plot mart*(logbili logalb age logproth edema)/markerattrs=(symbol=circlefilled) loess=(smooth=0.5); run; quit; ods graphics on; proc phreg data=A; model time*delta(0)=bili logalb age logproth edema; assess var=(bili) /crpanel resample seed=19; run; ods graphics off; ods graphics on; proc phreg data=A; model time*delta(0)=logbili logalb age logproth edema; assess var=(logbili) /crpanel resample seed=19; run; ods graphics off;