Tutorials › High-Dimensional Genomic Data Analysis › Heteroskedasticity And Standard Errors In Linear GWAS

Single-Variant GWAS · Tutorial 233 of 795

Heteroskedasticity And Standard Errors In Linear GWAS

Learn how heteroskedasticity changes uncertainty estimates for linear SNP effects, when robust standard errors are appropriate, and how to compare and report both estimates.

Intermediate 12 min read

What You'll Learn

  • State the linear-GWAS assumptions that allow residual variance to differ across individuals.
  • Derive the conventional and HC1 heteroskedasticity-robust variance estimators for an SNP coefficient.
  • Calculate conventional and robust standard errors from hypothetical genotype data.
  • Explain why robust standard errors can be either larger or smaller than conventional ones.
  • Report an SNP effect with its standard error and distinguish the two uncertainty estimates.
  • Identify diagnostics and limitations of heteroskedasticity-robust inference.

Why Residual Variance Matters in a Linear GWAS

In a quantitative-trait GWAS, a linear regression estimates how a trait changes with SNP genotype, usually while adjusting for covariates. The coefficient describes the estimated change in the trait per unit of the genotype coding; its standard error describes the estimated sampling variability of that coefficient. If individuals with different genotypes or covariate values have different residual variability, the coefficient can still be useful, but the usual standard-error formula may no longer be valid.

Here the focus is the uncertainty calculation, not a change to the mean model. In particular, using a heteroskedasticity-robust standard error does not remove confounding, correct an incorrectly specified conditional mean, or establish that a SNP causes a trait difference. It changes how uncertainty is estimated when the residual variance is not constant.

Definition: Let \(Y_i\) be a quantitative trait for individual \(i\), \(G_i\) the SNP genotype dosage, and \(C_i\) a vector of covariates. A linear association model can be written as \(Y_i=\beta_0+\beta_G G_i+C_i^\mathsf{T}\gamma+\varepsilon_i\). The residual error is \(\varepsilon_i\). The model is homoskedastic if \(\operatorname{Var}(\varepsilon_i\mid G_i,C_i)=\sigma^2\) for every individual, and heteroskedastic if this conditional variance is allowed to vary across individuals.

The key assumptions for the standard robust calculation are that the conditional mean is correctly specified, \(E(\varepsilon_i\mid G_i,C_i)=0\), and the observations are independent across individuals. The conditional variance may differ between individuals, but should be finite; for the usual large-sample inference, no small set of observations should dominate the fit. Genotype coding and covariate adjustment must also match the scientific model. These assumptions are distinct: allowing unequal variances does not protect against a nonzero conditional mean error or dependence between observations.

With an additive genotype dosage coded 0, 1, or 2, \(\beta_G\) is the fitted trait difference per additional effect allele, conditional on the included covariates. For example, if the trait is measured in milligrams per deciliter, \(\beta_G\) is in milligrams per deciliter per allele. This interpretation follows the quantitative-trait effects covered in the earlier material on interpreting quantitative-trait effects.

Conventional and Robust Standard Errors

Write the regression in matrix form as \(Y=X\beta+\varepsilon\), where \(X\) includes an intercept, the SNP dosage, and the covariates. Ordinary least squares estimates \(\hat\beta=(X^\mathsf{T}X)^{-1}X^\mathsf{T}Y\), provided the columns of \(X\) are linearly independent. If the conditional mean is correct, then \(E(\hat\beta\mid X)=\beta\). Under homoskedasticity and independent errors, the conventional covariance estimator is \(s^2(X^\mathsf{T}X)^{-1}\), where \(s^2\) is the residual sum of squares divided by \(n-p\), and \(p\) is the number of fitted regression coefficients.

When residual variance differs by individual, the actual conditional covariance of the estimator is instead \(\operatorname{Var}(\hat\beta\mid X)=(X^\mathsf{T}X)^{-1}X^\mathsf{T}\Omega X(X^\mathsf{T}X)^{-1}\), where \(\Omega\) is diagonal, with entry \(i\) equal to \(\operatorname{Var}(\varepsilon_i\mid X)\). The conventional formula replaces all these different variances with one pooled estimate. Its standard errors can therefore be too small or too large.

A heteroskedasticity-robust sandwich estimator replaces the unknown errors and their variances with fitted residuals. One widely used finite-sample adjustment is HC1. Let \(\hat\varepsilon_i=Y_i-X_i^\mathsf{T}\hat\beta\), where \(X_i^\mathsf{T}\) is row \(i\) of the design matrix. The HC1 covariance estimator is:

