Help using Base SAS procedures

PROC GLM predict values on some regressors

Reply
N/A
Posts: 0

PROC GLM predict values on some regressors

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
N/A
Posts: 0

Re: PROC GLM predict values on some regressors

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.
N/A
Posts: 0

Re: PROC GLM predict values on some regressors

Thanks a lot, I will do it manually then.
N/A
Posts: 0

Re: PROC GLM predict values on some regressors

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
Ask a Question
Discussion stats
  • 3 replies
  • 111 views
  • 0 likes
  • 1 in conversation