MATLAB: Error in nlparci in MatlabR2016b: The number of observations must exceed the number of parameters.

lsqcurvefitMATLABnlparcistatistics toolbox

I have an error in nlparci in MatlabR2016b:
Error using nlparci (line 34)
The number of observations must exceed the number of parameters.
The syntax I use:
ci=nlparci(Y1pars,res1,'jacobian',J1);
It worked fine in Matlab R2015a.
when debugging, it seems that in nlparci in
line 32: [m,n] = size(J);
J should refer to J1 but it refers to the string 'jacobian'. is this a bug? I realized nlparci in R2015a is different.

Best Answer

Star is correct. You cannot uniquely estimate the coefficients of a model that has more parameters than unknowns. There are infinitely many solutions, all equally good in terms of the fit. IF you think that you were using nlparci before on similar underdetermined problems, you are either wrong, or perhaps nlparci was giving you garbage for results. Almost certainly, it is the former case, but they may have fixed nlparci to err out on the underdetermined case. That is certainly the correct result.
Confidence intervals make no sense at all on an underdetermined problem. Sorry, but they don't. The point is, you need essentially at least n+1 distinct points to estimate n parameters, if you wish to also estimate confidence intervals.
Now, as to your question about a problem in nlparci. In order to debug what you have done, I think you need to show more than just the single line where you call nlparci, since the inputs to that function are crucially important, and they are created from nlinfit. Simplest is if you supply all of the inputs to nlparci in a .mat file. I suppose better yet is if you also include the original data and the model, so I can see how nlinfit was called. You can attach that file to a comment on this response.
My guess is that you are making a mistake in what you are doing, but I cannot really know what you have done wrong. For example, this works fine:
x = rand(100,1);
y = sin(x) + randn(size(x))/10;
modelfun = @(par,x) par(1) + par(2)*sin(x + par(3));
[BETA,R,J,COVB,MSE] = nlinfit(x,y,modelfun,[.1 1.25 .1]);
CI = nlparci(BETA,R,'jacobian',J)
CI =
-0.54335 0.4273
0.68449 1.248
-0.34875 0.53169
This was done using R2016b. The confidence intervals are reasonable, and contain the underlying true value for those parameters within the bounds.