Tutorials › Multiple Imputation by Chained Equations (MICE) › Domain Constraints in Logarithms and Ratios

Passive Imputation and Substantive-Model-Compatible Methods · Tutorial 312 of 497

Domain Constraints in Logarithms and Ratios

You will learn to check the domains of logarithmic and ratio transformations and to handle invalid or boundary-valued inputs without silently changing the intended quantity.

Advanced 11 min read

What You'll Learn

  • State the mathematical domains of logarithms, shifted logarithms, and ratios.
  • Distinguish a zero input from a missing input and an undefined derived quantity.
  • Explain why arbitrary offsets, clipping, and deletion change the intended calculation.
  • Assess when a support-respecting model may be appropriate for a positive variable.
  • Diagnose invalid transformed values in imputed data.

Why Domains Matter in Passive Transformations

A passive variable is calculated deterministically from its component variables. That calculation is straightforward only when the inputs lie in the function’s domain. If an imputed value makes a logarithm or ratio undefined, there is no valid passive value to recompute. Substituting a convenient number may make the software run, but it also changes what the derived variable means.

The central task is therefore not to repair an invalid result after it occurs. It is to determine what values the intended quantity allows, why invalid values arose, and whether the imputation model and the definition are consistent with those requirements. A zero may be a valid value of an input while making a particular derived quantity undefined; it is not automatically a missing value.

Definition: The domain of a function is the set of input values for which its output is defined. For the real natural logarithm, \(\log(x)\) is defined only for \(x>0\). For a ratio \(A/B\), the denominator must satisfy \(B\ne 0\). A passive transformation is undefined whenever its inputs fall outside the domain of the specified function.

For a logarithm with base \(b\), the standard real-valued definition requires \(b>0\), \(b\ne 1\), and a positive argument. A shifted logarithm \(\log(X+c)\) is defined only where \(X+c>0\). A ratio has a nonzero denominator as a mathematical requirement, but its scientific meaning may impose a stronger condition. For example, a rate per unit of exposure may require positive exposure, so a negative denominator is mathematically allowed by division but scientifically incompatible with the stated rate.

These conditions apply to observed as well as imputed values. Missingness does not relax the domain: once an input has been imputed, the deterministic formula still has to be defined for the completed value. Conversely, an observed zero should not be changed merely because it causes difficulty for a later calculation.

Define the Quantity Before Choosing a Fix

Before calculating a passive logarithm or ratio, write down its exact formula and domain. For \(\log(X)\), the domain condition is \(X>0\). For \(\log(X+c)\), it is \(X>-c\). For \(A/B\), it is \(B\ne0\); for a rate whose denominator is exposure, the substantive definition may instead require \(B>0\). These are different conditions, and the correct one follows from the quantity being defined.

A zero denominator does not yield a finite ratio. This remains true when the numerator is also zero: \(0/0\) is undefined, not zero. Nor should a positive numerator divided by zero automatically be recorded as an infinite rate. Division by zero has no defined real-valued result; the scientific interpretation may be that the rate is not defined for that record.

It is useful to distinguish three cases. First, the input itself may be missing, so an imputation is needed. Second, the input may be observed or imputed as zero, which can be valid for that input but outside the transformation’s domain. Third, the domain or formula may have been specified incorrectly for the scientific question. These cases call for different decisions. Treating all three as “bad data” and applying the same numerical adjustment obscures the distinction.

Worked Example: A Logarithm of a Positive Measurement

Consider a hypothetical study in which concentration \(X\), measured in milligrams per litre, is positive and the planned derived variable is \(L=\log(X)\). Suppose three completed records have concentrations \(0.8\), \(1.2\), and \(-0.4\) milligrams per litre.

For \(X=0.8\), \(L=\log(0.8)\approx-0.2231\). For \(X=1.2\), \(L=\log(1.2)\approx0.1823\). Both calculations are defined because their inputs are positive.

For \(X=-0.4\), the required condition \(X>0\) fails. Thus \(\log(-0.4)\) is not a real-valued passive result. Replacing \(X\) by \(|X|=0.4\) would produce \(\log(0.4)\), but that calculation describes the logarithm of a different input. Replacing \(X\) by a small positive constant would also change the input and therefore the derived variable.

