Linear Regression — Best Fit Line, LSM

Author: Ravi Poswal

Best Fit Line in Linear Regression:
The best fit line in linear regression is the straight line that most accurately represents the relationship between independent variable (input) and the dependent variable (output).
Equation: y = mx + b

Minimizing the Error: The Least Squares Method.
  Residual: yᵢ - ŷᵢ
  yᵢ = The Actual Observed Value.
  ŷᵢ = The Predicted Value from the line.

Limitations:
  Assumes Linearity → Assume relationship between the variable is linear. If the relationship is non-linear, this fails.
  Sensitivity to outliers → Outliers can significantly affect the slope & intercept.

Question:
  X (Week) | Y (Sales '00)
      1     |     1.2
      2     |     1.8
      3     |     2.6
      4     |     3.2
      5     |     3.8
Predict the 7th & 12th week Sales.

Formula: y = ax + b

  a = (x̄y̅ − x̄ × ȳ) / (x̄² − x̄²)

  b = ȳ − a × x̄