# Fit simbiology model to cmax or AUC data

2 views (last 30 days)
Oscar on 27 Oct 2023
Commented: Arthur Goldsipe on 1 Nov 2023
I have a simbiology model and want to fit the model to an expected cmax value. The problem is that I don't know the time of the cmax in the data so I don't know how to set up the fitting problem in simbiology. How could I do this?

recent works on 27 Oct 2023
Fitting a SimBiology model to data when you don't know the time of the Cmax (maximum concentration) can be challenging, but it's possible to handle this situation by using optimization techniques. One approach is to perform a global search to find the best parameter values that minimize the difference between the model prediction and the observed data, without assuming a specific time for Cmax. Here are the general steps to do this:
• First, make sure you have your SimBiology model properly defined with the parameters that you want to estimate during the fitting process. Ensure that you have appropriately linked your model to the observed data.
Create an Objective Function:
• You will need to create an objective function that quantifies the discrepancy between the model predictions and the observed data. In your case, this function should be based on the Cmax value. The objective function should take parameter values as inputs and return a measure of how well the model matches the data.
Implement a Search Algorithm:
• Since you don't know the time of Cmax, you can use an optimization algorithm that explores the parameter space globally. Genetic algorithms or particle swarm optimization are often used for such global optimization problems.
Set Up the Fitting Process:
• Use a global optimization function available in MATLAB, such as ga (genetic algorithm) or particleswarm, to perform the optimization. These functions allow you to search for parameter values that minimize the objective function.
Run the Fitting Process:
• Execute the optimization algorithm with your objective function and an initial guess for the parameters. The optimization algorithm will iteratively adjust the parameters to minimize the discrepancy between the model predictions and the data.
Analyze the Results:
• After the fitting process is complete, you can examine the estimated parameter values and the goodness of fit to assess how well the model aligns with the data. The estimated parameter values should provide information about the model parameters that produce the best fit to the data, including the time of Cmax.
Example of how to set up the fitting process using the ga function in MATLAB:
% Define the objective function
objectiveFunction = @(params) yourCustomObjectiveFunction(params, observedData);
% Set up optimization options
options = optimoptions('ga', 'MaxGenerations', 100, 'PopulationSize', 100);
% Perform the fitting using genetic algorithm
estimatedParams = ga(objectiveFunction, numParams, [ ], [ ], [ ], [ ], lb, ub, [ ], options);
% Now, you can analyze the results, including the estimated parameters
In this example, yourCustomObjectiveFunction is a function that calculates the Cmax value for the model prediction based on the parameter values and compares it to the observed Cmax value.

Arthur Goldsipe on 27 Oct 2023
One option would be to add Cmax to your model as an observable. Then, you can include Cmax in your fit the same way you fit to a species or anything else in your model. Depending on what else you are fitting to, you might want to pick a "late" time as the "measurement" time for Cmax, just to ensure that the simulation runs to this time point. Otherwise, the simulation might end before the time where the actual maximum occurs.
If you need more details, let me know.
##### 3 CommentsShow 1 older commentHide 1 older comment
Oscar on 1 Nov 2023
Hi Arthur, thank you for your response. I thought about using your approach but as you mentioned that would required addind extra time points in the data set and I didn't have more data and I'm only interested in matching the cmax. I ended up doing something similar to what was suggested in the first response. I created a custom objective function that has two arguments the parameter (dose) to be fitted and the observed cmax. In this custom function the model is run with the passed dose, the cmax is calculated and returns the square difference between the simulated and observed cmax. Then, we passed that custom function to the genetic algorithm (ga) for fitting and that worked quite well. If this is of interest I'll be happy to provide a demo with this workflow
Arthur Goldsipe on 1 Nov 2023
Thanks! I understand this approach. (It's very similar to what I do inside sbiofit itself!) But I'd still love to hear more about how you're using SimBiology. If you want to share more details about your work, feel free to contact me via my MATLAB Answers profile (and I will reply with my actual email address).

### Communities

More Answers in the  SimBiology Community

### Categories

Find more on Import Data in Help Center and File Exchange

R2023b

### Community Treasure Hunt

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

Start Hunting!