From a Scientific Question to a Coefficient Combination
Regression software reports coefficients one at a time, but a scientific question may concern something those coefficients express only together. For example, a question about the difference between predictions at two settings of several predictors can involve more than one coefficient. A linear contrast provides a precise way to represent that question: it is a weighted sum of model coefficients, with weights chosen to match the comparison.
The key task here is defining the quantity of interest—not calculating its uncertainty or deciding whether it differs from a benchmark. Those are separate steps. First, specify what scientific comparison is wanted; then express that quantity using the regression model’s coefficients.
The weights are part of the definition of the scientific question. They are not regression coefficients, and they are not chosen by the fitting procedure. They specify which coefficients matter and how they are combined. A weight can be zero, which means the corresponding coefficient does not contribute to the contrast.
A contrast is linear in the coefficients because each coefficient appears only multiplied by a fixed weight and the resulting terms are added. For instance, \(2\beta_1-\beta_2\) is linear. A product such as \(\beta_1\beta_2\), a ratio such as \(\beta_1/\beta_2\), or a square such as \(\beta_1^2\) is not a linear contrast.
Why Differences in Predictions Produce Contrasts
Consider a regression model with a conditional mean that is linear in its coefficients:
Here \(Y\) is the response, \(x_1,\ldots,x_k\) are predictors, and \(\beta_0,\ldots,\beta_k\) are the model coefficients. To compare the mean response at two specified predictor settings, write the model’s mean at each setting and subtract. The intercept cancels, and each remaining coefficient is multiplied by the change in its predictor. The resulting difference is a linear contrast.
This subtraction is a useful justification for the definition: it shows how coefficient weights can arise directly from a question about predicted responses, rather than being an arbitrary algebraic construction.
Worked Example: Comparing Two Predictor Settings
Suppose a hypothetical regression model predicts a laboratory measurement \(Y\), in milligrams per liter, from two predictors:
The scientific question is: how much does the model’s mean response differ between a setting with \(x_1=3,\ x_2=6\) and one with \(x_1=1,\ x_2=2\)? The comparison is defined by subtracting the second predicted mean from the first:
The contrast is therefore \(L=2\beta_1+4\beta_2\). Its weights are 2 for \(\beta_1\), 4 for \(\beta_2\), and 0 for the intercept. The contrast describes a difference in mean response, in milligrams per liter, between these two predictor settings. It is not generally the same as either slope coefficient by itself.
The weights reflect the chosen settings. Changing the comparison changes the weights, even though the fitted regression model remains the same. This is why it helps to state the scientific comparison in words and specify its direction before writing the algebra.
A Single Coefficient Can Also Be the Quantity of Interest
Some scientific questions are represented by just one coefficient. In a model with an intercept and an indicator \(T\) for whether a hypothetical participant received a program (\(T=1\)) or not (\(T=0\)), suppose the model is
At the same value of \(z\), the difference in model means between \(T=1\) and \(T=0\) is \(\beta_1\). In the language of linear combinations, this is the contrast \(L=0\beta_0+1\beta_1+0\beta_2=\beta_1\). Thus, a single-coefficient question is a special case of a linear contrast, with one weight equal to 1 and the others equal to 0.
This relationship clarifies the distinction between a quantity and a test. The contrast specifies what parameter or combination is relevant. A test asks a further question about that quantity, such as whether it equals a particular benchmark. A test of one coefficient concerns one special contrast; a question that combines coefficients concerns a different contrast. Defining the contrast does not, by itself, perform a test.
Worked Example: Comparing Two Categories Under Reference Coding
Suppose a hypothetical model uses category A as its reference and includes indicators \(B\) and \(C\) for categories B and C:
For category A, \(B=0\) and \(C=0\); for category B, \(B=1\) and \(C=0\); for category C, \(B=0\) and \(C=1\). At the same value of \(z\), the model’s mean for B minus its mean for C is
The requested comparison is the contrast \(L=\beta_B-\beta_C\), with weights 1 for \(\beta_B\), \(-1\) for \(\beta_C\), and 0 for the intercept and \(\beta_z\). The reference category does not appear in the final expression because both means were written using the same reference-based model and the shared terms cancel.
This example also illustrates why reading one coefficient alone may not answer the stated question. \(\beta_B\) describes B relative to A, and \(\beta_C\) describes C relative to A; their difference describes B relative to C.
Using Fitted Coefficients to Describe an Estimated Contrast
Once a contrast is defined, its estimated value is obtained by applying the same weights to the fitted coefficients. If the estimated coefficients are \(\hat{\beta}_0,\ldots,\hat{\beta}_k\), then the estimated contrast corresponding to \(L\) is formed by replacing each \(\beta_j\) in its definition with \(\hat{\beta}_j\). This substitution estimates the quantity; it does not change what the quantity means.
For example, if the fitted model in the first worked example had coefficients \(\hat{\beta}_1=1.2\) and \(\hat{\beta}_2=0.15\), the estimated difference for the specified predictor settings would be
The model’s estimated mean response at the first setting is 3.0 milligrams per liter higher than at the second setting. This numerical estimate alone does not describe its precision or establish that the underlying difference is nonzero. Those require additional calculations and interpretation.
Weights, Units, and the Word “Contrast”
A contrast’s units follow from the quantity it represents. In a difference between two predicted responses, the result has the units of the response. In the first worked example, the weights represent changes in predictor settings, and \(2\beta_1+4\beta_2\) has units of milligrams per liter. The terms in the sum must be compatible with the stated comparison; interpreting a coefficient without its predictor scale can obscure those units.
In some settings, particularly comparisons among group means, the word contrast is used more narrowly for a weighted sum whose weights add to zero. That restriction is appropriate for many comparisons of means because it removes a shared overall level. In regression discussions, “linear contrast of coefficients” is also commonly used for a general fixed linear combination, including one coefficient alone. Here the term refers to the general weighted sum defined above; the scientific question and the formula make clear what is being compared.
A useful discipline is to keep three things separate:
- The target: the response, slope, difference, or other model quantity the question concerns.
- The weights: the fixed numbers that translate that target into coefficients.
- The estimate: the value obtained by applying those weights to fitted coefficients.
Writing the target in words first helps prevent a common error: choosing a coefficient because its label sounds relevant, even though the question actually concerns a difference or combination.
Common Mistake: Treating One Relevant Coefficient as the Whole Answer
A common mistake is to see that a comparison involves categories B and C, notice that the software reports a coefficient for B, and use that coefficient as the B-versus-C comparison. This is incorrect when the model uses A as the reference: the B coefficient is B versus A, not B versus C. The correction is to write both model means at the settings of interest, subtract them in the requested direction, and simplify. In the example above, that gives \(\beta_B-\beta_C\).
Another pitfall is to assume every expression containing coefficients is a contrast. The fixed-weight condition matters: \(3\beta_1+2\beta_2\) is a linear contrast, but \(\beta_1\beta_2\) is not. Also, reversing the order of a difference reverses every sign. If the requested quantity is “first setting minus second setting,” the formula must preserve that direction.
Name the two quantities, settings, or model features being compared, and specify the direction if it is a difference.
Use the same coefficient definitions and the predictor settings stated in the question.
Subtract or otherwise combine the model expressions to identify the fixed weight on each coefficient.
Confirm that the resulting sum represents the stated target, has the right direction, and has an interpretable unit.
Why Defining the Contrast Matters
A regression model may contain many coefficients, but a practical question usually targets a particular feature of the model. Expressing that feature as a contrast makes the target explicit and prevents a mismatch between the scientific question and the quantity reported. It also makes later estimation and inference possible: once the exact combination is defined, its estimate and uncertainty can be calculated for that combination rather than inferred from separate coefficient results.
A carefully defined contrast does not guarantee that a model is appropriate for the scientific setting. The meaning of every coefficient and combination still depends on the model specification and its conditions. But the algebra provides a necessary first step: it identifies exactly which model quantity is being discussed.
Check Your Understanding
For each question, identify the relevant contrast or explain why the proposed expression is not a linear contrast.
- In a model \(E(Y\mid x)=\beta_0+\beta_1x+\beta_2x^2\), express the difference in mean response at \(x=4\) minus the mean response at \(x=1\) as a weighted sum of coefficients.
- A model uses category A as the reference and has coefficients \(\beta_B\) and \(\beta_C\) for indicators B and C. What contrast represents the model mean for C minus the model mean for B at the same covariate values?
- Why is \(\beta_1\beta_2\) not a linear contrast, even though it is an expression involving regression coefficients?
- Explain why a test of \(\beta_B=0\) does not directly test whether categories B and C have equal model means under reference coding.
- If the question asks for “setting 2 minus setting 1,” what should happen to the sign of the contrast if the subtraction order is reversed?