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?
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;
How do extract the eigenvalues from the analysis to calculate the confidence intervals?
Add this command:
ODS OUTPUT Eigenvalues=eigenvalues;
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;
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.
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?
This is an example.
Okay, so that's a formula for confidence intervals for eigenvalues. But ... you didn't answer my question.
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
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;
Calling @Rick_SAS
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.