BookmarkSubscribeRSS Feed
Golf
Pyrite | Level 9

Hello,  I have a model;
Y = b0+ b1X1+b2X2 + u
I want to use proc IML to create a column vector:
[beta] = [1 -b0 b1 -b2]'.      [Dimension: 4x1]
I also want to create a matrix of X
[X ] = [Y ones X1 X2].          [Dimension: nx4]
Then I calculate the vector of coint:
coint = [X]*[beta].            [Dimension: nx1]

 

I started with the following codes;

proc reg data = a outest = coefficients;
model y = x1 x2;
run;

How can I use Proc IML to obtain the desired results?

Thank You

5 REPLIES 5
sbxkoenk
SAS Super FREQ

I have moved this topic to 'SAS/IML' - board.

 

SAS/IML 14.2 User’s Guide
Tutorial: A Module for Linear Regression
A Module for Linear Regression
https://go.documentation.sas.com/doc/en/imlcdc/14.2/imlug/imlug_tutorial_sect003.htm

 

Home > Analytics > SAS/IML > Multiple linear regression using proc iml
https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Multiple-linear-regression-using-proc-iml...

 

BR,
Koen

Golf
Pyrite | Level 9
Thank You.
Rick_SAS
SAS Super FREQ

I don't understand why there are some (but not all) minus signs in the regression coefficient, but I think this program should get you started. If you intended to use -b1, then insert it in the obvious location.

 

proc iml;
/* use sample data */
use sashelp.class;
read all var "Weight" into Y;
read all var {"Height" "Age"} into XVars;

/* specify regression coefficients */
b0 = 13;
b1 = 9;
b2 = 5;

/* [beta] = [1 -b0 b1 -b2]'.      [Dimension: 4x1] */
beta = 1 // -b0 // b1 // -b2;

/* [X ] = [Y ones X1 X2].          [Dimension: nx4] */
ones = j(nrow(Y), 1, 1);
X = Y || ones || XVars;
coint = X*beta;
print Y coint;

 

Golf
Pyrite | Level 9

Thank You. @Rick_SAS 

Rick_SAS
SAS Super FREQ

Is there anything else we can help with? If your question is answered, please mark the solution and close this thread.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 5 replies
  • 2511 views
  • 0 likes
  • 3 in conversation