Weighted Linear Regression (Frequency-Weighted Least Squares)
Fit the line y = a + b x by weighted least squares, giving each data point a frequency (weight). Shows slope, intercept, R squared, and a scatter plot.
Input
Run linear regression with a frequency (weight) on each data point. Enter x and y on each line, plus an optional frequency.
One point per line. Separate with a comma or spaces. Frequency is optional and defaults to 1.
Result
Regression equation
y = 1.962857 x + 0.065714
Slope b
1.962857
Intercept a
0.065714
R squared
0.997
Correlation r
0.998
Total weight
15
Data points
5
Scatter plot and regression line
Data points and fitted values
| No. | x | y | Frequency | Fitted y |
|---|---|---|---|---|
| 1 | 1 | 2.1 | 3 | 2.029 |
| 2 | 2 | 3.9 | 5 | 3.991 |
| 3 | 3 | 6.2 | 2 | 5.954 |
| 4 | 4 | 7.8 | 4 | 7.917 |
| 5 | 5 | 10.1 | 1 | 9.88 |
How it works
- Enter x and y on each line, plus an optional frequency (weight). Separate values with a comma or spaces. A line without a frequency is treated as weight 1.
- Compute the weighted means xbar = sum of w x over sum of w and ybar = sum of w y over sum of w. The slope is b = sum of w (x minus xbar)(y minus ybar) over sum of w (x minus xbar) squared, and the intercept is a = ybar minus b xbar.
- The coefficient of determination is R squared = 1 minus SSres over SStot, where SSres = sum of w (y minus yhat) squared and SStot = sum of w (y minus ybar) squared. The correlation is found from the weighted covariance and variances.
- Frequencies act as weights for how many times each point was observed, so points with larger frequency pull the line more strongly. In the scatter plot, points with larger frequency are drawn larger.
- Each frequency must be positive, and the line cannot be fit when every x value is identical because the slope is undefined.
Reviews
Tell us what you think of this calculator.
Write a review
- Home
Weighted Linear Regression (Frequency-Weighted Least Squares)