I am trying to calculate the 95% confidence interval on parameters for my model fitted using lsqcurvefit. The curvefit is working great overall and the fitted parameters seem correct. But I am having trouble calculating the CIs.
First of all, is nlparci the correct function to use for this purpose? If it is not, can someone please guide me on how to get the CIs for the fitted parameters? If it is, then I have a big problem since I get the Error message: "??? Undefined function or method 'nlparci' for input arguments of type 'double'."
Seems that there is something wrong with the jacobian matrix, but I cannot solve the problem.
Has anyone a full example of calculating the confidence intervall of a 3 dimensional function in connection with lsqcurvefit? I have spent hours on the internet but could not get it to work.
Thanks in advance!
You shouldn't be getting an ‘undefined function’ error with nlparci if everything is working as it should. To be sure you have it and you don't have another function shadowing it, I suggest entering from the Command Line:
which nlparci -all
The lsqcurvefit function is part of the Optimization Toolbox, and nlparci is part of the Statistics Toolbox, so you have to have the Statistics Toolbox to use nlparci. If you supplied your own analytic Jacobian to lsqcurvefit, you may have to transpose it to make it work with nlparci. I had this problem in the past with an analytic Jacobian, however in that situation, nlparci should be throwing an error telling you that the dimensions of the parameter, residual, and Jacobian don't match.
Seems that I don't have the statistics toolbox since the "which nlparci -all" already gives a " 'nlparci' not found. " . Does this mean I cannot derive the confidence intervalls for my parameters?
Or is there any way to calculate the confidence intervals manually? I must admit my mathematical knowledge in this area is not really profound. I have read that the jacobi matrix can be used to calculate them but I didn't understand how.
Do you by any chance have a script that determines the confidence intervalls manually?
So far my fitting command looks like this: [p,resnorm,residual,exitflag,output,lambda,jacobian]=lsqcurvefit(@esx_2dfunc_col,p0,r,dat(:),[0 0 0 wmin wmin 0 0],[10 50 50 wmax wmax 12 3],... optimset('MaxFunEvals',4000,'MaxIter',1000));
the function esx_2dfunc_col is quite sick, but that shouldn't play a role for the determination of the confidence intervalls as far as I understood the problem.
Thanks already for your help :)