# Difference

**Difference or reverse Helmert contrasts.** Compares categories of an independent variable with the mean of
the previous categories of the variable. The general matrix form is

```
mean ( 1/k 1/k 1/k ... 1/k)
df(1) ( -1 1 0 ... 0)
df(2) ( -1/2 -1/2 1 ... 0)
. .
. .
df(k-1) (-1/(k-1) -1/(k-1) -1/(k-1) ... 1)
```

where *k* is the number of categories
for the independent variable. For example, the difference contrasts
for an independent variable with four categories are as follows:

```
( 1/4 1/4 1/4 1/4)
( -1 1 0 0)
(-1/2 -1/2 1 0)
(-1/3 -1/3 -1/3 1)
```