Author-reviewedv1.0.1

Weighted Least Squares Regression

Weighted least squares (WLS) is regression that weights each squared residual, ideally by the inverse of its error variance, as in meta-analysis for HTA.

Last reviewed byDr Darrin Baines

Concept Architecture

Weighted Least Squares Regression for Unequal Variances in Health Economics

Weighted least squares fits a regression by minimising a sum of squared residuals in which each residual is multiplied by a weight, so that precisely measured observations pull the fitted line harder than noisy ones. When the weights are the inverses of known error variances, it is the most precise linear unbiased estimator, which is why it sits behind inverse-variance meta-analysis and meta-regression. In health technology assessment these pooled effects feed decision models, so the weights reach the cost-effectiveness result through the estimate and its standard error. The same idea appears in heteroscedastic cost data and in survey-weighted regression, where "weight" means something different.

Why equal weighting fails when variances differ

Linear regression fitted by ordinary least squares treats every observation as equally informative. The NIST/SEMATECH e-Handbook of Statistical Methods describes the assumption as a constant error standard deviation across all values of the predictors, and notes that a procedure treating all data equally gives less precisely measured points more influence than they should have.

In health economics, trial estimates differ in precision with size and event counts, and Manning and Mullahy list heteroscedasticity among the common problems of skewed health expenditure data.

The weighted least squares estimator

The estimator chooses coefficients to minimise a weighted residual sum of squares. It is a direct extension of least squares approximation.

β^WLS=arg⁡min⁡β∑i=1nwi(yi−xiTβ)2=(XTWX)−1XTWy\hat{\beta}_{WLS} = \arg\min_{\beta} \sum_{i=1}^{n} w_i \left(y_i - x_i^{T}\beta\right)^2 = \left(X^{T} W X\right)^{-1} X^{T} W y

where yiy_i is the outcome for observation ii, xix_i is its vector of covariates, β\beta is the coefficient vector, XX is the design matrix, yy is the outcome vector and WW is a diagonal matrix of weights wiw_i. Setting wi=1/σi2w_i = 1/\sigma_i^2, the inverse of each observation's error variance, gives precision weights.

Solon, Haider and Wooldridge show the mechanics with group averages. If each observation is a mean over JiJ_i individuals, its error variance is proportional to the inverse of JiJ_i, and ordinary least squares after multiplying each row by Ji\sqrt{J_i} is the minimum-variance linear unbiased estimator.

With exact inverse-variance weights, each standard error is the square root of a diagonal element of (XTWX)−1(X^{T} W X)^{-1}. General regression software instead treats weights as correct only up to a constant, which it estimates from the residuals.

Precision weights in meta-analysis

The Cochrane Handbook (chapter 10) explains that the inverse-variance method weights each study by one over the square of its standard error, a choice that minimises the imprecision of the pooled estimate. A fixed effect model pooled this way is weighted least squares on an intercept alone.

θ^IV=∑iwiyi∑iwi,SE(θ^IV)=1∑iwi,wi=1vi\hat{\theta}_{IV} = \frac{\sum_i w_i y_i}{\sum_i w_i}, \qquad SE(\hat{\theta}_{IV}) = \frac{1}{\sqrt{\sum_i w_i}}, \qquad w_i = \frac{1}{v_i}

where θ^IV\hat{\theta}_{IV} is the pooled effect, yiy_i is the estimate from study ii (a log odds ratio for a ratio measure), viv_i is its within-study variance and wiw_i is its weight. Viechtbauer notes that when true effects differ, the weighted fit estimates their weighted average, whereas unweighted least squares estimates their simple average.

A random effects model adds the between-study variance, tau-squared, to every study's variance. Viechtbauer describes estimating τ2\tau^2 first and then the coefficients by weighted least squares with wi=1/(vi+τ^2)w_i = 1/(v_i + \hat{\tau}^2).

Meta-regression as weighted least squares with known variances

The Cochrane Handbook says meta-regression differs from simple regression because studies are weighted by the precision of their estimates and the model should allow for residual heterogeneity the covariates leave unexplained. Thompson and Higgins describe weighting for both within-trial variances and residual between-trial heterogeneity as random-effects meta-regression. The NICE manual (PMG36, section 3.4.10) says known clinical heterogeneity may be explored using subgroup analyses and meta-regression.

