Straight line fitting and error calculation
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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.
aditi
2015 年 2 月 9 日
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
aditi
2015 年 2 月 9 日
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.
aditi
2015 年 2 月 9 日
ohh... nice.. so in m +/- error and C +/- error errors are those which we are getting from SE?
Star Strider
2015 年 2 月 9 日
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.. :-)
Star Strider
2015 年 2 月 10 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
