turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Fitplot with Multiple Regression?

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-18-2014 10:32 PM

Hello,

I understand fitplot is not an option with Proc Reg when you have a multi-variable model. But what do I do if I want to plot the fitted values vs the actual values? Is there any work around that provides a similar look/feel? I used the output function to create a new dataset with the predicted values and tried plotting those (see code below), but when I tried to plot the fitted (yhat) values as a series the line was erratic (see attached).

ods graphics on;

proc sgplot data = fitted_model;

scatter X =x1 Y=Y /markerattrs =(color = blue);

series X =x1 Y=yhat /lineattrs =(color = red);

run;

quit;

Accepted Solutions

Solution

01-18-2014
11:39 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-18-2014 11:39 PM

If you want to show the linear relationship between x1 and Y then you should sort your data BEFORE doing the regression :

**proc sort data=myData; by my01variable x1; run;**

**proc reg data=myData ...;**

**....**

**run;**

**ods graphics on;**

**proc sgplot data = fitted_model;**

**scatter X =x1 Y=Y / markerattrs =(color = blue);**

**series X =x1 Y=yhat / group=my01variable lineattrs =(color = red);**

**run;**

where **my01variable** is the dummy variable that generates the two lines in the x1-Y relationship.

PG

PG

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-18-2014 11:06 PM

If you want actual by fitted (which is not a FITPLOT but a **OBSERVEDBYPREDICTED plot**), seems like you should be plotting

**scatter X =Yhat Y=Y / markerattrs =(color = blue);**

and no series.

PG

PG

Solution

01-18-2014
11:39 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-18-2014 11:39 PM

If you want to show the linear relationship between x1 and Y then you should sort your data BEFORE doing the regression :

**proc sort data=myData; by my01variable x1; run;**

**proc reg data=myData ...;**

**....**

**run;**

**ods graphics on;**

**proc sgplot data = fitted_model;**

**scatter X =x1 Y=Y / markerattrs =(color = blue);**

**series X =x1 Y=yhat / group=my01variable lineattrs =(color = red);**

**run;**

where **my01variable** is the dummy variable that generates the two lines in the x1-Y relationship.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-19-2014 02:58 PM

THANK YOU!!! Didn't realize I had to sort it...was driving me NUTS!!!!