Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- Scatterplot of logistic regression model-predicted log odds of the out...

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-02-2022 04:47 PM
(1693 views)

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;

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

How to Concatenate Values

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.