1
$\begingroup$

I'm trying to extract 4 parameters by fitting one set of data with an ODE via NonlinearModelFit. I originally thought the process should be straightforward, but later on I found I was totally wrong.

The data shown below has a sigmoidal curve:

data={{0,0},{49.7775,0.0229687},{99.555,0.0675156},{149.333,0.124518},{199.11,0.190047},{248.888,0.261029},{298.665,0.334263},{348.443,0.406511},{398.22,0.474956},{447.998,0.537032},{497.775,0.591725},{547.553,0.639402},{597.33,0.680795},{647.108,0.717289},{696.885,0.749756},{746.663,0.77867},{796.44,0.804481},{846.218,0.827329},{895.995,0.847812},{945.773,0.866318},{995.55,0.883013},{1045.33,0.897972},{1095.11,0.911227},{1144.88,0.92315},{1194.66,0.933717},{1244.44,0.943222},{1294.22,0.951594},{1343.99,0.958822},{1393.77,0.965246},{1443.55,0.970854},{1493.33,0.975964},{1543.1,0.98057},{1592.88,0.984747},{1642.66,0.988132},{1692.44,0.991107},{1742.21,0.993695},{1791.99,0.995825},{1841.77,0.997373},{1891.55,0.998711},{1941.32,0.999723},{1991.1,1}};

The model with 4 target parameters (n, m, Ea, LogZ) is below:

model65[n_?NumberQ,m_?NumberQ,Ea_?NumberQ,LogZ_?NumberQ]:=Module[{α,t},First[α /.NDSolve[{α'[t] == ((10^LogZ)/60) Exp[-Ea/(8.314 (65 + 273.15))] α[t]^m (1 - α[t])^n, α[0] == 0}, α, {t, 0, 2400}]]]

Using NonLinearModelFit to extract n, m ,Ea, LogZ (with initial guesses):

fit = NonlinearModelFit[data,model[n, m, Ea, LogZ][t], {{n, 1.5}, {m, 0.5},{Ea, 85000}, {LogZ, 10}}, t];
fit["BestFitParameters"]

Below is the error message I'm having:

NonlinearModelFit::fmgz: Encountered a gradient that is effectively zero. The result returned may not be a minimum; it may be a maximum or a saddle point. >>

Can anyone please help me with this problem? Thank you in advance for the great help!

$\endgroup$
2

1 Answer 1

1
$\begingroup$

I think the system can be simplified. There is no t dependence in ((10^LogZ)/60) Exp[-Ea/(8.314 (65 + 273.15))]). Time can also be rescaled. Jittering initial condition "just off" zero.

After this,

s = y /. ParametricNDSolve[{y'[t] == a y[t]^b (1 - y[t])^c, 
     y[0] == 0.001}, y, {t, 0, 1}, {a, b, c}];
datar = Transpose[{Rescale[#1], #2} & @@ Transpose[data]];

Now fit model (rescaled and simplifying a=1):

nlm = NonlinearModelFit[datar,s[a, b, c][t], {{a, 6}, {b, 0.21}, {c, 1.1}}, t];
Show[ListPlot[datar, PlotMarkers -> {Automatic, 8}],Plot[nlm[t], {t, 0, 1}, PlotStyle -> Red]]
nlm["BestFitParameters"]

where b and c are exponents and a is constant. enter image description here

I hope this is helpful. Note: I used Manipulate to help with starting values. I have left the full aim to OP or others.

$\endgroup$
3
  • $\begingroup$ Thank you so much @ubpdqn !! Just wondering why the time has to be scaled to make the NonlinearModelFit works? Will these fitted parameters be applicable to the real time scale? I really appreciate your great help! $\endgroup$
    – DavidC
    Mar 28, 2016 at 20:56
  • $\begingroup$ @DavidC apologies for delay (time zones). I do not think it needed rescaling but it just made it easier for me. Just look at what rescale does and you will be able to work it out.:) $\endgroup$
    – ubpdqn
    Mar 28, 2016 at 22:14
  • $\begingroup$ @ubpdqnThank you! I really appreciate your great help :) $\endgroup$
    – DavidC
    Mar 29, 2016 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.