simbiology-fit-model
Fit SimBiology model parameters to data — fitproblem, population NLME, virtual patients, and NCA
Install / Use
npx skills add matlab/matlab-agentic-toolkit --skill simbiology-fit-modelInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of simbiology-fit-model
simbiology-fit-model scores 90/100 on our quality scale, 1533rd of 4,582 Development & Engineering skills we index (top 34%).
Its SKILL.md is 16 KB long, well organised into 35 sections with 19 code examples: a thorough specification that gives an agent plenty to work with.
With 1,098 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 21 days ago, so simbiology-fit-model is actively maintained.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
simbiology-fit-model compared with similar skills
All 4 of these similar skills score higher than simbiology-fit-model; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| simbiology-fit-model (this skill)by matlab | 90 | 1.1k | 21d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 45.1k | 1d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.8k | 6d ago | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
Frequently asked questions
- How do I install simbiology-fit-model?
- Run
npx skills add matlab/matlab-agentic-toolkit --skill simbiology-fit-model. The install tabs above show the steps for each supported agent. - Which AI agents does simbiology-fit-model work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is simbiology-fit-model safe to use?
- It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is simbiology-fit-model still maintained?
- The repository was last updated 21 days ago, so simbiology-fit-model is actively maintained.
Skill content
View source on GitHubname: simbiology-fit-model description: "Fit SimBiology model parameters to data — fitproblem, population NLME, virtual patients, and NCA. Use when asked to fit, estimate, calibrate, or compute PK metrics." license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md metadata: author: MathWorks version: "2.0"
Fit SimBiology Models
Estimate parameters from data using fitproblem, fit population models
with NLME, generate virtual patients, and compute NCA metrics.
When to Use
- "fit", "estimate", "calibrate" model parameters
- Parameter estimation from experimental/observed data
- Population PK/PD, NLME, mixed effects, inter-individual variability
- Virtual patients, virtual cohorts
- NCA, AUC, Cmax, Tmax, half-life, clearance
- Keywords: "fit", "estimate", "calibrate", "population", "NCA", "AUC"
When NOT to Use
- Model construction or diagram (use
simbiology-build-model) - Simulation without fitting (use
simbiology-simulate-model) - Sensitivity analysis (use
simbiology-simulate-model)
Must-Follow Rules
1. Use fitproblem for parameter estimation
Always use fitproblem instead of calling sbiofit or sbiofitmixed
directly. fitproblem provides a unified, declarative interface:
prob = fitproblem;
prob.Model = model;
prob.Data = data;
prob.ResponseMap = "Species = DataColumn";
prob.Estimated = estimatedInfo({'param'}, 'Bounds', [lo hi]);
results = fit(prob);
Do NOT call sbiofit(model, data, ...) or sbiofitmixed(model, data, ...)
directly — their positional argument signatures are error-prone.
2. Fitting requires groupedData, NOT a plain table
Always wrap data:
data = groupedData(table(...));
data.Properties.IndependentVariableName = 'Time';
3. ResponseMap maps model outputs to data columns
Format is always "ModelOutput = DataColumnName":
% Single compartment — use species name on the left
prob.ResponseMap = "Drug = DrugConc";
% Multi-compartment — use qualified name to disambiguate
prob.ResponseMap = "Central.Drug = DrugConc";
% When species name matches data column name, still use the = format
prob.ResponseMap = "Drug = Drug";
Use the unqualified species name unless the same species name exists
in multiple compartments (then qualify with Compartment.Species).
4. Always set bounds
Prevent non-physical values (negative rates, etc.):
estimParams = estimatedInfo({'ke','ka'}, ...
'InitialValue', [0.2, 1.0], ...
'Bounds', [0.01 1; 0.1 5]);
5. Use log transform for rate constants
Parameters spanning orders of magnitude (clearances, rate constants)
benefit from log-transform estimation. Set .Transform after creation:
ei = estimatedInfo({'ke','ka'}, 'InitialValue', [0.1, 0.5], 'Bounds', [0.01 1; 0.1 5]);
ei(1).Transform = 'log';
ei(2).Transform = 'log';
Alternative: use 'log(param)' name syntax (equivalent result):
ei = estimatedInfo({'log(ke)','log(ka)'}, 'InitialValue', [0.1, 0.5], 'Bounds', [0.01 1; 0.1 5]);
Important: InitialValue and Bounds are always in the
untransformed (natural) domain. Do NOT pass log(value).
Available transforms: 'log', 'logit', 'probit'
Do NOT pass 'Transform' as a name-value pair to the estimatedInfo
constructor — it errors. Always set the .Transform property after.
6. Error models for population fitting
Choose the error model that matches the noise structure:
'constant'— absolute noise uniform'proportional'— noise scales with magnitude (most PK data)'combined'— both constant and proportional'exponential'— log-normal residual
7. NCA requires sbioncaoptions object
Do not use name-value pairs. Column names are camelCase.
EVDose column uses NaN for non-dose rows.
Decision Table
| Scenario | Approach |
|----------|----------|
| Single subject or pooled fit | fitproblem with FitFunction="sbiofit" |
| Individual fits per subject | fitproblem with Pooled=false |
| Population NLME (IIV, random effects) | fitproblem with FitFunction="sbiofitmixed" |
| Model-independent PK metrics | sbionca |
fitproblem Workflow (Preferred)
Use fitproblem for all parameter estimation. It provides a unified,
declarative interface that replaces direct calls to sbiofit/sbiofitmixed:
% 1. Prepare data
data = groupedData(table(tSample, yData, 'VariableNames', {'Time','Drug'}));
data.Properties.IndependentVariableName = 'Time';
% 2. Define parameters with bounds
estimParams = estimatedInfo({'ke','ka'}, ...
'InitialValue', [0.2, 1.0], ...
'Bounds', [0.01 1; 0.1 5]);
% 3. Build the fit problem
prob = fitproblem;
prob.Model = model;
prob.Data = data;
prob.ResponseMap = "Drug = Drug";
prob.Estimated = estimParams;
prob.Doses = dose; % optional
prob.FunctionName = 'scattersearch';
prob.ProgressPlot = true; % show live progress
% 4. Fit
results = fit(prob);
% 5. Inspect
disp(results.ParameterEstimates);
plot(results);
Key fitproblem properties
| Property | Purpose |
|----------|---------|
| Model | The SimBiology model object |
| Data | groupedData table |
| Estimated | estimatedInfo object (not EstimatedParameters) |
| ResponseMap | Maps model species to data columns |
| Doses | Dose object(s) (not Dose) |
| FitFunction | "sbiofit" (default) or "sbiofitmixed" |
| FunctionName | Algorithm: 'scattersearch', 'nlinfit', 'fminsearch', 'lsqnonlin', 'particleswarm' |
| ProgressPlot | true to show live fitting progress |
| UseParallel | true for parallel evaluation |
| Pooled | true/false/"auto" (sbiofit only) |
| ErrorModel | "constant", "proportional", "combined", "exponential" |
| Variants | Variants to apply during fitting |
Common property name mistakes: prob.Estimated (not EstimatedParameters),
prob.Doses (not Dose), prob.FunctionName (not Algorithm or Method).
Estimation algorithms
| Method | Use Case |
|--------|----------|
| 'scattersearch' | Built-in global search, no extra toolbox — start here |
| 'nlinfit' | Default local; smooth problems |
| 'lsqnonlin' | Bounded least squares (Optimization Toolbox) |
| 'fminsearch' | Derivative-free, simple problems |
| 'particleswarm' | Global search (Global Optimization Toolbox) |
Dosing from multi-subject data
When subjects receive different doses, use createDoses to extract
per-subject dose objects from the data. The dose column must have NaN
on non-dosing rows:
% Data format: dose amount only at administration time, NaN elsewhere
% ID Time Dose DrugConc Group
% 1 0 50 0 LowDose
% 1 1 NaN 2.05 LowDose
% ...
% 3 0 200 0 HighDose
% Create template dose targeting the depot species
tempDose = sbiodose('StudyDose');
tempDose.TargetName = 'Depot.Drug'; % match your model's dose target
% Extract per-subject doses from groupedData
doseArray = createDoses(gData, 'Dose', '', tempDose);
% Pass to fitproblem
prob.Doses = doseArray;
Critical: If all rows have the dose value (not just dosing times),
createDoses will treat every row as a dose event. Use NaN on
non-dosing rows.
Population fitting (pooled vs individual)
data.Properties.GroupVariableName = 'SubjectID';
% Pooled — one parameter set for all
prob.Pooled = true;
% Individual — separate per subject
prob.Pooled = false;
Category-based pooling (per-group estimates)
To estimate parameters separately per category (e.g., dose group), use
CategoryVariableName on the estimatedInfo object — not on
fitproblem or sbiofit:
estimParams = estimatedInfo({'ke'}, 'InitialValue', 0.1, 'Bounds', [0.01 1]);
estimParams.CategoryVariableName = 'DoseGroup'; % column in data table
% Do NOT set prob.Pooled — leave it at the default
Warning: Do NOT set prob.Pooled when using CategoryVariableName.
Setting Pooled=false triggers per-subject individual fitting that
ignores CategoryVariableName (MATLAB issues a warning). Leave
Pooled unset to let the category-based pooling work correctly.
NLME Population Fitting
For inter-individual variability and random effects estimation,
set FitFunction to "sbiofitmixed":
% 1. Load & tag grouped data
data = groupedData(readtable('pop_pk_data.csv'));
data.Properties.IndependentVariableName = 'Time';
data.Properties.GroupVariableName = 'SubjectID';
% 2. Define parameters (Bounds ignored by sbiofitmixed — use InitialValue only)
estimParams = estimatedInfo({'CL','Vd','ka'}, ...
'InitialValue', [5, 50, 1.2]);
% 3. Build the fit problem
prob = fitproblem;
prob.Model = model;
prob.Data = data;
prob.ResponseMap = "DrugConc = Concentration";
prob.Estimated = estimParams;
prob.FitFunction = "sbiofitmixed";
prob.ErrorModel = "proportional";
prob.ProgressPlot = true;
% 4. Fit
results = fit(prob);
% 5. Inspect
results.FixedEffects
results.RandomEffectCovarianceMatrix
results.IndividualParameterEstimates
When to use NLME vs sbiofit
| Criterion | FitFunction="sbiofit" | FitFunction="sbiofitmixed" |
|-----------|-----------|----------------|
| Single subject | Yes | |
| Multiple subjects, no IIV | Yes (pooled) | |
| Inter-individual variability | | Yes |
| Random effects estimation | | Yes |
| Covariate modeling | | Yes |
| Small datasets (< 5 subjects) | Yes | May not converge |
| Bounds on parameters | Yes (enforced) | Ignored — use good InitialValue instead |
NLME with covariates (CovariateModel)
When covariates (e.g., weight, age) influence parameters, use a
CovariateModel instead of estimatedInfo:
covModel = CovariateModel;
covModel.Expression = {
'CL = theta1 + theta2*WT + eta1'
'Vd = theta3 + theta4*WT + eta2'
'ka = theta5 + eta3'
};
initVals = covModel.constructDefaultFixedEffectValues;
initVals.theta1 = 5; initVals.theta2 = 0.1;
initVals.theta3 = 50; initVals.theta4 = 0.5;
initVals.theta5 = 1.2;
covModel.FixedEffectValues = initVals;
prob = fitproblem;
prob.Model = model;
prob.Data = data; % groupedData with WT column
prob.ResponseMap = "DrugConc = Concentration";
prob.FitFunction = "sbiofitmixed";
prob.Estimated = covModel;
prob.ErrorModel = "proportional";
results = fit(prob);
When to use which:
estimatedInfo— NLME without covariates (simpler, fewer parameters)CovariateModel— NLME with covariates (parameter-covariate relationships)
Expression rules: theta prefix for fixed effects, eta for random
effects. One random effect max per expression. Use verify(covModel) to
validate syntax before fitting.
Virtual Patient Generation
From assumed distributions (Scenarios)
Use SimBiology.Scenarios with makedist — avoids manual matrix construction:
sc = SimBiology.Scenarios;
add(sc, 'elementwise', 'ke', makedist('Lognormal', 'mu', log(0.1), 'sigma', 0.3), 'Number', 100);
add(sc, 'elementwise', 'ka', makedist('Lognormal', 'mu', log(0.5), 'sigma', 0.25), 'Number', 100);
simfun = createSimFunction(model, sc, {'Drug'}, []);
results = simfun(sc, 24);
From NLME results (sbiosampleparameters)
Use sbiosampleparameters to sample from fitted population parameters —
it respects the covariate model parameterization automatically:
% Extract from NLME results
covModel = covariateModel(nlmeResults);
thetas = nlmeResults.FixedEffects;
omega = nlmeResults.RandomEffectCovarianceMatrix;
% Sample 200 virtual patients
nVP = 200;
vpParams = sbiosampleparameters(covModel.Expression, thetas, omega, nVP);
% Simulate
simfun = createSimFunction(model, {'CL','Vd','ka'}, {'Cp'}, []);
vpSim = simfun(vpParams, 48);
Non-Compartmental Analysis (NCA)
From simulation output
Use explicit OutputTimes to ensure sufficient time-resolution for NCA
(the default solver output may have too few points near Cmax):
cs = getconfigset
Truncated for display — read the full file on GitHub.
Related Skills
ai-job-search
45.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.8kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
