I have the following two sets of experimental data, which show the dependencies of two quantities, namely, $S$ and $B$, on time ($0$ h, $3$ h, $6$ h, $9$ h, $15$ h, $18$ h, $21$ h, and $24$ h):
Sdata = {{0, 9.74},{3, 4.92},{6, 8.29},{9, 5.54},{15, 2.08},{18, 1.38},{21, 1.99},{24, 0.893}};
Bdata = {{0, 0.915094},{3, 0.736097},{6, 0.793694},{9, 0.833664},{15, 1},{18, 0.99578},{21, 0.897964},{24, 0.214499}};
I'm trying to model the dynamics of the above data by the following differential equations:
$$\frac{dS(t)}{dt} = 0.31 S(t) \Big( 1 - \frac{S(t)}{6.19} \Big) - \frac{a}{1 + b B(t)} S(t),$$
$$\frac{dB(t)}{dt} = c (1 - B(t)) - d B^2(t) \Big( \frac{1 - B(t)}{B(t)} \Big)^{0.96},$$
where $a$, $b$, $c$, and $d$ are some real, preferably positive, constants to be determined from the data.
S'[t] == 0.31 S[t] (1 - S[t]/6.19) - a/(1 + b B[t]) S[t]
B'[t] == c (1 - B[t]) - d B[t]^2 ((1 - B[t])/B[t])^0.96
Now, I'm trying to obtain the constants of my model using Mathematica. I found this answer might be helpful; but, this answer only deals with one set of data.
Any help or hint is appreciated.
EDIT
With the help of @ydd answer, I could modify the model and could do fitting with Mathematica:
Modified model:
$$\frac{dS(t)}{dt} = - \frac{a}{1 + B(t)} S(t),$$
$$\frac{dB(t)}{dt} = \frac{c}{1 + S(t)} B(t) - d B^2(t) \Big( \frac{1 - B(t)}{B(t)} \Big)^n,$$
where $a$, $c$, $d$, and $n$ are constants to be determined from the data.
We have:
Sdata = {{0, 9.74}, {3, 4.92}, {6, 8.29}, {9, 5.54}, {15, 2.08}, {18,
1.38}, {21, 1.99}, {24, 0.893}};
Bdata = {{0, 0.915094}, {3, 0.736097}, {6, 0.793694}, {9,
0.833664}, {15, 1}, {18, 0.99578}, {21, 0.897964}, {24, 0.214499}};
order = 1;
interpolatedData = {intS,
intB} = {Interpolation[Sdata, InterpolationOrder -> order],
Interpolation[Bdata, InterpolationOrder -> order]};
sys = {S'[t] == -a/( 1 + B[t]) S[t],
B'[t] == c B[t]/(1 + S[t]) - d B[t]^2 ((1 - B[t])/B[t])^n};
squareDiffs = MapApply[(#1 - #2)^2 &, sys];
withInt[t_] = squareDiffs /. {S -> intS, B -> intB};
totalSquaredError = Total@Flatten[withInt /@ (Range[0, 24, 3])];
forMin = Join[{totalSquaredError}, restrictions];
restrictions = Thread[{a, c, d, n} > 0];
{resid, bestFitParams} =
NMinimize[forMin, {a, c, d, n}, Method -> "RandomSearch"]
init = {S[0] == Sdata[[1, 2]], B[0] == Bdata[[1, 2]]};
new = Join[sys /. bestFitParams, init];
{sSol[t_], bSol[t_]} = NDSolveValue[new, {S[t], B[t]}, {t, 0, 24}];
lp = ListPlot[Bdata];
p = Plot[bSol[t], {t, 0, 24}, PlotRange -> All];
Show[lp, p]
lpp = ListPlot[Sdata];
pp = Plot[sSol[t], {t, 0, 24}, PlotRange -> All];
Show[lpp, pp]
Now, I have a question which is mostly mathematical: Can one slightly modify these two differential equations in order the fitted curve to the red data, i.e., $B(t)$, also captures the bump in the data around $t = 15$?






B[t]with parametersc,d. You should first check your model for this single ode. My simulations don't evaluate in this case (NMinimize,NonlinearModelFit) – Ulrich Neumann Nov 22 '23 at 17:01