Why a Contrast Needs Its Own Standard Error
A regression question often concerns more than one coefficient at a time. For example, a researcher may want the difference between two adjusted group effects, or a weighted average of several effects. The estimate is a weighted sum of the fitted coefficients. Its uncertainty, however, cannot generally be found by combining their standard errors as if the coefficients varied independently.
The missing information is the covariance between coefficient estimates. When estimates tend to vary together, or in opposite directions, that dependence affects the variability of their sum or difference. This tutorial develops the calculation and shows how to use a reported covariance matrix.
The weights specify the quantity being estimated, so their order must match the order of the coefficients. A coefficient with weight zero makes no contribution to the contrast. For a comparison between two coefficients, the weights are often \(1\) and \(-1\); other questions can call for different weights.
The Variance Formula
Write \(\widehat{\operatorname{Cov}}(\hat{\boldsymbol{\beta}})=\widehat{\mathbf{V}}\), where entry \((i,j)\) is the estimated covariance between \(\hat{\beta}_i\) and \(\hat{\beta}_j\). The diagonal entries are the estimated variances of the individual coefficients; the off-diagonal entries are their estimated covariances. The standard formula for a weighted sum is
For two coefficients, this expands to
The factor of \(2\) appears because the double sum contains both the \((1,2)\) and \((2,1)\) terms, which are equal for a symmetric covariance matrix. For a difference, the weights have opposite signs, so the covariance term is subtracted when the covariance is positive. If the covariance is negative, that same term increases the variance of the difference.
Why the Formula Holds
The calculation follows from the variance of a weighted sum. Define the estimation error for coefficient \(i\) as \(U_i=\hat{\beta}_i-\operatorname{E}(\hat{\beta}_i)\). The centered contrast error is \(\sum_i c_iU_i\). Expanding its squared value and taking an expectation gives
The final equality uses the definition of covariance: \(\operatorname{E}(U_iU_j)=\operatorname{Cov}(\hat{\beta}_i,\hat{\beta}_j)\). Writing the same expression in matrix form gives \(\mathbf{c}^\mathsf{T}\mathbf{V}\mathbf{c}\). In practice, the true covariance matrix is not known, so its estimate \(\widehat{\mathbf{V}}\) is used to calculate the estimated variance and standard error.
This is an algebraic variance result; it does not require coefficient estimates to be normally distributed. The quality of the reported standard error does depend on using a covariance estimate appropriate to the regression model and its assumptions. For conventional ordinary least squares, this calculation uses the model-based estimated covariance matrix under the usual linear-model conditions, including independent errors with constant variance and a full-rank design matrix. If software supplies a different appropriate covariance estimate, the same contrast formula applies to that matrix.
Worked Calculations
Worked Example: Difference Between Two Adjusted Effects
In a hypothetical regression, two coefficients represent adjusted differences in an outcome measured in points: \(\hat{\beta}_1=2.40\) points and \(\hat{\beta}_2=1.70\) points. Their estimated covariance matrix is
Suppose the target is the difference \(\beta_1-\beta_2\). The weights are \(\mathbf{c}=(1,-1)^\mathsf{T}\), so the contrast estimate is
The estimated variance includes both diagonal terms and the covariance term:
Therefore,
The estimated difference between the adjusted effects is \(0.700\) points, with an estimated standard error of \(0.6083\) points. This example shows why simply adding the two coefficient variances would be wrong: the positive covariance reduces the variance of their difference.
Worked Example: Weighted Average of Two Group Effects
In another hypothetical regression, the coefficients \(\beta_A\) and \(\beta_B\) are adjusted differences in outcome from a reference group, measured in points. Their estimates are \(3.00\) and \(6.00\) points. The coefficient vector is ordered as \((\hat{\beta}_0,\hat{\beta}_A,\hat{\beta}_B)^\mathsf{T}\), and its estimated covariance matrix is
Consider the equally weighted average of the two group effects. The weights, in the stated coefficient order, are \(\mathbf{c}=(0,\frac{1}{2},\frac{1}{2})^\mathsf{T}\). The intercept has weight zero. The estimate is
Only the variances and covariance of \(\hat{\beta}_A\) and \(\hat{\beta}_B\) contribute. Applying the formula,
Thus \(SE(\hat{L})=\sqrt{0.2725}=0.5220\) points. The point estimate is the average adjusted difference, and the standard error accounts for the fact that the two coefficient estimates have estimated covariance \(0.12\text{ points}^2\).
Worked Example: Calculating a Covariance From a Correlation
Suppose a hypothetical regression reports two adjusted group-effect estimates, \(\hat{\beta}_1=8.20\) and \(\hat{\beta}_2=5.60\), both in outcome units. Their standard errors are \(0.80\) and \(0.60\) outcome units, and the estimated correlation between the coefficient estimates is \(-0.25\). Find the estimate and standard error of \(\beta_1-\beta_2\).
A covariance is the correlation multiplied by the two standard errors:
The estimated contrast is \(8.20-5.60=2.60\) outcome units. Its estimated variance is
Therefore \(SE(\hat{\beta}_1-\hat{\beta}_2)=\sqrt{1.240}=1.114\) outcome units. The negative covariance increases the variance of this difference. The estimate and standard error describe the fitted contrast; they do not by themselves determine whether a hypothesis about the contrast is rejected.
A Reliable Calculation Routine
A careful calculation can be organized in four steps. Keeping the coefficient order and weight order visible helps prevent sign and indexing errors.
Express the requested quantity as \(L=\sum_i c_i\beta_i\), and list the coefficient vector in a definite order.
Use exactly the same weights and order to calculate \(\hat{L}=\sum_i c_i\hat{\beta}_i\).
Evaluate \(\mathbf{c}^\mathsf{T}\widehat{\mathbf{V}}\mathbf{c}\), including the off-diagonal covariance terms.
The result is \(SE(\hat{L})\). If the contrast is measured in outcome units, its variance is in squared outcome units and its standard error is again in outcome units.
Common Mistakes and Why This Calculation Matters
A frequent error is to treat coefficient estimates as independent without checking their covariance. For a difference, someone might calculate the estimated variance as \(SE(\hat{\beta}_1)^2+SE(\hat{\beta}_2)^2\) and stop. That expression is correct only when the estimated covariance is zero. The general formula includes the term \(-2\widehat{\operatorname{Cov}}(\hat{\beta}_1,\hat{\beta}_2)\). Depending on its sign, omitting it can either overstate or understate the contrast’s uncertainty.
Another mistake is to use the coefficient standard errors where the covariance matrix requires variances. The diagonal entries of \(\widehat{\mathbf{V}}\) are squared standard errors; the standard error of the contrast is obtained only after calculating the full variance and taking its square root. If a report gives coefficient correlations instead of covariances, first convert using
Finally, a valid calculation requires the weights to match the coefficient order and the covariance matrix to come from the same fitted model and covariance procedure as the coefficient estimates. A calculated standard error is only as appropriate as that covariance estimate. These calculations are useful because they let a research question about a combination of effects be answered on its own scale, rather than relying on separate coefficient standard errors.
Check Your Understanding
Use the coefficient order stated in each question, and include covariance terms where needed.
- If \(\hat{\beta}_1=4.0\), \(\hat{\beta}_2=1.5\), and the target is \(\beta_1-\beta_2\), what weight vector represents the contrast?
- Two coefficient estimates have variances \(0.25\) and \(0.49\), with covariance \(0.10\). Calculate the estimated variance of their difference.
- Why does the covariance term have a negative contribution to the variance of a difference when the coefficient covariance is positive?
- Two coefficient estimates have standard errors \(0.5\) and \(0.8\), with estimated correlation \(0.30\). What is their estimated covariance?
- In the formula \(\mathbf{c}^\mathsf{T}\widehat{\mathbf{V}}\mathbf{c}\), what do the diagonal entries and the off-diagonal entries of \(\widehat{\mathbf{V}}\) represent?