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
nlmixr2does. - Distinguish
rxode2andnlmixr2. - Describe the structure of an
nlmixr2model. - Interpret
ini()andmodel()blocks. - Understand where estimation fits into the workflow.
Key Ideas
nlmixr2fits nonlinear mixed-effects models.rxode2solves 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
- Explain the role of nlmixr2.
- Explain rxode2.
- Describe ini() vs model().
TipStep-by-Step Solutions
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.
TipQuick Tips
- Learn ideas before syntax.
- Build models incrementally.
- Estimation is not the first step.