Description Usage Arguments Details Value Author(s) See Also Examples

Contrast functions for factors that are appropriate for penalized regression.

1 2 3 | ```
contr.none(n, contrasts)
contr.diff(n, contrasts = TRUE)
``` |

`n` |
A vector of levels for a factor, or the number of levels. |

`contrasts` |
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 `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.

`contr.diff`

returns a matrix with `n`

rows and `k`

columns, with
`k=n-1`

if contrasts is `TRUE`

and `k=n`

if contrasts is `FALSE`

.

`contr.none`

returns a matrix with `n`

rows and `n`

columns, except when `n=2`

when it returns a matrix with 2 rows and one column.

Jelle Goeman: [email protected]

`penalized`

, `contr.treatment`

, `contr.poly`

, `contr.helmert`

,
`contr.SAS`

, `contr.sum`

.

1 2 3 4 5 6 7 8 | ```
# Three levels
levels <- LETTERS[1:3]
contr.none(levels)
contr.diff(levels)
# Two levels
levels <- LETTERS[1:2]
contr.none(levels)
``` |

penalized documentation built on May 30, 2017, 1:20 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.