2 edited body

This is an example of what I want to do. I want to calculate the best fit parameters from a set of experimental data with 3 and more differential equations. I use NDSolveValue to find the interpolation functions and I select one of them to calculate the best fit parameters. As example :

model[par1_: 1, par2_: 0.1, par3_: 2] := Module[{},

rate1 = par1*y[t];
rate2 = par2*y[t];
rate3 = par3*y[t]*z[t];

eq1 = y'[t] + rate1 == 2;
eq2 = z'[t] + rate2 == 0;
eq3 = w'[t] + rate3 == 1;

eqs = {eq1, eq2, eq3};
ic = {y == 2, z == 1, w == 1};
NDSolveValue[{eqs, ic}, {y, z, w}, {t, 0, 10}]
]


Now I create some random data for the w and run the NonLinearModelFit function

 expwvals =
Table[Evaluate@{t, model[1, 3, 5][][t]}, {t, 1, 10, 1}] +
Table[{0, RandomReal[{-20, 150}]}, {i, 1, 10, 1}]
ListPlot[expwvals]
nlf = NonlinearModelFit[expwvals,model[p1, p2, p3][t][]p3][][t], {{p1, 1}, {p2,
3}, {p3, 5}}, t]


However the selection of the third interpolation function as, model[p1, p2, p3][t][]p3][][t] doesn't work. How could I select the w interpolation factor to use it for fitting ? Your help is appreciated.

This is an example of what I want to do. I want to calculate the best fit parameters from a set of experimental data with 3 and more differential equations. I use NDSolveValue to find the interpolation functions and I select one of them to calculate the best fit parameters. As example :

model[par1_: 1, par2_: 0.1, par3_: 2] := Module[{},

rate1 = par1*y[t];
rate2 = par2*y[t];
rate3 = par3*y[t]*z[t];

eq1 = y'[t] + rate1 == 2;
eq2 = z'[t] + rate2 == 0;
eq3 = w'[t] + rate3 == 1;

eqs = {eq1, eq2, eq3};
ic = {y == 2, z == 1, w == 1};
NDSolveValue[{eqs, ic}, {y, z, w}, {t, 0, 10}]
]


Now I create some random data for the w and run the NonLinearModelFit function

 expwvals =
Table[Evaluate@{t, model[1, 3, 5][][t]}, {t, 1, 10, 1}] +
Table[{0, RandomReal[{-20, 150}]}, {i, 1, 10, 1}]
ListPlot[expwvals]
nlf = NonlinearModelFit[expwvals,model[p1, p2, p3][t][], {{p1, 1}, {p2,
3}, {p3, 5}}, t]


However the selection of the third interpolation function as, model[p1, p2, p3][t][] doesn't work. How could I select the w interpolation factor to use it for fitting ? Your help is appreciated.

This is an example of what I want to do. I want to calculate the best fit parameters from a set of experimental data with 3 and more differential equations. I use NDSolveValue to find the interpolation functions and I select one of them to calculate the best fit parameters. As example :

model[par1_: 1, par2_: 0.1, par3_: 2] := Module[{},

rate1 = par1*y[t];
rate2 = par2*y[t];
rate3 = par3*y[t]*z[t];

eq1 = y'[t] + rate1 == 2;
eq2 = z'[t] + rate2 == 0;
eq3 = w'[t] + rate3 == 1;

eqs = {eq1, eq2, eq3};
ic = {y == 2, z == 1, w == 1};
NDSolveValue[{eqs, ic}, {y, z, w}, {t, 0, 10}]
]


Now I create some random data for the w and run the NonLinearModelFit function

 expwvals =
Table[Evaluate@{t, model[1, 3, 5][][t]}, {t, 1, 10, 1}] +
Table[{0, RandomReal[{-20, 150}]}, {i, 1, 10, 1}]
ListPlot[expwvals]
nlf = NonlinearModelFit[expwvals,model[p1, p2, p3][][t], {{p1, 1}, {p2,
3}, {p3, 5}}, t]


However the selection of the third interpolation function as, model[p1, p2, p3][][t] doesn't work. How could I select the w interpolation factor to use it for fitting ? Your help is appreciated.

1

# How to find best fit parameters from interpolation functions by using NDSolveValue

This is an example of what I want to do. I want to calculate the best fit parameters from a set of experimental data with 3 and more differential equations. I use NDSolveValue to find the interpolation functions and I select one of them to calculate the best fit parameters. As example :

model[par1_: 1, par2_: 0.1, par3_: 2] := Module[{},

rate1 = par1*y[t];
rate2 = par2*y[t];
rate3 = par3*y[t]*z[t];

eq1 = y'[t] + rate1 == 2;
eq2 = z'[t] + rate2 == 0;
eq3 = w'[t] + rate3 == 1;

eqs = {eq1, eq2, eq3};
ic = {y == 2, z == 1, w == 1};
NDSolveValue[{eqs, ic}, {y, z, w}, {t, 0, 10}]
]


Now I create some random data for the w and run the NonLinearModelFit function

 expwvals =
Table[Evaluate@{t, model[1, 3, 5][][t]}, {t, 1, 10, 1}] +
Table[{0, RandomReal[{-20, 150}]}, {i, 1, 10, 1}]
ListPlot[expwvals]
nlf = NonlinearModelFit[expwvals,model[p1, p2, p3][t][], {{p1, 1}, {p2,
3}, {p3, 5}}, t]


However the selection of the third interpolation function as, model[p1, p2, p3][t][] doesn't work. How could I select the w interpolation factor to use it for fitting ? Your help is appreciated.