Nonlinear regression of multiple datasets with different functions but wit some shared parameters between datasets
Show older comments
Apologies since I am new to Matlab.
I have a model describing a drug-receptor system with multiple parameters. There are two different observables (binding , activity) for each drug. (I have separate but related equations for predicting the observables). The model has four parameters per drug and four system parameters that are shared for all drugs. I have datasets with a variable number of replicates for each observable (3 binding curves and one response curve per drug). I have data for 12 different drugs. I would appreciate some help setting up global nonlinear regression for all datasets to obtain best estimates of the drug specific and system specific (shared) parameters and their associated 95% confidence intervals. A general example that can handle this type of situation would be helpful to get me started.
17 Comments
Star Strider
on 12 Jun 2025
I'm going to bring this to the attention of @Arthur Goldsipe. I don't have Simbiology, however it can probably deal with this sort of problem.
Arthur Goldsipe
on 12 Jun 2025
Yes, Star Strider is correct that SimBiology has functionality to handle this. But it would require reimplementing your model in SimBiology. It’s specifically designed for modeling drug systems, so you might also get additional benefit from using it. But if you can’t or don’t want to use SimBiology, I can also share some details about how to do this sort of nonlinear regression. Let me know, and I’ll share more tomorrow when I’m back at my desk.
Arthur Goldsipe
on 12 Jun 2025
Oh, and confidence interval calculations are also available in SimBiology.
Jorge
on 12 Jun 2025
Arthur Goldsipe
on 12 Jun 2025
SimBiology models can consistent of a combination of differential and algebraic equations. It's not common, but it's certainly possible to create a SimBiology model that only contains algebraic constraints. That's probably what I would do to model equilbrium data in SimBiology.
And fitting (and confidence interval calculations) work for any SimBiology model. Some functionality (mostly local sensitivity analysis) may not be supported for certain kinds of algebraic constraints.
Can you share any more details about your problem? The equations would be most helpful. If you can also share the data (or at least say which of the variables from the equations are in your data sets), that could also help us construct example code to share with you.
Jorge
on 12 Jun 2025
Jorge
on 12 Jun 2025
Star Strider
on 12 Jun 2025
That is certainly an interesting problem. I understand the physiology, however modeling it would be difficult. I suspect that ligand binding could be modeled as first-order kinetics, however incorporating the alloseric effect of the second ligand and the expression for that interaction on the resulting ligand-receptor activation would be challenging. Since that image is obviously from the published lliterature, it would be helpful to have the mathematical approach those authors used, assuming they attempted to model it.
I do not know if SimBiology could model that, since I have no experience with it.
Jorge
on 13 Jun 2025
Arthur Goldsipe
on 13 Jun 2025
I'm most familiar with kinetic models of ligand-receptor binding. Can you provide the equations for a simpler ligand-receptor system that illustrates the kind of algebraic equations you are solving? Or can you share a reference to a similar sort of model? Then, I should be able to create a more realistic SimBiology project that illustrates how to build the model, fit parameters, and calculate confidence intervals.
Jorge
on 15 Jun 2025
Jorge
on 16 Jun 2025
Jorge
on 16 Jun 2025
Anybody knows why p is multiplied by 1/100 in "format long" at the end of the code ? Is this an output issue or a bug ?
M = [1.00E-10 17 22 19
3.16E-10 50 53 64
1.00E-09 146 146 123
3.16E-09 301 276 328
1.00E-08 329 487 412
3.16E-08 372 416 552
1.00E-07 566 527 493
3.16E-07 414 451 481 ];
D = M(:,1);
DD = [];
for i = 1:size(D,1)
DD = [DD;[M(i,1);M(i,1);M(i,1)]];
end
D = DD;
B = M(:,2:4);
BB = [];
for i = 1:size(B,1)
BB = [BB;[B(i,1);B(i,2);B(i,3)]];
end
B = BB;
A = [D,-B];
b = B.*D;
p = A\b;
B_max = p(1)
K_d = p(2)
fun = @(p)p(1)*D./(D+p(2))-B;
p = lsqnonlin(fun,p);
p
format long
p
Torsten
on 16 Jun 2025
It seems that simbiology is not well suited for this type of problem.
As pointed out already: I think the problem is different - the model is not well-suited for your data.
Arthur Goldsipe
on 16 Jun 2025
@Torsten the issue with long format looks like it might be specific to the display here in MATLAB Anwers. I'll report this to the appropriate developers.
@Jorge thanks for sharing the sample equation and data. It looks like this kind of probelm should be quite easy to implement in SimBiology. It will take me some time to create an example, due to other work obligations. But I hope to share an example in the next day or so.
Accepted Answer
More Answers (1)
Arthur Goldsipe
on 16 Jun 2025
Edited: Arthur Goldsipe
on 16 Jun 2025
I've attached a SimBiology project (created in R2024b) that illustrates how to set up this sort of problem in SimBiology. If you're not familiar with MATLAB, then it will probably be easiest to build the model in the SimBiology Model Builder app and then fit the data in the SimBiology Model Analyzer app and then calculate 95% Gaussian confidence intervals on parameter estimates and predictions. Just open this project file in the apps to view the model and the fit program.
But since it's easier to illustrate the capabilities here via the command line, here's how you could do the work programmatically.
If you don't want to use the same parameter estimate for each dose, then you just need to add a variable to your data that says which observations use the same esimate, and then update CategoryVariableName to that variable. For example, setting the value to D would result in a different parameter estimate for each unique value of D.
Construct the model
model = sbiomodel("Binding");
addspecies(model, "D", Constant=true);
addparameter(model, "Bmax", 1);
addparameter(model, "Kd", 1);
addspecies(model, "B");
addrule(model, "B - Bmax*D/(D+Kd)", "algebraic");
Construct the data
The data needs to be reformatted for us in SimBiology:
- Add a time variable (the value is arbitrary, since there are no dynamics).
- Add a grouping variable that gives a unique identifier to each distinct condition we need to simulate (in this case, each dose amount).
- Stack all measurements of the same state (B) into a single column.
rawDataMatrix = [
1.00E-10 17 22 19
3.16E-10 50 53 64
1.00E-09 146 146 123
3.16E-09 301 276 328
1.00E-08 329 487 412
3.16E-08 372 416 552
1.00E-07 566 527 493
3.16E-07 414 451 481 ];
tableData = array2table(rawDataMatrix, VariableNames=["D", "B1", "B2", "B3"]);
tableData.Time(:) = 1;
tableData.ID = (1:height(rawDataMatrix))';
tableData = stack(tableData, ["B1", "B2", "B3"], ...
NewDataVariableName="B", IndexVariableName="ReplicateID")
Set up and run the fit problem
prob = fitproblem;
prob.Data = tableData;
prob.Model = model;
prob.Estimated = estimatedInfo( ...
["log(Kd)", "log(Bmax)"], ...
Bounds=[1e-20 0.1; 0.1 1e3], ...
CategoryVariableName=["<None>", "<None>"]);
prob.ResponseMap = "B = B";
prob.Variants = createVariants(prob.Data, "D", Model=model);
prob.ProgressPlot = true;
prob.FunctionName = "scattersearch";
results = fit(prob);
plot(results);
results.ParameterEstimates
Calculate confidence intervals
ciParam = sbioparameterci(results);
plot(ciParam);
ciPred = sbiopredictionci(results);
plot(ciPred);
Categories
Find more on Import Data 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!





