pkpd-modeling skill (K-Dense scientific-agent-skills)
- Install
- SKILL.md (verbatim)
- When to use
- The three rules
- Scope
- Scripts
- Workflow
- 1. Non-compartmental analysis
- 2. Compartmental fitting and model selection
- 3. Population PK
- 4. Simulation and regimen selection
- 5. Exposure-response
- 6. Bioequivalence
- 7. Scaling, paediatrics, and first-in-human
- 8. Drug interactions
- 9. Therapeutic drug monitoring
- Software ecosystem
- What this skill exists to prevent
- References
- Assets
- Citing Scientific Agent Skills
- Other files in this skill
- assets/nca-reporting-checklist.md (verbatim)
- The four conventions that change the answer
- Data
- Parameters reported
- Terminal-phase quality, per subject
- Summary statistics
- Presentation
- Method and provenance
- The traps this checklist exists to catch
- assets/popk-analysis-plan.md (verbatim)
- 1. Objectives
- 2. Data
- 3. Software
- 4. Structural model
- 5. Between-subject and between-occasion variability
- 6. Residual error
- 7. Covariate model
- 8. Model evaluation
- 9. Simulations
- 10. Deviations
- references/antimicrobial-and-tdm.md (verbatim)
- PK/PD indices
- Probability of target attainment and cumulative fraction of response
- Vancomycin: AUC-guided dosing
- Model-informed precision dosing
- Reporting a TDM calculation
- references/bioequivalence.md (verbatim)
- The ICH M13 series
- Average bioequivalence
- Designs
- Reference-scaled approaches for highly variable drugs
- EMA: average bioequivalence with expanding limits (ABEL)
- FDA: reference-scaled average bioequivalence (RSABE)
- Sample size
- Common errors
- Endogenous compounds and other special cases
- references/dataset-standards.md (verbatim)
- The two worlds
- NONMEM data items
- The defects that do not stop a run
- Handling BLQ properly
- Structuring covariates
- Dataset specification
What it does. Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK/PD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when analysing concentration-time data, deriving exposure metrics, fitting PK or PD models, or evaluating dosing regimens. Triggers include "pharmacokinetics", "pharmacodynamics", "PK/PD", "NCA", "non-compartmental", "AUC", "Cmax", "lambda z", "half-life", "clearance", "volume of distribution", "compartmental model", "population PK", "popPK", "NONMEM", "nlmixr2", "Pharmpy", "Monolix", "exposure-response", "Emax", "EC50", "indirect response", "effect compartment", "TMDD", "PBPK", "bioequivalence", "RSABE", "ABEL", "allometric scaling", "first-in-human", "MABEL", "drug-drug interaction", "DDI", "ICH M12", "concentration-QTc", "therapeutic drug monitoring", "MIPD", and "dosing regimen". Part of K-Dense-AI/scientific-agent-skills (AI Scientist skills) (K-Dense-AI/scientific-agent-skills).
| Upstream | K-Dense-AI/scientific-agent-skills |
| Skill file | skills/pkpd-modeling/SKILL.md |
| License | MIT |
| Author | K-Dense Inc. |
| Fetched | 2026-09-10 |
Install
npx skills add K-Dense-AI/scientific-agent-skills --skill pkpd-modeling, or copy the skill folder into~/.claude/skills/pkpd-modeling/.- Raw file:
curl -sL https://raw.githubusercontent.com/K-Dense-AI/scientific-agent-skills/HEAD/skills/pkpd-modeling/SKILL.md
SKILL.md (verbatim)
name: pkpd-modeling
description: Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK/PD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when analysing concentration-time data, deriving exposure metrics, fitting PK or PD models, or evaluating dosing regimens. Triggers include "pharmacokinetics", "pharmacodynamics", "PK/PD", "NCA", "non-compartmental", "AUC", "Cmax", "lambda z", "half-life", "clearance", "volume of distribution", "compartmental model", "population PK", "popPK", "NONMEM", "nlmixr2", "Pharmpy", "Monolix", "exposure-response", "Emax", "EC50", "indirect response", "effect compartment", "TMDD", "PBPK", "bioequivalence", "RSABE", "ABEL", "allometric scaling", "first-in-human", "MABEL", "drug-drug interaction", "DDI", "ICH M12", "concentration-QTc", "therapeutic drug monitoring", "MIPD", and "dosing regimen".
license: MIT
compatibility: Requires Python 3.11+ with numpy and scipy. No network access and no proprietary software. The estimation tools this skill orients you towards (NONMEM, Monolix, Phoenix, Simcyp, GastroPlus) are licensed separately and are never invoked by these scripts.
allowed-tools: Read Write Edit Bash
metadata:
version: "1.2"
skill-author: K-Dense Inc.
last-reviewed: "2026-07-27"
Pharmacokinetic and Pharmacodynamic Modelling
When to use
Any question about what the body does to a drug or what the drug does to the body: deriving exposure metrics from concentration-time data, fitting a structural model, building or checking a population analysis, choosing a dose or a regimen, relating exposure to effect, comparing formulations, or scaling to a new population.
The three rules
1. Fix the exposure metric and the analysis population before computing anything. AUC(0-t), AUC(0-inf), AUC(0-tau) at steady state, and Cavg are different quantities and answer different questions. So do AUCinf based on observed versus predicted Clast. Choosing after seeing the numbers is how a negative study becomes positive.
2. Structural model, variability model, and covariate model are three separate decisions. They get conflated constantly — an extra compartment added to absorb what is really unmodelled between-occasion variability, a covariate added to fix what is really a misspecified absorption model. Diagnose which one is wrong before changing any of them.
3. Convergence is not identifiability. A fit that converges with 200% relative standard error on a parameter, or a correlation of 0.99 between two, has told you the data cannot separate them. Every fitting script here reports both and flags them, because the parameter table alone looks fine in exactly this situation.
Scope
This skill computes, diagnoses, and structures. It does not decide that a formulation is
bioequivalent, select a dose for a trial, recommend a dose for a patient, conclude that a drug has
no QT liability, or replace a qualified pharmacometrician, clinical pharmacologist, or the
regulatory review. The scripts report; none of them concludes. tdm_bayes.py in particular is a
modelling aid — any change to a patient's regimen is the treating clinician's decision.
Scripts
cd skills/pkpd-modeling/scripts
| Script | Question answered |
|---|---|
nca.py |
What are the exposure metrics, and is the terminal phase good enough to report them? |
fit_compartmental.py |
Which structural model do these data support, and are its parameters identifiable? |
simulate_regimen.py |
What does this regimen do at steady state, and to what fraction of the population? |
check_popk_dataset.py |
Will NONMEM read this dataset the way I think it will? |
exposure_response.py |
Is there an exposure-response relationship, and is the plateau in the data? |
bioequivalence.py |
Does the 90% CI meet the criterion, and which criterion applies? |
allometry_and_fih.py |
What is the starting dose, or the dose in a smaller/younger population? |
ddi_static.py |
Does the in vitro data trigger a clinical DDI study under ICH M12? |
tdm_bayes.py |
What are this patient's individual parameters from their measured levels? |
All take --format table|tsv|json. Data goes to stdout, provenance and findings to stderr, so
> out.tsv keeps them separate. Exit code is 0 for no findings, 1 when findings were raised,
2 for bad input, so any of them can gate a workflow.
Two private modules carry the shared machinery: _models.py (analytical solutions for linear
mammillary models, plus integrated Michaelis-Menten, TMDD and indirect-response structures) and
_common.py (I/O and reporting). Import them rather than re-deriving a Bateman function.
Workflow
1. Non-compartmental analysis
python3 nca.py -i profile.csv --dose 100 --route extravascular --partial-auc 0-24
Four choices decide the answer and are usually left implicit. This script makes all four explicit:
--auc-method (default linup-logdown), --blq-rule, --lambda-z-points or an explicit
--lambda-z-window, and whether you report auc_inf_obs or auc_inf_pred.
Lambda_z selection uses the standard rule: start from the last three quantifiable points, extend backwards, keep the longer window only if adjusted r-squared improves by more than 0.0001. Plain r-squared can only rise as points are added, so it would always pick the longest window. Points at or before Tmax are never eligible — including Tmax fits the tail of absorption and biases half-life, Vz and AUCinf downward.
On a noiseless simulated one-compartment oral profile with CL/F = 5, V/F = 20, ka = 1.2:
id cmax tmax auc_last lambda_z t_half r2_adj auc_inf_obs pct_auc_extrap cl_f vz_f
1 3.29678 1.5 19.8737 0.25 2.77259 1 19.8739 0.000781037 5.03173 20.1269
The 0.6% overestimate of CL/F is the trapezoidal rule on a sparsely sampled absorption phase, not an error — it is the irreducible bias of NCA on that sampling schedule, and it is why NCA and compartmental estimates of clearance never agree exactly.
The findings are the point. A steady-state profile truncated at tau produces:
finding: subject A: 25.2% of AUCinf is extrapolated (above 20%); AUCinf is driven by the
lambda_z fit, not by data
finding: subject A: lambda_z window spans 0.58 half-lives (below 2.0); the terminal phase may
not have been reached
Both are correct and both are routinely ignored. At steady state the reportable exposure metric is AUC(0-tau), not AUCinf; the script computes AUCinf anyway and tells you not to trust it.
2. Compartmental fitting and model selection
python3 fit_compartmental.py -i profile.csv --dose 500 --route iv-bolus --compare 1cmt,2cmt,3cmt
Parameters are estimated on the log scale, so they cannot go negative and their confidence
intervals come out asymmetric. Weighting defaults to 1/y2 (constant CV), which is the right
default for PK and the wrong one for a homoscedastic PD endpoint.
Fitting simulated two-compartment data (CL 4, V1 12, Q 6, V2 40, 8% proportional error):
model parameters wssr aic bic f_vs_simpler f_p_value compared_with
1cmt 2 3.13201 -19.4956 -18.0795 n/a n/a n/a
2cmt 4 0.0309579 -84.7477 -81.9155 550.936 9.38016e-12 1cmt
3cmt 6 0.0232859 -85.0193 -80.771 1.4826 0.27762 2cmt
AIC picks the three-compartment model. BIC and the F test both reject it. AIC's fixed penalty of 2 per parameter is weak at this sample size, and it selects the overparameterised model more often than practitioners expect. The parameter table settles it:
finding: fit: Q3 has 98% RSE - not estimable from these data at this model size
finding: fit: V3 has 71% RSE - not estimable from these data at this model size
The one-compartment fit meanwhile earns:
finding: fit: residual signs are not random (runs test p = 0.0036) - a structural
misspecification, which no amount of reweighting will fix
That distinction — structural misspecification versus a wrong error model — is the one to get right. A residual-versus-time plot with runs of the same sign means the model shape is wrong. Heteroscedastic residuals with random signs mean the weighting is wrong. Reweighting the first case hides it without fixing it.
3. Population PK
Check the dataset before running anything. This is where the time actually goes.
python3 check_popk_dataset.py -i nmdata.csv --covariates WT,CRCL --time-varying WT
The defects that matter are the silent ones. NM-TRAN does not reject a non-numeric DV — it reads
BLQ as zero and fits it as a genuine zero concentration. A blank covariate becomes 0, so a
missing body weight becomes a 0 kg patient. ADDL without II places no additional doses.
Records sharing a timestamp are applied in file order, so whether a level is pre- or post-dose
depends on which row came first. None of these stop a run.
severity check detail
error non-numeric DV DV contains text... NM-TRAN reads them as 0
error subject with no dose 1 subject(s) have observations but no dose: 2
error TIME not sorted 1 subject(s) have out-of-order TIME: 1
error covariate WT missing 1 record(s) have no value...
warning duplicate TIME within a subject NONMEM applies them in file order...
For the estimation itself, this skill does not reimplement NLME — see
references/population-pk.md for estimation methods, the BLQ M1-M7 methods, covariate model
building, and the diagnostics that decide whether a model is acceptable, and
references/software-ecosystem.md for which tool to reach for.
4. Simulation and regimen selection
python3 simulate_regimen.py --cl 5 --v 40 --dose 500 --interval 12 --n-doses 10 --steady-state
python3 simulate_regimen.py --cl 5 --v 40 --dose 500 --interval 12 --n-doses 10 \
--simulate 2000 --omega-cl 0.35 --omega-v 0.25 --target-trough 4.0
Deterministic simulation answers "what does the typical patient look like", which is almost never the question:
metric p5 p25 median p75 p95 geo_mean
peak 11.861 14.6018 16.6702 19.1476 22.9339 16.6453
trough 0.863226 2.15191 3.64412 5.49655 9.21053 3.27035
target fraction_attaining
trough >= 4 0.444
The typical trough is 3.6 and the target is 4, so 44% of the population attains it. A regimen tuned on the typical patient leaves about half the population on the wrong side of the target. Reported attainment is still optimistic here: this is between-subject variability only, with no residual or between-occasion component.
Linear models are solved analytically and superposed, which is exact. --nonlinear switches to
integrated Michaelis-Menten elimination, where superposition is invalid and multiple-dose
behaviour cannot be inferred from a single dose at all.
5. Exposure-response
python3 exposure_response.py --emax -i er.csv --sigmoid
python3 exposure_response.py --cqtc -i qt.csv --cmax 250
The Emax fit reports fraction_of_emax_reached and flags a fit whose plateau is outside the data.
When the highest observed exposure reaches only a third of the estimated Emax, Emax and EC50 are
extrapolations that are strongly correlated with each other; quoting them as independent estimates
is not supportable, and a "linear" exposure-response is simply the low-concentration limb of the
same curve.
--cqtc evaluates the upper bound of the two-sided 90% confidence interval of predicted
placebo-corrected change-from-baseline QTc against the 10 ms threshold, which is the question ICH
E14 actually asks. A point estimate, or a 95% interval, answers a different one. The bundled model
is an ordinary linear regression for screening; a submission-grade C-QTc analysis needs a mixed
model with random intercept and slope per subject.
Every mode carries the same caveat, because it is the one that gets forgotten: patients are randomised to dose, not to exposure. Exposure-response across quantiles is observational even inside a randomised trial, and can reflect the covariates that drive clearance.
6. Bioequivalence
python3 bioequivalence.py -i be.csv --design 2x2 --metric AUC
python3 bioequivalence.py -i be.csv --design replicate --metric Cmax --scaling both
python3 bioequivalence.py --power --cv 0.30 --gmr 0.95 --target-power 0.80
Three criteria share the word "bioequivalence" and are not interchangeable: average BE (90% CI
inside 80.00-125.00%), EMA's ABEL (limits widened as a function of CVwR, capped at
69.84-143.19%, point estimate still within 80-125%), and FDA's RSABE (a scaled linearised bound
via Hyslop's method, not an interval at all). --scaling refuses to run on a 2x2 design:
error: reference-scaling requires --design replicate. High observed variability in a 2x2 study
does not license widening: without replicated reference administrations there is no estimate of
within-subject reference variability to scale to.
Sample size reproduces the published tables exactly (CV 30%, GMR 0.95, 80% power → N = 40 for a 2x2). Power is computed by integrating over the sampling distribution of the estimated standard deviation rather than treating the standard error as known — the normal approximation overstates power at realistic sample sizes. Note that N is driven far more by the assumed GMR than by CV; assuming 1.00 instead of 0.95 roughly halves the calculated N and is the usual reason a BE study comes in underpowered.
7. Scaling, paediatrics, and first-in-human
python3 allometry_and_fih.py --scale --cl 5 --weight-from 70 --weight-to 6 --pma-weeks 44
python3 allometry_and_fih.py --fih --noael rat=50,dog=10 --safety-factor 10
Scaling by size alone below about 2 years of age overpredicts clearance, in a neonate by several
fold, because clearance is limited by enzyme and renal maturation rather than by size. Supplying
--pma-weeks adds the Anderson-Holford sigmoidal maturation term; omitting it below 20 kg raises
a finding.
parameter reference exponent size_scaled maturation_factor final
CL 5 0.75 0.792063 0.30634 0.242641
V 40 1 3.42857 1 3.42857
Size alone would predict 0.79 L/h; with maturation at 44 weeks post-menstrual age it is 0.24 L/h, a 3.3-fold difference. Volume is not matured — maturation describes eliminating capacity, not distribution space.
--fih uses the body-surface-area conversion from FDA's 2005 maximum-safe-starting-dose guidance
and always emits a finding that a NOAEL-derived MRSD is not sufficient on its own for agonist
immunomodulators: compute MABEL with --mabel and take the lower value.
8. Drug interactions
python3 ddi_static.py --basic --ki 0.5 --imax 2.0 --fu 0.05 --dose 0.4
python3 ddi_static.py --msm --ki 0.5 --imax 2.0 --fu 0.05 --dose 0.4 --fm 0.9 --fg 0.7
ICH M12 basic models with their cut-offs (R1 ≥ 1.02 hepatic, ≥ 11 intestinal; R2 ≥ 1.25 for TDI; R3 ≤ 0.8 for induction; transporter cut-offs by site), plus the mechanistic static model. The basic models are deliberately conservative: a negative is meaningful, a positive is a trigger for further work, not a prediction of clinical magnitude.
The mechanistic static model reports the ceiling alongside the prediction:
note: With fm = 0.9, no inhibitor of this pathway can raise the victim AUC above 10.00-fold. If
the prediction approaches that ceiling, fm is doing more work than the inhibition constants.
fm and Fg dominate the answer far more than the inhibition constants, and are usually the
least well established numbers in the calculation.
9. Therapeutic drug monitoring
python3 tdm_bayes.py --model vancomycin-adult --weight 80 --crcl 75 \
--dose 1500 --interval 12 --level 18.2@11.5 --level 42@2 --target-auc24 500
MAP Bayesian estimation shrinks towards the population when the data are uninformative and follows the data when they are not, which is why it beats both a trough read against population parameters and log-linear regression on two points. A single level raises a finding: it cannot separate clearance from volume, and whichever parameter the sample is uninformative about has simply returned its prior.
The bundled vancomycin parameterisation is explicitly labelled illustrative. Substitute a model validated in your population before the output means anything.
Software ecosystem
Verified against live sources on 2026-07-27; see references/software-ecosystem.md for the full
map and references/source-ledger.md for provenance.
- Pharmpy 2.1.1 (2026-05-19) is the practical Python entry point — model-agnostic, drives
NONMEM/nlmixr2/rxode2, and ships 19
run_*tools includingrun_amd,run_modelsearch,run_covsearch,run_structsearch,run_pdsearch,run_modelrank,run_vpcandrun_qa. Two breaking changes are recent enough to catch you out: 2.0.0 (2026-02-12) changed dataset row indices to start at 1, and 2.1.0 (2026-05-08) renamedadd_placebo_modeltoset_placebo_modeland now requires numpy ≥ 2. - NONMEM 7.6 (user guides dated November 2025) remains the regulatory default. New since 7.5: ADVAN16 (RADAR5 implicit Runge-Kutta for stiff delay differential equations), ADVAN17 (stiff delay differential-algebraic), NUTS Bayesian sampling, and SAEM storage of individual samples.
- nlmixr2 (requires rxode2 ≥ 5.0.0) is the credible open-source NLME alternative;
babelmixr2andmonolix2rxtranslate models between it, NONMEM and Monolix. - PKPy (PeerJ, 2025) is a Python popPK framework but is GitHub-only — not on PyPI, so
uv pip install pkpyfails.chi-drm(1.0.3) is on PyPI for Bayesian PKPD. - Open Systems Pharmacology Suite v12 (PK-Sim/MoBi) is the open-source PBPK platform; Simcyp
and GastroPlus are the commercial ones.
ospsuiteis R-only and needs .NET 8.
Python has no mature NCA or NLME package of regulatory standing. That gap is why this skill ships its own validated NCA and fitting implementations rather than wrapping one.
What this skill exists to prevent
- Lambda_z chosen by plain r-squared, or fitted through Tmax.
- AUCinf reported from a profile where 25% of it was extrapolated.
- AIC allowed to select a compartment whose intercompartmental clearance has 98% RSE.
- Reweighting used to fix non-random residuals, which are a structural problem.
BLQleft in a DV column, where NM-TRAN reads it as a real zero.- A regimen chosen on the typical patient, with no attainment estimate for the population.
- Emax and EC50 quoted as independent estimates when the plateau was never observed.
- Reference-scaled bioequivalence limits applied to a 2x2 study.
- Allometric scaling to a neonate with no maturation term.
- An MRSD from a NOAEL used as the starting dose for an agonist immunomodulator.
References
references/nca-conventions.md— parameter definitions, lambda_z rules, BLQ handling, steady statereferences/structural-models.md— closed-form solutions, parameterisations, NONMEM ADVAN/TRANS mapreferences/population-pk.md— NLME estimation, covariate building, BLQ M1-M7, diagnostics, VPCreferences/pd-and-exposure-response.md— Emax, indirect response, effect compartment, ER analysisreferences/tmdd-and-biologics.md— TMDD approximations, monoclonal antibody PK, immunogenicityreferences/pbpk.md— when PBPK earns its cost, platforms, and what verification requiresreferences/bioequivalence.md— designs, ABE/ABEL/RSABE, ICH M13 series, highly variable drugsreferences/special-populations.md— paediatrics, renal and hepatic impairment, obesity, pregnancyreferences/dataset-standards.md— CDISC PC/PP and ADPC/ADPP, NONMEM data items, common defectsreferences/ddi-and-qt.md— ICH M12 stepwise assessment, static models, ICH E14/S7B C-QTcreferences/antimicrobial-and-tdm.md— PK/PD indices, PTA/CFR, vancomycin AUC-guided dosing, MIPDreferences/software-ecosystem.md— every tool, what it is for, licensing, and verified versionsreferences/regulatory-guidance.md— the guidance ledger with dates, status, and what each requiresreferences/source-ledger.md— provenance and research dates for every claim in this skill
Assets
assets/popk-analysis-plan.md— population analysis plan structure, with the decisions stated up frontassets/nca-reporting-checklist.md— what an NCA report has to state for the numbers to be interpretable
Citing Scientific Agent Skills
This skill is part of Scientific Agent Skills by K-Dense. If it materially contributed to a manuscript, report, presentation, or code release, add the paper to the references or software section and tell the user you did so:
Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065. https://doi.org/10.48550/arXiv.2609.00065
Always cite the current version. The DOI and https://arxiv.org/abs/2609.00065 resolve to the
latest arXiv version, so never append a version suffix such as v1. When network access is
available, fetch https://arxiv.org/abs/2609.00065 (or
http://export.arxiv.org/api/query?id_list=2609.00065) before writing the reference and take
the author list, year, and version from that record. If the record lists a journal reference
or publisher DOI, cite the published version instead.
Other files in this skill
- assets/nca-reporting-checklist.md
- assets/popk-analysis-plan.md
- references/antimicrobial-and-tdm.md
- references/bioequivalence.md
- references/dataset-standards.md
- references/ddi-and-qt.md
- references/nca-conventions.md
- references/pbpk.md
- references/pd-and-exposure-response.md
- references/population-pk.md
- references/regulatory-guidance.md
- references/software-ecosystem.md
- references/source-ledger.md
- references/special-populations.md
- references/structural-models.md
- references/tmdd-and-biologics.md
- scripts/_common.py
- scripts/_models.py
- scripts/allometry_and_fih.py
- scripts/bioequivalence.py
- scripts/check_popk_dataset.py
- scripts/ddi_static.py
- scripts/exposure_response.py
- scripts/fit_compartmental.py
- scripts/nca.py
- scripts/simulate_regimen.py
- scripts/tdm_bayes.py
assets/nca-reporting-checklist.md (verbatim)
NCA reporting checklist
An NCA result is uninterpretable — and irreproducible — unless every item below is stated. Most disagreements between two analyses of the same data resolve to one of the first four.
The four conventions that change the answer
- Trapezoidal rule: linear / linear-up-log-down / log-linear
- BLQ handling, stated separately for each position:
- leading (before the first quantifiable sample): [ zero / excluded ]
- embedded: [ zero / LLOQ÷2 / excluded ]
- trailing: [ excluded / other ]
- Lambda_z selection: the rule, the minimum number of points, whether Tmax was excluded, and the window and point count actually used for each subject
- AUCinf basis: observed Clast or predicted Clast
Data
- Analyte, matrix, assay, LLOQ, and the bioanalytical validation report reference
- Actual elapsed times used, not nominal — and nominal times used only for grouping
- Dose actually administered per subject, including any deviations
- Records excluded, with the reason, and confirmation the criteria were set before unblinding
- Deviations in sampling time above [ ]% of the nominal time, and how they were handled
Parameters reported
- Cmax and Tmax as observed values, never interpolated
- AUClast, AUCinf (both observed- and predicted-based, or one with the basis stated)
- % AUC extrapolated, per subject
- lambda_z, t½, and the number of points and time span of the terminal fit, per subject
- CL or CL/F, Vz or Vz/F — with
/Fused for every extravascular route - Vss only for intravenous data
- At steady state: AUC(0-tau), Cavg, Cmin, PTF%, accumulation ratio — and not AUCinf
- Partial AUCs, if pre-specified, with their intervals
Terminal-phase quality, per subject
- Adjusted r-squared of the lambda_z regression
- Span ratio (window duration ÷ t½); flag below 2
- % AUC extrapolated; flag above 20%
- Number of points in the fit; flag below 3
- Subjects for whom lambda_z was not estimable, and how they were handled in the summary
Summary statistics
- Exposure metrics (AUC, Cmax) as geometric mean and geometric CV%
- Tmax as median and range
- Arithmetic mean, SD and CV% alongside, if wanted, but not instead
- n for each parameter, since it differs when lambda_z fails for some subjects
Presentation
- Individual concentration-time profiles on both linear and semi-logarithmic axes
- Mean profiles with a stated rule for handling BLQ in the mean
- A table of individual parameters, not only summary statistics
Method and provenance
- Software and version
- Units for every parameter, and confirmation that dose and concentration units are consistent
- Whether the analysis was pre-specified, and the reference to the plan
- Any deviation from the plan, with its reason
The traps this checklist exists to catch
- Reporting AUCinf from a truncated steady-state profile.
- Interpolating Cmax, or reporting a mean Tmax.
- Quoting Vz as if it were Vss, or reporting Vss from oral data.
- Applying one BLQ rule to the test arm and another to the reference.
- Presenting arithmetic means for AUC and Cmax.
- Summarising across subjects without saying that lambda_z failed for some of them.
- Omitting the lambda_z window, which makes the half-life unreproducible.
assets/popk-analysis-plan.md (verbatim)
Population Pharmacokinetic Analysis Plan
Template. Every bracketed field is a decision to make and record before the analysis starts. A plan written after the modelling is not an analysis plan, and the difference is visible to a reviewer.
Study/programme: [ ] Compound: [ ] Plan version and date: [ ] Author: [ ] Reviewers: [ ]
1. Objectives
Primary objective: [ ]
Each objective must name the decision it informs — a dose for the next study, a label statement, a covariate adjustment, a waiver. "Characterise the population pharmacokinetics" is not an objective; it is an activity.
Secondary objectives: [ ]
Intended use of the model: [ ] — regulators evaluate a model against its intended use, and the required rigour follows from it.
2. Data
| Item | Specification |
|---|---|
| Studies included | [ ] |
| Analysis population | [ ] |
| Analyte and matrix | [ ] |
| Assay and LLOQ | [ ] (see the bioanalytical validation report) |
| Time reference | actual elapsed time from the most recent dose |
| Dataset specification | [ reference the document ] |
| Derivation script | [ path / repository ] |
Exclusions, defined now and applied blind to the model:
- Records with no matching dose record
- Concentrations flagged by the bioanalytical laboratory
- Subjects with documented non-compliance
- Pre-dose concentrations in a first-dose profile above [ ]% of Cmax
- Other: [ ]
BLQ handling: [ M1 / M3 / other ]. Justification: [ ]. Expected BLQ fraction: [ ]%. If the observed BLQ fraction exceeds [ ]%, the method changes to M3.
Missing covariates: [ imputation rule, or exclusion ]. Missingness will be tabulated before imputation.
3. Software
| Estimation | [ NONMEM 7.x / Monolix / nlmixr2 ] version [ ] |
| Orchestration and post-processing | [ Pharmpy / PsN / R ] version [ ] |
| Estimation method | [ FOCE-I / SAEM followed by IMP ] |
| Environment | [ container / lockfile reference ] |
4. Structural model
Starting point: [ ] compartments, [ ] absorption, [ ] elimination.
Candidate structures to be evaluated: [ ]
Parameterisation is clearance-based (CL, V, Q, Vp) in all candidates.
Selection criteria, in this order: physiological plausibility; residual patterns; likelihood-ratio test for nested models (ΔOFV > [3.84] at 1 df); BIC; parameter precision. An extra compartment whose intercompartmental clearance has RSE above [50]% is not retained regardless of the objective function.
5. Between-subject and between-occasion variability
- IIV on: [ ] Distribution: [ exponential ]
- Correlations estimated between: [ ]
- IOV on: [ ], with an occasion defined as [ ]
- Rule for removing a variance component: [ ]
6. Residual error
Candidates: [ proportional / additive / combined / log-transform-both-sides ]. Separate error models by [ study / assay / matrix ]: [ yes / no, with justification ].
7. Covariate model
Covariates included a priori on mechanistic grounds, not tested:
- Body size: allometric scaling on CL (exponent [0.75], [fixed]) and V (exponent [1.0], [fixed])
- Maturation, if paediatric subjects are included: [ function, parameters, fixed or estimated ]
- Other: [ ]
Covariates to be evaluated:
| Covariate | Parameter(s) | Functional form | Rationale |
|---|---|---|---|
| [ ] | [ ] | [ ] | [ ] |
Procedure: [ stepwise covariate modelling / full model estimation ]. If stepwise: forward inclusion at p < [0.05] (ΔOFV > 3.84), backward elimination at p < [0.001] (ΔOFV > 10.83). Note that stepwise selection biases effect sizes upward and narrows intervals; a full-model approach is preferred where the objective is to quantify an effect.
Clinical relevance threshold: a covariate effect is reported as relevant if it changes [ exposure metric ] by more than [ ]% across the [5th–95th] percentile of the covariate.
8. Model evaluation
- Goodness-of-fit: DV vs PRED and IPRED; CWRES vs time and vs PRED; |IWRES| vs IPRED
- Eta shrinkage reported for every eta; covariate plots not interpreted above [30]% shrinkage
- Prediction-corrected VPC, [ n ] replicates, stratified by [ ]
- NPDE with tests of mean, variance and normality
- Parameter uncertainty by [ covariance step / bootstrap (n = ) / SIR / log-likelihood profiling ]
- Condition number reported; above 1000 is treated as ill-conditioned
Acceptance criteria for the final model: [ ]
9. Simulations
Purpose: [ ] Scenarios: [ ] Replicates: [ ] Population sampled from: [ ] Uncertainty in fixed effects propagated: [ yes / no ] Endpoint summarised: [ ]
10. Deviations
Any departure from this plan is recorded in the report with its reason and the date it was decided. Post hoc analyses are labelled as such and reported separately from the pre-specified analysis.
Approvals
| Role | Name | Signature | Date |
|---|---|---|---|
| Author | |||
| Reviewer | |||
| Clinical pharmacology |
references/antimicrobial-and-tdm.md (verbatim)
Antimicrobial PK/PD and therapeutic drug monitoring
PK/PD indices
Antimicrobial efficacy correlates with one of three exposure indices, determined by whether killing is concentration-dependent or time-dependent. The index is a property of the drug class, and using the wrong one leads to the wrong dosing strategy.
| Index | Killing pattern | Classes | Dosing strategy |
|---|---|---|---|
| fT>MIC — fraction of the interval with free concentration above MIC | Time-dependent, minimal persistent effect | Beta-lactams (penicillins, cephalosporins, carbapenems) | More frequent dosing, or extended/continuous infusion |
| fAUC/MIC | Time-dependent with persistent effect | Vancomycin, fluoroquinolones, linezolid, azithromycin, tetracyclines | Total daily dose matters; interval matters less |
| fCmax/MIC | Concentration-dependent | Aminoglycosides, daptomycin, colistin, metronidazole | Once-daily, high peak |
Targets commonly cited from preclinical and clinical work — targets, not regulation, and they vary by organism and endpoint:
| Drug or class | Target |
|---|---|
| Penicillins | fT>MIC ≥ 50% (stasis to 1-log kill) |
| Cephalosporins | fT>MIC ≥ 60-70% |
| Carbapenems | fT>MIC ≥ 40% |
| Vancomycin | AUC₂₄/MIC 400-600 (MIC = 1 mg/L by broth microdilution) |
| Fluoroquinolones | fAUC/MIC ≥ 100-125 for Gram-negatives; ≥ 30-40 for S. pneumoniae |
| Aminoglycosides | Cmax/MIC ≥ 8-10 |
| Daptomycin | fAUC/MIC ~ 666 (S. aureus) |
| Linezolid | fAUC/MIC 80-120 |
The free (unbound) fraction is what matters. For a highly bound agent such as ceftriaxone or daptomycin, total concentrations overstate the active exposure substantially.
Probability of target attainment and cumulative fraction of response
- PTA — for a fixed MIC, the fraction of a simulated population reaching the PK/PD target at a given regimen. Plotted against MIC, the PTA curve gives the PK/PD breakpoint: the highest MIC at which the regimen achieves (conventionally) ≥ 90% attainment.
- CFR — PTA integrated over the MIC distribution of the actual pathogen population, giving a single expected success probability for empirical therapy against that organism.
Both need a population PK model with realistic variability. simulate_regimen.py --simulate with
--target-auc or --target-trough gives the machinery; note it includes between-subject
variability only, so real attainment is lower once residual and between-occasion variability are
added.
Critically ill patients are the population where this matters most and where standard models fail: augmented renal clearance (creatinine clearance above 130 mL/min, common in young trauma and sepsis patients) can put a standard beta-lactam regimen well below target, while acute kidney injury and renal replacement therapy move it the other way.
Vancomycin: AUC-guided dosing
The 2020 consensus guideline (ASHP/IDSA/PIDS/SIDP) moved the target from trough-guided to AUC₂₄/MIC of 400-600, assuming an MIC of 1 mg/L, for serious MRSA infections.
Why troughs were abandoned: trough concentration is a poor surrogate for AUC. Achieving the historical 15-20 mg/L trough target frequently produces AUC₂₄ well above 600 and is associated with more nephrotoxicity, without better efficacy. Two patients with the same trough can have AUCs differing by 50% depending on their volume and interval.
Two accepted methods for estimating AUC:
- Bayesian estimation from one or two levels against a population model. Works with a single level, tolerates levels drawn at imprecise times, and is the preferred approach.
- First-order equations from a peak and a trough within the same interval, both drawn at steady state, with the peak at least 1-2 hours after the end of the infusion so that distribution is complete.
tdm_bayes.py --model vancomycin-adult implements method 1. Its bundled parameterisation is
explicitly illustrative — substitute a model validated in your population, because vancomycin
population models differ substantially between general ward, ICU, obese, paediatric and dialysis
populations.
Model-informed precision dosing
MAP Bayesian forecasting combines a population prior with a patient's measured concentrations:
minimise sum_j (obs_j - pred_j)^2 / var_j + sum_k (eta_k / omega_k)^2
The second term is the prior penalty. Its consequences:
- A single level is enough to be useful but cannot separate clearance from volume. Whichever parameter the sample is uninformative about returns essentially its population value; the reported "individual" estimate for it is the prior.
- Sample timing determines what is learned. Troughs are informative about clearance; a peak (after distribution) is informative about volume. All-trough sampling leaves volume weakly identified.
- A large eta is a data-quality signal first. An individual clearance three-fold the population value is more often a mis-recorded sampling or infusion time than a genuinely unusual patient. Check the times before acting on the estimate.
- The prior must be appropriate to the patient. A model built in general medical inpatients applied to a patient on continuous renal replacement therapy will shrink towards the wrong place, and the fit statistics will not reveal it.
Other drug classes where MIPD is established: aminoglycosides, busulfan (AUC-targeted conditioning), methotrexate rescue, immunosuppressants (tacrolimus, ciclosporin, mycophenolate), antiepileptics, infliximab and other anti-TNF biologics, and increasingly beta-lactams in critical care.
Reporting a TDM calculation
State the population model and its source, the assay and matrix, the actual (not scheduled) dose and sampling times, whether steady state was reached, the estimated individual parameters with the etas, the predicted exposure metric, and the target with its justification. Without the actual times, the calculation cannot be reproduced or audited.
Any change to a patient's regimen is a clinical decision that depends on the organism, the site of infection, renal trajectory, concomitant nephrotoxins and local protocol. The model provides an exposure estimate; it does not provide the decision.
references/bioequivalence.md (verbatim)
Bioequivalence
The ICH M13 series
M13 is the first globally harmonised bioequivalence guidance, replacing a patchwork of regional requirements.
| Guideline | Scope | Status |
|---|---|---|
| M13A | BE for immediate-release solid oral dosage forms: study design and data analysis | Step 4 July 2024; came into effect 25 January 2025 |
| M13B | Additional strengths, including additional-strength biowaivers | Endorsed 13 March 2025; Step 2b, public consultation opened 9 April 2025, comments closed 9 July 2025 |
| M13C | Data analysis for highly variable drugs, narrow therapeutic index drugs, and complex BE study designs | Follows M13B; this is where reference-scaling will finally be harmonised |
Until M13C is adopted, reference-scaled approaches remain regional and mutually incompatible. That is the single most important practical fact about scaled BE: FDA and EMA do not accept each other's method, and a study must be designed for the criterion of the agency it is going to.
Average bioequivalence
The default criterion everywhere:
The 90% confidence interval for the geometric mean ratio (test/reference) of AUC and Cmax must lie entirely within 80.00% to 125.00%.
Computed on log-transformed data — the interval is symmetric on the log scale and asymmetric back-transformed, which is why the limits are 0.80 and 1.25 rather than ±20%.
Narrow therapeutic index drugs are tightened to 90.00-111.11% in several regions, and the FDA additionally requires a comparison of within-subject variability between test and reference.
Designs
| Design | Periods | Gives you |
|---|---|---|
| 2×2 crossover (RT/TR) | 2 | Average BE. Cannot estimate within-subject variability of the reference separately |
| Parallel | 1 | For long half-life drugs; much larger N; only total variability |
| Partial replicate (RRT/RTR/TRR) | 3 | CVwR, so reference-scaling becomes possible |
| Full replicate (RTRT/TRTR or RTR/TRT) | 3-4 | CVwR and CVwT; required for the FDA NTI approach |
| Williams design | ≥3 treatments | Balanced for first-order carryover |
A crossover removes between-subject variability, which is why it needs far fewer subjects than a parallel design. It requires an adequate washout — at least 5 terminal half-lives — and pre-dose concentrations in later periods should be below 5% of Cmax, or the subject is excluded.
Reference-scaled approaches for highly variable drugs
A highly variable drug is one with CVwR > 30%. Both approaches require a replicate design; neither can be applied to a 2×2 study however high the observed variability, because without repeated reference administrations there is no CVwR to scale to.
EMA: average bioequivalence with expanding limits (ABEL)
limits = exp(± 0.760 * swR) capped at CVwR = 50% -> 69.84% - 143.19%
Conditions: replicate design; the widening must be pre-specified in the protocol with clinical justification; the point estimate must still fall within 80.00-125.00%; and widening is applied to Cmax (and for some products AUC, though EMA generally does not permit AUC widening).
FDA: reference-scaled average bioequivalence (RSABE)
Not an interval criterion at all. The criterion is
(mu_T - mu_R)^2 - theta^2 * s2wR <= 0 with theta = ln(1.25)/0.25 = 0.8926
evaluated as a 95% upper confidence bound using Hyslop's linearised method:
E = (Ybar_T - Ybar_R)^2 Eh = (|Ybar_T - Ybar_R| + t(0.95,df)*SE)^2
H = -theta^2 * s2wR Hh = -theta^2 * s2wR * df / chi2(0.05, df)
upper bound = E + H + sqrt((Eh-E)^2 + (Hh-H)^2)
Pass requires the upper bound ≤ 0 and the point estimate within 80-125%. Applied when
CVwR ≥ 30%; below that, unscaled ABE applies. bioequivalence.py --scaling rsabe implements this.
The two criteria can disagree on the same dataset. Which applies is a regulatory fact, not a statistical choice, and must be pre-specified.
Sample size
Driven by three things, in order of influence: the assumed true GMR, the within-subject CV, and the target power.
Published values for a 2×2 crossover, GMR 0.95, 80% power, 80-125% limits — reproduced exactly by
bioequivalence.py --power:
| CVw | N |
|---|---|
| 15% | 12 |
| 20% | 20 |
| 25% | 28 |
| 30% | 40 |
| 35% | 52 |
| 40% | 66 |
Assuming a GMR of 1.00 rather than 0.95 roughly halves the calculated N, and is the most common reason a bioequivalence study comes in underpowered. A GMR of exactly 1.00 is not a realistic planning assumption for two different formulations.
Power must be computed by integrating over the sampling distribution of the estimated standard deviation (equivalently, Owen's Q). Treating the standard error as known overstates power at these sample sizes.
Common errors
- Using a t test. "p > 0.05, therefore the formulations are equivalent" inverts the hypothesis. Failing to detect a difference is not evidence of equivalence, and on a small BE dataset that outcome is nearly guaranteed. The 90% CI (equivalently, two one-sided tests at α = 0.05) is the test.
- Analysing untransformed data. AUC and Cmax are log-normal; the criterion is defined on the log scale.
- Scaling from a 2×2 design. Refused by
bioequivalence.py, and by regulators. - Post hoc scaling. Deciding to widen limits after seeing high variability is not pre-specification.
- Dropping subjects after unblinding for reasons not defined in the protocol.
- Reporting only AUC. Cmax must meet the criterion too, and it is the more variable of the two.
- Ignoring the period effect by analysing as a paired comparison.
bioequivalence.pylabels this explicitly when the sequence column is missing.
Endogenous compounds and other special cases
- Endogenous substances (potassium, iron, hormones) require baseline correction, and the baseline-correction method changes the answer. Pre-specify it.
- Long half-life drugs: AUC(0-72h) is accepted in place of AUC(0-inf) under M13A for immediate release products, avoiding a very long sampling schedule.
- Highly variable Cmax with acceptable AUC is the usual pattern that pushes a programme towards a replicate design.
- Fed versus fasted: both usually required; the food effect study is separate from BE.
references/dataset-standards.md (verbatim)
PK dataset standards: CDISC, NONMEM data items, and the defects that survive review
The two worlds
Regulatory submission data is CDISC. Modelling data is NONMEM-format. They are different shapes and converting between them is where most defects are introduced.
| Layer | Domain / dataset | Contents |
|---|---|---|
| SDTM | PC | Pharmacokinetic concentrations, as collected |
| SDTM | PP | Pharmacokinetic parameters (NCA output) |
| SDTM | EX | Exposure — what was actually administered |
| ADaM | ADPC | Analysis-ready concentrations |
| ADaM | ADPP | Analysis-ready parameters |
| — | NONMEM dataset | One row per event, wide covariates, numeric only |
Useful SDTM PC variables: PCTESTCD/PCTEST (analyte), PCORRES/PCSTRESN (result as collected
and standardised), PCSTRESU, PCLLOQ, PCTPT/PCTPTNUM (nominal time), PCDTC (actual
date/time), PCSPEC (matrix). PP parameters use the CDISC PKPARM/PKUNIT controlled
terminology — AUCALL, AUCIFO, AUCIFP, CMAX, TMAX, LAMZ, LAMZHL, CLFO, VZFO.
Nominal versus actual time is the single most consequential conversion decision. NCA and population modelling should use actual elapsed time from the most recent dose. Using nominal time flattens the absorption phase, biases Cmax and Tmax, and inflates residual error. Nominal time is for grouping and presentation only.
NONMEM data items
| Item | Meaning | Traps |
|---|---|---|
ID |
Subject | Must be numeric and contiguous per subject; records for one subject must be together |
TIME |
Elapsed time | Must be non-decreasing within a subject. Use one unit consistently |
DV |
Dependent variable | Must be numeric. See below |
AMT |
Dose amount | On a dose record only; units must match the model's |
EVID |
Event ID | 0 observation, 1 dose, 2 other, 3 reset, 4 reset+dose |
MDV |
Missing DV | 1 means the record contributes nothing to the objective function |
CMT |
Compartment | Which compartment is dosed or observed |
RATE |
Infusion rate | >0 a rate; -1 model-estimated duration; -2 model-estimated rate |
SS |
Steady state | 1 = achieve steady state before this dose; requires II |
II |
Interdose interval | Required by both SS and ADDL |
ADDL |
Additional doses | n further doses every II; silently does nothing without II |
The defects that do not stop a run
These are the reason check_popk_dataset.py exists. None of them raises an error in NM-TRAN.
- Non-numeric
DV.BLQ,<LLOQ,NDare read as 0 and fitted as genuine zero concentrations. This is the most damaging defect in the list, and it is invisible. - Missing covariate read as 0. A blank or
.in aWTcolumn becomes a 0 kg patient in the covariate model. Missing covariates must be imputed explicitly and the imputation documented, or the subject excluded. ADDLwithoutII. No additional doses are placed. Exposure is understated by the whole accumulation.SSwithoutII. Same class of failure.- Duplicate timestamps. A dose and an observation at the same
TIMEare applied in file order, so whether the sample is pre- or post-dose depends on row order. Order dose records before observations at the same time, or offset the observation by a small negative amount. - Unsorted
TIMEwithin a subject. NONMEM does not sort for you. - A subject with doses but no observations. They contribute no information but appear in the N of the analysis and their etas come entirely from the prior.
- A subject with observations but no dose. Their predictions are zero and their residuals are the whole observation.
- Time-varying covariate declared as baseline. The model uses whichever value is on the record being evaluated, which is rarely what was intended.
- Units. Dose in mg with concentrations in ng/mL gives a volume off by 10⁶. Nothing checks this; the fit will converge on a nonsense volume.
RATEleft on an oral record, turning first-order absorption into a zero-order infusion.- Mixed time origins — some subjects timed from first dose, others from screening.
Handling BLQ properly
Keep the numeric DV and add a separate flag:
ID,TIME,DV,AMT,EVID,MDV,BLQ,LLOQ
1,0,.,100,1,1,0,0.5
1,1,4.21,.,0,0,0,0.5
1,24,0.5,.,0,0,1,0.5 <- DV set to LLOQ, BLQ flag set, method chosen in the control stream
Then implement the chosen method (usually M3) in the model rather than by editing the data. See
population-pk.md for the M1-M7 comparison.
Structuring covariates
- Baseline covariates appear once per subject and are repeated on every record.
- Time-varying covariates change between records and must be declared as such. Last-observation carried forward is the usual interpolation, and it is an assumption worth stating.
- Categorical covariates need a numeric coding and a documented reference level. Never leave a category blank to mean "reference".
- Derived covariates (creatinine clearance, BSA, lean body weight) should be computed once, documented with the formula used, and stored — not recomputed in the control stream where the formula is invisible to a reviewer.
Dataset specification
Every population analysis dataset should ship with a specification listing, per column: name, label, type, units, derivation (including the source SDTM/ADaM variable), permissible values, and the missing-data rule. This is the document a reviewer reads first, and producing it usually surfaces at least one defect on its own.
A reproducible derivation script from the ADaM datasets to the modelling dataset is worth more than the dataset itself: it is what makes a re-run possible after a database lock update.
Back to K-Dense-AI/scientific-agent-skills (AI Scientist skills) or Agent skills.