I'm trying to check that I meet the linearity assumption for logist regression.
I want to plot the model-predicted log odds of the outcome by a continuous predictor in a scatter plot. Is there a way to do this in SAS?
I'm not sure it's needed but the code for my logistic model is below:
proc logistic data=ST;
class dow moonphase;
model complication(event='1') = hour month_concern dow moonphase ;
run;
Something like these?
If so, look into the EFFECTPLOT statement.
@greesamu wrote:
I'm trying to check that I meet the linearity assumption for logist regression.
I want to plot the model-predicted log odds of the outcome by a continuous predictor in a scatter plot. Is there a way to do this in SAS?
I'm not sure it's needed but the code for my logistic model is below:
proc logistic data=ST;
class dow moonphase;
model complication(event='1') = hour month_concern dow moonphase ;
run;
Thanks, this is on the right track and I'll keep looking in this direction. That said, I'd like the Y-axis to be the predicted log odds instead of predicted probability and I'd like the plot to be a scatterplot.
Sorry, what's the difference with predicted log odds versus predicted probability? Is this to check the linearity of the terms with respect to the regression?
Since I suspect it's just conversions of the values, you may want to use the EFFECTPLOT and capture the data behind the graph. Then plot it yourself using SGPLOT.
Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...
For shown example, depending on your effectplot statement your ods table name may vary.
ods select none;
ods output SliceFitPanel=rawData;
proc logistic data=Neuralgia plots(only)=(oddsratio(range=clip));
class Treatment Sex /param=ref;
model Pain= Treatment Sex Age / noor;
effectplot / at(Sex=all) noobs;
run;
ods select all;
proc print data=rawData;
run;
data scaled;
set rawDAta;
logsvalue = log(_predicted/(1-_predicted));
run;
proc sgplot data=scaled;
where _at = "Sex=F";
scatter x=_xcont1 y=logsValue / jitter;
run;
There are too many data points in this one so the points blend together to form a line.
You could reduce the frequency and take every 5th or 10th value I suppose.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.