Why BQL Implementation Needs Its Own Checks
A censored-data likelihood can be specified correctly on paper and still be implemented incorrectly. A single branching error can assign a density to a below-quantification (BQL) record, use an LLOQ on the wrong scale, or count the same record twice. These errors can produce plausible-looking objective-function values while changing the estimates and their uncertainty.
The aim here is not to select a BQL method, but to verify that code implements the stated likelihood. The checks apply to the M3 likelihood and to other implementations that represent a BQL observation by the probability of falling below its applicable limit. They complement, rather than replace, the earlier material on stable computation of censored likelihoods, marginalization over random effects, and sensitivity analysis.
This distinction follows from what the record tells us. A quantified value identifies a measured value, so its likelihood contribution is a density at that value. A BQL result does not report an exact concentration; it reports that the concentration lies below a threshold, so its contribution is a probability over that interval. For a continuous distribution, using \(Y\leq L\) instead of \(Y<L\) gives the same probability.
The record-level formulas assume that the model distribution and its parameters are the ones intended for that observation, that the LLOQ is expressed in the same concentration units as the modeled observation (or transformed consistently), and that each measurement is represented once. When observations are conditionally independent, their record-level contributions multiply; subject-level random effects may require the appropriate integration over those effects. These checks do not authorize changing the model or its conditioning structure.
Establish the Correct Branch Before Checking the Arithmetic
For each record, first identify its status and the model scale. Then check the single contribution assigned to it. A quantified observation should reach the density branch; a BQL observation should reach the cumulative-probability branch. The measured concentration field for a BQL record may be missing or may contain a sentinel value, but neither circumstance turns the record into a quantified observation.
Use the data flag or the documented censoring rule to determine whether the record is quantified or BQL. Do not infer status from a numeric placeholder alone.
Establish whether the residual distribution is specified for concentration, log concentration, or another response scale, and express the LLOQ on that scale.
For a quantified record, evaluate the density at its observed value. For a BQL record, evaluate the cumulative probability at its applicable limit.
Use a hand calculation or trusted numerical reference for a small case, then check that the program returns the same contribution and log contribution.
Worked Example: A BQL Record Must Use a Probability
Suppose a hypothetical record has a BQL limit \(L=0.80\) mg/L. Conditional on the model predictions, let concentration \(Y\) follow a normal distribution with mean \(\mu=1.20\) mg/L and standard deviation \(\sigma=0.30\) mg/L. The BQL record contributes \(F(L)\), not a density at \(L\).
Thus its log-likelihood contribution is \(\log(0.09121)\approx -2.395\). The units cancel in the standardized argument, and the resulting probability is dimensionless.
A common faulty implementation evaluates the density at the LLOQ instead. Under the same model,
The density is not the BQL contribution: it has units of inverse concentration and describes density at one point. The correct BQL value is approximately \(0.09121\), not \(0.5467\). This test is especially useful because it checks both the status branch and whether the implementation has confused a probability with a density.
Check LLOQs on the Model Scale
An LLOQ is reported in the assay's concentration units, but the residual-error distribution may be defined on a transformed scale. A correct implementation applies the distribution function to a threshold transformed in the same way as the modeled random variable. For example, if \(Z=\log(Y)\) is normally distributed, then \(Y<L\) is equivalent to \(Z<\log(L)\). Using \(L\) itself as the threshold for \(Z\) is a scale error.
Worked Example: Transforming an LLOQ for a Log-Scale Model
Consider a hypothetical model with \(Z=\log(Y)\sim N(\mu_Z,\sigma_Z^2)\), where \(Y\) is concentration in mg/L, \(\mu_Z=\log(1.20)\), and \(\sigma_Z=0.30\). A record is BQL at \(L=0.80\) mg/L. The model is specified for log concentration, so the correct contribution is \(P(Z<\log(0.80))\).
The logarithm is applied to the dimensionless ratio of concentrations (equivalently, to numerical values expressed in the same units). If code instead substitutes \(0.80\) directly into the log-scale calculation, it obtains
That result is not a small numerical discrepancy: it reverses the implication of the observation. The error can be diagnosed by writing down the event being modeled, \(Y<L\), and checking the transformation of both sides before standardizing. The calculation also assumes the stated lognormal model and positive concentrations; a different residual model requires its own corresponding transformation.
Detect Duplicate Contributions and Verify Record Counts
A BQL record should not enter both the censored branch and a generic quantified-observation branch. This often happens when a BQL record is retained with a sentinel concentration, and a second section of code processes every nonmissing concentration as quantified. A record-level audit should therefore verify not only the value of a contribution but also how many contributions each input row creates.
Worked Example: A Duplicate Branch Changes the Likelihood
Return to the hypothetical normal model with \(\mu=1.20\) mg/L and \(\sigma=0.30\) mg/L. A single BQL record has \(L=0.80\) mg/L, so its correct likelihood contribution is \(0.09121\). Suppose an erroneous second branch also treats the limit as an exact observation and multiplies by its density, \(f(0.80)\approx0.5467\;(\mathrm{mg/L})^{-1}\).
The erroneous product is not a valid contribution for that one censored record; it has attached an exact-value density to information the assay did not provide. Its numerical value, approximately \(0.04987\), differs from the correct \(0.09121\), and its units also expose the problem: probability times density has units of inverse concentration.
By contrast, multiplying a BQL contribution by a density is appropriate when the factors belong to two distinct observations in a likelihood that treats them as conditionally independent. For example, if the same hypothetical profile has a separate quantified record \(y=1.10\) mg/L, then
Here the product represents two different records: one BQL and one quantified. The distinction is not whether a probability and density appear in the same product, but whether each factor corresponds to a separate observation exactly once.
Build Small Tests That Fail Loudly
A large model fit is a poor first test of a new BQL implementation. On a tiny, fixed dataset, the expected branches and values can be calculated independently. Compare likelihood contributions before summing them into a subject or dataset objective; an aggregate can conceal a missing or duplicated record.
- One quantified record: check that the code evaluates \(f(y)\), not \(F(y)\), and that the density has the expected units.
- One BQL record: check that the code evaluates \(F(L)\), returns a probability between zero and one, and does not use a sentinel as an exact value.
- Two distinct records: include one quantified and one BQL record and verify that the joint contribution is the product of their individual contributions under the stated conditional-independence assumption.
- Two assay limits: give records different LLOQs and verify that each BQL record uses its own limit, converted to the model scale as necessary.
- Boundary and unit tests: check that increasing \(L\) cannot decrease \(F(L)\), and that changing concentration units while converting both observations and LLOQs consistently leaves standardized probabilities unchanged.
For the normal example above, the monotonicity check has a direct interpretation: a larger threshold includes more of the distribution below it, so \(F(L)\) cannot decrease as \(L\) increases. If code violates this property, investigate the sign of the standardized residual, the selected cumulative distribution function, and the scale conversion. Also check records near the limit, missing-value handling, and the data flags that route observations into the likelihood.
A test suite should compare both likelihood-scale and log-likelihood-scale results where practical. A probability can be rounded to zero in ordinary arithmetic for an extreme tail; stable log-CDF calculations address that numerical issue, but they cannot correct a wrong branch or threshold. Numerical stability and correct model logic are separate checks.
How These Checks Relate to Alternative BQL Approaches
Different BQL approaches encode different assumptions and therefore need different test expectations. The M3 approach uses the probability below the limit for a BQL record and the density for a quantified record. An M4 approach uses a different treatment of BQL records; its implementation should be checked against the specific M4 formulation chosen, not judged by expecting an M3 contribution. Deletion or substitution methods likewise define different analyses and do not become equivalent to a censored likelihood merely because their code runs successfully.
The most useful common checks are structural: confirm which records are included, which limits apply, how the model scale is handled, and whether the implemented likelihood matches the stated method. Predicted BQL frequencies and simulation checks can reveal broader mismatches between model and data, but a plausible aggregate frequency does not prove that each record has the correct contribution. This tutorial's unit tests target that narrower implementation question.
Common Mistakes and Limitations
- Using \(f(L)\) for a BQL record. A BQL result reports an event below a limit, not an exact value at that limit. Use \(F(L)\).
- Putting a concentration LLOQ into a log-scale formula unchanged. Transform the threshold consistently with the modeled variable; for a log-concentration model, use \(\log(L)\).
- Processing a BQL row twice. Verify one contribution per record, not merely the total number of rows in the input file.
- Assuming every product is a duplicate. A probability and a density can properly multiply when they represent distinct observations and the model's factorization justifies it.
- Treating a passing numerical test as model validation. A test verifies code against a specified likelihood. It does not establish that the residual distribution, censoring mechanism, or random-effects assumptions are appropriate.
Implementation checks also depend on the data contract. If assay limits vary, the input must preserve the correct limit per record. If records are transformed or units are changed upstream, the status, observation, and limit must remain aligned. A coding check cannot recover information lost or misclassified during data preparation.
Check Your Understanding
Answer each question, then compare with the solutions below.
- Under a continuous normal model, what is the likelihood contribution for a BQL observation at limit \(L\): \(f(L)\) or \(F(L)\)?
- A log-concentration model uses \(Z=\log(Y)\). What threshold corresponds to a BQL limit \(L\) on the concentration scale?
- In the worked normal example, what is the correct contribution for a BQL record at \(0.80\) mg/L, and what is the approximate density at that value?
- When is it valid for a joint likelihood to contain both a BQL probability and a quantified-record density?
- Name one test that can detect a scale or limit-handling bug before fitting a large model.
Solutions. (1) The contribution is \(F(L)=P(Y<L)\), because the record reports an event below the limit, not an exact value. (2) Use \(\log(L)\) as the threshold for \(Z\), so the probability is \(P(Z<\log(L))\). (3) The BQL contribution is approximately \(0.09121\); the density at the limit is approximately \(0.5467\;(\mathrm{mg/L})^{-1}\), and it is not the BQL contribution. (4) It is valid when the factors represent distinct observations and the assumed likelihood factorization supports multiplying their conditional contributions. (5) For example, convert concentrations and LLOQs to another unit consistently and check that a standardized BQL probability is unchanged; alternatively, verify that increasing \(L\) cannot decrease \(F(L)\).