| contr.deviation | R Documentation |
Deviation-coding is a contrast-coding scheme that compares each level to the average of the other levels. It is often confused with sum-coding, which compares each level to the average of all levels. In the binary case, deviation coding works out to \( (+0.5,-0.5) \); in the ternary case and beyond, the coding is a little bit more involved.
contr.deviation(n, contrasts = TRUE, sparse = FALSE)
n |
See |
contrasts |
See |
sparse |
See |
contr.deviation starts by calling contr.sum and hence accepts the same arguments as it does.
A matrix of deviation-coded contrasts.
contr.sum
iris$Species <- contr.deviation(iris$Species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.