Why Plan a Weighted Comparison?
When a regression model represents several groups, the question of interest is not always whether two particular groups differ. A researcher might instead want to compare one group with the average of several others, or compare the average of two groups with a third. A planned weighted contrast states that comparison directly, using specified weights on the group means.
The weights encode the scientific question. For example, comparing one group with an equally weighted average of three others gives the three comparison groups equal influence, regardless of their sample sizes. That is different from comparing it with a sample-size-weighted pooled average. The choice should reflect the target comparison, not whichever weights make an observed result look strongest.
The zero-sum condition makes the contrast a comparison rather than an overall level. If the same constant \(a\) is added to every group mean, then \( \sum_j c_j(\mu_j+a)=\sum_j c_j\mu_j+a\sum_j c_j=L \), because \(\sum_j c_j=0\). The contrast therefore does not change just because the outcome has a different common reference level.
Choosing Weights for a Group Versus a Weighted Average
To compare group 1 with a weighted average of groups 2 through \(k\), choose nonnegative weights \(w_2,\ldots,w_k\) that sum to one. Set \(c_1=1\) and \(c_j=-w_j\) for the other groups. Then \( L=\mu_1-\sum_{j=2}^{k}w_j\mu_j \). The coefficients sum to zero, and the second term is the specified weighted average.
For an equal-weight average of three comparison groups, each receives weight \(1/3\), so the contrast coefficients are \(1,-1/3,-1/3,-1/3\). For a comparison of group 1 with 25% of group 2 and 75% of group 3, the coefficients are \(1,-0.25,-0.75\). A coefficient’s sign and size matter: reversing every sign reverses the direction of the contrast but leaves its two-sided test unchanged.
The choice of weights also identifies what population summary is being compared. Equal weights answer a question about the average of group means, giving each group equal standing. Weights proportional to group population shares may answer a different question. Neither choice is automatically correct in every setting; the intended comparison determines the weights.
Standard Errors and the Contrast Test
State the model assumptions before using a t test. In a one-way regression model for \(k\) groups, assume observations are independent, the mean is correctly represented by the group-specific means, and errors within groups are normally distributed with a common variance \(\sigma^2\). The usual pooled estimate of that variance is the residual mean square, denoted MSE, and the residual degrees of freedom are \(df=n-k\). Under these assumptions the t test and confidence interval below have their stated exact t distributions. In a regression with covariates, the mean model and error assumptions must instead be appropriate for that fitted regression; adjusted group means can be correlated, so their covariance must be included.
Let \(\hat{\boldsymbol{\mu}}\) be the vector of estimated means and let \(\widehat{\operatorname{Cov}}(\hat{\boldsymbol{\mu}})\) be its estimated covariance matrix. For coefficient vector \(\mathbf{c}\), the estimate is \(\hat{L}=\mathbf{c}^{\mathsf T}\hat{\boldsymbol{\mu}}\), and its estimated variance is the quadratic form below. The covariance terms are essential whenever the estimated means are correlated.
For independent group sample means from the one-way model, the estimated covariance matrix is diagonal, with the variance estimate for group \(j\)'s sample mean equal to \(\mathrm{MSE}/n_j\). Thus the contrast variance simplifies to \(\mathrm{MSE}\sum_j c_j^2/n_j\). This formula uses squared coefficients: signs determine the contrast’s direction, but variance contributions from independent means cannot be negative.
To test \(H_0:L=0\) against a two-sided alternative \(H_a:L\ne 0\), calculate \(t=\hat{L}/SE(\hat{L})\). Under the stated model and null hypothesis, this statistic follows a t distribution with the regression residual degrees of freedom. A confidence interval is \(\hat{L}\pm t^*SE(\hat{L})\), using the appropriate t critical value. The estimate and interval retain the outcome’s units; the t statistic does not.
Worked Comparisons
Worked Example: One Group Versus an Unequally Weighted Average
Suppose a hypothetical study compares three groups on an outcome measured in points. The fitted one-way model gives estimated means of 25 points for A, 20 for B, and 22 for C. Each group has \(n_j=10\), MSE is \(25\) points squared, and \(df=30-3=27\). Before examining the outcomes, the planned question is whether A differs from an average that gives B 25% weight and C 75% weight.
The contrast is \(L=\mu_A-0.25\mu_B-0.75\mu_C\), with coefficients \(1,-0.25,-0.75\), which sum to zero. Its estimate is \( \hat{L}=25-0.25(20)-0.75(22)=25-5-16.5=3.5 \) points.
Under the independent, common-variance group model, its estimated variance is \( 25\{1^2/10+(-0.25)^2/10+(-0.75)^2/10\}=25(0.1625)=4.0625 \) points squared. Therefore \(SE(\hat{L})=\sqrt{4.0625}=2.016\) points and \(t=3.5/2.016=1.736\), with 27 degrees of freedom.
A two-sided 95% interval uses \(t^*\approx2.052\), giving \(3.5\pm2.052(2.016)=3.5\pm4.136\), or approximately \((-0.636,7.636)\) points. Since zero lies in the interval, these data do not show a difference at the two-sided 5% level. The estimate is 3.5 points, but it is not precise enough here to distinguish the contrast from zero.
Worked Example: Comparing One Group With Three Equally Weighted Groups
Consider hypothetical data on an outcome measured in units. Four groups have estimated means \(68/3\), 17, 18, and 19 units, with sample sizes 8, 9, 10, and 9. Suppose the one-way model has MSE \(=16\) units squared and \(df=32\). The planned comparison is group A against the equally weighted average of B, C, and D. Assume independent normal errors with common variance and a correctly specified group-mean model.
The coefficients are \(1,-1/3,-1/3,-1/3\), so \( \hat{L}=68/3-(17+18+19)/3=68/3-18=14/3=4.667 \) units. The variance estimate is \( 16\{1/8+(1/9)/9+(1/9)/10+(1/9)/9\}=2.57284 \) units squared, and \(SE(\hat{L})=\sqrt{2.57284}=1.604\) units.
The test statistic is \(t=(14/3)/1.604\approx2.909\), with 32 degrees of freedom. The two-sided p-value is approximately 0.006537. If the null hypothesis of no contrast were true and the model assumptions held, a t statistic at least this extreme in either direction would occur with probability about 0.006537. The result is evidence that group A’s mean differs from the equal-weight average of the other three means; it does not establish that group membership caused the difference.
Worked Example: Including Covariances for Adjusted Means
Suppose a hypothetical regression reports adjusted means of 30, 34, and 32 units for three groups. The planned contrast is group 1 minus the equal-weight average of groups 2 and 3, so \(\mathbf{c}=(1,-0.5,-0.5)^{\mathsf T}\) and \(\hat{L}=30-0.5(34)-0.5(32)=-3\) units. Assume the fitted mean model and error assumptions are suitable for t inference, the residual degrees of freedom are 40, and the estimated covariance matrix of the adjusted means has diagonal entries 4, 3, and 2 and off-diagonal entries 1, 0.5, and 0.5 in the order (1,2), (1,3), and (2,3), in units squared.
Expanding \(\mathbf{c}^{\mathsf T}\widehat{\operatorname{Cov}}(\hat{\boldsymbol{\mu}})\mathbf{c}\) gives the three diagonal contributions plus twice each covariance contribution: \(4+0.25(3)+0.25(2)+2(1)(-0.5)(1)+2(1)(-0.5)(0.5)+2(-0.5)(-0.5)(0.5)=5.25-1.25=4.0\) units squared. Thus \(SE(\hat{L})=\sqrt{4.0}=2.000\) units, and \(t=-3/2=-1.500\).
With 40 degrees of freedom, the two-sided p-value is approximately 0.141. The observed adjusted contrast is 3 units below zero, but the test does not provide strong evidence against a zero contrast at the 5% level. Omitting the covariance contributions would give the wrong standard error and could change the test conclusion.
Planning, Interpretation, and Common Pitfalls
A planned contrast is useful because its weights make the scientific comparison explicit and interpretable. It is not a license to search through many possible contrasts after seeing the data and report only the most favorable one. When several contrasts are examined, the interpretation of their inferential results requires additional care; the single-contrast calculations here do not, by themselves, address that broader issue.
- Do not confuse equal weights with equal sample sizes. An equal-weight average of group means gives each group the same weight even if their sample sizes differ. Use the weights that match the question.
- Do not omit covariance terms. For correlated adjusted means, use the full covariance matrix. A formula based only on separate standard errors assumes zero covariance and may be inappropriate.
- Do not interpret a contrast as a causal effect automatically. A regression contrast describes a difference in modeled means. Causal interpretation requires a suitable study design and assumptions beyond the contrast calculation.
- Do not treat a nonsignificant result as proof of equality. A wide interval can include zero and still include differences that matter. Report the estimate and uncertainty in the outcome’s units.
Check Your Understanding
Try these questions before moving on.
- Write coefficients for comparing group A with an average that gives group B 40% weight and group C 60% weight. Verify that they sum to zero.
- Why does adding the same constant to every group mean leave a contrast unchanged?
- In the independent-groups model, which quantities enter the estimated variance of a contrast?
- Why must covariances be included when calculating the standard error of a contrast of correlated adjusted means?
- A contrast estimate is 2.4 units with standard error 1.2 units. What is its t statistic, and what does its sign indicate about the direction of the estimated contrast?