BookmarkSubscribeRSS Feed
mgilbert
Obsidian | Level 7

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?

 

Michael

3 REPLIES 3
PGStats
Opal | Level 21

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 data=sashelp.cars(firstobs=51) n=2 cov;
var engineSize cylinders horsepower weight wheelbase length;
ods output Eigenvectors=EV;
run;

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

data prinScore;
set evTransposed;
_TYPE_ = "SCORE";
run;

/* Compute the first two component scores for the 
 first 50 observations */
proc score data=sashelp.cars(obs=50) score=prinScore out=scoredCars; 
run;
PG
mgilbert
Obsidian | Level 7

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.

 

Michael

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2202 views
  • 0 likes
  • 3 in conversation