These functions are used for creating contrast matrices for use in fitting penalized
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.
contr.none
returns an identity matrix except when the number of levels is 2,
in which case it returns a single contrast. contr.none
ensures that all levels
of an unordered factor are treated symmetrically in a penalized regression model.
contr.diff
returns a lower triangular matrix of ones if contrasts=FALSE
and the same matrix without its first column if contrasts=TRUE
. This makes sure
that penalization is done on the difference between successive levels of an ordered factor.
It is not appropriate for unordered factors.