The OLS formula

Summary

  • Given data x1,x2,,xn and y1,y2,,yn , we can add a linear trendline to the scatterplot of the points (x1,y1),,(xn,yn) .
  • The equation of a linear trendline is given by

y=b1+b2x

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

b2=i=1n(xix¯)(yiy¯)i=1n(xix¯)2=sx,y2sx2

b1=y¯b2x¯

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