In ordinary least squares, each observation influences the fitted line equally. Weighted least squares (WLS) lets you prioritize points according to their reliability. Suppose you measure pairs with positive weights . The objective is to minimize the weighted sum of squared residuals where is the slope and the intercept.
Setting the partial derivatives of with respect to and equal to zero yields the normal equations. Solving the linear system produces and where denotes the total weight.
The table below uses four observations with weights that downplay the final two measurements. Enter the numbers into the calculator to verify that the weighted line matches the summary values.
| x | y | Weight |
|---|---|---|
| 1 | 2.1 | 1.0 |
| 2 | 3.9 | 1.0 |
| 3 | 6.2 | 0.5 |
| 4 | 7.8 | 0.5 |
For unweighted fits, compare results with the linear regression calculator. When smoothing a time series instead of fitting a straight line, the weighted moving average calculator may be more appropriate.