Orientation to nlmixr2

Understand what nlmixr2 is, why it is used, and how population models are organized before fitting models.
Tip

Big picture: Before fitting population models, it is helpful to understand what tools are available and how models are organized conceptually.

Learning Objectives

By the end of this lesson, you will be able to:

  • Explain what nlmixr2 does.
  • Distinguish rxode2 and nlmixr2.
  • Describe the structure of an nlmixr2 model.
  • Interpret ini() and model() blocks.
  • Understand where estimation fits into the workflow.

Key Ideas

  • nlmixr2 fits nonlinear mixed-effects models.
  • rxode2 solves and simulates models.
  • Models are written before estimation begins.
  • Population models combine structure and variability.

Why Do We Need Modeling Software?

Population models combine:

  • structural equations
  • variability
  • covariates
  • estimation
  • diagnostics
  • simulation

Modern tools automate these tasks.


What Is nlmixr2?

nlmixr2 is an open-source R ecosystem for population modeling.

It supports:

  • population PK
  • PK/PD
  • nonlinear mixed effects
  • simulation
  • diagnostics

The package separates:

Model

↓

Estimation

↓

Diagnostics

↓

Simulation

Worked Example 1: The Ecosystem

Data
↓
rxode2 Model Specification
↓
nlmixr2 Estimation
↓
Diagnostics
↓
Simulation

Typical responsibilities:

Package Purpose
rxode2 Solve and simulate
nlmixr2 Estimate population models
ggPMX Diagnostics
nlmixr2plot Evaluation

Anatomy of an nlmixr2 Model

A simplified model structure:

model <- function() {

  ini({

  })

  model({

  })

}

Interpretation:

ini()

↓

parameters

model()

↓

equations

Worked Example 2: Reading a Model

model <- function() {

  ini({

    tcl <- log(5)

  })

  model({

    cl <- exp(tcl)

  })

}

Interpretation:

  • initialize parameters
  • transform parameters
  • define model behavior

No estimation happens yet.


Estimation (Preview Only)

Later we will fit models.

Conceptually:

Model
+
Data

↓

Optimization

↓

Estimated Parameters

Common algorithms:

  • FOCEi
  • SAEM

We introduce these later.


Strategies

  • Understand structure first.
  • Fit later.
  • Interpret scientifically.

Common Mistakes

  • Memorizing syntax.
  • Ignoring assumptions.
  • Overcomplicating first models.

Practice Problems

  1. Explain the role of nlmixr2.
  2. Explain rxode2.
  3. Describe ini() vs model().

nlmixr2 estimates models.

rxode2 solves equations.

ini() defines parameters and model() defines equations.


Summary

  • nlmixr2 supports population modeling.
  • Models separate parameters and equations.
  • Estimation comes after model specification.

  • Learn ideas before syntax.
  • Build models incrementally.
  • Estimation is not the first step.