# Fitting Three-Dimensional Data with Parameters

I have been trying to fit a model of rate equations to data of three dimensions. The rate equations in my model are as follows.

x2'[t] == k1 (1 - (x2[t] + x3[t] + x4[t])) - k1*x2[t] - k5*x2[t] + k5*x3[t]- 2*k2*x2[t]^2 - k3*x2[t]*x3[t] + k3*x3[t]*x4[t],
x3'[t] ==  -k5*x3[t] + k5*x2[t] + 2*k2*x2[t]^2 - 2*k4*x3[t]^2,
x4'[t] == k3*x2[t]*x3[t] - k3*x3[t]*x4[t] + 2*k4*x3[t]^2,


I am trying to fit to data with the five parameters k1,k2,k3,k4,k5. The data itself is composed of 100 points with three coordinates per point. I have attempted to fit the model by applying the following code.

equation1 = {x2'[t] ==
k1 (1 - (x2[t] + x3[t] + x4[t])) - k1*x2[t] - k5*x2[t] +
k5*x3[t] - 2*k2*x2[t]^2 - k3*x2[t]*x3[t] + k3*x3[t]*x4[t],
x3'[t] ==  -k5*x3[t] + k5*x2[t] + 2*k2*x2[t]^2 - 2*k4*x3[t]^2,
x4'[t] == k3*x2[t]*x3[t] - k3*x3[t]*x4[t] + 2*k4*x3[t]^2,
x2[0] == 0, x3[0] == 0, x4[0] == 0};

sol = ParametricNDSolve[
equation1, {x2, x3, x4}, {t, 0, 10}, {k1, k2, k3, k4, k5}];

fit = FindFit[datax234,
x4[k1, k2, k3, k4, k5][t] /. sol, {k1, k2, k3, k4, k5}, t]


The above returns an error which results because of unequal number of variables. How can I fit to data of three dimensions this way?

EDIT: Some data as requested. The three columns represent x2, x3, and x4. Each row is a three coordinate point made by the corresponding values.

0   0   0
0   0   0
0   0   0
0   0   0
0   0   0
0   0   0
0.001137656 0   0
0.001137656 0   0
0.001137656 0   0
0.004550626 0   0
0.007963595 0   0
0.007963595 0   0
0.009101251 0   0
0.009101251 0   0
0.012514221 0   0.001137656
0.011376564 0   0
0.018202503 0   0
0.023890785 0   0
0.035267349 0   0
0.04778157  0   0
0.058020478 0.001137656 0
0.064846416 0.004550626 0
0.084186576 0.003412969 0
0.101251422 0.006825939 0
0.122866894 0.004550626 0.001137656
0.149032992 0.010238908 0.003412969
0.164960182 0.011376564 0.004550626
0.188850967 0.022753129 0.003412969
0.218430034 0.026166098 0.004550626
0.246871445 0.034129693 0.007963595
0.251422071 0.040955631 0.010238908
0.266211604 0.045506257 0.011376564
0.278725825 0.053469852 0.017064846
0.283276451 0.062571104 0.020477816
0.301478953 0.070534699 0.023890785
0.313993174 0.089874858 0.023890785
0.317406143 0.100113766 0.027303754
0.348122867 0.109215017 0.038680319
0.349260523 0.119453925 0.039817975
0.34698521  0.135381115 0.056882821
0.352673493 0.14334471  0.050056883
0.372013652 0.151308305 0.060295791
0.374288965 0.153583618 0.062571104
0.340159272 0.167235495 0.070534699
0.376564278 0.177474403 0.085324232
0.377701934 0.179749716 0.087599545
0.389078498 0.194539249 0.088737201
0.386803185 0.202502844 0.089874858
0.37883959  0.202502844 0.081911263
0.386803185 0.204778157 0.09556314
0.377701934 0.219567691 0.104664391
0.377701934 0.226393629 0.105802048
0.395904437 0.215017065 0.118316268
0.393629124 0.22298066  0.122866894
0.391353811 0.220705347 0.125142207
0.377701934 0.219567691 0.136518771
0.364050057 0.216154721 0.154721274
0.353811149 0.236632537 0.146757679
0.359499431 0.215017065 0.158134243
0.333333333 0.22298066  0.170648464
0.323094425 0.224118316 0.187713311
0.33105802  0.224118316 0.177474403
0.328782708 0.23890785  0.195676906
0.324232082 0.227531286 0.221843003
0.308304892 0.228668942 0.233219568
0.295790671 0.236632537 0.240045506
0.296928328 0.236632537 0.229806598
0.287827076 0.250284414 0.228668942
0.299203641 0.246871445 0.229806598
0.300341297 0.245733788 0.224118316
0.30261661  0.252559727 0.230944255
0.290102389 0.252559727 0.240045506
0.300341297 0.25483504  0.248009101
0.304891923 0.259385666 0.237770193
0.304891923 0.242320819 0.258248009
0.299203641 0.259385666 0.260523322
0.287827076 0.253697383 0.274175199
0.268486917 0.266211604 0.269624573
0.275312856 0.255972696 0.279863481
0.276450512 0.265073948 0.283276451
0.282138794 0.237770193 0.285551763
0.279863481 0.232081911 0.30261661
0   0   0
0.274175199 0.258248009 0.290102389
0.288964733 0.261660978 0.273037543
0.276450512 0.257110353 0.299203641
0.268486917 0.244596132 0.291240046
0   0   0
0   0   0
0   0   0
0   0   0
0   0   0
0.248009101 0.23890785  0.33105802
0.22298066  0.234357224 0.358361775
0.22298066  0.23890785  0.342434585
0.217292378 0.244596132 0.353811149
0.22298066  0.240045506 0.359499431
0   0   0
0.208191126 0.246871445 0.3629124
0.205915813 0.257110353 0.370875995
0.210466439 0.229806598 0.353811149

• Could you explain the meaning of each coordinate in the triplets representing your data points? x1, x2, x3, x4 all return a single value, so the fit will certainly fail as written. Also, can you share a portion of your data, and perhaps provide a link to a file containing your original data? Finally you will probably have to create a dummy objective function protected from premature symbolic evaluation using NumericQ on its arguments (see (this FAQ). – MarcoB Jun 10 '16 at 21:24
• Each coordinate is simply a position in some space that I call "Trajectory space" Each point is a snapshot of the position of this point at some time step. The coordinate is composed of (x2,x3,x4) as its coordinates so that is why the rate equations are defined with these variables. My goal is to fit the model to data of an experimental trajectory. Can you please elaborate on the dummy function? I am very new at this kind of analysis. I will add a part of my data above as an edit. – Aeromance Jun 12 '16 at 1:06
• How much is the time-bin for each point? – demm Jun 24 '16 at 13:23
• Each time step is just represented by a step so down the rows, each subsequent row is one additional "time-step" starting at zero. What I have been doing, is making a parametric plot of the solutions with respect to time and seeing if that fits the experimental parametric trajectory. – Aeromance Jun 27 '16 at 19:23