# Fitting data using ParametricNDSolveValue and NonlinearModelFit [closed]

I'm trying to evaluate the kinetics of the chemical reaction. For that I need to fit my experimental data to the kinetic equation. These are my steps in Mathematica.

data = Import["for model.xlsx"][[4]]
(* {{0., 182.115, 0.}, {1., 166.486, 1.87153}, {5., 136.178, 9.76618}, {10., 112.277, 19.1688}, {15., 111.448, 27.2978}, {25., 81.5446, 43.3609}, {35., 73.6962, 56.2542}, {45., 62.9892, 62.6874}, {55., 50.7161, 68.5274}, {65., 45.2139, 79.0054}} *)
{time, Xylose, Furfural} = Transpose[data];
Fin = Furfural[[1]];
Xin = Xylose[[1]];

sol = ParametricNDSolveValue[
{X'[t] == -a X[t] - b X[t], X[0] == Xin
, F'[t] == a X[t] - c F[t], F[0] == Fin}
, {F, X}
, {t, 0, 240}, {a, b, c}];
transformeddata = {ConstantArray[Range@Length[{Xylose, Furfural}], Length[time]] // Transpose, ConstantArray[time, Length[{Xylose, Furfural}]], {Xylose, Furfural}}~Flatten~{{2, 3}, {1}};
model[a_, b_, c_][i_, t_] := Through[sol[a, b, c][t], List][[i]] /; And @@ NumericQ /@ {a, b, c, i, t};
fit = NonlinearModelFit[transformeddata, model[a, b, c][i, t], {a, b, c}, {i, t}];
fit["RSquared"]
(* 0.398171 *)
fit["ParameterTable"]


Show[ListPlot[Table[Take[data, All, {1, l, l - 1}], {l, 2, 3}], PlotStyle -> PointSize[0.02]], Plot[{fit[1, t], fit[2, t]}, {t, 0, 70}]]


And as a final result I got this picture

And that was the best what I was able to get. I tried to put the guess for the values, nothing helped. The results and the fit doesn't make any sense. Can you help me to understand is it a problem in my coding or is it something wrong with my kinetic equations? Thank in advance!

## closed as off-topic by Dr. belisarius, m_goldberg, Karsten 7., MarcoB, ilianNov 19 '15 at 5:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Dr. belisarius, m_goldberg, Karsten 7., MarcoB, ilian
If this question can be reworded to fit the rules in the help center, please edit the question.

• ...and where's "for model.xlsx"? – J. M. is computer-less Nov 17 '15 at 18:19
• first you may notice your X equation is decoupled and has a trivial analytic solution. Making use of that may help. – george2079 Nov 17 '15 at 18:21
• Also, Without digesting the whole thing, you have somewhere transposed F and X. Your weird solution is because the X function is struggling to match the F initial condition and vice versa. – george2079 Nov 17 '15 at 18:26
• indeed switching {F,X} to {X, F} in ParametricNDSolveValue gives a nice result.. – george2079 Nov 17 '15 at 18:30
• Dear george2079, thanks a lot for the comment! Seems that I messed up! :) I switched {F,X} to {X, F} in ParametricNDSolveValue and now it works! – OlgaE Nov 18 '15 at 9:39