library(tidyverse)
library(nlmixr2)
library(nlmixr2data)
data(
"theo_sd",
package = "nlmixr2data"
)Residual Error Models
Big picture: Population models describe not only subject differences but also observation-level variability.
Learning Objectives
By the end of this lesson, you will be able to:
- explain residual error conceptually
- distinguish residual error from between-subject variability
- compare additive, proportional, and combined residual error models
- recognize residual error syntax in
nlmixr2 - explain when different error models may be useful
Key Ideas
- Predictions are never perfectly observed.
- Residual error represents remaining disagreement.
- Different residual error models imply different assumptions.
- Residual error is not model failure.
Setup
Why Residual Error Exists
Suppose the model predicts:
Concentration = 10
Do we always observe:
Concentration = 10
No.
Observed values differ.
Sources include:
- assay variability
- sampling timing
- biological fluctuations
- model simplification
Conceptually:
Prediction
+
Residual Error
↓
Observation
Worked Example 1: Locate Residual Error
Inspect earlier model syntax.
linCmt() ~ add(add.err)Interpretation:
Prediction
↓
Add Residual Error
↓
Observation
This line specifies the observation model.
Worked Example 2: Additive Error Model
One possibility:
\[ DV = IPRED + \epsilon \]
Interpretation:
Residual variability remains approximately constant.
Example:
Prediction = 10
Observed = 11
Observed = 9
Observed = 10
Same absolute spread.
In nlmixr2:
linCmt() ~ add(add.err)Worked Example 3: Proportional Error Model
Another possibility:
\[ DV = IPRED(1+\epsilon) \]
Interpretation:
Residual variability increases as prediction increases.
Example:
Prediction = 10 ±10%
In nlmixr2:
linCmt() ~ prop(prop.err)Larger concentrations show larger variability.
Worked Example 4: Combined Error Model
A common alternative:
\[ DV = IPRED(1+\epsilon_p)+\epsilon_a \]
Interpretation:
Combine:
- fixed variability
- relative variability
In nlmixr2:
linCmt() ~ add(add.err) + prop(prop.err)This often provides flexibility across concentration ranges.
Worked Example 5: Compare Variability Sources
Do not confuse:
| Source | Meaning |
|---|---|
| ETA | subject differences |
| Residual error | observation disagreement |
Conceptually:
Typical Parameter + ETA
↓
Prediction + Residual Error
↓
Observation
Population models contain both.
Additive vs Proportional Thinking
Conceptually:
Additive
Same Spread
versus
Proportional
Spread Grows
Choose based on scientific behavior.
Connect to Residuals
Earlier we used:
RES
IRES
Residual quantities measure disagreement.
Residual error models describe assumptions about that disagreement.
Residuals do not create the model.
Residual assumptions create the model.
Looking Ahead
We now understand:
Prediction
↓
Residual Error
↓
Observation
Next we ask:
Can variability components interact?
The next lesson introduces variability structures and correlations.
Strategies
- Think biologically.
- Compare assumptions.
- Interpret spread.
Common Mistakes
- Using one error model everywhere.
- Treating residuals as error models.
- Forgetting observation noise.
Practice Problems
What does residual error represent?
Compare additive and proportional error.
Why might combined error be useful?
Interpret:
linCmt() ~ prop(prop.err)- Explain:
Prediction
↓
Residual Error
↓
Observation
Problem 1
Residual error represents remaining disagreement.
Problem 2
Additive:
constant spread
Proportional:
spread increases
Problem 3
Combined error allows both behaviors.
Problem 4
Residual variability scales with prediction size.
Problem 5
Observations differ from predictions because of residual variability.
Summary
- Residual error models observation variability.
- Additive and proportional assumptions differ.
- Combined models offer flexibility.
- Residual error is not model failure.
- ETA ≠ residual error
- Error ≠ failure
- Residual assumptions matter