Tutorials › Pharmacometric Workflows and Reproducible Modeling › Observed Versus Population Predictions

Automating Diagnostics and Reports · Tutorial 283 of 399

Observed Versus Population Predictions

Build reproducible observed-versus-population-prediction plots by pairing records correctly and choosing defensible reference lines, ranges, units, and scales.

Intermediate 10 min read

What You'll Learn

  • Define the observed and population-prediction quantities that form each plotted point.
  • Pair observations and predictions by record rather than by row order alone.
  • Add an identity line using compatible units and appropriately matched axis limits.
  • Choose linear or logarithmic axes based on the data and the question.
  • Specify and report axis ranges, transformations, and exclusions reproducibly.
  • Recognize how scaling choices and repeated observations affect what a plot shows.

What the Plot Compares

An observed-versus-population-prediction plot places one observed response and its corresponding population prediction at each data record. It is a direct visual comparison of the measured values with predictions from the population model. Its usefulness depends on a basic condition: each point must pair quantities that refer to the same record, response, time, and covariate conditions.

Here, “population prediction” means the prediction generated from the population model according to the diagnostic output specification, without conditioning the prediction on an individual's estimated random effects. The exact output definition should be documented in the analysis workflow; software and model specifications can use prediction labels differently. Conditional or individual predictions are a distinct comparison.

Definition: For record \(i\), let \(y_i\) be the observed response and let \(\hat y_{\mathrm{pop},i}\) be the corresponding population prediction. Plot the paired point \((x_i,y_i)=(\hat y_{\mathrm{pop},i},y_i)\), with population prediction on the horizontal axis and observation on the vertical axis. When both quantities have the same meaning and units, the identity reference is \(y=x\).

The identity line is a reference for equality, not a fitted regression line. A point on it has an observed value equal to its population prediction. A point above it has an observed value greater than its prediction; a point below it has an observed value less than its prediction. These statements describe position relative to the reference and do not, by themselves, establish why a difference occurred.

Prepare and Pair the Data Before Plotting

A reliable plotting workflow starts from a tidy data set in which the observed response and population prediction are columns on the same record. Use the canonical record identifiers and response definitions established in the diagnostic data schema. If observations and predictions are held in separate tables, join them using the identifiers that uniquely define a record, such as subject, occasion, time, and response type. Do not match two columns merely because their rows happen to be in the same order.

Before drawing the plot, check that each retained record has both values, that both values describe the same response, and that the prediction corresponds to the observation's time and covariates. Confirm compatible units. For instance, an observation in milligrams per liter cannot be compared directly with a prediction in micrograms per liter: convert one column before plotting. If records are missing, duplicated, or nonfinite, apply the reporting rules specified for the diagnostic output and make exclusions visible in the report. Do not silently remove records or create artificial pairs.

Repeated observations from one subject normally appear as multiple points, since each point represents an observation record. Those points are not independent subjects. A plot can still display them, but a dense cluster of records from a few subjects should not be mistaken for broad subject-level coverage.

Worked Example: Pairing Records and Setting Linear Axes

Suppose a hypothetical diagnostic table contains four records for one response, concentration in milligrams per liter. Each row already matches the observation and population prediction by subject and time.

RecordPopulation prediction (mg/L)Observation (mg/L)
A at 1 h1.21.0
B at 2 h2.83.4
C at 4 h5.14.7
D at 8 h8.49.1

For record A, the plotted coordinate is \((1.2,1.0)\), not \((1.0,1.2)\), because predictions belong on the horizontal axis. The same rule gives \((2.8,3.4)\), \((5.1,4.7)\), and \((8.4,9.1)\) for the remaining records. Each pair uses the same units, so an identity line is meaningful.

Across both columns, the minimum is \(1.0\) mg/L and the maximum is \(9.1\) mg/L. A simple common axis range is therefore 0 to 10 mg/L on both axes. The reference runs from \((0,0)\) to \((10,10)\). The plotted coordinates retain their record pairing: for example, the point \((2.8,3.4)\) lies above the identity line because \(3.4>2.8\). This example is hypothetical and illustrates plotting choices, not a model assessment.

Identity Lines and Axis Ranges

