# Contrast (statistics)

In statistics, particularly in analysis of variance and linear regression, a contrast is a linear combination of variables (parameters or statistics) whose coefficients add up to zero, allowing comparison of different treatments.

## Definitions

Let $\theta _{1},\ldots ,\theta _{t}$ be a set of variables, either parameters or statistics, and $a_{1},\ldots ,a_{t}$ be known constants. The quantity $\sum _{i=1}^{t}a_{i}\theta _{i}$ is a linear combination. It is called a contrast if $\sum _{i=1}^{t}a_{i}=0$ . Furthermore, two contrasts, $\sum _{i=1}^{t}a_{i}\theta _{i}$ and $\sum _{i=1}^{t}b_{i}\theta _{i}$ , are orthogonal if $\sum _{i=1}^{t}a_{i}b_{i}=0$ .

## Examples

Let us imagine that we are comparing four means, $\mu _{1},\mu _{2},\mu _{3},\mu _{4}$ . The following table describes three possible contrasts:

$\mu _{1}$ $\mu _{2}$ $\mu _{3}$ $\mu _{4}$ 1 -1 0 0
0 0 1 -1
1 1 -1 -1

The first contrast allows comparison of the first mean with the second, the second contrast allows comparison of the third mean with the fourth, and the third contrast allows comparison of the average of the first two means with the average of the last two.

In a balanced one-way analysis of variance, using orthogonal contrasts has the advantage of completely partitioning the treatment sum of squares into non-overlapping additive components that represent the variation due to each contrast. Consider the numbers above: each of the rows sums up to zero (hence they are contrasts). If we multiply each element of the first and second row and add those up, this again results in zero, thus the first and second contrast are orthogonal and so on.

## Sets of contrast

• Orthogonal contrasts are a set of contrasts in which, for any distinct pair, the sum of the cross-products of the coefficients is zero (assume sample sizes are equal). Although there are potentially infinite sets of orthogonal contrasts, within any given set there will always be a maximum of exactly k – 1 possible orthogonal contrasts (where k is the number of group means available).
• Polynomial contrasts are a special set of orthogonal contrasts that test polynomial patterns in data with more than two means (e.g., linear, quadratic, cubic, quartic, etc.).
• Orthonormal contrasts are orthogonal contrasts which satisfy the additional condition that, for each contrast, the sum squares of the coefficients add up to one.

## Background

A contrast is defined as the sum of each group mean multiplied by a coefficient for each group (i.e., a signed number, cj). In equation form, $L=c_{1}{\bar {X}}_{1}+c_{2}{\bar {X}}_{2}+\cdots +c_{k}{\bar {X}}_{k}\equiv \sum _{j}c_{j}{\bar {X}}_{j}$ , where L is the weighted sum of group means, the cj coefficients represent the assigned weights of the means (these must sum to 0 for orthogonal contrasts), and ${\bar {X}}$ j represents the group means. Coefficients can be positive or negative, and fractions or whole numbers, depending on the comparison of interest. Linear contrasts are very useful and can be used to test complex hypotheses when used in conjunction with ANOVA or multiple regression. In essence, each contrast defines and tests for a particular pattern of differences among the means.

Contrasts should be constructed "to answer specific research questions", and do not necessarily have to be orthogonal.

A simple (not necessarily orthogonal) contrast is the difference between two means. A more complex contrast can test differences among several means (ex. with four means, assigning coefficients of –3, –1, +1, and +3), or test the difference between a single mean and the combined mean of several groups (e.g., if you have four means assign coefficients of –3, +1, +1, and +1) or test the difference between the combined mean of several groups and the combined mean of several other groups (i.e., with four means, assign coefficients of –1, –1, +1, and +1). The coefficients for the means to be combined (or averaged) must be the same in magnitude and direction, that is, equally weighted. When means are assigned different coefficients (either in magnitude or direction, or both), the contrast is testing for a difference between those means. A contrast may be any of: the set of coefficients used to specify a comparison; the specific value of the linear combination obtained for a given study or experiment; the random quantity defined by applying the linear combination to treatment effects when these are themselves considered as random variables. In the last context, the term contrast variable is sometimes used.

