Ordinary Least Squares Regression Vs Weighted Least Squares Regression
Aspect | Ordinary Least Squares (OLS) Regression | Weighted Least Squares (WLS) Regression |
---|---|---|
Objective | Minimize the sum of squared differences between observed and predicted values. | Minimize the weighted sum of squared differences between observed and predicted values. |
Assumption | Assumes constant variance (homoscedasticity) of errors. | Allows for varying variance (heteroscedasticity) of errors. |
Weighting of Observations | Assigns equal weight to each observation. | Assigns weights to observations based on the variance of the error term associated with each observation. |
Usage | Suitable for datasets with constant variance of errors. | Suitable for datasets with varying variance of errors. |
Implementation | Implemented using the ordinary least squares method. | Implemented using the weighted least squares method. |
Model Evaluation | Provides unbiased estimates of coefficients under homoscedasticity. | Provides more accurate estimates of coefficients under heteroscedasticity. |
Example | Fit a straight line through data points. | Fit a line that adjusts for varying uncertainty in data points. |
Weighted Least Squares Regression in Python
Weighted Least Squares (WLS) regression is a powerful extension of ordinary least squares regression, particularly useful when dealing with data that violates the assumption of constant variance.
In this guide, we will learn brief overview of Weighted Least Squares regression and demonstrate how to implement it in Python using the statsmodels library.