Tutorials › High-Dimensional Genomic Data Analysis › Deriving The MR-Egger Slope And Intercept

Mendelian Randomization · Tutorial 673 of 795

Deriving The MR-Egger Slope And Intercept

Learn how weighted regression produces MR-Egger estimates and uncertainty, and what the slope and intercept can—and cannot—tell you about causality and directional pleiotropy.

Advanced 11 min read

What You'll Learn

  • Derive the weighted MR-Egger slope and intercept from weighted least squares.
  • Calculate standard errors from the regression design and outcome-association weights.
  • Distinguish fixed-effect uncertainty from multiplicative overdispersion adjustment.
  • Interpret the slope in outcome-per-exposure units and the intercept as a directional-pleiotropy diagnostic.
  • Check rank, residual degrees of freedom, heterogeneity, and the limits of the regression approximation.

From the MR-Egger Model to Estimates

For variant \(j\), let \(\hat{\beta}_j\) denote its estimated association with the exposure and \(\hat{\gamma}_j\) its estimated association with the outcome. The MR-Egger regression relates these associations through an intercept and a slope. The intercept allows the variants to have a common directional component of direct effect, rather than forcing the fitted line through the origin as inverse-variance weighted (IVW) regression does.

The calculation is a weighted least-squares regression of \(\hat{\gamma}_j\) on \(\hat{\beta}_j\), including an intercept. The weights are usually the inverse variances of the estimated outcome associations. As in the standard first-order summary-data calculation, this treats the estimated exposure associations as fixed in the regression. It is an approximation: uncertainty in \(\hat{\beta}_j\) is not included in these standard errors.

Definition: For \(K\) variants, write \(x_j=\hat{\beta}_j\), \(y_j=\hat{\gamma}_j\), and \(w_j=1/\operatorname{SE}(\hat{\gamma}_j)^2\). The weighted MR-Egger estimates \((\hat{\alpha},\hat{\theta})\) minimize $$ \sum_{j=1}^{K} w_j\left(y_j-\alpha-\theta x_j\right)^2. $$ Here \(\hat{\alpha}\) is the intercept estimate and \(\hat{\theta}\) is the slope estimate. Under the MR-Egger model and the additional conditions needed for causal identification, \(\hat{\theta}\) estimates the causal effect; \(\hat{\alpha}\) is a diagnostic for an average directional pleiotropic component.

The weights give more influence to outcome associations measured with greater precision. Multiplying all weights by the same positive constant leaves both coefficient estimates unchanged, although it changes the scale used to express their variances. The weight definition above fixes that scale by using inverse variances.

Deriving the Weighted Coefficients

Define the total weight \(W\), the weighted means \(\bar{x}_w\) and \(\bar{y}_w\), and the weighted sums of squares and cross-products as follows:

$$ W=\sum_{j=1}^{K}w_j,\qquad \bar{x}_w=\frac{\sum_{j=1}^{K}w_jx_j}{W},\qquad \bar{y}_w=\frac{\sum_{j=1}^{K}w_jy_j}{W}, $$ $$ S_{xx}=\sum_{j=1}^{K}w_j(x_j-\bar{x}_w)^2,\qquad S_{xy}=\sum_{j=1}^{K}w_j(x_j-\bar{x}_w)(y_j-\bar{y}_w). $$

To obtain the estimates, minimize the weighted residual sum of squares over \(\alpha\) and \(\theta\). Differentiating with respect to the intercept and setting the derivative to zero gives \(\sum_jw_j(y_j-\alpha-\theta x_j)=0\). Rearranging this equation yields \(\alpha=\bar{y}_w-\theta\bar{x}_w\). Substituting this relation into the derivative with respect to the slope gives the centered weighted cross-product divided by the centered weighted sum of squares:

$$ \hat{\theta}=\frac{S_{xy}}{S_{xx}},\qquad \hat{\alpha}=\bar{y}_w-\hat{\theta}\bar{x}_w. $$

These formulas require \(S_{xx}>0\): the estimated exposure associations must not all be identical. Thus two variants with different \(x_j\) values are enough to estimate an intercept and slope. With exactly two such variants, the line fits both points exactly, but there are zero residual degrees of freedom. At least three variants are needed for positive residual degrees of freedom and an estimate of residual dispersion.

Worked Example: Calculating a Weighted Slope and Intercept

Suppose three hypothetical variants have exposure associations \(x=(0.1,0.2,0.3)\), outcome associations \(y=(0.03,0.05,0.08)\), and relative weights proportional to \((1,2,1)\). These weights can represent inverse variances after omitting a common positive factor; that factor does not change the coefficient estimates.

The total relative weight is \(W=1+2+1=4\). The weighted means are $$ \bar{x}_w=\frac{1(0.1)+2(0.2)+1(0.3)}{4}=0.2,\qquad \bar{y}_w=\frac{1(0.03)+2(0.05)+1(0.08)}{4}=0.0525. $$

