Tutorials › Pharmacokinetic-Pharmacodynamic (PK/PD) Modeling › Nonlinear Least Squares for Direct-Effect Models

Direct-Effect Models: Linear, Emax and Sigmoid Emax · Tutorial 28 of 598

Nonlinear Least Squares for Direct-Effect Models

You will learn to formulate and minimize the residual sum of squares for direct-effect models, interpret parameter updates, and distinguish genuine convergence from a stalled or unreliable fit.

Intermediate 12 min read

What You'll Learn

  • Define the residual sum of squares for linear, Emax, and sigmoid Emax models.
  • Distinguish a linear least-squares solution from an iterative nonlinear fit.
  • Use a Jacobian-based Gauss–Newton update to describe parameter estimation.
  • Evaluate a proposed update by comparing its residual sum of squares with the current fit.
  • Check convergence using objective changes, parameter steps, and residual behavior.
  • Recognize when apparent convergence may reflect poor scaling or weak identification.

From a Concentration-Effect Model to an Estimation Problem

A direct-effect model gives a predicted response at each measured concentration. Estimation chooses parameter values so those predictions are close to the observed responses. For a linear model, the least-squares solution can be calculated directly. For Emax and sigmoid Emax models, parameters such as \(EC_{50}\) enter nonlinearly, so fitting generally requires an iterative numerical search.

Let \(C_i\) be the concentration and \(y_i\) the observed effect for observation \(i\), where \(i=1,\ldots,n\). Write the model prediction as \(f(C_i;\boldsymbol{\theta})\), where \(\boldsymbol{\theta}\) is the parameter vector. The residual is the observed minus predicted effect. Ordinary, unweighted nonlinear least squares chooses parameters to minimize the sum of squared residuals.

Definition: For observations \((C_i,y_i)\) and model \(f(C_i;\boldsymbol{\theta})\), the residual is \(r_i(\boldsymbol{\theta})=y_i-f(C_i;\boldsymbol{\theta})\). The residual sum of squares (RSS) is
$$ RSS(\boldsymbol{\theta})=\sum_{i=1}^{n}\left[y_i-f(C_i;\boldsymbol{\theta})\right]^2. $$
An ordinary least-squares estimate is a parameter vector that minimizes this RSS over the parameter values allowed by the model.

For illustration, a stimulatory linear model can be written \(f(C)=E_0+sC\), with baseline \(E_0\) and slope \(s\). The Emax model is \(f(C)=E_0+E_{\max}C/(EC_{50}+C)\), and the sigmoid Emax model is \(f(C)=E_0+E_{\max}C^\gamma/(EC_{50}^\gamma+C^\gamma)\). Here \(E_{\max}\) is the maximum effect above baseline, \(EC_{50}\) is the concentration producing half of that maximum in the Emax model, and \(\gamma\) is the Hill coefficient. The same estimation principle applies to inhibitory parameterizations: use the specified model prediction and calculate its residuals.

The unweighted objective gives every observation the same squared-error weight. Its common statistical interpretation assumes errors are independent, have mean zero, and have constant variance; normally distributed errors additionally make least squares the maximum-likelihood method under that error model. The numerical minimization itself can still be defined without assuming normality. The concentration and response values must be paired correctly, and the chosen model must be meaningful for the observed range. These assumptions do not establish that a concentration causes an effect.

Linear Least Squares as a Reference Point

The linear concentration-effect model is linear in its parameters. Its RSS is a quadratic function of \(E_0\) and \(s\), and minimizing it gives the familiar least-squares solution. This provides a useful contrast: the objective is still RSS for an Emax curve, but the nonlinear dependence on \(EC_{50}\) usually prevents a single closed-form solution for all parameters.

Worked Example: RSS for a Linear Concentration-Effect Model

Suppose a hypothetical experiment measures effect units at concentrations \(C=0,1,2\) mg/L, giving responses \(y=2.1,3.9,6.2\). Fit \(f(C)=E_0+sC\) by ordinary least squares.

