Contrasts

For general linear model Y = XB + E with data Y, design matrix X, parameter vector B, and (independent) errors E, a contrast is a linear combination of the parameters c’B. Usually c is a column vector, defining a simple contrast of the parameters, assessed via an SPM{T}. More generally, c can be also a matrix, defining an “F-contrast” assessed via an SPM{F}.
The vector/matrix c contains the contrast weights and must be specified to define the contrast. The null hypothesis is that the linear combination c’B is zero. The order of the parameters in the parameter (column) vector B, and hence the order to which parameters are referenced in the contrast weights vector c, is determined by the construction of the design matrix.
There are two types of contrast in SPM: simple contrasts for SPM{T}, and “F-contrasts” for SPM{F}.
For a thorough theoretical treatment, see the Human Brain Function book and the statistical literature referenced therein.
To demonstrate the use of the contrast vector I have prepared some examples.

Anova

sample1   sample2   sample3
1 0 0
1 0 0
0 1 0
0 1 0
0 0 1
0 0 1
T-contrasts
-1 1 0 sample2>sample1
1 0 -1 sample1>sample3
2 -1 -1 sample1>(sample2 + sample3)
F-contrast
2/3
-1/3
-1/3
-1/3
2/3
-1/3
-1/3
-1/3
2/3
any difference between the samples

Ancova

sample1   sample2   covariate1
1 0 1
1 0 2
1 0 3
0 1 4
0 1 5
0 1 6
T-contrasts
-1 1 0 sample2>sample1 (without confounding effects of covariate1)
1 -1 0 sample1>sample2 (without confounding effects of covariate1)
F-contrast
0.5
-0.5
-0.5
0.5
0
0
any difference between sample1 and sample2 (without confounding effects of covariate1)

Simple regression

Please take care that the columns are switched if you use the default ‘Multiple regression’ design. In this case covariate1 is in column 1 followed by sample1 and you also have to switch the contrast vector.

sample1   covariate1
1 1
1 2
1 3
1 4
1 5
1 6
T-contrasts
0 1 positive correlation with covariate1
0 -1 negative correlation with covariate1

Interaction

sample1   sample2   covariate1@sF21   covariate1@sF22
1 0 1 0
1 0 2 0
1 0 3 0
0 1 0 4
0 1 0 5
0 1 0 6
T-contrasts
0 0 -1 1 regression slope sample2 > sample1
0 0 1 -1 regression slope sample1 > sample2
F-contrast
0
0
0
0
-0.5
0.5
0.5
-0.5
any difference between regression slopes

F-contrast: Effects of interest

If you would like to use the old SPM2 F-contrast “Effects of interest” the respective contrast vector is:
eye(n)-1/n
where n is the number of columns of interest. This F-contrast is often helpful for plotting parameter estimates of effects of interest.