Nonlinear Regression

Nonlinear regression fits a response to predictors through a known function . The function depends on the parameters in a non-linear way:

where is the parameter vector and is a noise term, typically assumed to be white noise . The standard estimator is nonlinear least squares (NLS), which minimizes the residual sum of squares over the parameters:

Unlike linear regression, this minimization has no closed-form solution in general and must be solved iteratively. The standard algorithms are:

  • Gauss-Newton: linearizes around the current parameter estimate and solves the resulting linear regression at each step.
  • Levenberg-Marquardt: a damped variant that interpolates between Gauss-Newton and gradient descent.

An important distinction is between linearizable and intrinsically nonlinear models:

  • Linearizable: a transformation makes the model linear in the parameters. The model with multiplicative log-normal noise becomes . This form is linear in the parameters and can be fit with OLS after the log transform. Such models inherit the exact finite-sample theory of linear regression.

  • Intrinsically nonlinear: no transformation reduces to linear in the parameters. These models require iterative NLS and only have asymptotic (large-) inferential theory.

Local Minima , the sum of squares above, is non-convex in general. Iterative methods can then converge to a local minimum instead of the global one. The choice of starting values is therefore critical. Standard practice is to try multiple starting points or to examine the profile likelihood to understand the surface. Where convergence is unreliable, global search methods such as simulated annealing, genetic algorithms or basin-hopping help.

The NLS objective

Intuition

Nonlinear regression is needed whenever the underlying mechanism produces a response that is not a linear combination of inputs. Population growth that saturates follows a logistic curve, and chemical reactions decay exponentially. Physical oscillations follow sinusoids whose frequency itself is unknown. In each case, a parametric shape links the predictors to the response. The parameters of that shape enter the model non-linearly, so the closed-form OLS formula does not apply.

The Gauss-Newton algorithm is the standard method for these problems. Near the current parameter estimate , the function is close to its first-order Taylor expansion. That expansion is linear in the parameter increment . Solving this linearized problem by ordinary least squares produces the next iterate , and the process repeats until convergence. So nonlinear regression becomes a sequence of linear regressions on the linearized residuals. Each one moves the estimate closer to the NLS minimum.

NLS is qualitatively harder than OLS because is non-convex. The OLS objective is a convex quadratic with a unique minimum, which any decent optimizer finds. The NLS objective can have many local minima. Which one Gauss-Newton converges to depends on where it starts. For this reason, production code typically tries several starts and reports the best fit.

Properties

(Gauss-Newton Algorithm) Each Gauss-Newton step is an OLS fit of the current residuals on the Jacobian.

At iteration , expand where is the gradient row vector. Substituting into the NLS objective produces a linear regression of the current residuals on the Jacobian . Its OLS solution gives the parameter update

Here stacks the rows . Iterating produces a sequence of parameter estimates that converge (locally) to the NLS minimum. Gauss-Newton is Newton’s method with half the Hessian of replaced by . The dropped term multiplies each residual by the second derivatives of . It is small when the fit is good.

(Levenberg-Marquardt Damping) A damping term shortens the step when the linear approximation is poor.

Gauss-Newton converges fast near the minimum but can overshoot or fail to converge when started far away. The Levenberg-Marquardt modification adds a damping factor to the Hessian approximation:

With this is pure Gauss-Newton; as it becomes gradient descent with a small step. The implementation adapts at every step: shrink it after a successful iteration, grow it after a failed one. scipy’s optimize.curve_fit uses this algorithm by default when no bounds are given. It is generally more robust than plain Gauss-Newton.

(Asymptotic Distribution) Large- inference uses the Jacobian instead of the design matrix.

Under regularity conditions, as ,

where is the Jacobian matrix of partial derivatives evaluated at . This result has the same form as the linear-regression result . The Jacobian takes the place of the design matrix . So standard errors, confidence intervals, and hypothesis tests are computed exactly as in linear regression, but using the Jacobian. The approximation is asymptotic, so for small samples the reported standard errors should be treated with caution.

(Residual Variance) adjusts for fitted parameters.

It has the same form as in linear regression, the residual sum of squares divided by the degrees of freedom. The denominator subtracts the number of fitted parameters. This number counts the independent constraints that the fit imposes on the residuals, since at the minimum.

(Linearizable vs. Intrinsically Nonlinear) Some non-linear models become linear after a transformation.

Another linearizable model is , which becomes linear in . A model such as needs no transformation. It is already linear in the parameters, with the new predictor (basis functions). After the linearization, OLS gives an exact closed-form fit with exact finite-sample inference. The transformation also changes the noise structure. Log-transforming a response with additive Gaussian noise gives non-Gaussian noise on the log scale, and vice versa. The right noise assumption therefore depends on which scale is natural for the application. Intrinsically nonlinear models (no transformation linearizes them) include the logistic curve and the sinusoid with unknown frequency .

(Local Minima) A fit that ends at a local minimum usually leaves visible structure in its residuals.

The NLS sum of squares can have several local minima. At a local minimum the gradient vanishes, but the value of is higher than at the global minimum. Iterative methods like Gauss-Newton usually converge to the minimum whose basin of attraction contains the starting point. For low-dimensional problems, a plot of the loss surface shows the competing minima. At convergence, residuals from the correct fit look like white noise. Residuals from a local minimum retain visible structure, such as a missed peak or a drifting phase.

(Model Selection) AIC and BIC compare NLS fits with different numbers of parameters.

The same AIC and BIC apply to NLS:

Here is the parameter count and is the maximum-likelihood variance estimate. It divides by rather than . For , BIC penalizes complexity more heavily and tends to select simpler models. Both criteria assume Gaussian residuals and a correctly specified family. For non-Gaussian noise or a misspecified family, cross-validation is the safer choice.

Examples

(Easy) Linearizing Exponential Growth

Bacterial population data follow with multiplicative noise. Estimate and .

(Medium) Logistic Growth Model

Cumulative adoption of a technology is modeled as . Here is the carrying capacity, controls the initial level, and is the growth rate.

(Hard) Why Local Minima Matter

A chemist fits a sum-of-Gaussians model to spectroscopic data. The data show two visible peaks, at and .

See Also