The line \(y=x\) is appropriate only when the two axes measure the same quantity in compatible units. Given common axis limits \(L\) and \(U\), draw the reference from \((L,L)\) to \((U,U)\). Setting both axes to the same limits makes the displayed range comparable: a given difference from equality is not visually altered by assigning a wider numeric range to one axis than the other.

For automatic ranges, calculate the limits from the combined values on both axes, not separately. A basic rule is \(L=\min(\{x_i\}\cup\{y_i\})\) and \(U=\max(\{x_i\}\cup\{y_i\})\). If padding is desired, apply the same padding rule to these shared limits, then use the resulting limits on both axes. In many reports, clean, prespecified bounds are easier to compare across runs than data-dependent bounds. If fixed bounds are used, report them and do not clip points without indicating that they fall outside the displayed range.

Equal numeric limits do not necessarily make the identity line appear at 45 degrees on the screen: the plotting panel may be wider than it is tall. When the visual angle matters, use an equal coordinate aspect ratio as well as equal axis limits. Otherwise, preserve the equal numerical scales and understand that the panel shape changes the line's apparent angle.

Justification: A point is on the equality reference exactly when its coordinates satisfy \(y=x\). The endpoints \((L,L)\) and \((U,U)\) satisfy that equation, so joining them draws the identity line across a shared range. Separate limits would still allow points to be compared numerically, but would give the two axes different visual units per plotting distance and could distort apparent departures from equality.

Worked Example: Logarithmic Axes for Positive Concentrations

Consider four hypothetical records with positive observed and predicted concentrations in the same units, mg/L.

RecordPrediction (mg/L)Observation (mg/L)
A0.20.1
B23
C2010
D816

A logarithmic scale can make the lower and higher concentrations visible together when values span a wide range. These data span a factor of \(20/0.1=200\). Choose a common range such as 0.1 to 100 mg/L for both axes, and plot the paired coordinates \((0.2,0.1)\), \((2,3)\), \((20,10)\), and \((8,16)\). Use the same logarithm base and limits on both axes.

The identity line remains the appropriate reference. To see why, let the displayed coordinates be \(X=\log_{10}(x)\) and \(Y=\log_{10}(y)\). On the identity line \(y=x\), so \(Y=\log_{10}(y)=\log_{10}(x)=X\). Thus the equality reference is still a straight diagonal in log coordinates. For record A, \(0.1<0.2\), so the observation is below the reference; for record D, \(16>8\), so it is above. Differences on a log scale reflect multiplicative rather than equal additive spacing.

A logarithm is defined only for positive values. A zero or negative observation or prediction cannot be displayed on these axes. Do not replace zero by an arbitrary small positive number simply to make the plotting function accept it. Investigate why the value occurs and follow a documented approach, such as using a linear-scale panel or a separately specified representation. State any exclusions and their reason.

Choosing a Scale and Automating the Plot

A linear scale is usually the clearest choice when the response range is moderate and differences in the response's original units are the main focus. A logarithmic scale can be useful when positive values span several orders of magnitude or when relative differences are more informative than absolute differences. Scale choice should follow the measurement and reporting purpose, not the appearance of a preferred pattern. A log axis does not make zero values valid and should not be selected solely because it makes a plot look more orderly.

For reproducible reports, treat scale and range choices as explicit configuration rather than informal plotting defaults. A plot specification should identify the response and units, the prediction definition, the axis variables, the scale transformation, the limits or range rule, and how missing or invalid values are handled. It should also specify whether plots use fixed limits across reports. These details make it possible to regenerate the same figure and compare runs without confusing a change in axis settings with a change in model output.

1
Select the records.
Filter to the intended response and population-prediction definition. Retain the identifiers needed to pair each prediction with its observation.
2
Validate the pairs.
Check units, record keys, duplicates, missing values, and whether each prediction corresponds to the observation's conditions. Apply documented handling rules rather than silently changing the data.
3
Set scales and limits.
Choose linear or logarithmic scales based on the response values and purpose. Use common limits for the two axes and ensure every retained value is visible.
4
Draw and label.
Put population prediction on the horizontal axis and observation on the vertical axis, include units on both labels, and add the identity reference across the displayed range.
5
Record the choices.
Store the transformation, limits, exclusions, and prediction definition with the report metadata so that the plot can be interpreted and reproduced.