The mean concentration is \(\bar{C}=1\) mg/L and the mean response is \(\bar{y}=(2.1+3.9+6.2)/3=4.0667\) effect units. The slope is

$$ s=\frac{\sum_i(C_i-\bar{C})(y_i-\bar{y})}{\sum_i(C_i-\bar{C})^2} =\frac{(-1)(-1.9667)+0( -0.1667)+(1)(2.1333)}{(-1)^2+0^2+1^2} =\frac{4.100}{2}=2.050\ \frac{\text{effect units}}{\text{mg/L}}. $$

The intercept is \(E_0=\bar{y}-s\bar{C}=4.0667-2.050(1)=2.0167\) effect units. The predictions at \(C=0,1,2\) mg/L are \(2.0167,4.0667,6.1167\). Thus,

$$ RSS=(2.1-2.0167)^2+(3.9-4.0667)^2+(6.2-6.1167)^2 =0.00694+0.02778+0.00694=0.04167\ \text{effect units}^2. $$

The fitted slope describes the estimated change in effect per mg/L over this linear model. It does not imply that the response continues to rise linearly at concentrations outside the measured range.

Why Emax Fits Require Iteration

In the Emax model, changing \(EC_{50}\) changes the prediction at every nonzero concentration in a nonlinear way. A numerical optimizer therefore starts from a parameter vector, calculates predictions and residuals, proposes a change to the parameters, and evaluates the new RSS. The starting-value tutorial covers how to choose plausible initial values; here the focus is what the fitting algorithm does with them.

The basic local update can be derived by approximating the model near the current parameter vector \(\boldsymbol{\theta}\). Let \(J\) be the Jacobian matrix, whose element \(J_{ij}\) is the derivative of prediction \(f(C_i;\boldsymbol{\theta})\) with respect to parameter \(\theta_j\). For a small proposed change \(\boldsymbol{\delta}\), approximate the predictions by \(f(\boldsymbol{\theta}+\boldsymbol{\delta})\approx f(\boldsymbol{\theta})+J\boldsymbol{\delta}\). The residual vector after the change is therefore approximately \(\mathbf{r}-J\boldsymbol{\delta}\). Choosing the change that minimizes its squared length gives the normal equations below.

$$ \underset{\boldsymbol{\delta}}{\operatorname{argmin}}\, \|\mathbf{r}-J\boldsymbol{\delta}\|^2 \quad\Longrightarrow\quad J^\mathsf{T}J\boldsymbol{\delta}=J^\mathsf{T}\mathbf{r}. $$

This is the Gauss–Newton step when the system has a suitable solution. The derivation is a local linear approximation, not a guarantee that the proposed step will reduce the actual, nonlinear RSS. Implementations commonly use damping, such as a Levenberg–Marquardt step, or a line search: if a proposal increases RSS, the algorithm reduces or modifies the step and checks again. The scale of parameters matters because \(E_0\), \(E_{\max}\), and \(EC_{50}\) can have different units and numerical magnitudes; the earlier material on scaling and reparameterizing Emax models is relevant when selecting a stable representation.

For \(f(C)=E_0+E_{\max}C/(EC_{50}+C)\), the prediction derivatives include

$$ \frac{\partial f}{\partial E_0}=1,\qquad \frac{\partial f}{\partial E_{\max}}=\frac{C}{EC_{50}+C},\qquad \frac{\partial f}{\partial EC_{50}}=-\frac{E_{\max}C}{(EC_{50}+C)^2}. $$

These derivatives supply the Jacobian at the current parameter values. For the sigmoid model, let \(q=(C/EC_{50})^\gamma\), so \(f=E_0+E_{\max}q/(1+q)\). For \(C>0\), derivatives with respect to \(EC_{50}\) and \(\gamma\) are \(-E_{\max}\gamma q/[EC_{50}(1+q)^2]\) and \(E_{\max}q\ln(C/EC_{50})/(1+q)^2\), respectively. At \(C=0\), the concentration-dependent contribution is zero. The optimizer uses such local sensitivities to determine which parameter changes could reduce the residuals.