Contrasts are sometimes used to compare mixed effects. A common example is the difference between two test scores — one at the beginning of the semester and one at its end. Note that we are not interested in one of these scores by itself, but only in the contrast (in this case — the difference). Since this is a linear combination of independent variables, its variance equals the weighted sum of the summands' variances; in this case both weights are one. This "blending" of two variables into one might be useful in many cases such as ANOVA, regression, or even as descriptive statistics in its own right.

An example of a complex contrast would be comparing 5 standard treatments to a new treatment, hence giving each old treatment mean a weight of 1/5, and the new sixth treatment mean a weight of −1 (using the equation above). If this new linear combination has a mean zero, this will mean that there is no evidence that the old treatments are different from the new treatment on average. If the sum of the new linear combination is positive, there is some evidence (the strength of the evidence is often associated with the p-value computed on that linear combination) that the combined mean of the 5 standard treatments is higher than the new treatment mean. Analogous conclusions obtain when the linear combination is negative. However, the sum of the linear combination is not a significance test, see testing significance (below) to learn how to determine if the contrast computed from the sample is significant.

The usual results for linear combinations of independent random variables mean that the variance of a contrast is equal to the weighted sum of the variances. If two contrasts are orthogonal, estimates created by using such contrasts will be uncorrelated. If orthogonal contrasts are available, it is possible to summarize the results of a statistical analysis in the form of a simple analysis of variance table, in such a way that it contains the results for different test statistics relating to different contrasts, each of which are statistically independent. Linear contrasts can be easily converted into sums of squares. SScontrast = ${\tfrac {n(\sum c_{j}{\bar {X}}_{j})^{2}}{\sum c_{j}^{2}}}$ , with 1 degree of freedom, where n represents the number of observations per group. If the contrasts are orthogonal, the sum of the SScontrasts = SStreatment. Testing the significance of a contrast requires the computation of SScontrast.

## Testing significance

SScontrast also happens to be a mean square because all contrasts have 1 degree of freedom. Dividing $MS_{contrast}$ by $MS_{error}$ produces an F-statistic with one and $df_{error}$ degrees of freedom, the statistical significance of Fcontrast can be determined by comparing the obtained F statistic with a critical value of F with the same degrees of freedom.
{"ft_lang_label":"__label__en","ft_lang_prob":0.85332096,"math_prob":0.9902951,"size":8480,"snap":"2021-31-2021-39","text_gpt3_token_len":1876,"char_repetition_ratio":0.15077867,"word_repetition_ratio":0.038575668,"special_character_ratio":0.23926887,"punctuation_ratio":0.13644978,"nsfw_num_words":1,"has_unicode_error":false,"math_prob_llama3":0.9996192,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"im_url_duplicate_count":[null,5,null,5,null,10,null,5,null,10,null,5,null,5,null,5,null,null,null,null,null,null,null,null,null,5,null,null,null,5,null,5,null,5,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-28T21:04:17Z\",\"WARC-Record-ID\":\"<urn:uuid:4a393689-f4e9-42fb-a2e8-e20e7580a757>\",\"Content-Length\":\"81206\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:49730f8a-6811-4be9-8fd6-23060802c8fe>\",\"WARC-Concurrent-To\":\"<urn:uuid:dee0bfac-52dd-4449-932d-fd83dee99b7e>\",\"WARC-IP-Address\":\"208.80.154.224\",\"WARC-Target-URI\":\"https://en.wikipedia.org/wiki/Contrast_(statistics)\",\"WARC-Payload-Digest\":\"sha1:FLOLSTBPA2MATHRI3CAXVJQ3NPZMYZWU\",\"WARC-Block-Digest\":\"sha1:F4GR2RTS6JJDU4UIUIMFIAQJSMBCSPVY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780060882.17_warc_CC-MAIN-20210928184203-20210928214203-00195.warc.gz\"}"}