MATLAB: How to obtain Std of Coefficients from Curve Fitting

curve fittingstd

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

Best Answer

Hi George
Conveniently, 12a also has a function call NonLinearModel
%%Generate some data
X = 2* pi*rand(100,1);
X = sortrows(X);
Y = 9 + 7*sin(1*X + 3) + randn(100,1);
Generate a fit
myFit = NonLinearModel.fit(X,Y, 'y ~ b0 + b1*sin(b2*x1 + b3)', [9, 7, 1, 3])
Here's the output
myFit =
Nonlinear regression model:
y ~ b0 + b1*sin(b2*x1 + b3)
Estimated Coefficients:
Estimate SE tStat pValue
b0 8.9014 0.094189 94.506 1.5635e-96
b1 6.8951 0.13773 50.06 1.3538e-70
b2 1.0018 0.011212 89.356 3.1924e-94
b3 3.0188 0.038947 77.511 2.2541e-88
The one thing that you won't get is convergence history. If you need a complete description of the path that the solvers are following you're probably better off using Optimization Toolbox rather than Stats.