Tutorials › Nonlinear Mixed-Effects Models (NLME) › Binning Time for a VPC

Visual and Numerical Predictive Checks · Tutorial 576 of 797

Binning Time for a VPC

Compare three ways to define VPC time bins and see how explicit boundaries determine the observed and simulated records summarized together.

Intermediate 12 min read

What You'll Learn

  • Define a time bin as a set of times with explicit lower- and upper-bound rules.
  • Compare fixed-width, equal-count, and design-informed bin boundaries.
  • Assign observed and simulated records consistently using the same boundaries.
  • Calculate bin membership and check the resulting record counts.
  • Diagnose misleading choices, including bins selected using observed outcomes.

Why Time Bins Matter in a VPC

A visual predictive check (VPC) compares summaries of observed outcomes with summaries from replicate data simulated under a fitted model. Time is often continuous, while the plot displays summaries at a manageable number of time locations. Binning provides those locations: each bin collects records whose sampling times fall within a defined interval, and the outcomes in that bin are the records used for its summaries.

Consequently, binning is not just a plotting convenience. Changing a boundary can move a record from one summary to another, changing the data represented at both locations. The time boundaries should be chosen to represent the sampling design and the intended time resolution, not to make observed outcomes appear to agree with the model.

Definition: A time bin is a specified set of sampling times, usually an interval with stated lower- and upper-bound rules. For bin \(k\), let \(B_k\) denote its set of times. An observed record with time \(t_{ij}\) belongs to bin \(k\) exactly when \(t_{ij}\in B_k\). The same bin definitions are applied to simulated records at the corresponding design times.

Here, \(i\) indexes subjects, \(j\) indexes records within a subject, \(t_{ij}\) is the time of record \(j\) for subject \(i\), and \(Y_{ij}\) is its observed outcome. Write \(Y^{\mathrm{rep}}_{ijr}\) for the corresponding outcome in replicate simulation \(r\). In a design-matched predictive check, the replicate outcomes are generated for the same subject and sampling-time design, so the observed record and its simulated counterparts have the same bin membership. If simulations instead use a different sampling design, that design must be mapped explicitly; it is not valid to silently assign records using unrelated time points.

Specify Boundaries Before Assigning Records

A set of bins needs both cutpoints and a convention for points exactly on a cutpoint. One convenient convention is left-closed and right-open intervals, such as \([0,2)\) and \([2,4)\), with the final interval closed at its upper boundary if needed. Under this rule, a time exactly equal to 2 belongs to \([2,4)\), not \([0,2)\). Other conventions can work, but they must create a non-overlapping partition: every eligible record belongs to one bin and only one bin.

For cutpoints \(c_0<c_1<\cdots<c_K\), a common definition is \(B_k=[c_{k-1},c_k)\) for \(k=1,\ldots,K-1\), with the last bin \(B_K=[c_{K-1},c_K]\). Its observed record count is

$$ n_k=\sum_i\sum_j I(t_{ij}\in B_k), $$

where \(I(\cdot)\) equals 1 when its condition is true and 0 otherwise. The corresponding simulated outcomes included in bin \(k\) are \(Y^{\mathrm{rep}}_{ijr}\) for precisely those \((i,j)\) satisfying \(t_{ij}\in B_k\). This membership rule is the key link between boundaries and VPC summaries. The later calculation of quantiles does not change which records belong to a bin.

Three Ways to Choose Time Bins

ApproachHow boundaries are chosenUseful featureMain caution
Fixed-widthUse intervals of a common duration, such as every 2 hours.Each bin has a consistent time span, making elapsed-time comparisons straightforward.Record counts can vary greatly across bins.
Equal-countChoose cutpoints so bins contain roughly similar numbers of observed records.Can avoid bins with very few records when the sampling-time distribution is suitable.Bin widths vary, and records—not necessarily subjects—are balanced.
Design-informedUse prespecified sampling times, dose-relative phases, or scientifically meaningful time regions.Boundaries can align with the study design or a known change in interpretation over time.Choices need a clear rationale and must not be tuned to observed outcomes.

Fixed-width bins are simple to communicate: a bin always spans the same duration. Equal-count bins target the number of records rather than the width of time. If sampling is dense in one region and sparse in another, equal-count bins may therefore be narrow in the dense region and wide elsewhere. A design-informed choice can reflect protocol timing or a prespecified scientific question; it need not have equal widths or counts.

