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
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
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;
Thank You. @Rick_SAS
Is there anything else we can help with? If your question is answered, please mark the solution and close this thread.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.