Tutorials › Pharmacometric Workflows and Reproducible Modeling › Parameter Scaling and Ill-Conditioning

Debugging Model Failures · Tutorial 145 of 399

Parameter Scaling and Ill-Conditioning

Use scaled coordinates to diagnose and reduce scale-driven optimization difficulty while checking that the fitted model and its inferential conclusions remain unchanged.

Advanced 12 min read

What You'll Learn

  • Derive how gradients and Hessians transform under affine parameter scaling.
  • Interpret Hessian condition numbers in the coordinates where they are calculated.
  • Choose scales that reflect meaningful parameter magnitudes.
  • Check whether rescaling improves numerical behavior without changing the fitted model.
  • Recognize weak directions and rank deficiency that scaling cannot remove.
  • Compare parameter scaling with optimizer preconditioning and substantive reparameterization.

Why Parameter Scale Matters

An optimizer searches parameter space using numerical quantities such as gradients, curvature, and step sizes. Those quantities depend on the coordinates used to represent the parameters. If one parameter typically changes by a tiny numerical amount while another changes by a very large amount, an optimizer applying a common step rule or convergence tolerance can make progress unevenly: it may take ineffective steps in one direction or declare convergence while another direction is not adequately settled.

This is a numerical issue, not automatically evidence that the model is wrong or that a parameter is unidentifiable. Scaling can make the optimization geometry easier to work with, but it cannot add information to the data or repair every cause of poor conditioning. The key diagnostic is to compare the fit in the original and scaled coordinates, including the objective value and model predictions, rather than treating a changed gradient norm as evidence of a changed fit.

Definition: Let \(\theta\) be a vector of model parameters and \(L(\theta)\) a twice-differentiable objective to minimize, such as a negative log-likelihood. An affine parameter scaling writes \(\theta=\theta_0+D z\), where \(\theta_0\) is a fixed reference vector, \(z\) is the vector of scaled coordinates, and \(D\) is a nonsingular scaling matrix, commonly diagonal with positive entries. The coordinates \(z\) are dimensionless when each diagonal entry of \(D\) is chosen in the units of its corresponding parameter.

A scale should be selected to make a typical meaningful change in each parameter correspond to a change of roughly order one in its scaled coordinate. It need not equal the final estimate: a plausible scientific range or a characteristic magnitude explored during optimization may be more useful. Scaling is a numerical coordinate choice; it does not alter the likelihood or the scientific meaning of the model.

What Changes Under Scaling

For an affine transformation, the chain rule gives the gradient and Hessian in the scaled coordinates. Write \(g_\theta=\nabla_\theta L\), \(H_\theta=\nabla^2_\theta L\), and \(g_z,H_z\) for the corresponding quantities in \(z\). Because \(\theta=\theta_0+D z\), the derivatives are:

$$ g_z=D^{T}g_\theta,\qquad H_z=D^{T}H_\theta D. $$

Thus, the numerical gradient components and Hessian eigenvalues depend on the chosen scales. If \(H_\theta\) is positive definite, its 2-norm condition number is \(\kappa_2(H_\theta)=\lambda_{\max}(H_\theta)/\lambda_{\min}(H_\theta)\). A very large value indicates substantial disparity in curvature across directions in those coordinates. It is not an invariant property of the model: a sensible rescaling can reduce it.

There is an important qualification. At a twice-differentiable interior local minimum, the Hessian is positive semidefinite, not necessarily positive definite. A positive-definite Hessian is a sufficient second-order condition for a strict local minimum, but it is not necessary: for example, \(L(x)=x^4\) has a strict minimum at zero and a zero Hessian there. The condition-number ratio above applies directly when the Hessian is positive definite. If it is singular, the usual condition number is infinite; if it is indefinite, the positive-definite eigenvalue ratio is not an appropriate description of curvature at that point.

Key result: For nonsingular \(D\), scaling preserves the objective values at corresponding points and preserves Hessian rank and inertia (the counts of positive, negative, and zero eigenvalues). It can change the numerical size and conditioning of the curvature, but it cannot remove an exactly flat direction or create information that was absent from the model.

A Short Derivation and Its Diagnostic Meaning

The affine transformation has constant derivative \(d\theta/dz=D\). Applying the chain rule to the scalar objective gives \(g_z=D^Tg_\theta\). Differentiating once more gives \(H_z=D^TH_\theta D\); there is no additional second-derivative term because the transformation is affine. For any vector \(v\), the scaled quadratic curvature is

$$ v^T H_z v=(Dv)^T H_\theta(Dv). $$

