Contrast functions for factors that are appropriate for penalized regression.
1 2 3
A vector of levels for a factor, or the number of levels.
A logical indicating whether contrasts should be computed. This
argument is ignored in
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
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.
contr.diff returns a matrix with
n rows and
k columns, with
k=n-1 if contrasts is
k=n if contrasts is
contr.none returns a matrix with
n rows and
n columns, except when
when it returns a matrix with 2 rows and one column.
Jelle Goeman: [email protected]
1 2 3 4 5 6 7 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.