The negative value calls for investigation: it might indicate an inappropriate model for a variable known to be positive, a coding or scale error, or a different substantive definition than assumed here. It does not justify silently changing the logarithm formula.

Support-Aware Imputation for Positive Inputs

When the quantity genuinely must be positive, an imputation model should be assessed against that support requirement. One option, when substantively and statistically appropriate, is to model \(Z=\log(X)\) and recover \(X=\exp(Z)\). This guarantees a positive imputed \(X\), since the exponential of every real number is positive. It is not a universal solution: it assumes that modelling the conditional distribution of \(\log(X)\) is suitable, and it cannot represent a genuine point mass at zero.

For example, suppose the conditional model is \(Z\mid W\sim N(\beta_0+\beta_1W,\sigma^2)\), where \(W\) denotes observed predictors. This model assumes that, given \(W\), the logarithm of the positive input follows a normal distribution with the stated mean and variance. It also assumes that the model is adequately specified for the imputation task. Missingness assumptions and the adequacy of the predictor set are separate considerations; a positive-support model by itself does not establish them.

The implied distribution for \(X\) follows from a change of variables. Since \(z=\log(x)\), the derivative is \(dz/dx=1/x\) for \(x>0\). Thus the density on the original scale includes the Jacobian factor \(1/x\), and is zero outside the positive support.

$$ f_X(x\mid W)= \begin{cases} f_Z(\log x\mid W)\dfrac{1}{x}, & x>0,\\[6pt] 0, & x\le 0. \end{cases} $$

The factor \(1/x\) is required when expressing a density for \(X\); it also shows why a normal model for \(Z\) is not the same as a normal model for \(X\). Modelling on the log scale can be reasonable when the distribution and scientific interpretation support it, but it is a modelling choice rather than a numerical patch.

Worked Example: Recovering a Positive Draw From a Log-Scale Model

Suppose, hypothetically, that a positive biomarker \(X\) is modelled through \(Z=\log(X)\). For a record with predictor value \(W=2\), let the fitted conditional mean be \(\beta_0+\beta_1W=0.20\). Suppose a draw from the conditional model adds a residual component of \(0.15\).

The drawn log value is \(z=0.20+0.15=0.35\). Transforming back gives \(x=\exp(0.35)\approx1.419\) in the biomarker’s original units. Because \(\exp(z)>0\) for every real \(z\), this draw meets the positive-support condition required by \(\log(X)\).

This calculation verifies the domain condition, not the model’s overall suitability. The log-scale approach would be inappropriate if zero were a genuine possible value that the model must represent, or if the conditional distribution of \(\log(X)\) were a poor description. In those cases, the input’s support and distributional model need to be reconsidered rather than forcing the log-scale formulation.

Ratios: Zero Denominators and Meaning

For a ratio \(R=A/B\), check the denominator after every relevant input update and before calculating \(R\). If the intended quantity is a rate per unit of exposure, specify whether zero exposure is impossible, a meaningful state, or an indication that the rate is not defined for that record. That decision belongs to the definition and scientific context, not to a software default.

Worked Example: Events Per Unit of Follow-Up

In a hypothetical data set, define \(R=E/T\), where \(E\) is the number of events and \(T\) is follow-up time in years. Consider three records: \((E,T)=(4,2)\), \((0,1)\), and \((3,0)\).

For the first record, \(R=4/2=2\) events per year. For the second, \(R=0/1=0\) events per year; a zero numerator is allowed because the denominator is positive. For the third, \(R=3/0\) is undefined, so no finite rate can be computed from this definition.

Adding an arbitrary small value, such as \(0.01\) years, would give \(3/0.01=300\) events per year. That is not the rate defined by \(E/T\) for \(T=0\); it is a different calculation. The appropriate response is to determine what zero follow-up means in this setting and whether the rate is meant to be defined for that record at all.

When a denominator is imputed, a model that can generate zero may produce undefined passive ratios even if the denominator is usually positive. A model restricted to positive values may be appropriate if positive support is a genuine feature of the variable, but that restriction must be part of the specified model. If zero is a real state, forcing every draw above zero can erase that state and change the implied distribution. The domain requirement of the ratio does not, by itself, tell us which of these models is scientifically correct.

Derivation and Practical Checks