The within-study variances are treated as known. Viechtbauer's comparison of the metafor function rma() with the general R function lm() explains that lm() assumes weights known only up to a proportionality constant, the residual variance, which it estimates and folds into the standard errors. Viechtbauer notes that Thompson and Sharp describe this as allowing for heterogeneity by a multiplicative factor, and they conclude that an additive component of residual heterogeneity should be used. General weighted regression software therefore reproduces the fixed-effect coefficients but not their standard errors.

Worked example with four trials and one covariate

All numbers in this example are illustrative. Four placebo-controlled trials report log odds ratios for hospital admission, with different planned treatment durations. A model for a health system funding only 6-month courses needs to know whether the effect depends on duration. The Cochrane Handbook advises that meta-regression should generally not be considered with fewer than ten studies, so four trials are used only to keep every step visible.

TrialDuration (months)Log odds ratioStandard errorVarianceWeight
A6-0.100.200.040025
B12-0.300.100.0100100
C18-0.350.250.062516
D24-0.600.200.040025

1. Pool with precision weights. The weights sum to 166 and the weighted effects to -53.1.

θ^IV=−53.1166=−0.320\hat{\theta}_{IV} = \frac{-53.1}{166} = -0.320

where -0.320 is the pooled log odds ratio, an odds ratio of 0.726, with a standard error of 0.0776. Trial B carries about 60% of the weight, against a quarter in the unweighted mean of -0.3375.

2. Fit the weighted slope. The weighted mean duration is 13.48 months, the weighted sum of squared deviations of duration is 4,711.4 and the weighted cross-product with the log odds ratios is -119.91.

β^1=−119.914711.4=−0.02545,β^0=−0.3199−(−0.02545×13.482)=0.0232\hat{\beta}_1 = \frac{-119.91}{4711.4} = -0.02545, \qquad \hat{\beta}_0 = -0.3199 - (-0.02545 \times 13.482) = 0.0232

where β^1\hat{\beta}_1 is the change in log odds ratio per extra month of treatment and β^0\hat{\beta}_0 is the intercept. With known variances the slope's standard error is the inverse square root of 4,711.4, or 0.01457, giving z=−1.75z = -1.75 and a two-sided p-value of about 0.08.

3. Compare general software. The weighted residual sum of squares is 0.173 on 2 degrees of freedom, so lm() estimates a scale factor of 0.0863 and multiplies the standard error by its square root.

SElm=0.01457×0.0863=0.00428SE_{lm} = 0.01457 \times \sqrt{0.0863} = 0.00428

where SElmSE_{lm} is the rescaled standard error. The trials fit the line more closely than their sampling variances imply, so lm() reports a t statistic near -5.9 (p about 0.03 on 2 degrees of freedom), a spurious finding. Larger residual scatter would inflate the standard error instead.

4. Add residual heterogeneity. With τ2=0.01\tau^2 = 0.01 assumed for illustration, since these data would give a moment estimate of zero, the weights become 20, 50, 13.79 and 20. Trial B's share falls to about 48%, the slope becomes -0.0256 and its standard error 0.0164, a zz of about -1.56.

5. Carry the result into the model. At 6 months the fixed-effect line predicts a log odds ratio of -0.1295, an odds ratio of 0.879. With a comparator one-year admission risk of 0.20, the baseline odds are 0.25.

odds1=0.25×0.8786=0.2196,p1=0.21961.2196=0.180\text{odds}_1 = 0.25 \times 0.8786 = 0.2196, \qquad p_1 = \frac{0.2196}{1.2196} = 0.180

where odds1\text{odds}_1 and p1p_1 are the odds and probability of admission with treatment. About 20 admissions are avoided per 1,000 patients, against about 46 with the pooled odds ratio of 0.726. The slope is imprecise and leans on trial A, so this effect suits a scenario analysis, not the base case.

Heteroscedastic cost and resource-use data

Patient-level costs are typically skewed, with excess zeros and heavy right tails. Mihaylova and colleagues report that generalised least squares estimators, or Huber and White variance estimates for ordinary least squares, are often used to obtain consistent estimates in such data.

The generalized linear model builds the weighting in. The same review explains that a GLM specifies a variance function and so accommodates skewness through variance weighting, and the R documentation for glm() states that its default fitting method is iteratively reweighted least squares. A gamma model for costs is solved as a sequence of weighted fits whose weights are updated from the current fitted means.

