proc genmod data = aa;
model totalmedcost= PDC age sex race education /dist=gamma link=log;
Here, I need to check if the estimate of the major predictor PDC is appropriate or unbiased. One of methods is to plot the error of the model (deviance) against PDC to see whether the error is randomly scattered around PDC; another way is to examine the association between deviance and PDC.
However, when I use PLOTS=RESDEV(XBETA), it only generates the plots of deviance residuals as a function of linear predictor, not necessarily the major predictor.
Q1: How could I get the plot of deviance against the specific predictor I want after controlling all the covariates?
Q2: How to get the deviance residual (DR) for each observation, so that I could run the regression of (DR) agaist the predictor PDC?
One way is to use the OUTPUT statement, with the needed keywords. You will need to check out the documentation, but something like:
output out=results pred=yhat resdev=resdev stdresdev=sresdev;
This example creates a file with yhat for the predicted log link, resdev for the deviance residual, and sresdev for the standardized deviance residuals. There are several other possible variables that can be created (other types of residuals, and so on). The file automatically has all your other (original) variables. Use a proc print data=results; to see what is in the file.
Then you can then use proc gplot, or one of the statistical graphics procedures to plot the relevant residuals vs. your predictor variables.
There may be other ods graphics options built right into GENMOD for doing this, but you will need to check out the documentation.