Polyfit and parameter uncertainty

조회 수: 3 (최근 30일)
Niles Martinsen
Niles Martinsen 2012년 6월 22일
댓글: Kamal Gurnani 2019년 2월 28일
Hi
I have some data (x, y), where y is proportional to x. I want to find the relationship, so I fit a function of the form f(x) = a*x+b to the data. This is how I do it:
p_RvsT = polyfit(r_vs_t(:, 1), r_vs_t(:, 2), 1);
Now this gives me a good estimate of a and b. What I want now is to find the uncertainty (= standard deviation) on the estimated values of a and b. I have found an older thread ( http://www.mathworks.com/matlabcentral/newsreader/view_thread/59468), which uses this technique:
x=1:100:10000;
y=x+.1*x.*(rand(size(x))-.5);
[p,s]=polyfit(x,y,1);
[yh,d]=polyval(p,x,s);
% show results
line(x,y);
line(x,[yh;yh-d;yh+d],'color',[1 0 0]);
My question is if this is the correct way to do so?
Best,
Niles.

채택된 답변

Walter Roberson
Walter Roberson 2012년 6월 22일
Yes.
  댓글 수: 2
Niles Martinsen
Niles Martinsen 2012년 6월 22일
Thanks for the quick help.
Kamal Gurnani
Kamal Gurnani 2019년 2월 28일
But the d-values are the prediction intervals for y, I still can not see the uncertainities in the coefficients.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by