Group-level costs need care. Solon, Haider and Wooldridge show that when group averages share a common group-level error, weighting by group size can harm precision; in their state divorce-rate example the robust standard error estimates for ordinary least squares over the first eight years of effects were about half those for population-weighted least squares. They recommend testing for heteroscedasticity first, for example by regressing squared residuals on inverse group size, and reporting heteroscedasticity-robust standard errors either way.

Precision weights compared with survey and frequency weights

Software options called "weights" mix different ideas, and the right standard errors depend on which is meant. Frequency weights record that an observation stands for several identical individuals. A positive integer weight in R glm() is closer to a precision weight, since the documentation reads it as the response being the mean of that many unit-weight observations.

Survey weights are inverse probabilities of selection. Solon, Haider and Wooldridge separate two purposes. For descriptive population statistics, weighting is needed whenever the sample is not representative. For causal effects, inverse-probability weighting is needed for consistency when the sampling rate varies endogenously, and should then be paired with White heteroscedasticity-robust standard errors because the weighting itself induces heteroscedasticity. When sampling is exogenous, both estimators are consistent and the unweighted one may be more precise.

Choices that change the answer

Weights are almost always estimated. The NIST handbook warns that the theory assumes exactly known weights and that results can be badly and unpredictably affected when weights rest on few replicated observations. The Cochrane Handbook advises against inverse-variance methods for rare events, when within-study variances are least reliable.

Weighting can also change what is estimated. Solon, Haider and Wooldridge note that under misspecification weighted and unweighted estimates converge to different values, so a large gap between them is a warning sign.

Boundaries with nearby methods

Weighted least squares assumes uncorrelated errors. Generalised least squares extends it to correlated errors, and generalized estimating equations handle clustering when the correlation structure is uncertain. Robust standard errors from the sandwich estimator keep the ordinary least squares coefficients and correct only the inference. For sparse binary outcomes the Mantel-Haenszel method uses count-based weights instead of estimated variances.

Limitations and common misreadings

Most errors come from misreading what the weights mean. Three recur in health economics.

  1. Running a meta-regression in general regression software. The coefficients match a fixed-effect fit, but the standard errors are rescaled by the residual variance and can be badly wrong.
  2. Treating survey weights as precision weights. Inverse selection probabilities correct representativeness, not unequal variance, and need robust standard errors.
  3. Assuming weighting always improves precision. With group-level error components, size weights can make estimates less precise, and the NIST handbook notes that a weighted fit that raises an outlier's influence can be far worse than an unweighted one.

Sources

Library

Publications

7
  • Journal article

    How should meta-regression analyses be undertaken and interpreted? — Thompson SG, Higgins JPT, Vol. 21, No. 11, pp. 1559-1573 ed., 2002 (Statistics in Medicine)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Weighted Least Squares Regression, where it is cited as a reference for that concept.

  • Journal article

    Explaining heterogeneity in meta-analysis: a comparison of methods — Thompson SG, Sharp SJ, Vol. 18, No. 20, pp. 2693-2708 ed., 1999 (Statistics in Medicine)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Weighted Least Squares Regression, where it is cited as a reference for that concept.

  • Journal article

    Count data, rates, rate differences, and rate ratios in meta-analysis: a tutorial — Rose CJ, Geist M, Bruschettini M, Vol. 3, No. 2, Article e70022 ed., 2025 (Cochrane Evidence Synthesis and Methods)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Discrete Data, where it is cited as a reference for that concept.

  • Journal article

    Spinal manipulation for low-back pain — Shekelle PG, Adams AH, Chassin MR, et al, Vol. 117, No. 7, pp. 590-598 ed., 1992 (Annals of Internal Medicine)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Confidence Profile Method, where it is cited as a reference for that concept.

  • Journal article

    Hierarchical models in generalized synthesis of evidence: an example based on studies of breast cancer screening — Prevost TC, Abrams KR, Jones DR, Vol. 19, No. 24, pp. 3359-3376 ed., 2000 (Statistics in Medicine)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Confidence Profile Method, where it is cited as a reference for that concept.

  • Journal article

    What are we weighting for? — Solon G, Haider SJ, Wooldridge JM, Vol. 50, No. 2, pp. 301-316 (earlier NBER Working Paper 18859, 2013) ed., 2015 (Journal of Human Resources)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Weighted Least Squares Regression, where it is cited as a reference for that concept.

  • Journal article

    Logic models help make sense of complexity in systematic reviews and health technology assessments — Rohwer A, Pfadenhauer L, Burns J, et al, Vol. 83, pp. 37-47 ed., 2017 (Journal of Clinical Epidemiology)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Causal Pathway, where it is cited as a reference for that concept.