Since \(D\) is nonsingular, \(v\ne 0\) implies \(Dv\ne 0\). Consequently, a direction of zero curvature in the original coordinates corresponds to a direction of zero curvature in the scaled coordinates, and positive or negative curvature is preserved under this change of coordinates. Equivalently, \(H_z\) is a congruence transformation of \(H_\theta\), which preserves rank and inertia. This explains the distinction between improving numerical conditioning and repairing weak identification: the former may be possible through scaling; the latter does not follow from it.

Worked Example: Reducing Curvature Disparity

Consider a hypothetical objective with two parameters: \(L(\theta)=\frac{1}{2}(10^6\theta_1^2+10^{-6}\theta_2^2)\). Its minimum is at \((0,0)\), and its Hessian is diagonal.

$$ H_\theta= \begin{pmatrix} 10^6&0\\ 0&10^{-6} \end{pmatrix}, \qquad \kappa_2(H_\theta)=\frac{10^6}{10^{-6}}=10^{12}. $$

Use \(\theta_1=10^{-3}z_1\) and \(\theta_2=10^3z_2\), so \(D=\operatorname{diag}(10^{-3},10^3)\). Substitution gives

$$ L(z)=\frac{1}{2}\left[10^6(10^{-3}z_1)^2+ 10^{-6}(10^3z_2)^2\right] =\frac{1}{2}(z_1^2+z_2^2). $$

Therefore \(H_z=I\) and \(\kappa_2(H_z)=1\). The same objective has been expressed in better-balanced coordinates; no data or model information has changed. This example is deliberately quadratic and exactly solvable, so it illustrates the geometric effect of scaling rather than a guarantee that every nonlinear fit will attain condition number one.

Choosing Scales and Checking a Fit

In practice, use scales \(s_j>0\) and set \(D=\operatorname{diag}(s_1,\ldots,s_p)\), where each \(s_j\) represents a characteristic change in parameter \(\theta_j\). The scaled coordinate \(z_j=(\theta_j-\theta_{0j})/s_j\) then measures changes in units of that characteristic scale. A useful first choice makes typical \(z_j\) values and meaningful optimization steps broadly comparable, without forcing all fitted estimates to equal one.

After fitting, compare the results in both coordinate systems. If the transformation is one-to-one, corresponding parameter values must describe the same model point. The objective value and predictions should agree up to numerical tolerances, and the reported parameter estimates must transform back consistently. For covariance estimates, the transformation follows the same coordinate map: if \(V_z\) is the covariance matrix for \(z\), then \(V_\theta=D V_z D^T\). Standard errors in original units therefore need to be recovered before reporting or interpreting them.

1
Choose a diagnostic scale.
Use plausible parameter magnitudes or meaningful changes to define each diagonal entry of \(D\). Record the transformation so fitted values and standard errors can be mapped back.
2
Refit using scaled coordinates.
Keep the model, data, objective, and constraints equivalent. Transform any bounds consistently; otherwise the scaled run may solve a different problem.
3
Compare more than convergence status.
Check objective values, back-transformed estimates, predictions, gradient diagnostics, and curvature diagnostics. A change in one raw gradient norm alone is not a sufficient comparison.
4
Interpret what remains.
If scaling improves numerical behavior while the fit agrees, scale disparity was likely contributing to difficulty. Persistent flat or unstable directions call for further diagnosis, not increasingly extreme scales.

Worked Example: Interpreting Gradients in Two Coordinate Systems

For the quadratic objective in the first example, consider the point \(\theta=(0.001,1000)\). Its objective value is \(L=\frac12[10^6(0.001)^2+10^{-6}(1000)^2]=1\). The original-coordinate gradient is

$$ g_\theta=H_\theta\theta= \begin{pmatrix}1000\\0.001\end{pmatrix}, \qquad \lVert g_\theta\rVert_2=\sqrt{1000^2+0.001^2}\approx1000. $$

Under the scales \(D=\operatorname{diag}(10^{-3},10^3)\), this same point is \(z=(1,1)\). Its scaled gradient is

$$ g_z=D^Tg_\theta= \begin{pmatrix}10^{-3}&0\\0&10^3\end{pmatrix} \begin{pmatrix}1000\\0.001\end{pmatrix} = \begin{pmatrix}1\\1\end{pmatrix}, \qquad \lVert g_z\rVert_2=\sqrt{2}\approx1.414. $$

The objective value is still 1, and the point is not a minimum in either system. The different gradient norms reflect the coordinates, not different evidence about fit quality. This is why convergence tolerances should be interpreted alongside the parameter scaling and, where available, scaled-gradient and curvature diagnostics.

When Scaling Cannot Fix the Problem

Consider an objective whose local Hessian is \(H_\theta=\begin{pmatrix}1&1\\1&1\end{pmatrix}\). It has eigenvalues 2 and 0, so one direction is exactly flat. For \(D=\operatorname{diag}(2,0.5)\), the transformed Hessian is

