Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

contr.dummy

Contrast Matrices


Description

Returns a matrix of contrasts.

Usage

contr.dummy(n, contrasts = TRUE)
contr.ordinal(n, contrasts = TRUE)
contr.metric(n, contrasts = TRUE)

Arguments

n

A vector containing levels of a factor, or the number of levels.

contrasts

A logical value indicating whether contrasts should be computed.

Details

contr.dummy is standard dummy-coding, contr.metric has the same effect like as.numeric (makes sense of course only for ordered variables). contr.ordinal computes contrasts for ordinal variables.

Value

A matrix with n rows and n-1 columns for contr.ordinal, a matrix with n rows and n columns for contr.dummy and a vector of length n for contr.metric.

Author(s)

Klaus P. Schliep klaus.schliep@gmail.com

References

Hechenbichler K. and Schliep K.P. (2004) Weighted k-Nearest-Neighbor Techniques and Ordinal Classification, Discussion Paper 399, SFB 386, Ludwig-Maximilians University Munich (http://www.stat.uni-muenchen.de/sfb386/papers/dsp/paper399.ps)

See Also

Examples

contr.metric(5)
contr.ordinal(5)
contr.dummy(5)

kknn

Weighted k-Nearest Neighbors

v1.3.1
GPL (>= 2)
Authors
Klaus Schliep [aut, cre], Klaus Hechenbichler [aut], Antoine Lizee [ctb]
Initial release
2016-03-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.