From: Tim on
Hi,

I built a function for use with nlinfit, see below:
yhat = (b3.*x1.^b1.*x2.^b2.*x3.*x4.*x5.*x6);

I'm happy with my results but was curious about nlintool. When I tried that
I recieved the following error:

??? Error using ==> set
Bad value for axes property: 'XLim'
Values must be increasing and non-NaN.

Error in ==> nlintool at 270
set(nlin_axes(k),'XLim',xlims(k,:),'Box','on','NextPlot','add',...

I was able to get nlintool to work but only when I modified my equation to:
yhat = (b3.*x1.^b1.*x2.^b2);

b3 is meant to be a factor times the entire equation and I want my regression paramaters for x3, x4, x5 and x6 to be forced to 1. It seems the opimization toolbox might(?) be helpful, but I don't have that. Any thoughts?

Thanks,

Tim
From: Tom Lane on
> I built a function for use with nlinfit, see below:
> yhat = (b3.*x1.^b1.*x2.^b2.*x3.*x4.*x5.*x6);
>
> I'm happy with my results but was curious about nlintool. When I tried
> that
> I recieved the following error:
>
> ??? Error using ==> set
> Bad value for axes property: 'XLim'
> Values must be increasing and non-NaN.

Tim, I assume you have no NaN values in your x or y data. It's possible that
the function encountered NaN somewhere along the way as it tried different
parameter values. For example, if there are zeros in the x values and one
parameter had a trial value that was negative, I can see this happening.

If you're comfortable with this sort of thing, you could "dbstop on error"
and try to poke around and see how things look when the error occurs.

I tried the following and it worked okay. Notice that I had to re-write your
expression to have just one coefficient vector and a matrix of x values. I
presume you did this too, or you embedded your expression in a function
where you unpacked the b and x values.

>> f = @(b,x)
>> (b(3).*x(:,1).^b(1).*x(:,2).^b(2).*x(:,3).*x(:,4).*x(:,5).*x(:,6));
>> x = rand(100,6);
>> y = f(1:3,x) + randn(100,1)/10;
>> nlinfit(x,y,f,[1 1 1])
ans =
1.6870 1.8919 3.9972
>> nlintool(x,y,f,[1 1 1])

-- Tom