Constraints on Parameter Estimation

I am trying to fit linear regression model and predict parameters without intercept. I have written my code as under;
tbl=table(yobs,x1,x2,x3);
mdl = fitlm(tbl,'yobs ~ x1 + x2 + x3 - 1')
but I am getting the estimates which are negative but in my model all parameters should be positive. LB>=0 and UB=inf. How to set these constraints while doing the prediction.

 採用された回答

Torsten
Torsten 2023 年 3 月 11 日

0 投票

Use lsqlin instead of fitlm.

6 件のコメント

Faizan Lali
Faizan Lali 2023 年 3 月 13 日
I am using lsqlin with lb=[0.5 0 0] and ub=[inf inf inf], but it is not changing the 1st parameter. I mean whatever I give the value as lb it it spitting out same for Beta1, but changing the values of other two betas.
Torsten
Torsten 2023 年 3 月 13 日
編集済み: Torsten 2023 年 3 月 13 日
C = [x1 x2 x3];
d = yobs;
lb = [0.5 0 0];
ub = [inf inf inf];
sol = lsqlin(C,d,[],[],[],[],lb,ub)
where x1, x2, x3 and yobs are column vectors of the same length doesn't work ?
Matt J
Matt J 2023 年 3 月 13 日
編集済み: Matt J 2023 年 3 月 13 日
Perhaps the columns of C need to be normalized.
C = [x1 x2 x3];
c=vecnorm(C,2,1);
d = yobs+1;
lb = [0.5 0 0];
ub = [inf inf inf];
sol = lsqlin(C./c,d,[],[],[],[],lb,ub);
sol=sol./c(:)
Faizan Lali
Faizan Lali 2023 年 3 月 13 日
Thank you, it worked. but it is not giving me the estimates with low SE. I mean the parameter estimates are way different from global values and it is not giving the best fit.
Torsten
Torsten 2023 年 3 月 13 日
This is the best fit you can get without intercept and the constraints you want to impose on the parameters.
Torsten
Torsten 2023 年 3 月 13 日
According to the documentation,
yobs ~ x1 + x2 + x3 - 1
means a three-variable linear model without intercept.
Thus the "-1" just means: no constant term, not
yobs = p1*x1 + p2*x2 + p3*x3 - 1
Very confusing.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022a

質問済み:

2023 年 3 月 11 日

コメント済み:

2023 年 3 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by