ArticleslgStudy

science

Non-linear least squares

Non-linear least squares is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Non-linear least squares rather than just read about it. In short: Non-linear least squares is the form of least squares analysis used to fit a set of m observations with a model that is non-linear in n unknown parameters (m ≥ n). It is used in some forms of nonlinear regression.

Key takeaways

  • Non-linear least squares belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Non-linear least squares to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Non-linear least squares from memory before moving on to harder problems.

Reference excerpt

Non-linear least squares is the form of least squares analysis used to fit a set of m observations with a model that is non-linear in n unknown parameters (m ≥ n). It is used in some forms of nonlinear regression. The basis of the method is to approximate the model by a linear one and to refine the parameters by successive iterations. There are many similarities to linear least squares, but also some significant differences. In economic theory, the non-linear least squares method is applied in (i) the probit regression, (ii) threshold regression, (iii) smooth regression, (iv) logistic link regression, (v) Box–Cox transformed regressors (m(x,θi)=θ1+θ2x(θ3)).

Theory Consider a set of m data points, (x1,y1),(x2,y2),…,(xm,ym), and a curve (model function) ŷ=f(x,𝜷), that in addition to the variable x also depends on n parameters, 𝜷=(β1,β2,…,βn), with m≥n. It is desired to find the vector 𝜷 of parameters such that the curve fits best the given data in the least squares sense, that is, the sum of squares S=∑i=1mri2 is minimized, where the residuals (in-sample prediction errors) ri are given by ri=yi−f(xi,𝜷) for i=1,2,…,m. The minimum value of S occurs when the gradient is zero. Since the model contains n parameters there are n gradient equations: ∂S∂βj=2∑iri∂ri∂βj=0(j=1,…,n). In a nonlinear system, the derivatives ∂ri∂βj are functions of both the independent variable and the parameters, so in general these gradient equations do not have a closed solution. Instead, initial values must be chosen for the parameters. Then, the parameters are refined iteratively, that is, the values are obtained by successive approximation, βj≈βjk+1=βjk+Δβj. Here, k is an iteration number and the vector of increments, Δ𝜷 is known as the shift vector. At each iteration the model is linearized by approximation to a first-order Taylor polynomial expansion about 𝜷k f(xi,𝜷)≈f(xi,𝜷k)+∑j∂f(xi,𝜷k)∂βj(βj−βjk)=f(xi,𝜷k)+∑jJijΔβj. The Jacobian matrix, J, is a function of constants, the independent variable and the parameters, so it changes from one iteration to the next. Thus, in terms of the linearized model, ∂ri∂βj=−Jij and the residuals are given by Δyi=yi−f(xi,𝜷k), ri=yi−f(xi,𝜷)=(yi−f(xi,𝜷k))+(f(xi,𝜷k)−f(xi,𝜷))≈Δyi−∑s=1nJisΔβs. Substituting these expressions into the gradient equations, they become −2∑i=1mJij(Δyi−∑s=1nJis Δβs)=0, which, on rearrangement, become n simultaneous linear equations, the normal equations ∑i=1m∑s=1nJijJis Δβs=∑i=1mJij Δyi(j=1,…,n). The normal equations are written in matrix notation as (𝐉𝖳𝐉)Δ𝜷=𝐉𝖳 Δ𝐲. These equations form the basis for the Gauss–Newton algorithm for a non-linear least squares problem. Note the sign convention in the definition of the Jacobian matrix in terms of the derivatives. Formulas linear in J may appear with factor of −1 in other articles or the literature.

Extension by weights When the observations are not equally reliable, a weighted sum of squares may be minimized, S=∑i=1mWiiri2. Each element of the diagonal weight matrix W should, ideally, be equal to the reciprocal of the error variance of the measurement. The normal equations are then, more generally, (𝐉𝖳𝐖𝐉)Δ𝜷=𝐉𝖳𝐖 Δ𝐲.

Geometrical interpretation In linear least squares the objective function, S, is a quadratic function of the parameters. S=∑iWii(yi−∑jXijβj)2 When there is only one parameter the graph of S with respect to that parameter will be a parabola. With two or more parameters the contours of S with respect to any pair of parameters will be concentric ellipses (assuming that the normal equations matrix 𝐗𝖳𝐖𝐗 is positive definite). The minimum parameter values are to be found at the centre of the ellipses. The geometry of the general objective function can be described as paraboloid elliptical. In NLLSQ the objective function is quadratic with respect to the parameters only in a region close to its minimum value, where the truncated Taylor series is a good approximation to the model. S≈∑iWii(yi−∑jJijβj)2 The more the parameter values differ from their optimal values, the more the contours deviate from elliptical shape. A consequence of this is that initial parameter estimates should be as close as practicable to their (unknown!) optimal values. It also explains how divergence can come about as the Gauss–Newton algorithm is convergent only when the objective function is approximately quadratic in the parameters.

Computation

Initial parameter estimates Some problems of ill-conditioning and divergence can be corrected by finding initial parameter estimates that are near to the optimal values. A good way to do this is by computer simulation. Both the observed and calculated data are displayed on a screen. The parameters of the model are adjusted by hand until the agreement between observed and calculated data is reasonably good. Although this will be a subjective judgment, it is sufficient to find a good starting point for the non-linear refinement. Initial parameter estimates can be created using transformations or linearizations. Better still evolutionary algorithms such as the Stochastic Funnel Algorithm can lead to the convex basin of attraction that surrounds the optimal parameter estimates. Hybrid algorithms that use randomization and elitism, followed by Newton methods have been shown to be useful and computationally efficient.

Solution Any method among the ones described below can be applied to find a solution.

Convergence criteria The common sense criterion for convergence is that the sum of squares does not increase from one iteration to the next. However this criterion is often difficult to implement in practice, for various reasons. A useful convergence criterion is |Sk−Sk+1Sk|<0.0001. The value 0.0001 is somewhat arbitrary and may need to be changed. In particular it may need to be increased when experimental errors are large. An alternative criterion is |Δβjβj|<0.001,j=1,…,n. Again, the numerical value is somewhat arbitrary; 0.001 is equivalent to specifying that each parameter should be refined to 0.1% precision. This is reasonable when it is less than the largest relative standard deviation on the parameters.

Calculation of the Jacobian by numerical approximation

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Non-linear least squares

Start with the simplest possible case. Write down what Non-linear least squares claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Non-linear least squares before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Non-linear least squares ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Non-linear least squares

In research
Non-linear least squares appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Non-linear least squares in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Non-linear least squares is common in secondary-school and first-year university syllabi. It links to neighbouring topics Least squares, so understanding it makes those chapters shorter.
In everyday life
Look for Non-linear least squares outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Non-linear least squares” →

How to study Non-linear least squares in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Non-linear least squares means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Non-linear least squares out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Non-linear least squares in simple terms?

Non-linear least squares is the form of least squares analysis used to fit a set of m observations with a model that is non-linear in n unknown parameters (m ≥ n). It is used in some forms of nonlinear regression.

Why does Non-linear least squares matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Non-linear least squares?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Non-linear least squares.

Tags

  • Least squares

Keep exploring