Tutorials › Nonlinear Mixed-Effects Models (NLME) › Scaling Parameters to Improve Numerical Optimization

Estimation Failures and Troubleshooting · Tutorial 272 of 797

Scaling Parameters to Improve Numerical Optimization

You will learn to choose scaled optimization coordinates, transform gradients correctly, and distinguish a scale problem from weak identification or model failure.

Advanced 11 min read

What You'll Learn

  • Identify parameters whose magnitudes or units make raw optimizer coordinates poorly balanced.
  • Choose meaningful reference scales for linear parameter transformations.
  • Use log coordinates for positive parameters when relative changes are more useful than absolute changes.
  • Derive how gradients and local curvature change under parameter scaling.
  • Check that the transformed problem preserves the intended likelihood and parameter constraints.
  • Recognize when scaling cannot remedy weak identification, an unsuitable model, or numerical integration error.

Why Parameter Scales Matter

An NLME objective can depend on parameters that differ greatly in magnitude and units. A clearance might be recorded in liters per hour, a volume in liters, and a random-effect standard deviation as a dimensionless number. An optimizer proposes changes in its parameter coordinates and uses objective-function changes to decide whether those changes are useful. When the coordinates are poorly scaled, a step that is substantial for one parameter can be negligible for another, or a step suitable for one can be excessive for another.

Scaling changes the coordinates used for optimization, not the scientific model. The aim is to make a change of order one in an optimization coordinate correspond to a sensible change in its associated model parameter. That can make numerical steps and local curvature calculations more informative. It does not add information to the data, make a parameter identifiable, or guarantee that an optimizer will converge to the desired solution.

Definition: Let \(\theta=(\theta_1,\ldots,\theta_p)^T\) denote the model parameters and let \(L(\theta)\) be the objective to minimize, such as a negative log-likelihood. Parameter scaling replaces \(\theta\) with optimization coordinates \(q\) through a specified transformation \(\theta=T(q)\), while evaluating the same objective as \(L(T(q))\). For linear scaling, \(\theta=\theta_{\mathrm{ref}}+Dq\), where \(\theta_{\mathrm{ref}}\) is a reference vector and \(D\) is a diagonal matrix of positive scale constants.

For linear scaling, the \(j\)th diagonal entry of \(D\) has the units and approximate magnitude of a meaningful change in \(\theta_j\). Thus, a change of one unit in \(q_j\) changes \(\theta_j\) by that scale constant. The reference vector can be a plausible parameter value, but a scale constant should not be confused with an estimate or an initial value. Choosing initial values for random-effect variances addresses where optimization begins; scaling addresses the units and magnitudes of the coordinates in which it proceeds.

How Gradients Change Under Scaling

Suppose \(L\) is differentiable and \(\theta=\theta_{\mathrm{ref}}+Dq\). The chain rule relates the gradient in the scaled coordinates to the gradient in the original coordinates:

$$ \nabla_q L = D^T \nabla_\theta L. $$

Because \(D\) is diagonal, the derivative with respect to \(q_j\) is the derivative with respect to \(\theta_j\), multiplied by the scale constant \(s_j\). Raw derivatives with respect to parameters measured in different units are not directly comparable: changing liters to milliliters changes the numerical derivative even when the scientific model is unchanged. Scaling expresses changes in terms of chosen parameter increments instead.

The same transformation affects local curvature. For a linear transformation, the Hessian, the matrix of second derivatives, satisfies:

$$ \nabla_q^2 L = D^T(\nabla_\theta^2 L)D. $$

This follows by differentiating \(\nabla_q L=D^T\nabla_\theta L\) once more with respect to \(q\); \(D\) is constant, and \(\partial\theta/\partial q=D\). If a scale constant is much larger or smaller than the others, it changes the corresponding curvature entries. A sensible choice can make the local geometry easier for a numerical method to handle, but it cannot remove genuine dependence between parameters or flat directions in the objective.

Worked Example: Balancing Clearance and Volume Coordinates

Consider a hypothetical local approximation to an NLME objective for clearance \(CL\), in liters per hour, and volume \(V\), in liters:

$$ L(CL,V)=\frac{1}{2}\left[\left(\frac{CL-5}{5}\right)^2+ \left(\frac{V-40}{40}\right)^2\right]. $$

The reference values are \(5\ \mathrm{L/h}\) and \(40\ \mathrm{L}\), and the scales are \(5\ \mathrm{L/h}\) and \(40\ \mathrm{L}\). Define \(q_1=(CL-5)/5\) and \(q_2=(V-40)/40\). Then \(L=\tfrac12(q_1^2+q_2^2)\). At the hypothetical current point \(CL=10\ \mathrm{L/h}\) and \(V=80\ \mathrm{L}\), the scaled coordinates are \(q_1=1\) and \(q_2=1\), and \(L=1\).

