12-04-2011 04:25 PM
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;
proc gplot DATA=PCSORES;
Any advice on how to add confidence ellipses to the output graph would be appreciated.
12-04-2011 07:36 PM
...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.
12-04-2011 07:49 PM
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.
12-04-2011 10:12 PM
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.
input grpvar $3. (x1-x14) (1.);
ods _all_ close;
ods listing close;
ods html path='c:\temp' (url=none)
ods graphics on;
PROC PRINCOMP DATA=testdata OUT=PCSCORES COVARIANCE
title '1)PRINCOMP direct approach with ODS GRAPHICS';
VAR X1 X2 X3 X4 X5 X6 X7 X8 X9 ;
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;
ods _all_ close;