fitlm - only positive coefficients

19 次查看(过去 30 天)
Tobias Grempels
Tobias Grempels 2022-10-24
评论: Torsten 2022-10-24
Hi
I made a linear regression Model with fitlm. Some of the calculated coefficients are negative. In my Project this doesnt make sense. Is there an opportunity to set Boundaries for the coefficients or only allow positive ones?
Thank you!

回答(1 个)

Torsten
Torsten 2022-10-24
Use "lsqlin" instead. Here, you can set upper and lower bounds for the parameters.
  2 个评论
Tobias Grempels
Tobias Grempels 2022-10-24
Here i need some help. How can i use lsqlin for optimizing my r-squared?
Torsten
Torsten 2022-10-24
The r-squared is only optimized in the model with no bounds on the regression coefficients.
You can compute the r-squared after fitting with lsqlin and with the bound constraints on the parameters, but it will of course be smaller than the optimal one.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by