Adding an Error Model to a Nonlinear Mixed Effects Model
14 views (last 30 days)
Show older comments
Hello all,
First, I used SimBiology Model Builder to restore the PPK model that had been established in NONMEM. Since SimBiology Model Builder cannot add parameters for inter-individual variation and error models, I added them using code. But I found that the exponential error model has not been added to the model.
I would like to ask how to add the exponential error model to the following code and how to optimize the simulation process code? Thank you for your help!
opts = spreadsheetImportOptions("NumVariables", 3);
opts.Sheet = "Sheet1";
opts.DataRange = "A2:C237";
opts.VariableNames = ["ID", "TIME", "DV"];
opts.VariableTypes = ["double", "double", "double"];
Dose = readtable("Dose.xls", opts, "UseExcel", false)
data = groupedData(Dose);
sbiotrellis(data,@semilogy,"ID","TIME","DV",Marker="+",LineStyle="--");%%@semilogy
% Extract the model overall model file
s = sbioloadproject("Version-2-20241218.sbproj");
model = s.m1;
covModel = CovariateModel;
covModel.Expression = {'V1 = exp(theta1 + eta1)',' V2 = exp(theta2 + eta2)','F1 = exp(theta3 + eta3)','CL = exp(theta4 + eta4)'};
covModel.FixedEffectNames
covModel.FixedEffectDescription
options.ErrorModel = 'exponential';
options.ErrorModelParameters = struct('sigma', 1.0928)
thetas = table(4.0056,-20.3634,-7.9054,7.0873,'VariableNames',["theta1","theta2","theta3","theta4"])
omega = table([2.4432;0;0;0],[0;0.0534;0;0],[0;0;9.4391;0],[0;0;0;0.0729],'VariableNames',["eta1","eta2","eta3","eta4"])
phi = sbiosampleparameters(covModel.Expression,thetas,omega,Dose)
f = createSimFunction(model,covModel.ParameterNames,'Drug_Central',[])
simresults = f(phi,24)
t = sbiotrellis(simresults,[],'Time',' Drug_Central');
t.hFig.Position(3:4) = [800 500];
set(t.plots,'XGrid','on','YGrid','on');
set(t.plots,'YScale','log');
lh = findobj(t.plots,'Type','line');
set(lh,'LineWidth',2);
0 Comments
Accepted Answer
Jeremy Huard
on 20 Mar 2025
Assuming you want to add noise to the simulation data based on the exponential error model, you could use sbiosampleerror:
noisysimresults = sbiosampleerror(simresults, 'exponential', 1.0928);
More Answers (0)
Communities
More Answers in the SimBiology Community
See Also
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!