$$ \widehat{\operatorname{Var}}_{\mathrm{HC1}}(\hat\beta) = \frac{n}{n-p} (X^\mathsf{T}X)^{-1} \left(\sum_{i=1}^{n}X_iX_i^\mathsf{T}\hat\varepsilon_i^2\right) (X^\mathsf{T}X)^{-1}. $$

The standard error for the SNP coefficient is the square root of the diagonal entry corresponding to \(\hat\beta_G\). HC1 multiplies the HC0 sandwich estimate by \(n/(n-p)\). This correction does not make the estimator exact in small samples; it is a common adjustment to the asymptotic sandwich estimator. Other robust variants, such as HC2 and HC3, adjust residual contributions differently, particularly to account for leverage.

Why the Sandwich Formula Works

The robust calculation follows from the way least squares combines individual outcomes. Conditional on \(X\), the estimation error is \(\hat\beta-\beta=(X^\mathsf{T}X)^{-1}X^\mathsf{T}\varepsilon\). If errors are independent but have variances \(\sigma_i^2\), their covariance matrix is diagonal, \(\Omega=\operatorname{diag}(\sigma_1^2,\ldots,\sigma_n^2)\). Applying the covariance rule for a linear transformation gives the true covariance below. Replacing each unknown \(\sigma_i^2\) by \(\hat\varepsilon_i^2\) yields HC0; HC1 then applies its degrees-of-freedom multiplier.

$$ \begin{aligned} \operatorname{Var}(\hat\beta\mid X) &=(X^\mathsf{T}X)^{-1}X^\mathsf{T} \operatorname{Var}(\varepsilon\mid X)X(X^\mathsf{T}X)^{-1}\\ &=(X^\mathsf{T}X)^{-1}X^\mathsf{T}\Omega X(X^\mathsf{T}X)^{-1}. \end{aligned} $$

This derivation also clarifies what the robust estimator does not do. It estimates uncertainty for the specified least-squares coefficients under a potentially nonconstant diagonal error covariance. It does not alter the fitted coefficients, and it does not accommodate correlated errors between individuals merely by using HC1.

Worked Calculations

Worked Example: HC1 Standard Error Slightly Larger

Consider a hypothetical regression with an intercept and SNP dosage \(G=(0,0,1,2,3)\), with no additional covariates. Suppose the trait values are \(Y=(11,9,10.4,10.8,11.2)\). The fitted line is \(\hat Y=10+0.4G\), giving residuals \((1,-1,0,0,0)\). Their sum is zero, and their genotype-weighted sum is \(0(1)+0(-1)+1(0)+2(0)+3(0)=0\), as required for these least-squares residuals.

Here \(n=5\), \(p=2\), and the mean genotype is \(\bar G=1.2\). The centered genotype sum of squares is \(S_{GG}=\sum_i(G_i-\bar G)^2=1.44+1.44+0.04+0.64+3.24=6.80\). The residual sum of squares is \(1^2+(-1)^2=2\), so \(s^2=2/(5-2)=0.6667\). The conventional slope variance and standard error are:

$$ \widehat{\operatorname{Var}}_{\mathrm{conv}}(\hat\beta_G) =\frac{0.6667}{6.80}=0.09804, \qquad SE_{\mathrm{conv}}=\sqrt{0.09804}=0.3131. $$

For a regression with an intercept and one predictor, the HC0 slope variance is \(\sum_i(G_i-\bar G)^2\hat\varepsilon_i^2/S_{GG}^2\). Here its numerator is \(1.44(1)+1.44(1)=2.88\). Applying HC1 gives:

$$ \widehat{\operatorname{Var}}_{\mathrm{HC1}}(\hat\beta_G) =\frac{5}{3}\frac{2.88}{6.80^2} =\frac{4.80}{46.24}=0.1038, \qquad SE_{\mathrm{HC1}}=\sqrt{0.1038}=0.3222. $$

The robust standard error is slightly larger than the conventional one in this example. The coefficient estimate remains \(0.400\) trait units per allele under either calculation. This small hypothetical sample illustrates the arithmetic only; it is not a basis for reliable large-sample inference.

Worked Example: HC1 Standard Error Smaller

For a second hypothetical regression, take \(G=(0,1,2,3)\), \(Y=(6,5.25,2.5,7.75)\), and the fitted line \(\hat Y=5+0.25G\). The residuals are \((1,0,-3,2)\). They sum to zero, and their genotype-weighted sum is \(0(1)+1(0)+2(-3)+3(2)=0\), so they satisfy the least-squares residual constraints.

The mean genotype is \(1.5\), and \(S_{GG}=2.25+0.25+0.25+2.25=5\). The residual sum of squares is \(1+0+9+4=14\), giving \(s^2=14/(4-2)=7\). Thus the conventional slope variance is \(7/5=1.400\), and \(SE_{\mathrm{conv}}=\sqrt{1.400}=1.183\).

