My equation is:
alpha=1+B.*(1-exp(-C.*t.*tau));
dydt = Kg.*(1-y./ymax).*y-((C.^H).*Kk)./(C.^H+alpha.*C50k.^H).*y;
I am trying to estimate 6 parameters which are B, tau, ymax, H, C50k, and Kk with minimal sum of squares.
I have start a file, but I am receiving errors such as:
lsqcurvefit stopped because the size of the current step is less than
the default value of the step size tolerance.
my codes are:
%First File
function dydt = BP1(t,y,ModelParams)
C=4;
Kg=2.31;
Kk=ModelParams(1);
C50k=ModelParams(2);
H=ModelParams(3);
ymax=ModelParams(4);
B=ModelParams(5);
tau=ModelParams(6);
alpha=1+B*(1-exp(-C*t*tau));
dydt = Kg*(1-y/((ymax*10^9))*y-((C^H)*Kk)/(C^H+alpha*C50k^H))*y;
%Second File
function y = BP2(ModelParams,t,y0)
[t,y]=ode45(@BP1,t,y0,[],ModelParams);
%Third File
t=[0 2 4 8 12 24];
y0=8.216*10^8;
A=[8.216 8.216 8.002 7.834 7.882 8.312];
ydata=A'*10^8;
ydata(1)=y0;
ModelParams0=[3.2,2,2.4,10,6,.01];
options = optimset('MaxFunEvals', 1000, 'MaxIter', 1000);
ModelParams_Fit=lsqcurvefit(@BP2,ModelParams0,t,ydata,[],[],options,y0);
parameters = (ModelParams_Fit)
Would fmincon be more reliable for parameter estimation?
The exit message you report does not represent an error. Instead, it
tells you the reason lsqcurvefit stopped. lsqcurvefit probably returned
a good solution. For more information, see
http://www.mathworks.com/help/toolbox/optim/ug/brwvb8m.html#brw34o7
Alan Weiss
MATLAB mathematical toolbox documentation
I am guessing that the major reason why some use nlinfit or lsqcurvefit depends on whether you have the stats or optimization toolbox. With lsqcurvefit, I would think that the LM algorithm would be better for most odes?
Not sure, but in your options you may want to try LM method vs the trust region which is the default for lsqcurvefit.
If you have the stats toolbox, I recommend trying nlinfit with some of the options. LM is default for nlinfit plus you can develop confidence and predictive intervals with nlinfit combined with nlparci and nlpredci.