Straight line fitting and error calculation
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello everyone,
I have done straight line fitting by using polyfit command where i gave polynomial = 1 and found the values of m and c of the equation mx + c = y
Now i want to find errors associated with m and c i.e I want finally
m +/- error c +/- error
It would be nice if anyone could help me with it. I am badly stuck :(
Thanks
채택된 답변
Star Strider
2015년 1월 30일
댓글 수: 10
aditi
2015년 1월 30일
Thanks strider for your reply.
Could you please help on how to use it.
My present program giving m and c values uses polyfit and polyval. How should i include this in my program.
Thanks
Star Strider
2015년 1월 30일
편집: Star Strider
2015년 1월 30일
My pleasure!
First, download it and put it in with your other user files.
It’s internally documented, so quoting from that:
% CALLING POLYPARCI:
% [p,S] = polyfit(x,y,n); % Fit the data
% ci = polyparci(p,S); % NOTE: specifying a value for ‘alpha’ is
% optional
Call polyfit as you would normally, but include ‘S’ in the desired outputs. (Here ‘p’ is the vector of polynomial coefficients.) Then pass ‘p’ and ‘S’ to ‘polyparci’ as illustrated. It will return a matrix of confidence intervals as ‘ci’, whose columns correspond to the columns in the ‘p’ vector, so ‘ci(:,1)’ are the confidence intervals for ‘p(1)’, and so for all the others.
Example:
x = rand(10,1);
y = rand(10,1);
[p,S] = polyfit(x,y,1)
ci = polyparci(p,S)
Note that ‘polyparci’ has no relevance to polyval or anything it does.
hey.. thanks a lot for the detailed explanation. I am highly obliged.
One more small confusion.. this will give confidence intervals for m and c but i want errors associated with these two parameters. So how will i find that from confidence intervals?
Star Strider
2015년 2월 9일
편집: Star Strider
2015년 2월 9일
My pleasure!
You can get the standard errors from the ‘S’ structure returned by polyfit (I call it ‘PolyS’ in this code snippet):
COVB = (PolyS.R'*PolyS.R)\eye(size(PolyS.R)) * PolyS.normr^2/PolyS.df;
SE = sqrt(diag(COVB)); % Standard Errors
okay.. So COVB gives matrix or errors with slope and intercept? and what does SE gives? also what is R in COVB formula.. could you please explain jst a little bit so that i can understand what these commands are acually doing??
Thanks a lott once again..!! :)
Star Strider
2015년 2월 9일
편집: Star Strider
2015년 2월 9일
My pleasure!
The ‘COVB’ matrix is the covariance matrix for the parameters. Its diagonal are the variances of the individual parameters. The ‘SE’ variable is the standard error of the estimate for each parameter. As for its calculation from the ‘S’ structure, the documentation for polyfit explains it better than I can. See the documentation for S — Error estimation structure for details. I used those values to calculate the data necessary to generate the t-scores for the parameter confidence intervals.
ohh... nice.. so in m +/- error and C +/- error errors are those which we are getting from SE?
Yes.
I use the SE to calculate the confidence intervals.
aditi
2015년 2월 10일
hey.. thanks a lot..!! :-)
I will bother you again if required.. bt thanks for everything.. you were of great help.. :-)
My pleasure!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear Least Squares에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
