Tutorials › Pharmacometric Workflows and Reproducible Modeling › Transforming Parameter Draws To Respect Constraints

Simulation Pipelines · Tutorial 238 of 399

Transforming Parameter Draws To Respect Constraints

Use log and logit transformations to generate constrained parameter draws, and understand how back-transformation changes their summaries and intervals.

Advanced 10 min read

What You'll Learn

  • Choose log, logit, or scaled-logit transformations to represent positive and bounded parameters.
  • Map transformed-scale draws back to the natural parameter scale without violating constraints.
  • Calculate and interpret lognormal means, medians, and quantiles.
  • Explain why symmetric transformed-scale uncertainty usually becomes asymmetric on the natural scale.
  • Check scale assumptions, draw summaries, and common failure modes.

Why Transform Parameter Draws?

Parameter uncertainty is often represented by repeatedly drawing plausible values around an estimate. A direct normal draw for a clearance, variance, or fraction can be unsuitable: a normal distribution assigns positive probability to values below zero and, for a fraction, to values outside its allowed range. Such values may be mathematically invalid or incompatible with the pharmacometric model. Transforming the parameter before drawing offers a way to represent uncertainty while respecting its constraints.

The transformation is not just a computational device. A symmetric distribution on a transformed scale generally becomes asymmetric after back-transformation. Consequently, the transformed-scale center is not always the natural-scale mean, and a symmetric interval on the transformed scale does not usually become a symmetric interval on the natural scale.

Definition: Let \(\theta\) be a parameter whose allowed values lie in a specified range, and let \(Z=g(\theta)\) be a one-to-one transformation from that range to the real line. Transformed-scale sampling draws \(Z\) from a specified distribution, then maps each draw back using \(\theta=g^{-1}(Z)\). If \(Z\sim N(m,s_z^2)\), the resulting natural-scale distribution is determined by both the normal distribution and the inverse transformation.

Choosing and Applying a Transformation

For a parameter that must be positive, the natural choice is the logarithm. It maps the positive real line to the real line, and its inverse, the exponential function, always returns a positive value. For a fraction strictly between zero and one, the logit maps the fraction to the real line. A parameter bounded between two finite limits can first be rescaled to the unit interval, then transformed with the logit.

$$ \begin{aligned} Z &= \log(\theta), \qquad \theta>0; & \theta &= \exp(Z),\\ Z &= \operatorname{logit}(\theta)=\log\left(\frac{\theta}{1-\theta}\right), \qquad 0<\theta<1; & \theta &= \frac{1}{1+\exp(-Z)},\\ Z &= \operatorname{logit}\left(\frac{\theta-L}{U-L}\right), \qquad L<\theta<U; & \theta &= L+(U-L)\frac{1}{1+\exp(-Z)}. \end{aligned} $$

Here \(L\) and \(U\) are fixed lower and upper bounds. These transforms cover open ranges: a finite transformed draw gives a value strictly inside the corresponding natural-scale range, not exactly at a boundary. If a model permits a boundary value, such as a fraction exactly equal to zero, a logit-normal draw alone cannot represent that point. The model for the parameter must then account for the boundary explicitly rather than silently treating it as an interior value.

Before sampling, check that the uncertainty distribution is specified on the scale that matches its estimate and covariance. A normal approximation for \(Z\) means that the transformed parameter is being modeled as approximately normal; it does not mean that the original parameter is normal. If an estimate and standard error are reported on the natural scale, do not simply use them as the mean and standard deviation of \(Z\). A first-order delta-method approximation for a small uncertainty is \(SE_Z\approx SE_\theta/|d\theta/dZ|\), evaluated near the estimate. For example, for the log transform, \(SE_Z\approx SE_\theta/\theta\); for the logit, \(SE_Z\approx SE_\theta/[\theta(1-\theta)]\). These are local approximations, not exact conversions for large uncertainty.

Positive Parameters and the Lognormal Distribution

Suppose \(Z=\log(\theta)\sim N(m,s_z^2)\). Then \(\theta=\exp(Z)\) has a lognormal distribution. Its median is \(\exp(m)\), because the normal distribution has median \(m\) and the exponential function is increasing. Its mean is \(\exp(m+s_z^2/2)\), which is greater than the median whenever \(s_z>0\). Its variance is \((\exp(s_z^2)-1)\exp(2m+s_z^2)\). The asymmetry arises because an equal-sized change on the log scale corresponds to multiplication, not addition, on the natural scale.

$$ P(\theta\leq t)=P(Z\leq\log t),\quad t>0; \qquad Q_\theta(q)=\exp\left(m+s_z\Phi^{-1}(q)\right) $$

Here \(Q_\theta(q)\) is the natural-scale quantile at probability \(q\), and \(\Phi^{-1}(q)\) is the standard normal quantile. A central 95% interval is therefore obtained by transforming the two normal quantiles \(m-1.96s_z\) and \(m+1.96s_z\). The resulting interval is positive but usually asymmetric around the natural-scale median.

