BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bills1
Fluorite | Level 6

Hi, I have just run a PCA but now want to calculate the confidence intervals for the eigenvalues. How do extract the eigenvalues from the analysis to calculate the confidence intervals? 

 

For example using this code that comes from here: https://blogs.sas.com/content/iml/2019/11/04/interpret-graphs-principal-components.html 

 

ods graphics on;
proc princomp data=iris         /* use N= option to specify number of PCs */
              STD               /* optional: stdize PC scores to unit variance */
              out=PCOut         /* only needed to demonstate corr(PC, orig vars) */
              plots=(scree profile pattern score);
   var SepalLength SepalWidth PetalLength PetalWidth;  /* or use _NUMERIC_ */
   ID id;                       /* use blank ID to avoid labeling by obs number */
   ods output Eigenvectors=EV;  /* to create loadings plot, output this table */
run;

The data gets exported to PCOut. How do I read that in to use with proc iml?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Your code example that you posted earlier uses the number 179. I don't have your data, so I don't know if that is correct, you will have to vouch for the correctness of using 179.

 

data want;
    set eigenvalues;
    CI_lower=Eigenvalue/(1+1.96*sqrt(2/179));
    CI_upper=Eigenvalue/(1-1.96*sqrt(2/179));
run;
--
Paige Miller

View solution in original post

12 REPLIES 12
PaigeMiller
Diamond | Level 26

How do extract the eigenvalues from the analysis to calculate the confidence intervals? 

Add this command:

ODS OUTPUT Eigenvalues=eigenvalues;
--
Paige Miller
bills1
Fluorite | Level 6

Thanks Paige, but how do I use them. For example, I want to run this after extracting the eigenvalues.

 

proc iml;
CI_1_lower=Eigenvalues[1]/(1+1.96*sqrt(2/179));
CI_1_upper=Eigenvalues[1]/(1-1.96*sqrt(2/179));
run;
PaigeMiller
Diamond | Level 26

I have never seen confidence intervals for eigenvalues from PCA, and so I don't know a formula to compute the confidence intervals or how you would use them. (Why do you want confidence intervals for eigenvalues anyway, what use are they?)

 

I'm sure you could compute the confidence intervals from either a bootstrap or jackknife method, and I'm sure Google knows more about this than I do.

--
Paige Miller
bills1
Fluorite | Level 6
I am doing an assignment and we need to calculate the confidence intervals for the eigenvalues. I can manually put the eigenvalues in to a vector, but I thought there might be an easier way. I just want to know how I would read in the Eigenvectors that you just showed me how to output in to the next bit of code. I normally use R and Python and it is fairly easy to do.

Thanks for your help anyway Paige.
PaigeMiller
Diamond | Level 26

I am doing an assignment and we need to calculate the confidence intervals for the eigenvalues

 

I have used PCA hundreds of times in my life, and I still can't think of a reason why you would want confidence intervals for eigenvalues, and your brief statement does not provide me any enlightenment. But I admit I don't know everything, and I would like to understand, what are you going to do with the confidence intervals once you compute them? I helped you, could you please explain this for me in terms of actual usage(s) of the confidence intervals, instead of explaining that you have an assignment?

--
Paige Miller
bills1
Fluorite | Level 6

This is an example.Screenshot 2020-09-23 213305.png

PaigeMiller
Diamond | Level 26

Okay, so that's a formula for confidence intervals for eigenvalues. But ... you didn't answer my question.

--
Paige Miller
bills1
Fluorite | Level 6

That is an example of a use case. That is probably the best answer that I can give you. I've only been learning this for the last week so can't tell you of other use cases. I am calculating because I want to pass the assignment and to do that I need to get the confidence intervals for the eigenvalues (which I have already done by manually entering the values in). I just want to know if there is a better way of doing it.

 

I found this article which explains a bit (using a different formula): http://ijpam.uniud.it/online_issue/201737/50-Liu.pdf

PaigeMiller
Diamond | Level 26

Your code example that you posted earlier uses the number 179. I don't have your data, so I don't know if that is correct, you will have to vouch for the correctness of using 179.

 

data want;
    set eigenvalues;
    CI_lower=Eigenvalue/(1+1.96*sqrt(2/179));
    CI_upper=Eigenvalue/(1-1.96*sqrt(2/179));
run;
--
Paige Miller
Ksharp
Super User
You can use function eigen() in IML to get primary component .
read table into iml ,try :
proc iml;
use pcout;
read all var _all_ into x ;
close;
print x;
quit;
Ksharp
Super User

Calling @Rick_SAS 

bills1
Fluorite | Level 6
Great. Thanks for your help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 911 views
  • 3 likes
  • 3 in conversation