CalcWorldHub
Free online calculator · no signup

Relative weight least squares line fit calculator

Fit a straight line when observations have different relative precision and calculate slope uncertainty with an estimated common residual scale.

4,000 tools
Relative weight least squares line fit calculator — Predictor values, Response values, Positive relative precision weights and calculation method
Relative weight least squares line fit calculator: inputs and calculation method.

How to use this calculator

Fit a straight line when observations have different relative precision and calculate slope uncertainty with an estimated common residual scale.

  1. Enter Predictor values, Response values, Positive relative precision weights. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Relative weight least squares line fit explained

Relative precision weights let lower-variance observations contribute more to the fitted line than less precise observations.

Weighted fitted slope1.8014y units/x unit
Weighted fitted slope: 1.80136986 y units/x unit in the worked scenario.

How the calculation works

β=(XᵀWX)⁻¹XᵀWy; s²=Σwi·ri²/(n−2); Var(β)=s²(XᵀWX)⁻¹.

The model includes an intercept and uses entered weights as relative inverse variances. A common residual scale is estimated from weighted residuals, so multiplying all weights by the same positive constant leaves the coefficient standard errors unchanged.

Set up the calculation

x — Predictor values
Ordered values in the role named above. Match row positions with other lists and use a consistent measurement unit within the same variable. Use comma-separated values in the stated order.
y — Response values
Ordered values in the role named above. Match row positions with other lists and use a consistent measurement unit within the same variable. Use comma-separated values in the stated order.
w — Positive relative precision weights
Positive weights proportional to inverse observation variances. All weights may be multiplied by one common constant. Use comma-separated values in the stated order.

Limits of this model

At least three independent observations, varying predictor, positive weights. Weights are relative precisions, not frequencies or arbitrary importance scores. Normal-equation fitting rejects singular or strongly ill-conditioned inputs.

Check this example

Predictor values = 1,2,3,4,5; Response values = 2,4,5,8,9; Positive relative precision weights = 1,1,2,2,3.

  • Weighted fitted slope: 1.80136986 y units/x unit
  • Weighted fitted intercept: 0.15068493 y units
  • Relative-weight slope standard error: 0.18030749 y units/x unit
  • Weighted R²: 0.97082023
  • Weighted residual sum of squares: 1.58219178 weighted squared y units

The last three observations receive weights two, two, and three. Their deviations influence the fitted line more than the first two, but the fitted slope remains in response units per predictor unit.

Reading the outputs

Weighted R squared uses the weighted response mean. The reported slope standard error assumes the relative-variance model and is not a heteroskedasticity-robust sandwich estimate.

Frequently asked questions

Can weights be zero?

No. Remove excluded observations explicitly.

Should I use 1/SD or 1/SD²?

Relative inverse variances use 1/SD² when SDs describe measurement error precision.

What if weights are absolute known precisions?

Then covariance estimation differs; this page estimates an additional common residual scale.

How do I use the Relative weight least squares line fit calculator?

Enter Predictor values, Response values, Positive relative precision weights. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Relative weight least squares line fit?

Predictor values = 1,2,3,4,5; Response values = 2,4,5,8,9; Positive relative precision weights = 1,1,2,2,3. Weighted fitted slope: 1.80136986 y units/x unit Weighted fitted intercept: 0.15068493 y units Relative-weight slope standard error: 0.18030749 y units/x unit Weighted R²: 0.97082023 Weighted residual sum of squares: 1.58219178 weighted squared y units The last three observations receive weights two, two, and three. Their deviations influence the fitted line more than the first two, but the fitted slope remains in response units per predictor unit.