ArticleslgStudy

mathematics

Ordinary least squares

Ordinary least squares is a mathematics 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 Ordinary least squares rather than just read about it. In short: In statistics, ordinary least squares (OLS) is a type of linear least squares method for choosing the unknown parameters in a linear regression model by the principle of least squares: minimizing the sum of the squares of the differences between the observed dependent variable (values of the variable being observed) in the input dataset and the output of the (linear) function of the independent variable. Some source…

Ordinary least squares — main illustration
Ordinary least squares — illustration

Key takeaways

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

Reference excerpt

In statistics, ordinary least squares (OLS) is a type of linear least squares method for choosing the unknown parameters in a linear regression model by the principle of least squares: minimizing the sum of the squares of the differences between the observed dependent variable (values of the variable being observed) in the input dataset and the output of the (linear) function of the independent variable. Some sources consider OLS to be linear regression. Geometrically, this is seen as the sum of the squared distances, parallel to the axis of the dependent variable, between each data point in the set and the corresponding point on the regression surface—the smaller the differences, the better the model fits the data. The resulting estimator can be expressed by a simple formula, especially in the case of a simple linear regression, in which there is a single regressor on the right side of the regression equation. The OLS estimator is consistent for the level-one fixed effects when the regressors are exogenous and forms perfect colinearity (rank condition), consistent for the variance estimate of the residuals when regressors have finite fourth moments and—by the Gauss–Markov theorem—optimal in the class of linear unbiased estimators when the errors are homoscedastic and serially uncorrelated. Under these conditions, the method of OLS provides minimum-variance mean-unbiased estimation when the errors have finite variances. Under the additional assumption that the errors are normally distributed with zero mean, OLS is the maximum likelihood estimator that outperforms any non-linear unbiased estimator.

Linear model

Suppose the data consists of n {\displaystyle n} observations { x i , y i } i = 1 n {\displaystyle \left\{\mathbf {x} _{i},y_{i}\right\}_{i=1}^{n}} . Each observation i {\displaystyle i} includes a scalar response y i {\displaystyle y_{i}} and a column vector x i {\displaystyle \mathbf {x} _{i}} of p {\displaystyle p} parameters (regressors), i.e., x i = [ x i 1 , x i 2 , … , x i p ] T {\displaystyle \mathbf {x} _{i}=\left[x_{i1},x_{i2},\dots ,x_{ip}\right]^{\operatorname {T} }} . In a linear regression model, the response variable, y i {\displaystyle y_{i}} , is a linear function of the regressors:

y i = β 1 x i 1 + β 2 x i 2 + ⋯ + β p x i p + ε i , {\displaystyle y_{i}=\beta _{1}\ x_{i1}+\beta _{2}\ x_{i2}+\cdots +\beta _{p}\ x_{ip}+\varepsilon _{i},}

or in vector form,

y i = x i T β + ε i , {\displaystyle y_{i}=\mathbf {x} _{i}^{\operatorname {T} }{\boldsymbol {\beta }}+\varepsilon _{i},\,}

… excerpt ends here. Continue reading the full article.

Illustrations

Ordinary least squares: Okun's law in macroeconomics states that in an economy the GDP growth should depend linearly on the changes in the unemployment rate. Here the ordinary least squares method is used to construct the regression line describing this law.
Okun's law in macroeconomics states that in an economy the GDP growth should depend linearly on the changes in the unemployment rate. Here the ordinary least squares method is used to construct the regression line describing this law.
Ordinary least squares: OLS estimation can be viewed as a projection onto the linear space spanned by the regressors. (Here each of 
  
    
      
        
          X
          
            1
          
        
      
    
    {\displaystyle X_{1}}
  
 and 
  
    
      
        
          X
          
            2
          
        
      
    
    {\displaystyle X_{2}}
  
 refers to a column of the data matrix.)
OLS estimation can be viewed as a projection onto the linear space spanned by the regressors. (Here each of X 1 {\displaystyle X_{1}} and X 2 {\displaystyle X_{2}} refers to a column of the data matrix.)
Ordinary least squares: Least squares as projection of y onto col(X) for three observations; ŷ = Xβ gives fitted values and y − ŷ is the residual.
Least squares as projection of y onto col(X) for three observations; ŷ = Xβ gives fitted values and y − ŷ is the residual.
Ordinary least squares: Example of a cubic polynomial regression, which is a type of linear regression. Although polynomial regression fits a curve model to the data, as a statistical estimation problem it is linear, in the sense that the conditional expectation function 
  
    
      
        
          E
        
        [
        y
        
          |
        
        x
        ]
      
    
    {\displaystyle \mathbb {E} [y|x]}
  
 is linear in the unknown parameters that are estimated from the data. For this reason, polynomial regression is considered to be a special case of multiple linear regression.
Example of a cubic polynomial regression, which is a type of linear regression. Although polynomial regression fits a curve model to the data, as a statistical estimation problem it is linear, in the sense that the conditional expectation function E [ y | x ] {\displaystyle \mathbb {E} [y|x]} is linear in the unknown parameters that are estimated from the data. For this reason, polynomial regression is considered to be a special case of multiple linear regression.
Ordinary least squares: Visualization of heteroscedasticity in a scatter plot against 100 random fitted values using Matlab
Visualization of heteroscedasticity in a scatter plot against 100 random fitted values using Matlab

Worked examples

Example 1 — a first encounter with Ordinary least squares

Start with the simplest possible case. Write down what Ordinary least squares claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, 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 Ordinary 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 Ordinary 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 Ordinary least squares

In research
Ordinary least squares appears in mathematics 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 Ordinary 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
Ordinary least squares is common in secondary-school and first-year university syllabi. It links to neighbouring topics Least squares, Parametric statistics, so understanding it makes those chapters shorter.
In everyday life
Look for Ordinary 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 “Ordinary least squares” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Ordinary least squares in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Ordinary 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 Ordinary least squares out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Ordinary least squares in simple terms?

In statistics, ordinary least squares (OLS) is a type of linear least squares method for choosing the unknown parameters in a linear regression model by the principle of least squares: minimizing the sum of the squares of the differences between the observed dependent variable (values of the variab…

Why does Ordinary least squares matter?

Because it connects several mathematics 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 Ordinary 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 Ordinary least squares.

Tags

  • Least squares
  • Parametric statistics

Keep exploring