Nonlinear regression of multiple datasets with different functions but wit some shared parameters between datasets
2 views (last 30 days)
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
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
Matt J
on 11 Jun 2025
Edited: Matt J
on 11 Jun 2025
You would probably need to use lsqcurvefit. There is nothing about having multiple data sets, following different functions, that changes the approach to its use. The form of their dependence on the unknown variables and how they are shared is also irrelevant. You just provide a model function F(x,xdata) like in the examples which returns a matrix of your predicted values. The only requirement is that the matrix of predicted values that F(x,xdata) generates has the same size as your matrix of measurements ydata..
Confidence interval post-analysis is not something Matlab has any direct tools for when it comes to regression of vector-valued measurements. However, lsqcurvefit will give you the Jacobian at the solution,
so you can implement confidence interval calculations based on that.
3 Comments
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);
See Also
Categories
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!