Tutorials › Pharmacometric Workflows and Reproducible Modeling › Choosing Replicate Counts And Virtual-Population Size

Simulation Pipelines · Tutorial 258 of 399

Choosing Replicate Counts And Virtual-Population Size

Learn to match each simulation count to the uncertainty it reduces, then plan a practical allocation using a target precision and computational budget.

Advanced 12 min read

What You'll Learn

  • Distinguish parameter draws, virtual subjects, and repeated outcomes within a subject.
  • Identify which simulation level contributes variability to a chosen estimand.
  • Use a nested variance decomposition to relate counts to Monte Carlo precision.
  • Compare count allocations under a computational budget.
  • Recognize when additional within-subject replicates do not address the main source of error.
  • Diagnose unstable estimates and document the rationale for chosen counts.

Why Replicate Counts Must Match the Simulation Target

A simulation can be computationally large yet poorly designed. Thousands of simulated observations do not guarantee a precise estimate if they come from too few parameter draws or too few independent virtual subjects. Conversely, a simulation can waste substantial computation by repeating a level of sampling that contributes little to uncertainty in the target quantity.

The count decision begins with the estimand: the numerical quantity the simulation is intended to estimate. For example, the target might be the population mean of an exposure metric under a fixed parameter set, an average prediction over parameter uncertainty, or the distribution of an observed endpoint when residual error is included. Those targets require different sampling levels. The earlier material on separating parameter and individual variability provides the key distinction: parameter uncertainty, between-subject variation, and residual variation are not interchangeable sources of variation.

Definition: Let \(M\) be the number of parameter draws, \(N\) the number of virtual subjects simulated per parameter draw, and \(R\) the number of within-subject replicate outcomes per subject. A parameter draw represents one draw of the relevant population-level parameter vector; a virtual subject represents one draw of subject-level characteristics and, where appropriate, individual random effects; a within-subject replicate represents another outcome realization for that same subject, such as a new residual-error realization. These counts describe different levels of a nested simulation and should not be treated as one interchangeable total.

A common nested structure is to draw \(\theta_m\), the parameter vector for draw \(m\); simulate \(N\) subjects conditional on \(\theta_m\); and, if the target includes outcome-level randomness, simulate \(R\) outcomes for each subject. The total number of outcome records is \(MNR\), but the number of independent draws at each level is \(M\), \(MN\), or \(MNR\), respectively. In particular, repeated outcomes on one subject do not create new parameter draws or new virtual subjects.

State the Target and Its Sampling Levels

Before choosing counts, write down which randomness belongs in the target. If the goal is a prediction conditional on one fixed parameter estimate, drawing parameters repeatedly from an uncertainty distribution changes the target rather than improving its precision. If the goal averages predictions over parameter uncertainty, parameter draws are part of the design. Similarly, residual-error replicates are needed when the target concerns simulated observations, but may be unnecessary for a target based on an expected response when residual error has conditional mean zero and can be integrated out.

For a simple mean target with a balanced nested design, a useful planning approximation is

$$ \operatorname{Var}(\hat{\mu}) \approx \frac{A}{M}+\frac{B}{MN}+\frac{C}{MNR}. $$

Here \(A\) is the variance across parameter draws of the conditional mean target; \(B\) is the variance across virtual subjects of their expected outcome, conditional on the parameter draw; and \(C\) is the residual outcome variance among replicate outcomes for a subject. The approximation assumes independent parameter draws, independent subjects conditional on each parameter draw, independent residual replicates conditional on a subject and its parameter draw, and finite component variances. It also assumes a balanced design and that the reported estimate averages over all levels relevant to the target. If the simulation has dependence, unequal allocation, or a nonlinear summary such as a quantile, this formula may not apply directly; a pilot simulation and repeated-batch diagnostics are then important.

The first term decreases by increasing \(M\); the second decreases by increasing either \(M\) or \(N\); and the third decreases by increasing any of \(M\), \(N\), or \(R\). The formula therefore clarifies why simply increasing the number of outcome records can be inefficient: if \(A\) dominates, many subjects and replicates under a small number of parameter draws will leave most of the uncertainty untouched.

A Short Justification for the Nested Variance Formula

Let \(Y_{mnr}\) be the outcome for replicate \(r\) of subject \(n\) under parameter draw \(m\), and let \(\mu(\theta_m)\) be the expected outcome averaged over subjects and residual error at that parameter draw. For each parameter draw, the sample average across its subjects and replicates estimates \(\mu(\theta_m)\). The overall estimate averages those \(M\) conditional averages.

By the law of total variance, the variance of an estimate that averages \(M\) independent parameter-level averages is the variance of a parameter-level conditional mean divided by \(M\), plus the expected conditional variance of one parameter-level average divided by \(M\). Within that conditional average, independent subjects contribute a between-subject term divided by \(N\), and independent replicate outcomes contribute a residual term divided by \(NR\). Therefore,

$$ \operatorname{Var}(\hat{\mu}) =\frac{A}{M}+\frac{1}{M}\left(\frac{B}{N}+\frac{C}{NR}\right) =\frac{A}{M}+\frac{B}{MN}+\frac{C}{MNR}. $$

This derivation also states the limits of the formula. If repeated outcomes share an unmodeled time trend or are correlated, the residual contribution does not generally fall as \(1/R\). If subjects are reused across parameter draws, the draws are not independent in the required way. The counts must be interpreted alongside the actual simulation dependence structure.

Work From a Precision Goal

A target Monte Carlo standard error (the standard deviation of the simulation estimator under repeated runs of the same design) can be used to compare proposed counts. For a mean target, its approximate value is the square root of the variance formula. A precision goal should be set in context and in the units of the target, not as an arbitrary number of records. Variance components can be estimated from a pilot run, analytic calculations, or prior validated simulations. Planning estimates need not be exact, but uncertainty in them should be considered by checking more than one plausible set of components.

Worked Example: Checking a Candidate Nested Design

Suppose a hypothetical simulation targets mean exposure, measured in mg·h/L, averaged over parameter uncertainty, virtual subjects, and residual outcomes. Pilot estimates of the three variance components are \(A=0.040\), \(B=0.360\), and \(C=0.600\) \((\mathrm{mg\cdot h/L})^2\). Consider \(M=25\), \(N=50\), and \(R=2\). Assume the pilot supports independent draws at the relevant levels and a balanced design.

Substitute the counts and components:

$$ \widehat{\operatorname{Var}}(\hat{\mu}) =\frac{0.040}{25}+\frac{0.360}{25(50)}+\frac{0.600}{25(50)(2)} =0.001600+0.000288+0.000240 =0.002128. $$

The estimated Monte Carlo standard error is \(\sqrt{0.002128}=0.04613\) mg·h/L. If the planning goal is at most \(0.050\) mg·h/L, this candidate meets that goal under the stated assumptions. This is a planning calculation, not a guarantee: the component estimates and independence assumptions should be checked, and the run should be assessed using diagnostics after simulation.

When there is a fixed computational budget, candidate allocations can be compared by their estimated precision. If each parameter-subject combination has approximately equal cost and residual error can be integrated out, the approximate cost is proportional to \(MN\). If each replicate requires a separate costly simulation, cost may instead be close to proportional to \(MNR\). In practice, setup and data-handling costs can matter, so a short timing run is often more informative than assuming exact proportionality.

Worked Example: Allocating a Fixed Subject-Simulation Budget

For a hypothetical mean prediction averaged over parameter uncertainty, residual error is integrated out analytically. Pilot components are \(A=0.090\) and \(B=0.250\) in squared target units. The budget allows 1,200 parameter-subject evaluations, so \(MN=1{,}200\). Compare \(M=30,\ N=40\) with \(M=60,\ N=20\). Assume the draws are independent and each evaluation has the same computational cost.

For \(M=30,\ N=40\), the approximate variance is

$$ \frac{0.090}{30}+\frac{0.250}{30(40)} =0.003000+0.0002083 =0.003208, $$

giving a standard error of \(\sqrt{0.003208}=0.05664\) target units. For \(M=60,\ N=20\), it is

$$ \frac{0.090}{60}+\frac{0.250}{60(20)} =0.001500+0.0002083 =0.001708, $$

giving a standard error of \(\sqrt{0.001708}=0.04133\) target units. The second allocation is more precise because the parameter-level component \(A\) is appreciable, and increasing \(M\) reduces it. The subject-level contribution is the same in these two allocations because both have the same product \(MN\). If \(B\) were much larger relative to \(A\), the practical choice could differ, especially if parameter draws have additional computational overhead.

When Within-Subject Replication Helps

Within-subject replication is most useful when the target includes outcome-level variability and the residual component is large enough to matter. It does not replace independent subjects when the subject-to-subject variation is important. For an average of \(R\) outcomes per subject, a subject’s persistent characteristics are still shared across those outcomes; only the part that genuinely varies independently between replicates is reduced by averaging.

Worked Example: More Replicates Cannot Replace More Subjects

Consider a hypothetical endpoint with no parameter uncertainty. The target is the mean across subjects and residual outcomes. The between-subject variance is \(0.250\) endpoint units squared, and the independent residual variance per outcome is \(0.360\) endpoint units squared. Compare \(N=100,\ R=1\) with \(N=100,\ R=4\), assuming subjects and residual replicates satisfy the independence conditions.

With one replicate per subject, the variance of the sample mean is

$$ \frac{0.250}{100}+\frac{0.360}{100(1)} =0.006100, $$

so its standard error is \(\sqrt{0.006100}=0.07810\) endpoint units. With four replicates per subject, it is

$$ \frac{0.250}{100}+\frac{0.360}{100(4)} =0.003400, $$

so its standard error is \(\sqrt{0.003400}=0.05831\) endpoint units. The improvement occurs because the residual contribution falls from \(0.003600\) to \(0.000900\); the between-subject contribution remains \(0.002500\). If the goal is a subject-level expected response and residual error has mean zero, simulating four residual outcomes may be unnecessary: computing the conditional expectation directly can reduce cost without changing the target.

Diagnostics, Alternatives, and Limitations

Count planning is a design decision, not a substitute for checking the resulting simulation. Examine the estimate across independent batches or progressively larger runs, and compare the observed variability with the planning approximation where appropriate. Large shifts between batches, unstable tail summaries, or a standard error that does not decrease as expected can indicate too few draws at a relevant level, dependence between draws, an incorrect variance decomposition, or failed simulations. For a mean based on independent samples, doubling a relevant count is expected to reduce that component’s standard error by about a factor of \(\sqrt{2}\), not by half.

The nested formula is most directly useful for averages with manageable variance components. Quantiles, maxima, and other nonlinear summaries can converge differently; a simple mean-based variance formula should not be treated as their precision guarantee. A pilot can compare candidate counts for the actual reported summary. When computation is expensive, alternatives include analytically integrating residual error, using a more efficient sampling design where appropriate, or allocating computation to the level that dominates uncertainty. Any alternative must preserve the intended estimand and the dependence structure of the simulation.

A practical allocation can be organized as follows:

1
Specify the target.
State whether the result is conditional on fixed parameters or averaged over parameter uncertainty, and whether it describes expected outcomes or simulated observations.
2
Map randomness to levels.
Identify which variation comes from parameter draws, virtual subjects, and within-subject replicates; do not count a repeated outcome as a new subject.
3
Set precision and cost goals.
Choose a contextually meaningful precision target, estimate relevant variance components, and measure or approximate the cost of each level.
4
Compare and validate allocations.
Evaluate plausible count combinations, run the simulation, and assess stability and assumptions using batches or targeted diagnostics.

Common pitfall: “The simulation has one million records, so the result must be precise.” That conclusion is not justified. If those records arise from one parameter draw and a small number of subjects with many repeated outcomes, parameter and subject-level uncertainty may remain large. Report \(M\), \(N\), and \(R\) separately, state which levels are independent, and explain why those counts are adequate for the target.

Key takeaway: Choose counts by asking which independent sampling level reduces each component of uncertainty in the estimand. More computation improves precision only when it is spent on the level that limits the result, or when the target genuinely requires that additional replication.

Check Your Understanding

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

  1. A target is conditional on a fixed parameter vector and is the mean expected response over virtual subjects. Which of \(M\), \(N\), and \(R\) are needed in principle?
  2. In the nested variance approximation, which component is reduced by increasing only \(R\)?
  3. Suppose parameter-level variability dominates the estimated variance. Should a fixed-cost design generally favor more parameter draws or more subjects per parameter draw? State the assumption behind your answer.
  4. Why can 100 repeated outcomes from each of 10 subjects fail to provide the same subject-level information as 1,000 independent subjects?

Solutions. (1) Use one fixed parameter vector, so \(M=1\); use \(N\) to represent the virtual-subject population. \(R\) is unnecessary if the target is expected response and residual error can be integrated out. (2) Only the residual contribution \(C/(MNR)\) is reduced directly; the parameter and between-subject components are unchanged when \(M\) and \(N\) are fixed. (3) Generally favor more parameter draws, provided each draw and subject evaluation have comparable costs and the independence assumptions hold, because increasing \(M\) reduces the dominant term \(A/M\). (4) Repeated outcomes share each subject’s persistent characteristics, so they reduce independent residual noise but do not create additional independent subject draws; the between-subject contribution is still governed by \(N\).

Clinical Biostats