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

조회 수: 4 (최근 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 CenterFile Exchange에서 Multiple Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by