Help using Base SAS procedures

Applying Results of Principal Component Analysis on New Data

Posts: 20

Applying Results of Principal Component Analysis on New Data

I started with a small data set (under 20 variables) and conducted truncation, trimming, and imputing. I finally prepped the data where I wanted it to be, and ran PROC PRINCOMP. I then used the results to run a regression model where my response variable (TARGET_WINS) = specified principal components (and only principal components).


I'm now tasked with applying my model to another data set and scoring it. This new data set is a clone of my original data set, except it has fewer observations and no response variable. If this were a "normal" regression and I did not use principal components, I could construct the beta coefficients from the parameter estimates, and simply substitute the variables in the new data set to create the predicted values.


But (as far as I know) since principal components are relative to the other data in the data set, I have absolutely no clue how to go about this. I can create the new principal components in the new data set, but since there's no response variable, I can't model it via PROC REG and score the predicted values.


I've taken a look at PROC SCORE, but have not had much luck. I have stored the OUTSTAT from PROC PRINCOMP in the original data set, and reduced it to only have principal components used in the regression model (from here and here). Any thoughts?



Respected Advisor
Posts: 4,651

Re: Applying Results of Principal Component Analysis on New Data

[ Edited ]

Use ODS to get the eigenvectors and then proc score to get the component scores. Here is an example


/* Keep the first 50 observations for scoring. 
 Compute the two first principal components on the rest */
proc princomp n=2 cov;
var engineSize cylinders horsepower weight wheelbase length;
ods output Eigenvectors=EV;

proc transpose data=ev out=evTransposed;
var Prin1 Prin2;
id Variable;

data prinScore;
set evTransposed;

/* Compute the first two component scores for the 
 first 50 observations */
proc score score=prinScore out=scoredCars; 
Posts: 20

Re: Applying Results of Principal Component Analysis on New Data

Thanks - I'll give this a shot tonight.


Less on the procedure but more on the theory side... Once I get the new data scored, it is then appropriate to hand-code the regression equation using the beta coefficients from the old data, and substituting the new scored data in? Greatly appreciate the help.



Posts: 3,480

Re: Applying Results of Principal Component Analysis on New Data

If "beta coefficients from the old data" means "beta coefficients from the regression that uses the prinipal components as explanatory variables," then the answer is yes.  Remember that the prinipal components are just linear combinations of your original explanatory variables. When you score the new data, you are creating coordinates in a new coordinate system in which the prinipal components replace the usual (x,y,z,...) coordinates. Mathematically, this is called a change of basis.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation