ANON
ANON

Reputation: 3

Output discrepancy between SAS and R

I have coded the same program in R and in SAS (University Edition running on Oracle VirtualBox on Mac) and I'm noticing a discrepancy - which means I messed something up.

The first discrepancy appears in a principal component analysis that I run and I believe it has to do with options intrinsic to the functions available in the two programs. I am diligently working on looking over the documentation but I would be very grateful for the assistance of the brilliant experts on this site.

I have been using this file - https://drive.google.com/file/d/0B9oqAm9yKaC3bEpicEstRW8wUzg/view?usp=sharing - to test the two programs.

In R, my code for the PCA is very simple:

pca1=prcomp(predictor_matrix, scale.=TRUE)

and the very first observation is transformed into the following

<1.01,  -0.79,  -0.03,  -1.08,  1.86,   
-0.13,  0.04,   -0.03,  0.02,   -0.01>

In SAS, my code for the PCA looks like:

proc factor data=regressors 
    simple corr
    Mineigen=0 /*Retain all eigenfunctions*/
    NFactors=10 
    All /*Print All Optional data*/
    Out=NewData /*Get the transformed data*/ 
    ;
run;

and the very first observation is transformed into the following

<0.55,  -0.53,  -0.02,  -0.89,  1.96,   
1.45,   0.89    ,    1.18,  1.15,   1.46>

NOW - the eigenvector matrices are identical in both programs but the eigenvalues are different, so I'm thinking the problem has to do with scaling. But I am brand new to SAS and could really use some pointers on how to get the results of these two programs to converge.

Upvotes: 0

Views: 216

Answers (1)

Hong Ooi
Hong Ooi

Reputation: 57686

The SAS proc for PCA is proc princomp, not proc factor. Try

proc princomp data=regressors n=10 out=newdata;
run;

Upvotes: 2

Related Questions