Worked Example: Applying Shared Limits Across Report Panels

A hypothetical automated report makes separate panels for two groups, but both panels show the same response in mg/L. The first group's values range from 0.8 to 4.0 mg/L across observations and predictions; the second group's values range from 2.0 to 18.0 mg/L. Suppose the report is intended to support visual comparisons of absolute values between groups.

The combined minimum is 0.8 mg/L and the combined maximum is 18.0 mg/L. Choose, for example, shared limits of 0 to 20 mg/L for both axes in both panels. Each panel then uses the same coordinate system, and each identity line runs from \((0,0)\) to \((20,20)\). A point at \((4,6)\) has the same visual meaning in either panel: its observation is 2 mg/L above its prediction.

If instead each group received limits tailored to its own range, the narrow-range group's points would occupy more of its panel. That may help inspect within-group structure, but a given absolute difference could look larger in one panel than another. It would no longer support straightforward visual comparison of absolute values. The appropriate choice depends on the reporting question, so the automated specification must say whether ranges are shared or panel-specific.

Diagnostics, Alternatives, and Limitations

Several checks can reveal that the plotting pipeline is not doing what was intended. Confirm that the number of plotted points agrees with the number of eligible paired records and that plotted coordinates can be traced back to the source table. Check for points outside the limits, unexpected empty panels, or a scale that cannot represent the retained values. Inspect labels for both the response and its units. A reversed axis assignment can produce a plausible-looking cloud, so verify a few known records against their expected coordinates.

The main alternative within this comparison is to use different axis ranges or different scales in separate panels. This can be useful when the purpose is to inspect each group at its own resolution, but it sacrifices some direct visual comparability. A population-prediction plot can also be presented on a linear scale or a logarithmic scale; neither is universally preferable. The choice affects which differences are visually prominent and must be made explicit.

This plot is a compact comparison, not a complete diagnostic assessment. Points can overlap, repeated observations from the same subject can be numerous, and a broad pattern can conceal behavior across time, covariates, or subjects. The identity line is a fixed equality reference; it does not estimate a regression relationship or quantify uncertainty. Use the plot for its intended comparison and consult complementary diagnostics when the question concerns a different feature of model performance.

Common Mistakes

  • Pairing by row order. Two separately sorted columns can contain the right values but the wrong pairs. Join by record identifiers and verify representative records.
  • Putting observations on the horizontal axis by habit. Use the stated convention: prediction horizontally, observation vertically, and label both axes.
  • Using separate limits without noticing. Unequal ranges can distort visual comparisons. Set a shared range for the two axes and document whether limits are shared across panels.
  • Applying a log scale to zeros. Logarithmic axes require positive values. Do not silently drop or arbitrarily alter nonpositive records.
  • Comparing incompatible quantities. An identity line requires the same response quantity and compatible units. Convert units or do not use that equality reference.
Key takeaway: A defensible observed-versus-population-prediction plot starts with correctly paired records, uses compatible quantities and units, and makes its identity line, limits, scale, and exclusions explicit.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. For an observation of 6 mg/L and its population prediction of 8 mg/L, what coordinates should be plotted, and where is the point relative to the identity line?
  2. Predictions range from 1 to 9 mg/L and observations range from 2 to 12 mg/L. Give a shared linear range that includes all values and state the identity-line endpoints.
  3. Why does the identity reference remain a straight line when both axes use the same logarithmic transformation?
  4. A record has a zero observation. Can it be included on a logarithmic observed-versus-prediction plot without changing its value? What is a defensible response?

Solutions. 1. Plot \((8,6)\), with prediction on the horizontal axis and observation on the vertical axis. Since \(6<8\), the point is below \(y=x\). 2. A shared range of 0 to 12 mg/L includes all values; the identity line runs from \((0,0)\) to \((12,12)\). 3. On log axes, equality \(y=x\) gives \(\log(y)=\log(x)\), so the transformed coordinates are equal and the reference is still a diagonal. 4. No. The logarithm of zero is undefined. Use an appropriate linear-scale display or another documented treatment; do not replace zero with an arbitrary positive value.

Clinical Biostats