Working out a metric for the goodness of fit for 2D data in time

I have a dataset which I wish to optimise a fit for. The data might look something like

I.e. orange is t=0, blue is t=1, and green is t=2.

I wish to find a fit. I have a differential equation which I think will fit well and I'm interested in modelling.

My method is as follows:

1. I interpolate the data at t=0.
2. I solve the differential equation with guesses for the coefficients. I use the interpolation from t=0 as an initial condition.
3. I compare the differential equation solution and the actual data by calculating a residue.
4. I try to minimize the residue by altering the guesses in step 2.

My question is how best to calculate the residue - i.e. what metric to use to work out how well the fit works.

At the moment I calculate the residue by calculating the magnitude difference between the solution and original data. However, this means I give less weighting for smaller signals - which mean my fit works well at the start, but don't fit as well in long time as the signals have a smaller magnitude.

Is there a better way I can calculate the goodness of fit? Is it appropriate to calculate the goodness of fit for each time frame then sum? Or should I do it at all frames at once?

I'm struggling here - so any pointers to good resources or reading would be appreciated.

• If all dependent data values are greater than zero, you can calculate the relative error giving you a fit to the lowest percent error. – James Phillips Mar 19 at 17:01
• So a percentage error? - How do I add the percentages from each frame in the video? just a sum? – Tomi Mar 19 at 18:10
• The same way you were using magnitude previously, use relative magnitude. – James Phillips Mar 19 at 18:16