The weighted sums are $$ S_{xx}=1(0.1-0.2)^2+2(0.2-0.2)^2+1(0.3-0.2)^2=0.02, $$ $$ S_{xy}=1(0.1-0.2)(0.03-0.0525)+2(0)(0.05-0.0525)+1(0.3-0.2)(0.08-0.0525)=0.005. $$ Therefore \(\hat{\theta}=0.005/0.02=0.25\), and \(\hat{\alpha}=0.0525-(0.25)(0.2)=0.0025\). If the associations are expressed per allele, the slope is in outcome-association units per exposure-association unit, and the intercept is in outcome-association units per allele. In an MR analysis, the causal interpretation of the slope requires more than this regression calculation.

Standard Errors and Residual Dispersion

For the usual first-order calculation, suppose the outcome-association errors are independent across variants and have variances \(1/w_j\), while the \(x_j\) values are treated as fixed. In matrix notation, the regression design has columns \(1\) and \(x\); weighted least squares gives coefficient covariance matrix \((X^\mathsf{T}WX)^{-1}\). Centering the \(x_j\) values at their weighted mean makes the resulting entries explicit:

$$ \operatorname{Var}(\hat{\theta})=\frac{1}{S_{xx}},\qquad \operatorname{Var}(\hat{\alpha})=\frac{1}{W}+\frac{\bar{x}_w^2}{S_{xx}},\qquad \operatorname{Cov}(\hat{\alpha},\hat{\theta})=-\frac{\bar{x}_w}{S_{xx}}. $$

These are fixed-effect variances when the stated inverse-variance weights correctly describe the outcome-association errors. The slope standard error is \(SE(\hat{\theta})=1/\sqrt{S_{xx}}\); the intercept standard error is \(SE(\hat{\alpha})=\sqrt{1/W+\bar{x}_w^2/S_{xx}}\). The intercept uncertainty includes both uncertainty in the weighted mean outcome and the effect of estimating the slope.

Variant-specific direct effects can create extra residual variability around the fitted line. Define the weighted residual sum of squares \(Q=\sum_jw_j(y_j-\hat{\alpha}-\hat{\theta}x_j)^2\). When the design has rank two, the residual degrees of freedom are \(df=K-2\). A multiplicative random-effects calculation estimates the residual scale by \(\hat{\phi}=Q/(K-2)\), then multiplies the fixed-effect variances by \(\hat{\phi}\). Consequently, both standard errors are multiplied by \(\sqrt{\hat{\phi}}\). Some implementations use \(\max(1,Q/(K-2))\) for this multiplier, so they do not reduce standard errors below their fixed-effect values. State which convention is used when reporting results.

The \(Q\) statistic also describes residual heterogeneity: a large value relative to its degrees of freedom indicates more scatter around the fitted line than the specified outcome variances alone predict. It does not identify the cause of that scatter. With \(K=2\), \(Q\) can be calculated but \(K-2=0\), so residual dispersion cannot be estimated this way.

Worked Example: Estimating the Intercept and Slope with Two Variants

Consider hypothetical association points \((x_1,y_1)=(0.1,0.04)\) and \((x_2,y_2)=(0.3,0.10)\), with equal positive weights. The exposure associations differ, so \(S_{xx}>0\) and both regression coefficients are estimable.

The weighted means are \(\bar{x}_w=(0.1+0.3)/2=0.2\) and \(\bar{y}_w=(0.04+0.10)/2=0.07\). Thus \(S_{xx}=(-0.1)^2+(0.1)^2=0.02\) and \(S_{xy}=(-0.1)(-0.03)+(0.1)(0.03)=0.006\). The fitted slope is \(0.006/0.02=0.30\), and the intercept is \(0.07-(0.30)(0.2)=0.01\).

The fitted line passes through both points, leaving no residual degrees of freedom. The estimates exist, but the data cannot estimate a residual dispersion multiplier \(Q/(K-2)\). This is why “at least three variants” is a requirement for estimating residual dispersion, not for estimating the line itself.

A Full Example with Standard Errors

Suppose four hypothetical variants have \(x=(0.1,0.2,0.3,0.4)\), \(y=(0.04,0.09,0.11,0.20)\), and each outcome-association standard error is \(0.02\). The corresponding weights are all \(1/(0.02)^2=2500\). Equal weights make the weighted means ordinary means: \(\bar{x}_w=0.25\) and \(\bar{y}_w=0.11\).

Worked Example: MR-Egger Estimates and Their Uncertainty

The centered exposure values are \(-0.15,-0.05,0.05,0.15\), so $$ S_{xx}=2500(0.15^2+0.05^2+0.05^2+0.15^2)=2500(0.05)=125. $$ The centered outcome values are \(-0.07,-0.02,0,0.09\). Their cross-product with the centered exposure values is \(0.0105+0.001+0+0.0135=0.025\), giving \(S_{xy}=2500(0.025)=62.5\). Therefore \(\hat{\theta}=62.5/125=0.50\), and \(\hat{\alpha}=0.11-(0.50)(0.25)=-0.015\).