For HC0, the weighted squared-residual sum is \(2.25(1)+0.25(0)+0.25(9)+2.25(4)=13.50\). Since \(n/(n-p)=4/2=2\), the HC1 slope variance is \(2(13.50)/5^2=1.080\), and \(SE_{\mathrm{HC1}}=\sqrt{1.080}=1.039\). Here the robust standard error is smaller. Neither example establishes that residual variances truly differ; they show why the two formulas need not agree.

Worked Example: Reporting a SNP Effect Under Both Methods

Suppose a hypothetical large-sample GWAS reports an estimated effect of \(0.018\) mg/dL per effect allele. The conventional standard error is \(0.0030\) mg/dL per allele, and the HC1 standard error is \(0.0034\) mg/dL per allele. A Wald statistic is the estimate divided by its standard error. Using a standard normal reference distribution for this large-sample illustration gives:

$$ z_{\mathrm{conv}}=\frac{0.018}{0.0030}=6.00, \qquad z_{\mathrm{HC1}}=\frac{0.018}{0.0034}=5.294. $$

The corresponding approximate two-sided p-values are \(2P(Z\geq 6.00)\approx 2.0\times10^{-9}\) and \(2P(Z\geq5.294)\approx1.2\times10^{-7}\), for \(Z\sim N(0,1)\). These are different uncertainty calculations for the same estimated effect, not different estimated effects. A clear report labels the method: “The estimated effect was \(0.018\) mg/dL per allele (conventional \(SE=0.0030\); HC1 \(SE=0.0034\)).” The p-value should be identified with the standard-error method used to calculate it.

Diagnostics, Alternatives, and Limitations

Residual diagnostics can reveal patterns that make a constant-variance assumption implausible. Plot residuals against fitted values, genotype dosage, and important covariates; a changing vertical spread or a funnel shape suggests that residual variance may depend on the fitted mean or predictors. In a GWAS, inspect plots and summaries rather than relying only on a formal test: with large samples, small departures can be statistically detectable without materially changing a standard error. A residual plot cannot prove homoskedasticity, and the fitted residuals are estimates, not the unobserved errors themselves.

The conventional formula is more efficient when its homoskedasticity assumptions hold, but can misestimate uncertainty otherwise. HC1 is a practical alternative under independent observations and a correctly specified conditional mean; with a large enough sample, it estimates the sandwich covariance without requiring equal variances. If observations are dependent, such as through family or other grouping structure, the individual-level HC1 formula is not a general solution. Correlation requires an approach that accounts for that dependence, rather than simply substituting HC1.

Robust standard errors also have limitations. They do not repair omitted-variable bias, an unsuitable genotype model, influential observations, or a wrong conditional mean. They can be unstable in small samples or when a few individuals have high leverage. Very large residuals can strongly affect the squared-residual terms, while HC1's simple multiplier does not specifically correct high leverage. Check sample size, leverage, residual patterns, genotype counts, and model specification; consider whether a different variance model or a dependence-aware analysis is scientifically warranted.

A frequent mistake is to assume that “robust” means “larger” or “safer in every respect.” The examples show that HC1 can be larger or smaller than the conventional standard error, depending on how residual magnitudes align with the design. The correction is to report which estimator was used, inspect whether its assumptions are reasonable, and interpret it as an uncertainty estimate for the fitted model—not as a remedy for every possible GWAS problem.

Key takeaway: Under a correctly specified conditional mean and independent observations, heteroskedasticity-robust standard errors allow residual variance to vary across individuals. They can change the standard error and test statistic without changing the OLS SNP effect estimate.

Check Your Understanding

Try each question, then compare your reasoning with the brief solutions.

  1. In the linear model, what assumption is relaxed by using an HC1 standard error, and what assumptions are still needed?
  2. Why does a heteroskedasticity-robust standard error not change the fitted SNP coefficient?
  3. A SNP effect is \(0.012\) trait units per allele with \(SE_{\mathrm{HC1}}=0.004\). Calculate the Wald statistic.
  4. Can an HC1 standard error be smaller than a conventional standard error? Explain.
  5. Does HC1 account for correlation between related individuals? Explain briefly.

Solutions. (1) HC1 relaxes the assumption of constant conditional residual variance; a correctly specified conditional mean, independent observations, and suitable large-sample conditions are still needed. (2) The coefficient is the same OLS estimate; only its estimated covariance changes. (3) \(z=0.012/0.004=3.00\). (4) Yes. The residuals' squared magnitudes and their positions in the design determine the sandwich estimate, so it can be smaller or larger. (5) No. Individual-level HC1 does not generally account for dependence between individuals.

Clinical Biostats