MATLAB Answers

Handling incorrect parameter values in sbiofit and sbiofitmixed

2 views (last 30 days)
Ben on 14 Mar 2021
Commented: Ben on 15 Mar 2021
I have a question regarding the regression tools in SimBiology. I have an ODE model which I would like to fit for a given dataset using sbiofit or sbiofitmixed. When i want to find some parameter set using sbiofitmixed, the ODE model can return with invalid values (e.g. complex, NaN or Inf) which completely halts the search process. My experience with sbiofit is that the algorithms can recover from these values (as opposed to sbiofitmixed) for the vast majority of cases, but in some occasion the procedure still halts. Even if I set bounds on my parameters, there could be a (hidden) nonlinear relationship which makes the ODE invalid for a specific combination of the fitted parameter values. The following error message can occur using sbiofitmixed:
Error using sbiofitmixed (line 249)
A simulation errored or returned NaN, Inf, or complex values during parameter estimation. This typically indicates that the estimated parameter values converged to values that are invalid for the model.
My question is if there is any way to recover sbiofitmixed from these parameter values? For example defining an event during the ODE simulation which stops the integration. It would be nice, if there was a way to find a different trial point for the current iteration in such cases for the algorithm.
Bonus question: Is there any 'best practice' in the literature to handle these situations? For example if I code the algorithm by hand, I could just stop the integration if some state variable exceeds some given value. At these instances I could just set the cost function to some high value (for example 1e5), however I have a gut feeling that this is not the best solution for this issue.
Thank you in advance,

Accepted Answer

Florian Augustin
Florian Augustin on 15 Mar 2021
Hello Czakó,
Unfortunately, it is currently not possible to stop model simulations in SimBiology programatically. A better error handling has been requested by multiple users and we are investigating the options. But this is not available at this point (R2020b). Currently, the only way to explore different starting points is to run sbiofitmixed with different initial values, which may not prevent running into parameter region where model simulations fail.
Since there is not much you can do with tweaking the ode integration or sbiofitmixed, you could try to find values for fixed / random effects / covariates where the model simulation returns nan or complex values by looking at the progress plot. It is very technical, but you could also set a breakpoint in the Matlab debugger (run dbstop if caught to set, and dbclear if caught to clear the breakpoint) before running the fit. This will stop the Matlab debugger in the internal functions of SimBiology; the failing set of parameter values is likely in the phi or initialValues input argument of the functions that is executed.
This may give you some information about parameter values for the fixed / random effects where the fit fails. Running a scan task by sampling from the random effects could give some insight which model dynamics and parameter values are the culprit for failing simulations.

More Answers (0)


More Answers in the  SimBiology Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!