Worked Example: One Gauss–Newton Update for an Emax Fit

Consider hypothetical observations \((C,y)=(0,2.1),(1,4.4),(2,6.2),(4,7.8)\), with concentration in mg/L and effect in arbitrary effect units. To keep the arithmetic focused on the update, hold \(E_0=2\) effect units and \(E_{\max}=8\) effect units fixed, and estimate \(K=EC_{50}\), in mg/L. Start at \(K=2\) mg/L. The predictions are \(2,4.6667,6.0000,7.3333\), giving residuals \(0.1000,-0.2667,0.2000,0.4667\). The starting RSS is

$$ RSS(2)=0.1000^2+(-0.2667)^2+0.2000^2+0.4667^2 \approx 0.3389\ \text{effect units}^2. $$

The observation at \(C=0\) has derivative zero with respect to \(K\). At the other three concentrations, the Jacobian entries are \(-8C/(2+C)^2\), namely \(-0.8889,-1.0000,-0.8889\). For this single fitted parameter, the Gauss–Newton update is \(\delta=(J^\mathsf{T}r)/(J^\mathsf{T}J)\). Substitution gives

$$ \delta= \frac{(-0.8889)(-0.2667)+(-1)(0.2000)+(-0.8889)(0.4667)} {(-0.8889)^2+(-1)^2+(-0.8889)^2} \approx \frac{-0.3778}{2.5802}=-0.1464\ \text{mg/L}. $$

The proposed value is \(K_{\text{new}}=2-0.1464=1.8536\) mg/L. Using this value gives predictions approximately \(2.0000,4.8035,6.1520,7.4669\). The corresponding RSS is approximately

$$ RSS(1.8536)\approx 0.1000^2+(-0.4035)^2+(0.0480)^2+(0.3331)^2 =0.2861\ \text{effect units}^2. $$

Because \(0.2861<0.3389\), this update improves the fit. It is not a complete estimate of all Emax parameters: two parameters were deliberately fixed, and further iterations would be needed to minimize RSS over \(K\). In a full fit, the Jacobian has columns for every estimated parameter, and the update solves the corresponding system of equations.

Assessing Convergence and Detecting Failure

An optimizer stopping is not, by itself, proof that it found a useful minimum. Convergence checks should assess the objective, the parameter changes, and whether the fit is numerically and scientifically credible. A practical stopping rule commonly combines a small relative change in RSS with small scaled parameter changes; tolerances depend on the software and the scale of the problem.

1
Evaluate the current fit.
Calculate each prediction, residual, and the total RSS at the current parameter values. Confirm that predictions and objective values are finite.
2
Propose and test an update.
Use a local step, then recalculate the actual nonlinear RSS. Keep or modify the step according to whether it improves the objective.
3
Check more than the objective.
Inspect the size of parameter changes relative to their scales and the size of the remaining gradient. A tiny step with a substantial gradient can indicate a stalled algorithm rather than a well-converged solution.
4
Verify stability and plausibility.
Check that estimates and predictions are finite and relevant to the observed concentration range. Starting from other plausible values and reaching similar objective values provides useful evidence of stability, but does not prove a global minimum.

A monotonically decreasing RSS is encouraging when the algorithm is designed to accept only improving steps. However, the decrease can become tiny because the optimum has been reached, because the parameters are weakly identified, or because the numerical method is stuck. A nearly singular \(J^\mathsf{T}J\) can signal that different parameter changes produce very similar predictions. Earlier material on identifiability and confounding explains why the data may not distinguish \(EC_{50}\), \(E_{\max}\), or \(\gamma\) well even when an optimizer reports convergence.

Other warning signs include an RSS that becomes undefined, non-finite predictions, large oscillating updates, and materially different solutions from different starts. Poor scaling can make one parameter appear unchanged while another continues to move. A small residual sum alone is not enough: the number and placement of concentrations, the response scale, and the model assumptions all affect whether the fitted parameters are informative. Detailed residual diagnostics and uncertainty assessment are separate steps; convergence does not replace them.

