- Introduced by
- Gallant (1987); Wooldridge (2010) for econometric treatment
- Year
- 1974–1987
- Type
- Nonlinear regression estimator
- Family
- Econometrics / time series
What does it do?
Nonlinear Ordinary Least Squares (NLS) estimates regression models in which the conditional mean function is nonlinear in the parameters.
Like standard OLS it minimises the sum of squared residuals, but because no closed-form solution exists the estimator is found by iterative numerical optimisation. Under standard regularity conditions NLS is consistent and asymptotically normal.
The intuition behind the method
Standard OLS fits a hyperplane through the data whose shape is fixed by the regressors entering linearly, and it has a closed-form solution. When the true relationship bends, for example with diminishing returns, exponential growth, or threshold effects, a linear-in-parameters fit can be systematically wrong. Nonlinear OLS applies the same least-squares criterion, minimising the sum of squared vertical deviations, to a parametric function that is nonlinear in its parameters. Because no closed-form solution exists, the parameter values are found by iterative search rather than by solving linear equations.
History
The least-squares criterion and the iterative algorithms used to minimise it, such as Gauss-Newton and Levenberg-Marquardt, predate the modern large-sample theory of the estimator. Gallant (1987), Nonlinear Statistical Models, cited on this page, is the reference for its asymptotic properties, including consistency and asymptotic normality under general conditions.
When to use it
Use Nonlinear OLS when economic theory or the structure of the data implies a regression function that is nonlinear in its parameters, for example an exponential growth curve, a logistic saturation model, a CES production function, or a Box-Cox transformation with an estimated transformation parameter. It fits best when the functional form can be specified before estimation and the sample is large enough for the asymptotic approximation to be reasonable relative to the number of parameters. Do not use NLS when the nonlinearity can be removed by a simple transformation, such as taking logs of a Cobb-Douglas function, because OLS on the transformed model is simpler and avoids convergence problems. Avoid NLS when starting values are entirely unknown, when the objective surface is highly non-convex, or when the outcome is binary or count-valued, where nonlinear models such as logit or Poisson are designed for the data. For time series and panel data, check the errors for serial correlation and the regressors for persistence; with lagged dependent variables or strongly persistent series, consistency and standard inference no longer follow automatically, and a nonlinear GLS or nonlinear ARDL-type specification is often the better choice.
Limitations and considerations
- No closed-form solution: the estimate depends on starting values and the chosen algorithm, and local minima are a genuine risk.
- Asymptotic standard errors can be unreliable in small samples, where bootstrap inference is generally preferred.
- If the functional form is misspecified, the estimates are biased and inconsistent, and the standard output gives no direct signal of this.
- Computationally more demanding than linear regression, and convergence may fail when the objective surface is flat or ill-conditioned.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Handles genuinely intrinsic nonlinearity in parameters that cannot be removed by a variable transformation.
- Consistent and asymptotically normal under mild regularity conditions, with well-understood inference.
- Lets a theoretically motivated functional form (for example CES or logistic growth) be estimated directly rather than approximated by a linearisation.
- Sandwich (robust) standard errors accommodate heteroscedasticity without changing the point estimates.
- Available in common statistical software, including R (nls), Stata (nl), Python (scipy.optimize), and EViews.
Applications
- Estimating CES (constant elasticity of substitution) production functions in macroeconomics and growth accounting.
- Fitting exponential or logistic growth curves to GDP, population, or technology diffusion data.
- Modelling asymmetric price adjustment using nonlinear error-correction specifications.
- Calibrating pharmacokinetic concentration-time profiles, where the model is nonlinear in the rate and volume parameters.
- Estimating Box-Cox regression models where the transformation parameter is estimated jointly with slope coefficients.
- Nonlinear demand and supply systems where parameters enter multiplicatively or in ratio form.
How it works
How it works
Write the regression model as y_i = f(x_i, theta) + epsilon_i, where f is a known function that is nonlinear in the parameter vector theta. Common examples include exponential, logistic, power-law, and CES (constant elasticity of substitution) functions.
Formula
y_i = f(x_i, \theta) + \varepsilon_i
The NLS estimator minimises the sum of squared residuals S(theta) = sum [y_i - f(x_i, theta)]^2. Unlike OLS there is no closed-form formula, so the minimum is found by iterative algorithms such as Gauss-Newton or Levenberg-Marquardt, which require starting values for theta.
Formula
\hat{\theta} = \arg\min_{\theta} \sum_{i=1}^{n} [y_i - f(x_i, \theta)]^2Starting from an initial guess, the algorithm linearises f around the current parameter values and updates them in the direction that reduces S(theta). Iterations continue until the change in S is below a convergence tolerance. Good starting values are important: poor ones risk converging to a local rather than the global minimum.
Under regularity conditions (correct specification, sufficient variation in x, and errors that are mean-zero and independent of x), the NLS estimator is consistent and asymptotically normal, with the sandwich variance form A^{-1}BA^{-1}. Here A is built from the derivatives of f with respect to theta, averaged over observations (it is proportional to the expected Hessian of the objective), and B is built from the squared residuals weighted by those same derivatives. Heteroscedasticity-robust standard errors are estimated by plugging sample analogues of A and B into this expression. Independence across observations is the natural assumption for cross-sectional samples. For time series, the errors and regressors must instead satisfy stationarity and weak dependence (mixing) conditions, and B must be estimated with a HAC estimator, such as Newey-West, that accounts for serial correlation. For panel data, cluster-robust versions of B are used. Heteroscedasticity-robust errors alone do not correct for serial dependence.
Formula
\sqrt{n}(\hat{\theta} - \theta_0) \xrightarrow{d} N(0, A^{-1} B A^{-1})Common pitfalls
- Using arbitrary or zero starting values without checking sensitivity; re-running from several starting points or a grid over the parameter space is the usual check.
- Applying NLS when a log transformation would linearise the model: OLS on the log-transformed equation is simpler, avoids convergence problems, and models errors on the log scale, which can be a different assumption.
- Relying on asymptotic standard errors in small samples; bootstrap confidence intervals are the safer choice there.
- Ignoring heteroscedasticity: if residual diagnostics suggest unequal error variance, use nonlinear WLS or heteroscedasticity-robust (sandwich) standard errors rather than plain NLS standard errors.
- Using heteroscedasticity-robust standard errors alone on time series or panel data with serial correlation; use HAC standard errors (for example Newey-West) for time series and cluster-robust standard errors for panels.
- Treating a converged solution as the global optimum without checking; plot the objective function or re-run from perturbed starting values.
Frequently asked questions
What is the difference between nonlinear OLS and standard OLS?
Standard OLS requires that the regression function be linear in the parameters, which gives a closed-form solution. Nonlinear OLS (NLS) minimises the same sum-of-squared-residuals criterion for functions that are nonlinear in the parameters, and so requires iterative numerical optimisation. Under regularity conditions the large-sample properties (consistency and asymptotic normality) are similar.
How do I choose starting values?
Starting values strongly affect convergence. Useful sources include parameter estimates from a related linearised model, values reported in prior work on the same relationship, or a grid search over a plausible parameter range. Re-run the optimisation from several different starting points to check that the solution is stable.
When should I use nonlinear WLS instead of NLS?
When residual diagnostics suggest heteroscedasticity, for example a formal heteroscedasticity test or a plot of squared residuals against fitted values, nonlinear WLS, which weights observations by the inverse of their error variance, can be more efficient than NLS. Both remain consistent under the stated conditions. Alternatively, keep NLS and report heteroscedasticity-robust sandwich standard errors.
Can I compare NLS models with AIC or BIC?
Information criteria can be used to compare NLS models estimated on the same data and outcome, because under normally distributed errors the NLS criterion is closely related to the log-likelihood. The exact penalty term depends on whether the error variance is counted as a parameter, so check the convention used by your software before comparing values across programs.
What if NLS fails to converge?
Try alternative starting values, re-parameterise the model to reduce collinearity among parameters, switch from Gauss-Newton to Levenberg-Marquardt, which is more robust to ill-conditioning, or simplify the functional form. Persistent non-convergence often signals model misspecification.
Related methods
Sources
Gallant, A. R. (1987). Nonlinear Statistical Models. John Wiley & Sons.
ISBN: 978-0471802600Wooldridge, J. M. (2010). Econometric Analysis of Cross Section and Panel Data (2nd ed.). MIT Press.
ISBN: 978-0262232586