Constrained Multiple Linear Regression using lsqlin

7 ビュー (過去 30 日間)
Hannah Doss
Hannah Doss 2022 年 10 月 4 日
回答済み: Hannah Doss 2022 年 10 月 4 日
Hi All,
I am trying to solve a multiple linear regression equation: y = a*x1 + b*x2 + c*x3 + d*x4 + e
where x's are my inputted data (all of same length), and I am solving for a-e. Originally, I successfully used 'regress' to obtain by solutions, but I realized after that I needed to constrain a and b to be >= 0. I am trying to transition from 'regress' to 'lsqlin' (I have the optimization toolbox), but the syntax for 'lsqlin' is confusing me and my answers aren't making sense. Could someone please help check my input parameters? I think I'm almost there but I am missing something, primarily with my "d" vector (I have no idea what I should have here, i.e., how the constant vector works for multiple linear regression cases). Thanks so much!!
C = [blankF NPF wavelength.^-4 wavelength ones(size(wavelength))];
d = [ones(size(wavelength))];
lb = [0 0 -Inf -Inf -Inf];
x = lsqlin(C,d,[],[],[],[],lb,[])

採用された回答

Hannah Doss
Hannah Doss 2022 年 10 月 4 日
For anyone who was also confused by this, I solved my own problem! The d vector is your y.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by