Clear Filters
Clear Filters

Problem with Fit Data in SimBiology

11 views (last 30 days)
Good afternoon
I built the physiologically based pharmacokinetic (PBPK) model of nanoparticles. It has 10 compartments, about 30 parameters.
When I try to fit my model to experimental data (Fit Data), Matlab either freezes (does not respond to requests, I have to restart it), or it takes a very long time after which it gives an error (for example, the matrix is singular). If the data fitting begins, no more than 10 iterations take place, after which the fitting ends and the obtained values have a huge error. So I could not approximate the data, even for one compartment and two or three parameters.
At the same time, changing the model parameters during the simulation leads to change in the shape of the curve, but I can’t fit all the parameters.
Verification of the model does not find any error in the model. All other functions work normally (simulation, sensitivity analysis).
My data was imported from a .txt file.
What could be the problem?
You can get the file from the link:

Accepted Answer

Sietse Braakman
Sietse Braakman on 25 Feb 2020
Edited: Sietse Braakman on 25 Feb 2020
Hi Valentina,
Looking at your description of the problem and the files you attached I have a few thoughts on what could be happening.
  • During the optimization process, the optimization algorithm will propose parameter values to simulate the model with. An optimization often gets stuck when the parameters that the model is simulated with cause "stiff" model behavior: the solution changes very rapidly with time and the solver needs to take many small time-steps to calculate the solution to the ODEs within the tolerance requested. Because solving the ODEs requires so many time steps, it can take a long time. An examples when this can happen is when, during optimization, a parameter that occurs in the denominator in your ODEs, goes to zero. As a result, the particular term with that parameter in the denominator will increase rapidly, cause fast changes and "stiff" behavior. Suggestion 1: I recommend using a stiff ODE solver (sundials or ode15s), see also here. Note that even when using a stiff solver, this behavior can still occur. Suggestion 2: impose log-transformation of the parameters you are estimating. This ensures positivity of the parameters. See here, under point 6. It looks like you’re already doing this in the project you attached. Suggestion 3: impose lower and upper bounds on the parameters you are estimating. See here, under point 7. Suggestion 4: Use the progress plot for the optimization to see whether any parameters are ‘exploding’ or going to zero during subsequent iterations. Perhaps fix those parameters (don’t estimate) to start with.
  • When you say MATLAB doesn't respond, what is likely going on is that SimBiology is simulating an iteration of the model that is extremely "stiff". Because SimBiology accelerates simulations by compiling the model to C-code, the simulation doesn't take place in MATLAB (but in C) and therefore cannot be paused at that point. As a result, your MATLAB session appears stuck. If you encounter this again, you could try to repeatedly use the Ctrl-C (Command + period-key on Mac) command to interrupt the computation and get MATLAB to respond again.
  • In your fit task, your response is for the liver data only but you have multiple responses in your data. SimBiology supports using multiple responses for estimation, see also this nanoparticle project. You can add responses for the spleen, plasma etc. by mapping the data columns to the appropriate component in your model.
  • It looks like the data you used isn’t appropriately formatted for SimBiology’s estimation. I am making the assumption that your dose is only administered at time zero. If this is the case, your data should have a row with time stamp zero and the corresponding dose amount (87 for the Yodel dataset), while all responses are left empty (in excel), or NaN (once imported in MATLAB/SimBiology). Similarly, the entries in the dose column after time zero should be empty. See screenshot at point 5 here.
Here are some further relevant resources on parameter estimation with SimBiology.

More Answers (1)

Valentina Kasianova
Valentina Kasianova on 25 Feb 2020
Thank you very much for your detailed answer.
I delved into this topic and program completely myself, by video and webinars, so I don't fully understand some issues.
I will try to follow your advice and suggestions.


Find more on Scan Parameter Ranges 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!