In the original coordinates, \(\partial L/\partial CL=(CL-5)/25=5/25=0.200\) per \(\mathrm{L/h}\), while \(\partial L/\partial V=(V-40)/1600=40/1600=0.0250\) per liter. In the scaled coordinates, the derivatives are \(\partial L/\partial q_1=q_1=1\) and \(\partial L/\partial q_2=q_2=1\). The numerical raw derivatives differ, partly because the units and scales differ; the scaled derivatives express the objective change per chosen, meaningful increment. This transformation has not changed the minimum: it remains \(CL=5\ \mathrm{L/h}\), \(V=40\ \mathrm{L}\).

Choosing a Transformation

For parameters that can take values on both sides of a reference value, linear scaling is often sufficient. A practical scale is a typical magnitude or a scientifically meaningful change. If an estimate may be near zero, do not set the scale equal to that estimate: choose a nonzero scale representing a change worth resolving. A poor scale can merely move the numerical imbalance rather than improve it.

Positive parameters often benefit from log coordinates when relative rather than absolute changes are appropriate. For a positive parameter \(\theta\), define \(q=\log(\theta/\theta_{\mathrm{ref}})\), so \(\theta=\theta_{\mathrm{ref}}\exp(q)\). A step of one in \(q\) multiplies \(\theta\) by \(e\); a small step \(\Delta q\) gives a relative change of approximately \(\Delta q\), since \(\Delta\theta/\theta\) is approximately \(\Delta q\). The transformation enforces positivity, but it does not automatically solve poor scaling: choose \(\theta_{\mathrm{ref}}\) so that the resulting coordinates and steps are sensible.

Worked Example: Log-Scaling a Positive Random-Effect Standard Deviation

Suppose a hypothetical optimization involves a positive random-effect standard deviation \(\omega\), and a scientifically meaningful reference scale is \(\omega_{\mathrm{ref}}=0.10\). Use \(q=\log(\omega/0.10)\), so \(\omega=0.10\exp(q)\). At \(\omega=0.020\), \(q=\log(0.20)=-1.609\). The transformed coordinate is finite and the corresponding value of \(\omega\) is positive.

To show the derivative transformation, take the hypothetical objective contribution \(L(\omega)=\tfrac12[(\omega-0.020)/0.010]^2\). At \(\omega=0.010\), \(L=\tfrac12(-1)^2=0.500\), and \(\partial L/\partial\omega=(\omega-0.020)/(0.010)^2=-0.010/0.0001=-100\). Because \(d\omega/dq=\omega\), the chain rule gives \(\partial L/\partial q=(\partial L/\partial\omega)\omega=(-100)(0.010)=-1.00\). The derivative now describes a change in a relative log coordinate, not a change per unit of \(\omega\). The minimum remains at \(\omega=0.020\), or \(q=-1.609\); the parameter and its objective have not been altered.

A change of measurement units can itself create a scale problem. For example, \(5\ \mathrm{L/h}=83.33\ \mathrm{mL/min}\). These are the same clearance, not different parameter values in a scientific sense. If the optimization uses numerical parameter values directly, recording clearance in milliliters per minute instead of liters per hour changes the coordinate magnitudes and derivatives. A scale transformation can make the coordinates comparable without changing the model’s predictions. Always make the units explicit when specifying reference values and interpreting estimates.

Worked Example: Scaling a Clearance-to-Volume Rate

A hypothetical one-compartment model uses the elimination rate \(k=CL/V\). Suppose \(CL=5\ \mathrm{L/h}\) and \(V=50\ \mathrm{L}\), so \(k=5/50=0.100\ \mathrm{h}^{-1}\). Define dimensionless coordinates \(q_{CL}=CL/(5\ \mathrm{L/h})\) and \(q_V=V/(50\ \mathrm{L})\). Then \(CL=5q_{CL}\ \mathrm{L/h}\), \(V=50q_V\ \mathrm{L}\), and

$$ k=\frac{CL}{V} =\frac{5q_{CL}\ \mathrm{L/h}}{50q_V\ \mathrm{L}} =0.100\frac{q_{CL}}{q_V}\ \mathrm{h}^{-1}. $$

At the stated values, \(q_{CL}=q_V=1\) and \(k=0.100\ \mathrm{h}^{-1}\), exactly as before. If clearance is instead written as \(83.33\ \mathrm{mL/min}\), its numerical value changes, but \(k\) does not when units are converted consistently. Scaling coordinates by the reference values gives values near one in this example and keeps the model relationship intact. It does not imply that clearance and volume are independently well identified by the data.