These approaches are alternatives, not guarantees of a good check. Whatever the rule, inspect the resulting counts and time coverage. A chosen method should be applied consistently to the observed data and to all replicate simulations, with the same boundaries and endpoint convention. If the purpose is to compare outcomes at corresponding sampling times, bin membership should be based on time, not on whether an observed or simulated outcome is high or low.

Worked Example: Assigning Records to Fixed-Width Bins

Suppose one subject has observed samples at times 0, 1, 2, 4, 5, and 7 hours. For illustration, use fixed-width bins \([0,2)\), \([2,4)\), \([4,6)\), and \([6,8]\). Apply the stated left-closed, right-open convention, closing the last interval at 8.

Assign the observations. The 0- and 1-hour records enter \([0,2)\). The 2-hour record enters \([2,4)\), while 4 and 5 hours enter \([4,6)\). The 7-hour record enters \([6,8]\).

Check the counts. The bin counts are \(n_1=2\), \(n_2=1\), \(n_3=2\), and \(n_4=1\). Their sum is \(2+1+2+1=6\), the number of observed records, so each record has been assigned exactly once.

Map simulated outcomes. If replicate simulations contain outcomes at those same six sampling times, their outcomes at 0 and 1 hours enter the first bin; the simulated outcome at 2 hours enters the second; and so on. A simulated value at 2 hours does not move to the first bin merely because 2 is its upper boundary: the endpoint convention assigns it to the second.

Choosing Boundaries and Verifying Membership

For equal-count bins, first sort the observed record times, then select cutpoints that divide the records into groups of approximately the desired size. The resulting boundaries are still time cutpoints: once selected, they define intervals that are applied to records, rather than assigning a fixed number of records anew in every simulation. If multiple records occur at the same time, the cutpoint rule should not split records at that time across bins. Exact equality of counts may then be impossible, and approximate balance is preferable to an ambiguous assignment.

Equal-record counts do not imply equal subject representation. A subject with many samples can contribute more records to a bin than a subject with only one sample there. The binning rule answers which times are grouped; it does not, by itself, determine whether summaries give equal weight to subjects. Keep those two decisions conceptually separate.

Design-informed boundaries can be set using protocol features or a scientific rationale defined before reviewing outcome patterns. For example, a planned early sampling phase and a later phase might motivate separate time regions. The resulting cutpoints should be stated numerically and their endpoint convention made explicit. A convenient-looking label such as “early” is not enough to reproduce the assignment.

Worked Example: Constructing Equal-Count Bins

Consider eight observed records at distinct times 0, 1, 2, 3, 4, 5, 6, and 7 hours. To form four equal-count bins, target two records per bin. Put cutpoints halfway between adjacent times at the desired divisions: 1.5, 3.5, and 5.5 hours. Use the intervals \([0,1.5)\), \([1.5,3.5)\), \([3.5,5.5)\), and \([5.5,7]\).

Assign the records. The first bin contains 0 and 1 hours; the second contains 2 and 3 hours; the third contains 4 and 5 hours; and the fourth contains 6 and 7 hours. Thus \(n_1=n_2=n_3=n_4=2\), and the total is \(4(2)=8\) records.

Interpret the widths. The first interval spans 1.5 hours, the middle intervals each span 2 hours, and the final interval spans 1.5 hours. Equal counts did not produce equal-width bins. The midpoint cutpoints lie between observed times, so no observed time is on a boundary in this example.

Apply the bins consistently. The same numerical cutpoints classify the corresponding simulated outcomes. They are not recalculated separately for each replicate according to that replicate’s outcome values. If records share a time at a proposed cutpoint, keep all records at that time together and accept unequal counts or revise the cutpoint using a prespecified time-based rule.

Worked Example: Defining Design-Informed Time Regions

Suppose a hypothetical protocol motivates three time regions: an early region from 0 to 1 hour, a middle region from 1 to 4 hours, and a later region from 4 to 12 hours. Use \([0,1)\), \([1,4)\), and \([4,12]\). For one subject, observed sample times are 0.25, 1, 2.5, 4, and 8 hours.

Assign the observations. The 0.25-hour record enters the early bin. The records at 1 and 2.5 hours enter the middle bin. The records at 4 and 8 hours enter the later bin. The counts are therefore 1, 2, and 2, which sum to the five observed records.

Check the scientific boundary. The sample at exactly 1 hour belongs to the middle region, and the sample at exactly 4 hours belongs to the later region. Those decisions follow from the interval definitions, not from the observed concentrations.

Use the same mapping for replicates. Simulated outcomes at 1 hour are included in the middle region, and those at 4 hours are included in the later region. A design-informed rationale can justify the boundaries, but the boundaries must still partition time without overlap or gaps over the analyzed range.

