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
- /
- Prediction and Confidence Ellipse about a single p...

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

02-28-2016 10:24 AM

I am trying to recreate an example in SAS from "Applied Multivariate STatistical Analysis" by Johnson and Wichern. The example is 7.10, pg 400-401 of the 6th edition. There are 2 predictors and 2 outcomes; we are predicitng a single point based on the fit of the regression model. The problem comes when trying to actually plot the prediction and confidence ellipses centered about the specific predicted piont (therefore, we are not concrned with the overall ellipses for the means of the data, which SAS easily generates).

Does anyone have a any suggestions how to obtain such a plot?

Using SAS 9.3.

Thank you,

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

Posted in reply to Soula

02-28-2016 11:13 AM - edited 02-28-2016 11:14 AM

If you have computed the center of the ellipse, the semi-major and semi-minor axis lengths with possibly the slope, then you can plot these using the GTL ELLIPSEPARM statement. The parameters can come from a data set or values.

Example attached. Note use of LAYOUT OVERLAYEQUATED to keep x and y mapping uniform. Also, the SCATTER is necessary, but if you don't want to see the origin points plotted, you can set their size to zero using the option MARKERATTRS=(SIZE=0).

data ellipse;

input x y semimajor semiminor slope;

datalines;

10 5 10 4 1

8 4 8 6 0

;

run;

proc template;

define statgraph ellipse;

begingraph;

entrytitle 'Parametric Ellipse';

layout overlayequated;

scatterplot x=x y=y;

ellipseparm xorigin=x yorigin=y semimajor=semimajor semiminor=semiminor slope=slope;

endlayout;

endgraph;

end;

run;

proc sgrender data=ellipse template=ellipse;

run;

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

Posted in reply to Soula

02-29-2016 08:18 AM

I only have access to the 3rd edition, which uses different page numbers, but I think I found the example that you mention. The example is given in terms of covariance matrices and linear algebra, so I assume that you don't want to use the ELLIPSE statement in PROC SGPLOT but that you want to use the POLYGON statement to plot points that you have already computed. Thus this really isn't a GRAPHICS question, but a question about computing an ellipse by hand.

I suggest you look at the article "Computing prediction ellipses from a covariance matrix", which shows how to generate points on an ellipse when you have the covariance matrix. The example in the article is not your use-case, but it is releated. The blog example is for bivariate (X,Y) variables, and the prediction ellipse assumes a bivariate normal distribution. That is similar to your use-case, since for multiple regression the two predicted values at X=Z_0 are beta`*Z_0 and that point estimate is distributed as N(beta`*Z_0, Z_0`*inv(Z`Z)*Z_0*Sigma), as shown in the Johnson and Wichern text on the page before Example 7.10.

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

Posted in reply to Soula

03-03-2016 05:33 PM

I've actually answered had to solve this recently and was looking for more ways to work on plots like these. I have the same edition you do and ended up being able to use the code that is found in the PROC TEMPLATE for ellipses, (like an earlier contributor said) on the SAS site here.

If you make new a dataset with both measures of the width and legnth of the axies for each ellipse, to extend what the previous contributor did, then you can easily pull that into the PROC TEMPLATE code, and include it in a second ELLIPSEPARM statement in the PROC TEMPLATE step. This will allow you to have both of the ellipses on the same graph, just like the book; I'm not sure what the correct slope should be though. I used a slope of 1, and it looked ok.

Hope this helps.