These functions are used for creating contrast matrices for use in
fitting analysis of variance and regression models. The columns of
the resulting matrices contain contrasts which can be used for coding
a factor with `n`

levels. The returned value contains the
computed contrasts. If the argument `contrasts`

is `FALSE`

a square indicator matrix (the dummy coding) is returned **except**
for `contr.poly`

(which includes the 0-degree, i.e.constant,
polynomial when `contrasts = FALSE`

).

`contr.helmert`

returns Helmert contrasts, which contrast the
second level with the first, the third with the average of the first
two, and so on. `contr.poly`

returns contrasts based on
orthogonal polynomials. `contr.sum`

uses ‘sum to zero
contrasts’.

`contr.treatment`

contrasts each level with the baseline level
(specified by `base`

): the baseline level is omitted. Note that
this does not produce ‘contrasts’ as defined in the standard
theory for linear models as they are not orthogonal to the intercept.

`contr.SAS`

is a wrapper for `contr.treatment`

that sets
the base level to be the last level of the factor. The coefficients
produced when using these contrasts should be equivalent to those
produced by many (but not all) SAS procedures.

For consistency, `sparse`

is an argument to all these contrast
functions, however `sparse = TRUE`

for `contr.poly`

is typically pointless and is rarely useful for
`contr.helmert`

.