- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello out there,
I need advice on creating a scatter plot of my first two principal componants with confidence ellipses around each of the five species I am investigating, I know how to do this in SAS, but not the enterprise guide. Here is the input I have been using to get the graph without ellipses:
PROC PRINCOMP DATA=PCA OUT=PCSCORES COVARIANCE;
VAR X1 X2 X3 X4 X5 X6 X7 X8 X9;
title 'PCAVCANMAND';
RUN;
proc gplot DATA=PCSORES;
plot prin2*prin1=Species
RUN;
Any advice on how to add confidence ellipses to the output graph would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
you could just edit the code to look like what you do in regular SAS.
Doc Muhlbaier
Duke
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
...well yes...but what I normally would do in sas is get the output for the PCA, go up to solutions-->analysis-->interactive data analysis, get the PCS scores and then use analyze-->multivariate to get it to produce graphs with ellipses. Those options don't exist in enterprise but I'm told that it's possible to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I can't help further. I haven't done a PCA in years. If you are hand coding the entire thing, then PROC SGPLOT might be a good tool to bet your elipses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
If you are running SAS 9.2 or higher, you can modify the PRINCOMP code directly to create an ellipse from your PRINCOMP procedure using the PLOTS= option.
Otherwise, as Doc suggested, if you want to make a dataset and then plot the points yourself, I find SGPLOT to be the most straightforward -- you only need a SCATTER statement and an ELLIPSE statement. Of course, with the PRINCOMP "direct" approach, you only need the PLOTS= option.
I believe that either one involves modifying the code a bit. The attached program makes some fake data then. shows both approaches.
cynthia
data testdata;
input grpvar $3. (x1-x14) (1.);
return;
datalines;
s1 26838853879867
s2 74758876857667
s1 56757863775875
s2 67869777988997
s3 99997798878888
s3 89897899888799
s1 89999889899798
s2 87794798468886
s3 35652335143113
s1 89888879576867
s2 76557899446397
s3 97889998898989
s1 76766677598888
s2 99899899899899
s3 76656399567486
;
run;
ods _all_ close;
ods listing close;
ods html path='c:\temp' (url=none)
file='something.html' style=egdefault;
ods graphics on;
PROC PRINCOMP DATA=testdata OUT=PCSCORES COVARIANCE
PLOTS(NCOMP=2)=(SCORE(ellipse));
title '1)PRINCOMP direct approach with ODS GRAPHICS';
VAR X1 X2 X3 X4 X5 X6 X7 X8 X9 ;
RUN;
ods graphics off;
proc sgplot data=pcscores;
title '2) Use SGPLOT with SCATTER and ELLIPSE';
scatter x=prin1 y=prin2/group=grpvar;
ellipse x=prin1 y=prin2;
run;
ods _all_ close;