$$ H_z=D^T H_\theta D= \begin{pmatrix}4&1\\1&0.25\end{pmatrix}, \qquad \det(H_z)=4(0.25)-1=0. $$

Its rank is still one. The entries and nonzero eigenvalue have changed, but the zero-curvature direction remains; the usual condition number is infinite. A nearly flat direction may likewise remain practically difficult after scaling, even if the numerical condition number changes. Earlier material on small Hessian eigenvalues, weak directions, and practical nonidentifiability provides the relevant distinctions; rescaling is a diagnostic and numerical aid, not a substitute for them.

Common warning signs include large differences in parameter magnitudes, gradient components that are strongly imbalanced after accounting for meaningful parameter changes, large curvature disparities in a positive-definite Hessian, or major changes in convergence behavior between reasonable scalings despite agreement in objective value. Conversely, a scaled fit that returns very different objective values or predictions is not validated merely because its optimizer reports convergence. Check that the transformation and bounds were applied correctly, and investigate whether the optimizer reached a different solution.

Alternatives, Limitations, and a Common Mistake

Parameter scaling is one of several ways to address difficult optimization. An optimizer may offer internal scaling or preconditioning, which adjusts its numerical steps while leaving the user's parameterization intact. Explicit parameter scaling makes the coordinate transformation visible and can improve interpretability of diagnostics, but requires careful transformation of bounds and results. A substantive reparameterization changes how the model is expressed—for example, a transformation used to enforce a constraint—and may have additional consequences for derivatives and interpretation. Scaling alone is usually preferable when the issue is simply disproportionate parameter magnitudes; it is not a reason to alter the scientific model.

A common mistake is to see a smaller gradient norm or a more favorable Hessian condition number after scaling and conclude that the model is now well identified. That conclusion does not follow. The gradient norm depends on coordinates, and a nonsingular scaling preserves Hessian rank. The correction is to verify that the fit is equivalent and then assess any remaining small-curvature directions, parameter dependence, or instability on their own terms. Also avoid extreme scales chosen solely to make a diagnostic look good: they can worsen floating-point behavior or obscure the meaning of steps.

Key takeaway: Scale parameters according to meaningful changes, transform the derivatives and constraints consistently, and compare equivalent fits after mapping estimates back. Improved numerical conditioning is useful evidence about the optimization workflow, but it is not proof of identifiability or model adequacy.

Worked Example: Mapping Estimates and Uncertainty Back

Suppose a hypothetical fit uses \(\theta_1=0.005z_1\) and \(\theta_2=200z_2\). A scaled-coordinate fit reports \(\hat z=(0.96,1.20)\), standard errors \(0.20\) for each coordinate, and objective value \(128.437\). The corresponding estimates are

$$ \hat\theta_1=0.005(0.96)=0.00480,\qquad \hat\theta_2=200(1.20)=240. $$

The original-coordinate standard errors are \(0.005(0.20)=0.00100\) and \(200(0.20)=40.0\), respectively. If the scaled covariance matrix is diagonal with entries \(0.20^2=0.0400\), then \(V_\theta=D V_z D^T\) has diagonal entries \(0.005^2(0.0400)=1.00\times10^{-6}\) and \(200^2(0.0400)=1600\). The objective value remains \(128.437\) at the mapped parameter point because this is only a change of coordinates. These calculations verify the mapping; they do not, by themselves, establish that the estimates are precise or that the model is adequate.

Check Your Understanding

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

  1. If \(H_\theta\) is positive definite, what is the scaled Hessian under \(\theta=\theta_0+Dz\), and why can its condition number change?
  2. At a twice-differentiable interior minimum, must the Hessian be positive definite? State the correct general condition.
  3. A nonsingular diagonal scaling changes a zero Hessian eigenvalue into a positive one. Is that possible? Explain using rank or curvature.
  4. A fit has a much smaller gradient norm after scaling, but its predictions and objective value are unchanged. What can and cannot be concluded?

Solutions. (1) \(H_z=D^TH_\theta D\). Its eigenvalues and their ratios depend on the coordinate scales, so its condition number can change even though the model point is equivalent. (2) No. The Hessian must be positive semidefinite at a twice-differentiable interior local minimum; positive definiteness is sufficient, but not necessary, for a strict local minimum. (3) No. For nonsingular \(D\), congruence preserves rank and inertia, so an exactly zero-curvature direction remains. (4) The gradient norm is coordinate-dependent, and the equivalent objective and predictions support that the same model fit was obtained. The smaller norm alone does not establish stronger identification, greater precision, or model adequacy.

Clinical Biostats