fitlm - only positive coefficients
조회 수: 5 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
Torsten
2022년 10월 24일
Use "lsqlin" instead. Here, you can set upper and lower bounds for the parameters.
댓글 수: 2
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 Center 및 File Exchange에서 Linear Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!