Tools & Resources

3
  • Other

    glm: fitting generalized linear models — R Core Team, Web page, accessed 14 October 2026 ed., 2026 (R stats package documentation)

    Source listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Weighted Least Squares Regression, where it is cited as a reference for that concept.

  • Other

    A comparison of the rma() and the lm(), lme(), and lmer() functions — Viechtbauer W, Last modified 14 November 2023 ed., 2023 (metafor package website)

    Source listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Weighted Least Squares Regression, where it is cited as a reference for that concept.

  • Journal article

    Conducting meta-analyses in R with the metafor package — Viechtbauer W, Vol. 36, No. 3, pp. 1-48 ed., 2010 (Journal of Statistical Software)

    Journal article listed in the Sources of the HealthEconomics.wiki Concept Architecture article on Meta-Regression, where it is cited as a reference for that concept.

Frequently Asked Questions (6)

  • What is weighted least squares (WLS)?

    Weighted least squares (WLS) is regression that weights each squared residual, ideally by the inverse of its error variance, as in meta-analysis for HTA.

    Source: Viechtbauer 2010

  • How does weighted least squares relate to inverse-variance meta-analysis?

    The inverse-variance method weights each study by one over the square of its standard error, a choice the Cochrane Handbook explains minimises the imprecision of the pooled estimate. A fixed effect meta-analysis pooled this way is weighted least squares on an intercept alone, giving the weighted mean of the study estimates with a standard error of one over the square root of the summed weights. A random effects model adds the between-study variance, tau-squared, to each study's variance before weighting, which evens out the weights. The Handbook advises against inverse-variance methods for rare events, when within-study variances are least reliable.

    Source: Deeks et al. 2024

  • Why can general regression software give wrong standard errors for a weighted least squares meta-regression?

    Meta-regression treats each study's within-study variance as known, but a general function such as R's lm() assumes the weights are known only up to a proportionality constant, the residual variance, which it estimates and folds into the standard errors. Viechtbauer explains that the coefficients then match a fixed-effect meta-regression while the standard errors do not. In an illustrative four-trial example, lm() shrank the slope's standard error from 0.0146 to 0.0043 and produced a spurious t statistic near -5.9. Thompson and Sharp concluded that an additive component of residual heterogeneity should be used instead.

    Source: Viechtbauer 2023

  • How is weighted least squares used to fit a meta-regression for a decision model?

    A meta-regression relates study effect estimates to study-level covariates, such as treatment duration, with each study weighted by its precision. Viechtbauer describes fitting the mixed-effects version in two steps, first estimating the residual heterogeneity tau-squared and then fitting the coefficients by weighted least squares with weights of one over the sum of the within-study variance and tau-squared. When true effects differ, the fixed-effect weighted fit estimates their weighted average, whereas unweighted least squares estimates their simple average. A fitted slope can predict the effect for the population a model needs, though an imprecise slope suits a scenario analysis better than the base case.

    Source: Viechtbauer 2010

  • How is weighted least squares used for skewed cost data in health economics?

    Patient-level costs are typically skewed, with excess zeros and heavy right tails, and heteroscedasticity is common. Mihaylova and colleagues report that generalised least squares estimators, or Huber and White variance estimates for ordinary least squares, are often used to obtain consistent estimates in such data. They explain that a generalised linear model specifies a variance function and so accommodates skewness through variance weighting. A gamma model for costs is solved by iteratively reweighted least squares, a sequence of weighted fits whose weights are updated from the current fitted means.

    Source: Mihaylova et al. 2011

  • How do survey weights differ from the precision weights used in weighted least squares?

    Precision weights reflect how much error variance each observation carries, while survey weights are inverse probabilities of selection meant to make a sample represent its target population. Solon, Haider and Wooldridge note that for causal effects, inverse-probability weighting is needed for consistency when the sampling rate varies endogenously, and should then be paired with White heteroscedasticity-consistent standard errors because the weighting itself induces heteroscedasticity. When sampling is exogenous, both weighted and unweighted estimators are consistent and the unweighted one may be more precise. Treating survey weights as precision weights therefore produces misleading standard errors.

    Source: Solon, Haider & Wooldridge 2015

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 14 Oct 2026

Content version: 1.0.1

Canonical Identity

Term code
HE-ES-SA-254

Stable URI · Machine-readable · Resolvable · CC BY 4.0