Why the Assignment Rule Works—and How It Can Fail

The assignment is a deterministic function of time and the prespecified boundaries. For a partition \(B_1,\ldots,B_K\), each included time belongs to one set only. Therefore, summing the indicators over bins gives

$$ \sum_{k=1}^{K} I(t_{ij}\in B_k)=1. $$

Summing this identity over all included records shows that the bin counts must add to the total number of included records:

$$ \sum_{k=1}^{K} n_k =\sum_i\sum_j\sum_{k=1}^{K} I(t_{ij}\in B_k) =\sum_i\sum_j 1. $$

This is a simple but useful audit: if the counts do not add up, some times may fall in a gap, some records may have been counted twice, or the analysis may have excluded records without documenting the exclusion. It is also why cutpoint conventions matter. If adjacent intervals both include their shared boundary, a record exactly at that time can be counted twice.

Several checks help detect problems before interpreting a VPC:

  • Inspect counts and coverage. Tabulate the number of observed records in each bin and check that all intended records are assigned. Record counts are not a complete measure of subject representation, but they reveal empty or unexpectedly populated bins.
  • Review cutpoints against actual times. Check whether many observations lie exactly on a boundary and confirm that the written convention assigns each one once.
  • Confirm simulation alignment. For design-matched replicates, verify that the times used for assignment match the intended sampling design and that every replicate uses the same boundaries.
  • Look for outcome-driven choices. Moving a boundary because a particular observed quantile looks unfavorable makes the check harder to interpret. Choose boundaries using time and design information, not the outcomes being checked.

A common mistake is to calculate equal-count cutpoints separately for observed data and for each simulated replicate. That gives observed and simulated summaries different time regions, so apparent differences may reflect different bin membership rather than model performance. The correction is to choose the boundaries once under a stated rule and apply those same boundaries to every relevant data set.

Choosing Among the Approaches

The main trade-off is between consistent time width, balanced record counts, and alignment with design or scientific regions. Fixed-width bins make the duration represented by each summary easy to interpret. Equal-count bins allocate similar numbers of records to each time region when the data permit, but their widths vary and record balance can obscure unequal subject contributions. Design-informed bins can make a VPC easier to relate to protocol phases, but depend on a defensible rationale.

No rule is universally best. A useful choice is one that answers the predictive-check question at the desired time resolution and produces interpretable membership. Document the method, numerical cutpoints, endpoint convention, and any record exclusions. If comparing candidate binning schemes, treat that as a sensitivity check: report how the boundaries and record membership differ, rather than selecting only the scheme with the most appealing outcome pattern.

Binning also limits what the plot can show. A bin-level summary represents a range of times, not a pointwise model assessment at every time within that range. Wide bins can combine observations from meaningfully different times; very narrow bins can contain few records. Binning cannot create information absent from the sampling design. The appropriate response is to inspect the time coverage and interpret summaries at the resolution the data support, rather than assuming that any set of boundaries will yield a precise picture.

Key takeaway: A VPC bin is a time interval with explicit boundaries and endpoint rules. Choose those rules using the intended time resolution, sampling design, or a prespecified scientific rationale; then assign observed and simulated records consistently and verify that every included record appears in exactly one bin.

Check Your Understanding

Try each question, then compare your reasoning with the solutions below.

  1. Using bins \([0,2)\) and \([2,5]\), which bin contains a record at exactly 2 hours?
  2. Six records occur at distinct times 0, 1, 2, 3, 4, and 5 hours. How many records per bin are targeted by three equal-count bins? Why might exact balance be impossible if two records share the same time at a cutpoint?
  3. Why should the same time cutpoints be applied to observed records and design-matched simulated records?
  4. State one advantage and one limitation of fixed-width bins compared with equal-count bins.
  5. A researcher moves a boundary after seeing that an observed concentration quantile falls outside the simulated range. What is the problem with this decision?

Solutions. (1) The record belongs to \([2,5]\), because the first interval excludes its upper endpoint and the second includes its lower endpoint. (2) The target is \(6/3=2\) records per bin. If tied records at one time would be divided between bins, keeping the time together prevents exact balance; use approximate counts rather than splitting those records. (3) Shared cutpoints ensure summaries refer to the same time regions, so differences are not created merely by different membership rules. (4) Fixed-width bins represent consistent durations, but their record counts can vary; equal-count bins balance records approximately, but their time widths vary. (5) The boundary is being chosen using the outcome pattern under evaluation, which can make the check outcome-dependent and misleading; use a prespecified rule based on time or design instead.