How to obtain Std of Coefficients from Curve Fitting
Mostrar comentarios más antiguos
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
1 comentario
George
el 2 de Abr. de 2012
Respuesta aceptada
Más respuestas (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 comentarios
George
el 3 de Abr. de 2012
Carlos Claiton Noschang Kuhn
el 27 de Mzo. de 2018
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
el 30 de Mzo. de 2018
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
el 6 de Mayo de 2018
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
el 2 de Abr. de 2012
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
el 14 de Mzo. de 2021
0 votos
Categorías
Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!