Assumptions, Checks, and Alternatives

A coordinate transformation is useful when the objective is well defined in the region being optimized and the transformation maps the intended parameter domain correctly. For linear scaling, positive scale constants give a one-to-one transformation over the corresponding domain. For log scaling, the parameter must be strictly positive; exact zero is not represented by a finite log coordinate. Bounds must also be transformed consistently. For example, a bound \(a\leq\theta\leq b\), with \(0<a<b\), becomes \(\log(a/\theta_{\mathrm{ref}})\leq q\leq\log(b/\theta_{\mathrm{ref}})\).

Before and after changing coordinates, check that the model returns the same predictions and objective at equivalent parameter values. Also check that the reported parameter values are converted back to the original units and parameterization. If the same likelihood is being maximized or minimized, re-expressing its coordinates does not add a likelihood Jacobian term: the objective is evaluated at the transformed parameter value. A Bayesian density expressed as a density in new coordinates is a different matter and must account for the relevant change-of-variables Jacobian.

Scaling is one option among several. Directly changing units can reduce awkward numerical magnitudes, but it can make other parameters less convenient and requires consistent unit conversion throughout the model. Linear scaling is straightforward for parameters with a meaningful absolute increment; log scaling is often suitable for positive parameters whose relative changes matter. An optimizer may also offer automatic scaling or internally adjusted steps. Such features can help, but they do not remove the need to check parameter constraints, units, and the model’s numerical behavior.

Scaling has clear limits. If different parameter combinations produce nearly indistinguishable predictions, the problem is weak identification, not merely mismatched units. If a variance estimate is at a boundary, log coordinates may exclude the boundary rather than resolve why it occurs. A misspecified model, invalid likelihood evaluation, or inaccurate numerical integration is likewise not repaired by rescaling. Scaling also cannot guarantee a successful fit or a reliable uncertainty estimate.

A useful check is to compare the original and transformed evaluations at several equivalent parameter values and confirm that the objective agrees. If a fit changes substantially after a coordinate transformation, check the transformation, bounds, units, and convergence to the same region before interpreting the result. A persistent failure may have another cause; a differently scaled problem is not automatically a better-identified one.

Common Pitfall

A common mistake is to see a small raw derivative for one parameter and conclude that it is already optimized, while a larger derivative for another means that parameter still needs a large change. Derivatives are measured per unit of their parameter: a derivative per liter cannot be compared directly with one per \(\mathrm{L/h}\) or per unit of a dimensionless variance parameter. The correction is to examine changes in meaningful scaled coordinates and to consider the objective’s local shape, not the raw derivative magnitudes in isolation.

Another mistake is to treat rescaling as evidence that a troublesome parameter is now identifiable. Scaling can improve the numerical representation of the same optimization problem; it does not change the information in the observations or the model predictions. Keep numerical conditioning and scientific identifiability as separate questions.

Key takeaway: Choose parameter scales so that order-one optimization steps correspond to meaningful changes in the original parameters. Verify the transformation and constraints, interpret results in the original units, and investigate identification or model problems separately.

Check Your Understanding

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

  1. For \(\theta=\theta_{\mathrm{ref}}+sq\), what is \(\partial L/\partial q\) in terms of \(\partial L/\partial\theta\) and \(s\)?
  2. A positive parameter is \(0.050\), with reference value \(0.10\). What is its log coordinate \(q=\log(\theta/\theta_{\mathrm{ref}})\), to three significant figures?
  3. Why is a raw gradient of \(0.02\) per liter not automatically smaller in a meaningful sense than a gradient of \(0.10\) per \(\mathrm{L/h}\)?
  4. Does linear scaling change the minimum of an objective, assuming the transformation is one-to-one over the domain? Explain briefly.
  5. What is one reason log scaling may be unsuitable for a variance parameter that can equal zero?

Solutions. (1) The chain rule gives \(\partial L/\partial q=(\partial L/\partial\theta)(\partial\theta/\partial q)=s\,\partial L/\partial\theta\). (2) \(q=\log(0.050/0.10)=\log(0.500)=-0.693\). (3) The derivatives are per different units and so refer to different parameter increments; compare them only after expressing changes in meaningful common scaled coordinates. (4) No. A one-to-one reparameterization preserves the objective value at corresponding parameter values, so its minimizer maps to the same original parameter value. (5) The logarithm represents strictly positive values only; zero is not reached at any finite \(q\), so the boundary requires separate handling.