The OLS formula

Summary

  • Given data \(x_1,x_2,…,x_n\) and \(y_1,y_2,…,y_n\) , we can add a linear trendline to the scatterplot of the points \(\left( x_1,y_1 \right),…,(x_n,y_n)\) .
  • The equation of a linear trendline is given by

\[y=b_1+b_2x\]

  • We say that we use the OLS (Ordinary Least Squares) formula if we calculate the intercept \(b_1\) and the slope \(b_2\) using the following formulas:

\[b_2= \frac{\sum_{i=1}^{n}{ \left( x_i-\bar{x} \right)\left( y_i-\bar{y} \right) }}{\sum_{i=1}^{n}{ {\left( x_i-\bar{x} \right)}^2 }}= \frac{s_{x,y}^2}{s_x^2}\]

\[b_1=\bar{y}-b_2\bar{x}\]

  • The linear trendline calculated using the OLS formula is called the OLS trendline .
  • OLS in Excel: Linest(ydata,xdata,constant,statistics)