keisoku

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

1.460.683.781.846.138.424.1610.745.32x = 1, y = 2.1, frequency 3x = 2, y = 3.9, frequency 5x = 3, y = 6.2, frequency 2x = 4, y = 7.8, frequency 4x = 5, y = 10.1, frequency 1

Data points and fitted values

No.xyFrequencyFitted y
112.132.029
223.953.991
336.225.954
447.847.917
5510.119.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

  1. Home
  2. Weighted Linear Regression (Frequency-Weighted Least Squares)