BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I'm running a PROC GLM with two groups of regressors - say vectors X1 and X2 (some of which are class variables). The standard OUTPUT statement allows me to compute the predicted values of the Y on X1 and X2.

However, I need to predict Y only with the information in X1, i.e. instead of b1*X1+b2*X2, just b1*X1.

As these vectors have thousands of variables, I can't do it manually. Do you know of a way to do it in SAS?

Thanks a lot!
Stefano
3 REPLIES 3
deleted_user
Not applicable
It seems that there's no option to output the design matrix X.
According to the last paragraph of http://support.sas.com/onlinedoc/913/getDoc/en/statug.hlp/glm_sect29.htm, the design matrix is not actually constructed.
Basically you got to generate the design matrix for factors in X1 by yourself using the rules on that web page before multiply it with the estimate of b1.
deleted_user
Not applicable
Thanks a lot, I will do it manually then.
deleted_user
Not applicable
You don't have to, because PROC GLMMOD will generate the design matrix for you. For example,
/*
data plants;
input Type $ @;
do Block = 1 to 3;
input StemLength @;
output;
end;
datalines;
Clarion 32.7 32.3 31.5
Clinton 32.1 29.7 29.1
Knox 35.7 35.9 33.1
O'Neill 36.0 34.2 31.2
Compost 31.8 28.0 29.2
Wabash 38.2 37.8 31.9
Webster 32.5 31.1 29.7
;
ods output designpoints=X(drop=obsnumber stemlength);
proc glmmod;
class Block Type;
model StemLength = Block Type;
run;
ods output parameterestimates=b(keep=estimate) predictedvalues=yhat;
proc glm data=plants;
class Block Type;
model StemLength = Block Type/p solution;
run;
proc iml;
use x;
read all var _num_ into X;
use b;
read all var {estimate} into b;
yhat = x*b;
b1 = b;
b1[5:11]=0;
yhat1 = x*b1;
print b b1;
print yhat yhat1;
quit;
*/
where b are the estimates of intercept, block, and type; yhat=X*b are the predicted values using both block and type; b1 are the estimates of intercept and block only; yhat1 = X*b1 are the predicated values using block only.
reference: http://support.sas.com/kb/23/217.html

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
  • 677 views
  • 0 likes
  • 1 in conversation