Worked Example: Sampling a Positive Clearance

Suppose, hypothetically, that a clearance estimate is represented by \(Z=\log(CL)\sim N(\log(8),0.200^2)\), where clearance is measured in L/h. The model assumes approximate normality on the log scale; the corresponding natural-scale draws will all be positive.

Median and mean. The median is \(\exp(\log(8))=8.000\) L/h. The mean is not 8.000 L/h, because it includes the upward effect of the lognormal right tail:

$$ E(CL)=\exp\left(\log(8)+\frac{0.200^2}{2}\right) =\exp(2.0994)\approx 8.161\ \text{L/h}. $$

The arithmetic uses the displayed rounded inputs: \(0.200^2/2=0.0200\) and \(\log(8)\approx2.0794\). The mean exceeds the median, as expected for a non-degenerate lognormal distribution.

Central 95% interval. On the log scale, the endpoints are \(\log(8)\pm1.96(0.200)\). Back-transforming gives

$$ \left[\exp(\log(8)-0.392),\ \exp(\log(8)+0.392)\right] \approx [5.406,\ 11.84]\ \text{L/h}. $$

Under the assumed lognormal model, this interval covers 95% of the parameter draws. It is not symmetric around 8.000 L/h: multiplying the median by \(\exp(0.392)\) gives the upper endpoint, while dividing it by the same factor gives the lower endpoint.

Fractions and Other Bounded Parameters

For a fraction \(\theta\) strictly between zero and one, write \(Z=\operatorname{logit}(\theta)\) and model \(Z\) as normal if that assumption is appropriate. The inverse-logit is increasing, so quantiles can be transformed directly: the natural-scale \(q\)-quantile is the inverse-logit of \(m+s_z\Phi^{-1}(q)\). The transformed-scale median maps to the natural-scale median, but the natural-scale mean generally does not equal the inverse-logit of \(m\). In general it is an integral over the transformed-scale distribution, \(E(\theta)=\int \{1/[1+\exp(-z)]\}\,f_Z(z)\,dz\), where \(f_Z\) is the normal density. It typically requires numerical integration or simulation.

Worked Example: Drawing a Bounded Fraction

Suppose, hypothetically, that a fraction \(F\) is represented by \(Z=\operatorname{logit}(F)\sim N(\operatorname{logit}(0.30),0.500^2)\). This model places every finite draw strictly between zero and one.

Median and interval. The transformed mean is \(\log(0.30/0.70)\approx-0.8473\). Since the inverse-logit is increasing, the natural-scale median is 0.300. A central 95% interval on the transformed scale has endpoints \(-0.8473\pm1.96(0.500)\), or approximately \(-1.8273\) and \(0.1327\). Back-transform each endpoint:

$$ \left[ \frac{1}{1+\exp(1.8273)},\ \frac{1}{1+\exp(-0.1327)} \right] \approx [0.1386,\ 0.5331]. $$

Thus, 95% of draws from this assumed model fall between approximately 0.139 and 0.533. The interval is not centered at 0.300, and its upper endpoint exceeds 0.5. Both features are compatible with symmetric normal uncertainty on the logit scale.

Probability of exceeding 0.5. Since the inverse-logit of zero is 0.5, \(F>0.5\) exactly when \(Z>0\). Standardizing gives

$$ P(F>0.5)=P(Z>0) =1-\Phi\left(\frac{0-(-0.8473)}{0.500}\right) =1-\Phi(1.695)\approx0.0451. $$

Under this distribution, about 4.51% of draws exceed 0.5. This is a probability under the stated parameter-draw model, not a probability that an unknown fixed parameter is above 0.5 unless the distribution is being used as a probability model for that parameter.

Worked Example: A Parameter With Two Fixed Bounds

Suppose, hypothetically, that a parameter \(\theta\) must lie between \(L=0.100\) and \(U=0.900\). Let \(Z=\operatorname{logit}((\theta-L)/(U-L))\sim N(m,0.300^2)\), with \(m=\operatorname{logit}((0.400-0.100)/0.800)=\log(0.6)\approx-0.5108\). The transformed-scale median therefore maps to \(\theta=0.400\).

For one hypothetical draw, take \(Z=m+0.300=-0.2108\). The inverse-logit of this value is approximately \(0.4475\), so the parameter draw is

$$ \theta=0.100+0.800\left(\frac{1}{1+\exp(0.2108)}\right) \approx0.100+0.800(0.4475)=0.4580. $$

The draw is inside the required interval. For a central 95% interval, the transformed endpoints are \(-0.5108\pm1.96(0.300)\), approximately \(-1.0988\) and \(0.0772\). Applying the scaled inverse-logit gives an interval of approximately \([0.300,\ 0.515]\). Both endpoints remain between 0.100 and 0.900.

Justification: Why Back-Transformation Changes the Distribution