The fixed-effect slope standard error is $$ SE(\hat{\theta})=\sqrt{\frac{1}{125}}=\sqrt{0.008}=0.08944. $$ For the intercept, \(W=4(2500)=10000\), so $$ SE(\hat{\alpha})=\sqrt{\frac{1}{10000}+\frac{0.25^2}{125}} =\sqrt{0.0001+0.0005} =\sqrt{0.0006}=0.02449. $$

The fitted outcome associations are \(0.035,0.085,0.135,0.185\), giving residuals \(0.005,0.005,-0.025,0.015\). Hence $$ Q=2500\left(0.005^2+0.005^2+(-0.025)^2+0.015^2\right) =2500(0.0009)=2.25. $$ With \(df=4-2=2\), \(\hat{\phi}=2.25/2=1.125\). Under the multiplicative random-effects convention, the adjusted standard errors are \(0.08944\sqrt{1.125}=0.09487\) for the slope and \(0.02449\sqrt{1.125}=0.02598\) for the intercept.

Using a normal-approximation 95% interval, the slope interval is \(0.50\pm1.96(0.09487)\), or approximately \((0.314,0.686)\). Its units are outcome-association units per exposure-association unit. The intercept interval is \(-0.015\pm1.96(0.02598)\), or approximately \((-0.0659,0.0359)\) outcome-association units per allele. Because this interval includes zero, these data do not provide clear evidence of a nonzero average directional component under this model. They do not prove that directional pleiotropy is absent.

Interpretation, Diagnostics, and Limitations

The MR-Egger intercept estimates a common directional component in the outcome associations that is not explained by the fitted exposure-association slope. Its magnitude and uncertainty are useful diagnostics, but variant-specific pleiotropic effects can differ and cancel in the average. A near-zero intercept therefore does not establish that every instrument has no direct effect. Conversely, a nonzero intercept is evidence of an average directional component under the regression model, not proof of a particular biological mechanism.

The slope is interpreted as a causal estimate only when the instrumental-variable conditions needed for MR-Egger identification hold, including the InSIDE condition, and when the regression approximation is adequate. The regression formulas alone establish an association-line fit; they do not establish causality. MR-Egger can also have low precision, especially when the exposure associations have little spread, since \(S_{xx}\) is then small and the slope standard error \(1/\sqrt{S_{xx}}\) is large.

Check that alleles are harmonized, that the regression design has rank two, and that outcome-association standard errors yield sensible weights. Inspect \(Q\) relative to \(K-2\), the intercept and its uncertainty, and whether a few variants dominate the weighted fit. These checks can flag fragility, but none by itself validates the causal assumptions.

ApproachRegression constraintPractical implication
IVWFits through the originCan be more precise, but does not estimate a nonzero intercept.
MR-EggerFits an intercept and a slopeAllows an average directional component, generally with greater uncertainty and additional identification requirements.

A common mistake is to treat “intercept not statistically distinguishable from zero” as proof that all variants are valid, or to treat the MR-Egger slope as automatically causal because an intercept was fitted. The correction is to interpret the intercept as a limited average diagnostic and the slope as causal only under the required identification assumptions. Another frequent error is to require three variants to calculate the line: two distinct exposure associations suffice for the coefficients, but not for estimating residual dispersion.

1
Check the design.
Confirm there are at least two variants with nonidentical estimated exposure associations; positive residual degrees of freedom require at least three.
2
Fit the weighted line.
Use inverse outcome-association variances and calculate \(\hat{\theta}=S_{xy}/S_{xx}\) and \(\hat{\alpha}=\bar{y}_w-\hat{\theta}\bar{x}_w\).
3
Report uncertainty and diagnostics.
Give the standard-error convention, residual \(Q\), and intercept interpretation, then state the assumptions required for a causal reading of the slope.

Check Your Understanding

Answer each question, then compare with the concise solutions below.

  1. What condition on the estimated exposure associations makes the slope and intercept estimable?
  2. Why can two variants estimate coefficients but not residual dispersion?
  3. If \(S_{xx}=80\) under inverse-variance weights, what is the fixed-effect slope standard error?
  4. For \(K=6\) and \(Q=10\), what is \(df\) and the multiplicative estimate \(\hat{\phi}\)?
  5. What does an intercept confidence interval containing zero establish about directional pleiotropy?

Solutions. (1) The exposure associations must not all be identical, so \(S_{xx}>0\). (2) Two distinct points determine a line exactly, leaving \(K-2=0\) residual degrees of freedom. (3) \(SE(\hat{\theta})=1/\sqrt{80}=0.1118\). (4) \(df=6-2=4\), and \(\hat{\phi}=Q/df=10/4=2.5\). (5) It means the data do not clearly distinguish the fitted average intercept from zero at the chosen confidence level; it does not prove that all pleiotropic effects are absent.

Clinical Biostats