Hi all. Is there a way to graph odds ratios with Proc GAM? In the graph produced by the code below, "spline" is the y-axis. What does that mean when I have a logistic model?
data bweight; set sashelp.bweight; run;
proc gam data=bweight order=internal plots=components(clm commonaxes); class boy married black;
model boy(event='1')=param(married black) spline(momwtgain) / dist=binary;
run;
Thanks!
PROC GAM (and the newer PROC GAMPL which is recommended now for fitting GAMs) do not compute odds ratios since they fit a much wider range of models than just logistic models where odds ratios are relevant. You can get the odds ratio estimates for your two CLASS variables by simply exponentiating their parameter estimates. Since the spline smoothed predictor does not have a parameter estimate, an odds ratio is not easily available. For information on the plots provided, see this note.
You will probably be better off by using the EFFECT statement in PROC LOGISTIC to add a spline to your model. You can then get odds ratios for all of your predictors and get a plot of model fit. See this note which discusses and illustrates this. See, in particular, the example at the end of the note.
Hi, thanks for the suggestion. I can't seem to get odds ratios still, and it doesn't seem to handle covariates in a way I'd expect: it just creates a plot when married=1 and black=1. Any ideas?
data bweight; set sashelp.bweight; run;
proc logistic data=bweight;
class boy married black;
effect s=spline(momwtgain/naturalcubic);
model boy(event='1') = s married black;
effectplot fit / link;
run;
Thanks!
That code provides a table of odds ratio estimates for the two CLASS variables. If you add an ODDSRATIO statement for the spline variable, as shown in the note I referred to, then you will also get odds ratio estimates for the spline variable and plots of all the odds ratios. The plot is for the continuous spline variable. The only way to present such a plot is to fix the other variables at specific values. Since the response is a function of all of the variables in the model, all variables must be set to a value to obtain a predicted response.
There is not an automatic way to plot the odds ratio with PROC GAM. I have two comments:
1. You should use PROC GAMPL, which is faster and more powerful.
2. As mentioned in the SAS/STAT documentation, "the odds ratio can be computed by exponentiating the difference of the logits between any two population profiles." The discussion is for parametric models, whereas a GAM model is nonparametric. However, in principle, it seems possible to score the model on a common set of points for different values of a binary regressor (such as 'married' or 'black' in your example) and use the predicted probabilities to plot the odds ratio. (I've never done it that way.)
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.