How to obtain Std of Coefficients from Curve Fitting
古いコメントを表示
Dear folkers, I want to obtain standard deviation of coefficients after using curve fitting. but I couldn't find information from help documents. how can I get it? thanks!!
ex.: the general model is: f(x) = a*x +b Coefficients: a = 1.5 (-1 3) b = 2 (0.5 4.5) now, how do i get the "std" of "a" and "std" of "b"
thank you
採用された回答
その他の回答 (3 件)
You can get more information when you invoke the fit command:
[obj,gof,opt] = fit(...)
This gives the fitted obj, goodness-of-fit statistics, and optimization info.
The Curve Fitting output is aimed at confidence intervals rather than standard errors. The confidence intervals are roughly the estimated coefficient plus or minus two standard errors. If you have the Statistics Toolbox then you can find the confidence level you'd need to get intervals that are plus or minus one standard error, then pass that level into the confint method. Something like this:
level = 2*tcdf(-1,gof.dfe)
% confint(obj,level) <- this original is incorrect
confint(obj,1-level) %<- corrected
4 件のコメント
George
2012 年 4 月 3 日
Carlos Claiton Noschang Kuhn
2018 年 3 月 27 日
Hi Tom, I am trying to understand the way you calculated the level, why are you using -1 as the first argument for the tcdf function?
Pavel Kolesnichenko
2018 年 3 月 30 日
Hi Tom. I am also curious, why did you put -1 in tcdf function. Also, I reckon it should be
level = 1 - 2*tcdf(-1,gof.dfe)
Tom Lane
2018 年 5 月 6 日
The 1 comes from wanting 1 standard error. The negative sign is to get the level associated with 1 standard error below zero. The multiplication by 2 is to include the values beyond 2 standard error above the mean, by symmetry. You are right, to get a confidence level you should subtract from 1. I will try to correct that.
Richard Willey
2012 年 4 月 2 日
The 12a release of Statistics Toolbox has some very nice new capabilities for regression analysis.
%%Generate some data
X = linspace(1,100, 50);
X = X';
Y = 5*X + 50;
Y = Y + 20*randn(50,1);
%%Generate a fit
myFit = LinearModel.fit(X,Y)
The object that is generated by LinearModel includes the Standard Error as part of the default display.
myFit = LinearModel.fit(X,Y)
myFit =
Linear regression model:
y ~ 1 + x1
Estimated Coefficients:
Estimate SE tStat pValue
(Intercept) 63.499 7.0973 8.9469 8.4899e-12
x1 4.8452 0.12171 39.809 2.0192e-38
Number of observations: 50, Error degrees of freedom: 48
Root Mean Squared Error: 25.1
R-squared: 0.971, Adjusted R-Squared 0.97
F-statistic vs. constant model: 1.58e+03, p-value = 2.02e-38
Please note:
This same information is available in earlier versions of the product. For example, the second output from regress is "bint" which are the confidence intervals for the regression coefficients.
However, I think that the display capabilities for the LinearModel objects are a big improvement over what came before.
laurent jalabert
2021 年 3 月 14 日
0 投票
カテゴリ
ヘルプ センター および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!