The necessity of respecting the domain follows directly from the definition of a passive variable. Let \(g\) be a deterministic transformation of inputs \(U\), and let \(D_g\) denote its domain. The passive value is \(g(U)\) only when \(U\in D_g\). If an imputation draw has \(U\notin D_g\), there is no value specified by \(g\) for that draw. Any substituted output must therefore come from an additional rule, not from the original deterministic definition.

$$ U\in D_g \ \Longrightarrow\ \text{passive value}=g(U); \qquad U\notin D_g \ \Longrightarrow\ g(U)\text{ is undefined}. $$

This also explains the importance of checking inputs before recomputing passive terms. A transformation step cannot fix an unsupported input without changing the definition or adding a separate policy. In a chained procedure, a model that repeatedly proposes values outside the domain can make the dependent passive calculation undefined at repeated updates. The calculation should be checked at the point where the relevant input changes.

A practical diagnostic review should include the following checks:

  • Write the formula and its domain explicitly, including any stricter scientific support requirement.
  • Count observed and imputed values that violate the required condition, such as \(X\le0\) for \(\log(X)\) or \(B=0\) for \(A/B\).
  • Inspect why invalid values occur: consider the scale, coding, model support, and whether the intended formula matches the scientific question.
  • Recheck the condition after imputations and before each passive calculation, rather than relying on a single initial check.
  • Record how genuine zero or undefined cases are represented and explain any change to the target quantity.

A useful distinction is between restricting a model and clipping its outputs. A model that explicitly assigns probability only to the scientifically supported range has a stated distributional meaning. By contrast, clipping a draw to a boundary after it is generated piles values at that boundary and changes the distribution. Likewise, adding a constant to avoid a zero denominator changes the ratio. Such operations are not equivalent to preserving the original formula.

Alternatives, Limitations, and Common Mistakes

There are several principled options when a transformation is not defined for some valid input values. One is to choose an imputation model for the input whose support matches a genuine restriction, such as a positive measurement. Another is to retain the original inputs and define the derived quantity only where it is meaningful, with an explicit representation for cases where it is undefined. A third is to reconsider the scientific question and specify a different quantity if that is what the investigators actually intend. Each option changes or limits the analysis in a different way, so the choice should be explicit.

A direct imputation of a derived variable is not automatically a substitute for a passive calculation: it can break the deterministic relationship to its components. Similarly, deleting records with invalid transformations may change the population represented by the analysis. These choices require substantive justification; neither is a neutral way to make the computation succeed.

A frequent mistake is to reason, “The logarithm or ratio must exist in every completed data set, so I will add a tiny constant, take an absolute value, or replace invalid values by the boundary.” The correction is to check the intended domain and decide whether the input model, the definition, or the handling of genuinely undefined cases needs revision. A computational workaround is not automatically a statistically valid imputation rule.

Support constraints alone also do not guarantee good imputations. A model can always generate positive values and still be misspecified, poorly calibrated, or inconsistent with the substantive analysis. Conversely, a real zero may be essential to the data-generating process even though a logarithmic transformation cannot accommodate it. The transformation’s domain is a necessary condition for calculation, not a complete model-selection criterion.

Key takeaway: Preserve the stated definition. Check its domain, distinguish invalid imputed values from valid zeros and undefined derived quantities, and make any support restriction or change of target explicit.

Check Your Understanding

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

  1. For what values of \(X\) is \(\log(X-2)\) defined?
  2. If \(A=0\) and \(B=5\), is \(A/B\) defined? What if \(A=0\) and \(B=0\)?
  3. A positive variable is imputed with a model that can produce negative values. Name one possible model-based response and one reason it might not be suitable.
  4. Why does replacing a zero denominator by a small positive constant change a ratio’s definition?

Solutions. (1) The argument must be positive: \(X-2>0\), so \(X>2\). (2) \(0/5=0\) is defined, but \(0/0\) is undefined because the denominator is zero. (3) A model for \(\log(X)\), followed by exponentiation, produces positive values when positivity is substantively correct and the log-scale model is suitable. It may be unsuitable if zero is a genuine possible value or if the conditional distribution of \(\log(X)\) is poorly specified. (4) If the original denominator is zero, the stated ratio is undefined. Substitution of a small constant computes a ratio with a different denominator, and hence a different quantity.

Clinical Biostats