Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a problem with a parameter estimation in a non-linear model. I think the culprit is that ode45 (an ode solver in matlab) is not properly solving my ode. It's the in red highlighted part, which very quickly drops and by this seems to ruin the fit.

Also interesting, this happens in all my data (10 patients) so it doesn't seem to be data dependant. I think this is stopping the optimum-fit algorithms from doing their job.

Anyone familiar with this behaviour?

EDIT: I'm working with 94 data points, and it drops between the first and the second point.

EDIT 2: It's solving the following, if this helps anyone:

$$\frac{d}{dt} y_{1}(t) = -p_{1}\cdot y_{1}(t)\; + \;p_{1}\cdot p_{2}\cdot Input(t)$$ $$\frac{d}{dt} y_2(t) = -\left(p_3+y_{1}(t)\right) \cdot y_2(t)\; +\; p_4 \;+\; R_A(t)$$

with $R(t)$ a well behaved function of time.

Plot of fit (dots data, line model prediction

share|cite|improve this question
I don't think it's possible to tell what's going on from looking at this picture. What is the ode you're trying to solve? Are you expecting a curve that goes through the circles? – Robert Israel Jan 22 '12 at 20:32
Actually, maybe it is possible to make a guess at the trouble: your ode may be singular at the initial point. In that case, no ODE solver is likely to do very well. – Robert Israel Jan 22 '12 at 20:35
Sorry if I didn't make that clear. I'm trying to minimize the sum squared error between the data (dots) and the model prediction (line) by varying the parameters of the model. I'm using the Levenberg-Marquardt algorithm to do this for a system of 2 differential equations. – BallzofFury Jan 22 '12 at 20:36
@Robert: Any ideas, if that is the case, how I might be able to get around this? It doesn't seem to be depending on the parameters, or the initial conditions of the ode. I also just tried starting it at a later time and that doesn't seem to help either. – BallzofFury Jan 22 '12 at 20:40
You seem to be right. I've interpolated the data to intervals of 1, and the jump then happens in the first minute. – BallzofFury Jan 22 '12 at 21:03

I consider it unlikely that ode45 would give you a wrong result for a fairly simple ODE such as the one you wrote down. A quick test would be to replace ode45 by another solver, for instance ode15s (you can probably just change the function name).

Thus, my guess would be that the solution of the ODE actually does drop down that fast. The plot does not look right near t = 0, but that may be an artifact of how you plot it.

Is the plot the end result of the parameter fitting? If yes, then one potential issue is that the initial estimate you gave to the optimization routine is not very good. Another possibility is that this is in fact the best fit; do you have reason to believe otherwise?

share|cite|improve this answer
Have you looked at Eureqa Formulize at It can help you with complex data fits. – ja72 Apr 24 '12 at 18:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.