Weighted Linear Regression Calculator
Paste X, Y, and response standard deviation for each observation. Compare inverse-variance and ordinary fits, inspect how the weighted line treats each observation, and audit the fitted mean and its uncertainty.
Fit a line when measurements have different precision
Compare an inverse-variance fit with ordinary least squares and inspect how individual measurements affect the fit.
Measurements and response precision
Enter 3 to 24 rows of X, Y, and response standard deviation (SD). Use one row per measurement, with commas, spaces or tabs.
Precision weighting changes the fitted line.
Compare the two fits
- Weighted slope
- 25/11
- Ordinary slope
- 7/2
- Weighted fit error score
- 15/11
- Ordinary fit error score
- 345/64
Both error scores sum squared residuals divided by the corresponding response variance.
Fitted values at X = 2
- Weighted fitted mean
- 59/11
- Ordinary fitted mean
- 7
- Weighted mean standard error
- 0.85811633
Inspect the fit and its residuals
X 3 · Y 12 · SD 4
- Precision weight
- 1/16
- Weighted residual ÷ SD
- 12/11
- Weighted leverage
- 7/55
- Held-out residual ÷ SD
- 5/4
Export the precision audit
Save exact fit coefficients, probe variance, weights, and row diagnostics.
View CSV text
How to use this calculator
- Paste X, Y, and response SD for each row. Use the same units for Y and SD.
- Enter the X where you want to compare the fitted means and their uncertainty.
- Inspect the fitted lines or residuals scaled by response SD. Choose a row to inspect its weight, leverage, and held-out error.
- Download the exact coefficients, probe variance, and observation diagnostics.
The Formula
The mathematical logic powering this calculation is:
Enter Xᵢ, Yᵢ, and the response standard deviation σᵢ for each row. The fixed precision weight is wᵢ = 1/σᵢ². Let W = Σwᵢ and compute the weighted means x̄w and ȳw. The weighted line has slope Sxy/Sxx, with Sxy = Σwᵢ(Xᵢ − x̄w)(Yᵢ − ȳw) and Sxx = Σwᵢ(Xᵢ − x̄w)². Its intercept is ȳw minus slope times x̄w. The ordinary line uses equal weights. Compare both lines with the same error score, Σ[(Yᵢ − fitted Yᵢ)/σᵢ]².
With fixed X and independent errors of known variances σᵢ², the covariance of the weighted coefficients is the inverse of the weighted normal matrix. This gives slope variance 1/Sxx and fitted mean variance at X = t of 1/W + (t − x̄w)²/Sxx. The shaded band shows the fitted mean plus or minus one standard error. A future individual Y observation also has its own response variance. If the entered standard deviations are estimates, the reported uncertainties treat them as fixed.
Weighted leverage is wᵢ times the fitted mean variance at Xᵢ. The displayed residual is the signed observed minus fitted value divided by σᵢ. The held-out version divides this by 1 − leverage, which is equivalent to refitting after removing the row. At exact leverage one, deleting that row leaves only one distinct X, so the held-out result is unavailable.
Enter 3 to 24 rows with at least two distinct X values. Use decimals from −1,000,000 through 1,000,000 with up to six fractional places, and require a positive response SD. Estimation and CSV values use exact fractions. Square roots and the drawn uncertainty envelope use numerical approximations. The plot spans the observed X values and flags probe extrapolation.Worked Example
If you input:
- Observations: 0, 1, 1 · 1, 3, 1 · 2, 5, 1 · 3, 12, 4
- X to evaluate: 2
Result:
The first three rows have weight 1 and the last row has weight 1/16. The weighted slope is 25/11 and the ordinary slope is 7/2. At X = 2, the weighted mean is 59/11 and its standard error is about 0.8581.
Frequently Asked Questions
What does a smaller response SD do?
A smaller SD gives the observation a larger inverse-variance weight. Halving a row’s SD quadruples its weight. Leverage also depends on how far the point is from the weighted center of X.
What happens if all SD values are equal?
The weighted and ordinary coefficients agree. The supplied SD still determines the weighted mean’s uncertainty and the scale of the plotted residuals.
What if both X and Y have meaningful measurement uncertainty?
This model treats X as fixed. An errors-in-variables method, such as Deming regression, uses assumptions about uncertainty in both measurements.
Why can a small fitted residual become large when a row is held out?
A high-leverage observation can pull the fitted line toward itself. The held-out residual shows the discrepancy when the line is estimated using only the other rows.
Similar Calculators
Deming Regression Calculator for Measurement Error
Fit Deming regression when X and Y both have measurement error. Compare with ordinary least squares and inspect each adjusted pair.
Linear Regression Calculator
Fit a least-squares line, inspect scatter and residual plots, and calculate Student-t confidence and prediction intervals. Paste paired data and export the full ledger.
Gauge Accuracy & Linearity Calculator
Audit gauge accuracy with five reference values and three repeat readings per value. Compare signed bias, repeatability, linearity and lack of fit.
Theil–Sen Regression & Outlier Sensitivity Calculator
Compare robust Theil–Sen and ordinary least-squares fits. Inspect their disagreement at a chosen x and test the influence of one observation.
