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:
- I interpolate the data at t=0.
- I solve the differential equation with guesses for the coefficients. I use the interpolation from t=0 as an initial condition.
- I compare the differential equation solution and the actual data by calculating a residue.
- 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.