How to force my robust regression to pass through y=1?

3 ビュー (過去 30 日間)
Carlos Goncalves Moreira
Carlos Goncalves Moreira 2017 年 11 月 13 日
コメント済み: Walter Roberson 2017 年 11 月 17 日
I have a very simple code with two vectors. I want to compute a robust regression on those values, but forcing the function to pass in y(0)=1. I tried to apply the polyfit function, but honestly I don't have much experience with Matlab. Does anyone have a simple solution for this, so I can extract my statistic results? Thanks
x=[1 1 1 1 1 1 28 28 28 28 28 28 56 56 56 56 56 56 84 84 84 84 84 84 112 112 112 112 112 112];
of_wt_veh=[1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.739660 0.697400 0.604162 0.748125 0.683022 0.761243 0.984600 0.675027 0.639655 0.662086 0.660443 0.845765 1.126925 0.709459 0.828230 0.604704 0.635310 0.783181 1.019504 0.640609 0.462813 0.616220 0.754486 0.6987264];
[b,stats] = robustfit(x,of_wt_veh);
scatter(x,of_wt_veh,'filled'); grid on; hold on
plot(x,b(1)+b(2)*x,'g','LineWidth',2)
legend('Data','Robust Regression')

採用された回答

John D'Errico
John D'Errico 2017 年 11 月 13 日
編集済み: John D'Errico 2017 年 11 月 13 日
Use robustfit with no constant term. But subtract 1 from y.
That forces the fit to pass through y==1, at x==0.
b(1) = 1;
[b(2),stats] = robustfit(x,of_wt_veh - 1,[],[],'off');
The point is, if your fit has no constant term in a polynomial, then it goes through (0,0). EXACTLY. ALWAYS. So if you subtract 1 from y, then you want the fit to go through 0.
  5 件のコメント
Walter Roberson
Walter Roberson 2017 年 11 月 17 日
Carlos asks,
Does anyone know a solution for my question? Thanks.
Walter Roberson
Walter Roberson 2017 年 11 月 17 日
kstest2() possibly.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by