Worked Example: A Sigmoid Emax Candidate That Should Be Rejected

Suppose a hypothetical dataset has concentrations \(0,2,4\) mg/L and effects \(1.0,4.2,5.6\) units. At the candidate parameters \(E_0=1\), \(E_{\max}=6\), \(EC_{50}=2\) mg/L, and \(\gamma=2\), predictions are \(1.0,4.0,5.8\). The residuals are \(0,0.2,-0.2\), so

$$ RSS=0^2+0.2^2+(-0.2)^2=0.0800\ \text{effect units}^2. $$

Now test a proposed update to \(E_0=1.05\), \(E_{\max}=5.9\), \(EC_{50}=2.1\) mg/L, and \(\gamma=2\). At \(C=2\), the prediction is \(1.05+5.9(4)/(2.1^2+4)=3.8562\). At \(C=4\), it is \(1.05+5.9(16)/(2.1^2+16)=5.6752\); at zero concentration it is \(1.05\). Thus,

$$ RSS_{\text{candidate}}=(1.0-1.05)^2+(4.2-3.8562)^2+(5.6-5.6752)^2 \approx 0.1264\ \text{effect units}^2. $$

The proposed update raises RSS from \(0.0800\) to \(0.1264\) effect units squared. An algorithm that accepts only improving steps should reject it, reduce or otherwise revise the step, and reevaluate. Simply reaching a small parameter change after repeatedly shrinking unsuccessful steps would not establish that a satisfactory minimum had been found.

Choosing and Interpreting the Fitting Approach

For the linear model, ordinary least squares has a direct solution and avoids iterative-search issues. For Emax and sigmoid Emax models, nonlinear least squares directly minimizes discrepancies on the response scale and accommodates the model’s nonlinear concentration-effect shape. The cost is dependence on starting values and numerical behavior. A fit that converges is a numerical result, not evidence by itself that the selected model is correct or that every parameter is well determined.

The objective here is unweighted RSS. It treats a one-unit residual as equally costly at low and high fitted responses. Weighted fitting changes that objective and is a distinct method; it should not be introduced by informally rescaling a few observations. Similarly, choices about additive or proportional residual error change the error model, not merely the optimization algorithm. Keep the objective and its assumptions explicit when interpreting a fitted curve.

Key takeaway: Nonlinear least squares repeatedly uses local information to propose parameter changes, but every candidate must be checked against the actual RSS. Reliable convergence requires a small objective change and appropriately small parameter steps, alongside finite, stable, and plausible estimates.

Check Your Understanding

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

  1. For observations \(y_i\) and predictions \(f(C_i;\boldsymbol{\theta})\), write the residual and ordinary RSS.
  2. Why does the linear model usually have a direct least-squares solution while a full Emax fit generally uses iteration?
  3. An optimizer proposes a parameter update that lowers RSS but changes \(EC_{50}\) by a substantial amount. Is that enough to declare convergence? Explain.
  4. A sigmoid Emax optimizer reports a very small final step, but the gradient remains substantial and different starts give different solutions. What are two possible explanations?

Solutions. (1) \(r_i=y_i-f(C_i;\boldsymbol{\theta})\), and \(RSS=\sum_i r_i^2\). (2) The linear prediction is linear in its parameters, so minimizing its quadratic RSS gives a direct solution. In a full Emax model, \(EC_{50}\) enters nonlinearly, so a local iterative search is generally required. (3) No. A lower RSS shows that the proposed step improved the objective, but a substantial relative parameter change indicates that the estimate may still be moving; assess subsequent steps and objective changes. (4) The small step may reflect a numerical stall, and the differing solutions may reflect weak identification, local minima, or sensitivity to starting values. Check scaling, the gradient, objective values, and predictions before treating the fit as reliable.

Clinical Biostats