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

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Support Vector Machine Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by