Calculating the error on a non-linear least squares fit

4 views (last 30 days)
Hi, so I'm currently running a program which fits some noisy data to a monoexponential function using a non-linear least squares fit. I know that the equation can be linearized by taking a logarithm, but since the data is noisy and the curve decays to zero I've found that a non-linear least squares fits the best (to avoid taking the logarithm of very small and/or negative values). Here is my fitting code:
s = fitoptions('Method','NonlinearLeastSquares',...
'Lower',[0.00001,1E-3],...
'Upper',[100,1],...
'Startpoint',[0.8 1/40]);
f = fittype('a*exp(-x*b)','options',s);
fitresults = fit(t',S',f);
ci = confint(fitresults,0.6827);
R2Values(counterTE,counterTR) = fitresults.b;
R2Error(counterTE,counterTR) = (ci(2,2)-ci(1,2))/2;
I believe this is right and I get reasonable values for both R2 (relaxation rate) and the error on it. But what I am curious is how exactly matlab calculates the error on the fit parameters. This is quite important for my particular application because I'm interested in the noise properties. If possible I was wondering if anyone knew the equation matlab used to calculate the error (intuitively I feel like it must use the residual), so that I could actually calculate the error myself. Thanks very much in advance!

Answers (0)

Categories

Find more on Linear Model Identification in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!