Pharmacometrics in R on the Posit blog

By Matthew Fidler in nlmixr2

October 16, 2026

Watch on YouTube

Janice Goh and I wrote a post for the Posit blog: Tiny Doses for Tiny Babies – How much is too much? It is a hands-on introduction to pharmacometrics for R users who have never built a pharmacokinetic model. Posit also published a narrated video walkthrough of the post (above).

The question

A preterm infant weighing 900 g is having seizures. A doctor has read that one flat dose of phenobarbital might work for every neonate, which would save dose calculations at the bedside. Is a flat dose chosen for the average 1.5 kg baby right for a 900 g baby?

To answer that we use pheno_sd, the Grasela and Donn (1985) data set that ships with nlmixr2. It has 59 infants, 589 doses and only 155 concentrations; most infants have one or two samples.

What the post covers

  • Why a pharmacokinetic model. If you have fit a mixed model you have done half of this. The mean function is the solution to an ODE, and its parameters (clearance and volume) mean something physiologically.
  • Writing and fitting the model in nlmixr2. One R function with an ini({}) block and a model({}) block, fit with SAEM.
  • Adding body weight. Allometric weight scaling more than halves the between-infant variability, from 38.9% to 19.0% CV on clearance.
  • Simulating both dosing options with rxode2. Under the flat dose the median week-2 concentration falls from 39.4 mg/L at 0.7 kg to 12.3 mg/L at 3.1 kg, and only 3.3% of the heaviest infants reach the 15-40 mg/L target. Weight-based dosing keeps about 94-100% of simulated infants in the target range across all weights.
  • The wider ecosystem. babelmixr2, nonmem2rx and monolix2rx for working with NONMEM and Monolix, plus PKNCA, PopED, xpose.nlmixr2, ggPMX, tidyvpc, shinyMixR and nlmixr2rpt.

A flat dose works for the average infant and fails at the extremes. This is a teaching example, not dosing guidance. A real neonatal analysis would also need postnatal age and maturation.

The full code is in the post, so you can run the analysis yourself. Read it on the Posit blog or watch the video.

Thanks to Posit for hosting it, and to Janice for the clinical framing.

Posted on:
October 16, 2026
Length:
2 minute read, 362 words
Categories:
nlmixr2
See Also: