Fitting global parameters using fminsearch with nested ode
17 views (last 30 days)
Show older comments
Matthias Müller
on 15 Feb 2016
Commented: Star Strider
on 15 Feb 2016
Hello,
I have a problem fitting a parameter to experimental data. The model equations build a system of ODE´s. The simplified version looks like this (A and B are model parameters, C is a constant):
dx1_dt = -A*(x1-x2)
dx2_dt = A*(x1-x2) - B*(x2-C)
The task is to estimate the optimal value of A and B for both, x1(t) and x2(t).
Currently I use fminsearch with a nested ode45 in a loop. I calculate the RMSE for x1 and x2, then add them together to a global RMSE and give it back to fminsearch as quality criteria. It works quite well if you´re not in a hurry.
But I believe theres a better way to do it.
Please consider that I don´t have access to any toolboxes. I am aware of fminsearch´s drawbacks. More generally I am wondering how the algorithm should look like.
Thanks in advance.
mulm
2 Comments
Torsten
on 15 Feb 2016
There is no easier way to proceed as the one you describe above.
You can speed up the calculations by solving your system of ODEs analytically (which is at least possible for your simplified version from above) and/or to use the optimization toolbox. But I think both options are not possible for you.
For a guideline, take a look at
Best wishes
Torsten.
Accepted Answer
Star Strider
on 15 Feb 2016
I refer you to: Monod kinetics and curve fitting. I used lsqcurvefit here, but you can use fminsearch with slight modification of the code.
2 Comments
Star Strider
on 15 Feb 2016
My pleasure!
You can create a least-squares estimator using fminsearch fairly easily:
x = ...; % Independent Variable Data
y = ...; % Dependent Variable Data
obj_fcn = @(B,xdata) ...; % Objective Function (Incorporating Your ODE)
SSECF = @(B) sum((y - obj_fcn(B,xdata)).^2); % Sum-Squared-Error Cost Function
B_init = [ ... ]; % Initial Parameter Estimate Vector
[B_hat,SSE] = fminsearch(SSECF, B_init); % Estimate Parameters (‘SSE’ Is The Sum-Squared-Error At Convergence)
y_fit = obj_fcn(B_hat, x);
figure(1)
plot(x, y, 'bp') % Plot Data
hold on
plot(x, y_fit, '-r') % Plot Fitted Data
hold of
grid
I just sketched it out here, so you will likely have to modify it a bit to make it work with your code.
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!