turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- PROC GLM predict values on some regressors

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-17-2008 01:07 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

12-18-2008 11:39 PM

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.

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

12-21-2008 01:23 PM

Thanks a lot, I will do it manually then.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

12-31-2008 06:04 PM

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

/*

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