Problem using lsqnonlin with nlparci toolbox

I have a problem when calculating the confidence intervals using lsqnonlin and nlparci toolbox.
I wanted to calculate the CI using the Jacobian, however, I am getting the following error: Error using nlparci (line 93) The size of J does not match the sizes of BETA and RESID. I am fitting 6 parameters.
Here is the syntax of the fitting function and of the calculation of the CI.
[par_out, residual,jacobian] = lsqnonlin(@eq_2D3D1TR_set, MAT1,zeros(1,i),MAT2, options, tau_range, g_in_range,MAT3,FIX);
ci = nlparci(par_out, residual, 'jacobian', jacobian);
@eq_2D3D1TR_set is the fitting method
MAT1 are the starting points
zeros(1,i) and MAT2 are the lower and upper bounds
options contain different options of the fitting: options=optimset('Display', 'final','LargeScale', 'Off', 'DiffMaxChange', 0.1, 'DiffMinChange', 0.00001,'TolFun', 1e-100, 'TolX', 0.001, 'MaxFunEvals', 5000, 'MaxIter', 1000);
tau_range, g_in_range are the input data with the selected range
FIX contains information about which of the parameters are fixed during the fitting (the GUI provides this information)
Currently I am fitting with all of the 6 parameters non-fixed.
Truly, when I have a look at the computed Jacobian and residual, then the Jacobian has only 1 column (instead of 6 since I have 6 parameters) and the residual contains only 1 number, what seems also not OK.

 Akzeptierte Antwort

Alan Weiss
Alan Weiss am 19 Jul. 2017

0 Stimmen

You can give the outputs of lsqnonlin any names you like, but calling the third output "jacobian" doesn't mean that it returns the Jacobian of your function:
[par_out, residual,jacobian] = lsqnonlin(@...
The lsqnonlin function reference page shows that the function has this signature:
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(___)
In other words, the Jacobian is the seventh output, not the third.
Alan Weiss
MATLAB mathematical toolbox documentation

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

Ed
am 19 Jul. 2017

Kommentiert:

Ed
am 20 Jul. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by