Hello sas users
Can anyone help me estimate OLS with restriction?
My model is
Y=b0+b1*x1+b2*x2+b3*x3
I want to impose restrictions where
(i) b1,b2,b3>=0
(ii) b1+b2+b3=1
Which procedure do I use?
If you let me know it will be really appreciated
proc model data=loading_&howmany(where=(year(date)=&i)) plots=none;
by wficn date;
retmrf=b0+b1*rm+b2*smb+b3*hml+b4*umd ;
bounds 0 <= b1 b2 b3 b4;
restrict b1+b2+b3+b4 = 1;
fit retmrf ;
ods output ResidSummary=rsq_&howmany._&i(keep=wficn date RSquare);
run;
quit;
PROC REG with the RESTRICT statement can handle your second restriction, but not the first (because PROC REG cannot handle greater than or less than restrictions).
Then there's this: https://communities.sas.com/t5/Statistical-Procedures/Regression-analysis-with-only-positive-coeffic... (scroll down to the reply by @stanmarciano
I believe you can program PROC IML to handle greater than or less than restrictions on the regression coefficients, but I leave that up to our in-house PROC IML author @Rick_SAS.
Thanks but I didnt mean to do Bayesian inference
And this: https://support.sas.com/kb/22/800.html
Remember, Google is your friend in situations like this.
Replace b3 with 1 - b1 - b2 in your model and use proc nlin to fit your model with a bounds statement.
Check @Rick_SAS blog ,about this question.
proc model data=loading_&howmany(where=(year(date)=&i)) plots=none;
by wficn date;
retmrf=b0+b1*rm+b2*smb+b3*hml+b4*umd ;
bounds 0 <= b1 b2 b3 b4;
restrict b1+b2+b3+b4 = 1;
fit retmrf ;
ods output ResidSummary=rsq_&howmany._&i(keep=wficn date RSquare);
run;
quit;
For more about solving regression problems in SAS that have constraints on the parameters, see
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.