Programming the statistical procedures from SAS

Another question about GENMOD Gamma log link error term

Occasional Contributor
Posts: 8

Another question about GENMOD Gamma log link error term


I am building a model as follows:

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?

Thanks for help!
Valued Guide
Valued Guide
Posts: 673

Re: Another question about GENMOD Gamma log link error term

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.
Occasional Contributor
Posts: 8

Re: Another question about GENMOD Gamma log link error term

Hi lvm, I tried that on my data, and your information is quite helpful! Thank you very much!
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation