Tutorials › Nonlinear Mixed-Effects Models (NLME) › Handling Failed Parameter Draws

Simulation From Fitted Models · Tutorial 710 of 797

Handling Failed Parameter Draws

Learn how to diagnose and account for failed parameter draws without changing the uncertainty distribution or hiding simulation problems.

Intermediate 12 min read

What You'll Learn

  • Distinguish parameter draws outside the model's domain from numerical failures during model evaluation.
  • Track attempted, failed, retried, and ultimately successful draws using explicit denominators.
  • Understand why dropping failures can bias simulated summaries toward parameter values that are easier to evaluate.
  • Choose parameter transformations or constraints that match the model and the intended uncertainty distribution.
  • Use solver retries and diagnostics to investigate non-finite or invalid model outcomes.
  • Separate numerical failure from an extreme but valid simulated result.

Why Failed Draws Need Explicit Treatment

When propagating parameter uncertainty through a fitted NLME model, each parameter draw is an input to a model evaluation. A draw may produce a valid concentration-time profile and derived outcome, or the model evaluation may fail: a parameter may be outside the model's mathematical domain, an equation may be undefined, or a numerical solver may not return a finite solution. These outcomes are not interchangeable. In particular, a failed evaluation is not automatically evidence that the parameter draw itself should be removed.

The central requirement is to preserve the meaning of the simulation. A summary over only successful evaluations describes outcomes conditional on successful evaluation. If success depends on the sampled parameters, this summary may differ systematically from the intended uncertainty summary. The failure count, reasons, and any resolution therefore belong in the simulation record, not just in a software log.

Definition: Let \(M\) be the number of parameter draws attempted, and let \(\theta^{(m)}\) denote the \(m\)th draw. An evaluation is a failed draw if the model cannot produce the prespecified, mathematically defined output for that draw under the stated evaluation procedure. Record the number of failed evaluations and their reasons. A failed evaluation is not, by itself, a rule for excluding \(\theta^{(m)}\) from the target distribution.

Define What Counts as Failure

Before simulation, specify the parameters, covariates, dose, time points, model equations, and output being evaluated. Then define failure in relation to that target. Examples include an undefined expression, a solver reporting that it did not converge, or an output containing NaN or infinity where a finite value is required. An output that is surprising, extreme, or outside a preferred clinical range is not necessarily a computational failure. It may be a valid implication of the model and draw, or it may signal a model limitation that should be investigated separately.

A useful first distinction is between domain failure and numerical failure. Domain failure occurs when a draw violates a mathematical or scientific constraint required by the model, such as a negative clearance in a model that requires positive clearance. Numerical failure occurs when the mathematical problem is defined, but the computational procedure does not successfully evaluate it—for example, a solver reaches its step limit for a stiff differential equation. A third category is an output validation failure: the software returns values, but they violate a prespecified mathematical check, such as a concentration that must be nonnegative under the model.

The classification should be based on the model and implementation, not on whether the result is convenient. For example, an unusually high but finite exposure is not a failed draw merely because it is inconvenient for a summary. Conversely, replacing a non-finite value with zero does not make the evaluation successful; it changes the output without a model-based justification.

Operational rule: For each attempted draw, retain its draw identifier, parameter values, evaluation status, failure category, error message, and any retry outcome. Define validation checks in advance and apply them consistently to all draws.

Assumptions and Failure Accounting

A failure rate is meaningful only relative to a defined set of attempted draws and a consistent evaluation procedure. Let \(F\) be the number of draws that remain failed after any prespecified diagnostic retries. The empirical failure fraction is

$$ \hat{q}_{\mathrm{fail}} = \frac{F}{M}. $$

The denominator is the number of distinct parameter draws attempted, not the number of successful solver calls. If a draw is retried with a more appropriate solver, it remains one parameter draw. Report both the initial and final failure counts if retries are used, so that the retry policy and its effect are visible.

This accounting assumes that the target parameter-draw distribution and the evaluation rules are stated clearly. If some draws lie outside the model's valid parameter space, the analyst must decide how the uncertainty distribution should represent that space. The decision is part of defining the simulation, not a post hoc way to improve the results. The same applies to a model that is mathematically defined for a draw but has a scientifically implausible implication: that concern should be reported and assessed rather than silently recoded as a numerical failure.

Worked Example: Reporting the Failure Fraction

Suppose a hypothetical simulation attempts \(M=200\) distinct parameter draws. On the initial evaluation, 12 draws fail: 7 produce non-finite outputs and 5 trigger a solver convergence warning. After prespecified diagnostic retries, 3 of the 5 solver-warning draws evaluate successfully; the remaining 2 still fail. The 7 non-finite outputs remain unresolved.

The initial failure fraction is \(12/200=0.0600\), or 6.00%. After retries, there are \(7+2=9\) unresolved draws, so the final failure fraction is \(9/200=0.0450\), or 4.50%. There are 191 successful final evaluations.

The final result should report both counts and categories: 7 non-finite-output failures and 2 unresolved solver failures among 200 distinct draws. It would be inaccurate to say that only 2 draws failed because the 7 non-finite outputs are still unresolved. It would also be inaccurate to use the number of solver attempts, rather than the 200 distinct draws, as the denominator.

Why Dropping Failures Can Change the Summary

Suppose an outcome \(Y\) is defined for every draw in the intended target distribution, but the computation succeeds only for some parameter values. Let \(S\) denote the event that evaluation succeeds. Averaging only successful evaluations estimates an average conditional on \(S\), not the unconditional target average. The distinction follows directly from the definition of conditional expectation:

$$ E(Y\mid S) = \frac{E(Y\,I(S))}{P(S)}, $$

where \(I(S)\) equals 1 when evaluation succeeds and 0 otherwise. If success is related to \(Y\) or to parameters associated with \(Y\), then \(E(Y\mid S)\) need not equal \(E(Y)\). Even when the success fraction is high, a small set of failures can matter if those draws correspond to extreme outcomes. If the model genuinely has no defined output for part of the draw distribution, an unconditional mean may not be defined as intended; the target and parameter distribution need reconsideration.

This is why replacing failed draws by new draws until a fixed number of successful evaluations is obtained is not automatically harmless. It samples from the original draw distribution conditional on evaluation success. That conditional distribution can differ from the one originally specified. Redrawing is defensible only if the target distribution is explicitly defined as restricted to an acceptable parameter region, and the restriction is justified and reported.

Worked Example: The Successful-Draw Mean Is Conditional

In a hypothetical simulation, \(M=100\) draws are attempted. Twenty draws fail, and the mean outcome among the remaining 80 valid evaluations is 12.0 mg·h/L. Suppose the 20 failed draws are then silently discarded and replaced until 100 successful outcomes are available.

The mean of the original successful set is \(12.0\) mg·h/L, but it summarizes draws conditional on success. The replacement procedure does not recover the outcomes for the original 20 draws; it obtains more draws from the distribution conditional on successful evaluation. The resulting estimate is still conditional unless failures are independent of the target outcome and the relevant parameter values, an assumption that should not be presumed.

For instance, if failures occur mostly at high-clearance draws, and those draws would tend to produce lower exposure, the mean among successful draws may be higher than the intended mean over the full draw distribution. The direction is not guaranteed: it depends on how failure relates to the outcome. With the information given, the unconditional mean cannot be calculated because the 20 outcomes are unknown or undefined. The defensible report is the 80-of-100 success count, the 20 failures and their reasons, and the 12.0 mg·h/L mean explicitly labelled as the mean among successful evaluations.

Constraints, Transformations, and Numerical Remedies

A constraint should reflect the parameterization and scientific or mathematical domain of the model. Parameters that must be positive are often represented on an unconstrained scale and transformed back to the natural scale. For example, if \(\eta\) is a draw on a log scale, then \(CL=\exp(\eta)\) is positive for every finite \(\eta\). This prevents negative clearance values caused by drawing directly from an unconstrained normal approximation on the clearance scale. It does not, however, establish that the log-scale uncertainty distribution is the correct one; the scale and distribution must agree with the fitted model and the intended uncertainty representation.

For parameters with other constraints, a suitable transformation or a constrained distribution may be needed. For covariance matrices, for example, draws must satisfy the matrix properties required by the model. A repair such as changing negative eigenvalues after a draw can alter both marginal uncertainty and dependence. It should not be applied as an undocumented numerical fix. A constrained or reparameterized approach should be specified as part of the draw procedure.

When the draw is in the model's domain, investigate numerical failure using the error message and the parameter values. Check units, initial conditions, time grid, tolerances, and solver settings. A solver appropriate for a stiff system may resolve a failure that a general-purpose method cannot. Any retry should use a defined procedure and should be checked for numerical stability—for example, by confirming that important outputs are materially unchanged under a tighter tolerance. A retry can resolve a computational failure; it cannot make an invalid parameter draw scientifically valid.

Worked Example: Enforcing Positive Clearance on the Draw Scale

Suppose, purely hypothetically, that a clearance draw is generated directly as \(CL\sim N(10,4^2)\) L/h. A standard normal draw \(z=-3\) gives

$$ CL = 10 + 4(-3) = -2 \text{ L/h}. $$

A model requiring \(CL>0\) cannot use this parameter value. Simply deleting it would condition the draw distribution on positive clearance. Instead, one possible parameterization is to draw \(\eta=\log(CL)\) and set \(CL=\exp(\eta)\). For illustration, if \(\eta=\log(10)+0.4z\), the same \(z=-3\) gives \(\eta=2.3026-1.2000=1.1026\), and thus \(CL=\exp(1.1026)\approx3.012\) L/h, which is positive.

This calculation demonstrates how a log-scale parameterization enforces positivity. It does not show that the illustrative log-scale distribution is interchangeable with the original normal distribution on clearance: they are different distributions. The analyst must use a parameter-draw distribution justified for the fitted model, rather than choosing a transformation solely because it eliminates inconvenient failures.

Worked Example: Diagnosing a Solver Failure

In a hypothetical one-compartment elimination model, \(C(t)=C_0\exp(-kt)\), with \(C_0=10\) mg/L and \(k=250\) h\(^{-1}\), the analytic concentration at \(t=0.1\) h is

$$ C(0.1)=10\exp(-250\times0.1) =10\exp(-25) \approx 1.389\times10^{-10}\text{ mg/L}. $$

This is finite and nonnegative, so the parameter values do not make the analytic model undefined. Suppose a numerical implementation reports failure for this draw because its solver reaches a step limit. The evidence points to a numerical evaluation issue, such as solver settings or stiffness, rather than an invalid value of \(k\). A suitable diagnostic is to evaluate the same draw using a solver and tolerances appropriate for the problem, then compare the result with the analytic value. If the numerical result agrees within the specified tolerance, record the initial failure and its resolution; do not count the retry as a new parameter draw.

Diagnostics, Alternatives, and Limitations

A useful diagnostic sequence is to inspect failures before summarizing outcomes. Group them by failure category and parameter region; examine whether they cluster near a constraint boundary or occur at extreme parameter combinations; and check whether the same draw fails reproducibly. A reproducible domain violation suggests a draw-distribution or model-domain problem. A failure that disappears with an appropriate solver or a tighter, stable evaluation procedure suggests numerical difficulty. Unexplained non-finite results require investigation of the equations and implementation rather than automatic replacement.

1
Record the target and checks.
Specify the output, model domain, parameter-draw procedure, and criteria for a valid evaluation before drawing parameters.
2
Classify each failure.
Separate domain violations, solver or numerical failures, and output-validation failures. Retain parameter values and diagnostic messages.
3
Apply only justified remedies.
Use a valid parameterization for constraints; use solver diagnostics for numerical issues. Document retries and avoid silently replacing outcomes.
4
Report the denominator and consequences.
Give initial and unresolved failure counts out of distinct draws, describe any restriction or retry, and label summaries based only on successful evaluations.

The main alternatives have different implications. Retaining only successful draws is simple, but the resulting summaries describe the successful subset and can be biased for the intended target. Redrawing until success likewise changes the sampled distribution when success depends on parameters. Transforming or constraining parameters before evaluation can prevent invalid draws, but it defines a particular draw distribution and must be justified. Improving the numerical method can resolve computational failures without changing the target distribution, provided the model is defined and the evaluation is verified. None of these approaches justifies hiding unresolved failures.

Failure accounting also has limits. A low failure fraction does not prove that the successful draws represent the intended distribution, and a high fraction is not automatically evidence that every failed draw is scientifically impossible. Software may report failure for a solvable problem, while a numerical result may appear finite despite being inaccurate. The distinction requires checking the model, parameter support, and numerical evaluation. Report the unresolved fraction and avoid presenting a successful-draw summary as an unconditional summary when its interpretation is conditional.

Common Mistake

A common mistake is: “These draws failed, so they are outliers; I will delete them and calculate the summaries from the rest.” That reasoning confuses evaluation status with scientific relevance. A failed draw may be invalid under the model, or the evaluation may have failed for computational reasons; the label alone does not decide which. The correction is to classify the failure, apply a prespecified and justified remedy where possible, and report unresolved failures using the number of distinct attempted draws as the denominator. If a summary excludes unresolved draws, state that it describes successful evaluations and assess whether that conditioning changes its interpretation.

Check Your Understanding

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

  1. Out of 500 distinct parameter draws, 15 evaluations fail initially. After a defined retry, 4 still fail. What are the initial and final failure fractions?
  2. A parameter draw produces a finite exposure that is much larger than expected. Is it automatically a failed draw? Explain.
  3. Why can replacing every failed draw with a new draw until the requested number of successes is reached change the target distribution?
  4. A negative clearance draw is incompatible with the model, while a positive clearance draw causes a solver warning. Are these the same type of failure, and what should be investigated?

Solutions. (1) Initially, \(15/500=0.0300\), or 3.00%; after retry, \(4/500=0.00800\), or 0.800%. The retries do not increase the denominator because there are still 500 distinct parameter draws. (2) No. A finite, mathematically valid extreme exposure is not automatically a computational failure; check the model and prespecified validation criteria, and report the result if valid. (3) If success depends on parameter values, redrawing samples from the original distribution conditional on successful evaluation, which can change parameter and outcome distributions. (4) No. The negative clearance is a domain violation for a model requiring positive clearance; investigate the draw parameterization or distribution. The positive-clearance solver warning may be numerical; inspect the solver, settings, and reproducibility before deciding whether a justified retry resolves it.