Weighted Non-negative Least Square Linear Regression in python [closed]

老子叫甜甜 提交于 2019-12-07 23:54:17

问题


I know there is an weighted OLS solver, and a constrained OLS solver.

Is there a routine that combines the two?


回答1:


You can simulate OLS weighting by modifying the X and y inputs. In OLS, you solve β for

XtX β = Xty.

In Weighted OLS, you solve

XtX W β = Xt W y.

where W is a diagonal matrix with nonnegative entries. It follows that W0.5 exists, and you can formulate this as

(X W0.5)t(XW0.5) β = (X W0.5)t(XW0.5) y,

which is an OLS problem with X W0.5 and W0.5 y.


Consequently, by modifying the inputs, you can use a non-negative constraint system which does not directly recognize weights.



来源:https://stackoverflow.com/questions/36112290/weighted-non-negative-least-square-linear-regression-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!