ARBIMETRA LAB
Weighted Least Squares
Estimates a regression where each observation has its own weight.
What it does
Estimates a regression where each observation has its own weight.
Use it when error variances differ in a known way, or with survey-style weights.
Data you need
- Dependent variable
- Independent variables
- Positive weights
Supported data: Numeric. Level: Intermediate.
Formula and method
β̂ = (X′WX)⁻¹X′WY
Each observation is multiplied by the square root of its weight, and ordinary least squares is applied to the transformed data. Fit statistics therefore describe the weighted problem.
Assumptions
- Weights are proportional to the inverse of the error variance
Input checks
- Weights must be strictly positive
Diagnostics included
Jarque-Bera on weighted residuals, residual and Q-Q plots. Breusch-Pagan and White are not reported for weighted fits.
How to read the result
A larger weight gives an observation more influence.
Worked example
Illustrative run on Simulated study data (teaching data). These figures are the actual output of this model on that example, and they say nothing about your own data.
- R² (weighted) = 0.47, F = 105.0705, p = <0.0001, n = 240.
- The joint test of the slopes is statistically significant at the 5% level.
Limitations
- Wrong weights give misleading standard errors
Numerical validation
Validated 16 of 16 automated checks passed, including numerical results, invalid input, missing values, small samples, constant variables, charts and the interpretation text.
| Check | Reference | Result | Abs. error | Tolerance | Source |
|---|---|---|---|---|---|
| WLS by transformation: slope | 1.90845458 | 1.90845458 | 2.7e-15 | 1e-9 | Independent NumPy calculation |
| WLS standard error | 0.10919068 | 0.10919068 | 6.9e-17 | 1e-9 | Independent NumPy calculation |
Computed with python 3.13.2, numpy 2.2.5, scipy 1.14.1, pandas 2.3.3, statsmodels 0.14.4, scikit-learn 1.7.0, in your browser. A passing check confirms the listed comparison only. It does not make any result suitable for your data, and it is not a claim of equivalence with other statistical software.
Questions
How do I choose weights?
Use the inverse of each observation's error variance when it is known. If it is not, OLS with robust standard errors may be safer.
ARBIMETRA LAB is an educational and research tool. Results should be checked by the researcher and are not professional advice.