For a positive parameter, the change-of-variables formula gives the natural-scale density directly. If \(Z=\log(\theta)\), then \(dZ/d\theta=1/\theta\). Therefore the density of \(\theta\), for \(\theta>0\), is the density of \(Z\) evaluated at \(\log(\theta)\), multiplied by \(1/\theta\):

$$ f_\theta(\theta) =f_Z(\log\theta)\left|\frac{d}{d\theta}\log\theta\right| =\frac{1}{\theta s_z\sqrt{2\pi}} \exp\left[-\frac{(\log\theta-m)^2}{2s_z^2}\right]. $$

The factor \(1/\theta\) is the Jacobian. It makes explicit why a normal density on the log scale is not a normal density on the natural scale. The moments follow from the normal exponential moment \(E[\exp(kZ)]=\exp(km+k^2s_z^2/2)\). Setting \(k=1\) gives \(E(\theta)=\exp(m+s_z^2/2)\); setting \(k=2\), then subtracting the square of the mean, gives \(\operatorname{Var}(\theta)=(\exp(s_z^2)-1)\exp(2m+s_z^2)\).

Diagnostics, Alternatives, and Common Mistakes

A valid inverse transformation guarantees mathematical bounds, but it does not guarantee that the draws are scientifically plausible or that the assumed uncertainty distribution is suitable. Review the transformed-scale estimate and uncertainty, the resulting natural-scale quantiles, and the consequences of unusually large or small draws. If a few tail draws dominate predictions, investigate whether they reflect genuine uncertainty, a weakly identified parameter, or an unsuitable approximation. Do not resolve the issue by deleting draws without a prespecified rule and a clear account of the resulting change in the distribution.

The normal approximation on a transformed scale is an assumption. It can be questionable when the estimate is close to a boundary, uncertainty is large, or the sampling distribution is strongly skewed or multimodal. A transformation enforces support; it does not make a poor approximation accurate. When the available uncertainty information is on the natural scale, a delta-method conversion may be useful for small uncertainty, but it should be checked against a more suitable source of draws when one is available.

The main alternatives have different implications. Direct normal draws on the natural scale are simple, but can violate constraints. Truncated normal draws remove invalid values by conditioning on being within bounds; this changes the distribution and its moments relative to the original normal. Repeatedly rejecting invalid draws is likewise not equivalent to drawing from the untruncated distribution. A specified distribution on the natural scale can be appropriate when its form and parameters are justified, but it is not interchangeable with a transformed-normal model. Choose based on the parameter support and the uncertainty model, not only on computational convenience.

  • Check the scale: confirm whether the estimate and standard error or covariance refer to the natural or transformed parameter.
  • Check the support: verify that each back-transformed draw is in the required range and that the chosen transform matches the model’s actual bounds.
  • Check summaries: report the scale and statistic for centers and intervals. A transformed-scale mean maps to a natural-scale median under these monotone transforms, not generally to a natural-scale mean.
  • Check sensitivity: compare important summaries or simulation targets under reasonable alternative uncertainty assumptions when tails or boundary behavior matter.

Common mistake. “The estimate is 8 L/h with a log-scale standard deviation of 0.2, so the natural-scale mean is 8 L/h.” This confuses the transformed-scale center with the natural-scale mean. If \(Z\sim N(\log(8),0.2^2)\), the natural-scale median is 8 L/h, but the mean is \(\exp(\log(8)+0.2^2/2)\approx8.162\) L/h. State which summary is being reported and compute it on the intended scale.

Key takeaway: Transformations can enforce parameter constraints while sampling, but the back-transformed draws have distributions and summaries determined by the inverse transformation. Specify the uncertainty model on the correct scale, transform interval endpoints individually, and interpret natural-scale summaries rather than assuming they remain symmetric.

Check Your Understanding

Answer each question using the stated transformation assumptions. Brief solutions are included below.

  1. If \(Z=\log(\theta)\sim N(m,s_z^2)\), which natural-scale summary is \(\exp(m)\): the mean or median?
  2. A fraction has \(Z=\operatorname{logit}(\theta)\sim N(0,0.4^2)\). What is its median, and what proportion of draws exceed 0.5?
  3. For a parameter restricted to \(2<\theta<10\), write a transformation from its allowed range to the real line and its inverse.
  4. Why is clipping negative draws from a natural-scale normal distribution at zero not generally the same as log-scale sampling?

Solutions. (1) \(\exp(m)\) is the median; the mean is \(\exp(m+s_z^2/2)\). (2) The median is the inverse-logit of zero, 0.5. Symmetry gives \(P(Z>0)=0.5\), so half the draws exceed 0.5. (3) Use \(Z=\operatorname{logit}((\theta-2)/8)\) and \(\theta=2+8/[1+\exp(-Z)]\). (4) Clipping creates a point mass at zero and changes the distribution; log-scale sampling produces strictly positive values with a lognormal distribution instead.

Clinical Biostats