Successive Differences Contrast Coding
A coding for factors based on successive differences.
contr.sdif(n, contrasts = TRUE, sparse = FALSE)
- The number of levels required.
- logical: Should there be
n - 1columns orthogonal to the mean (the default) or
ncolumns spanning the space?
- logical. If true and the result would be sparse (only
contrasts = FALSE), return a sparse matrix.
The contrast coefficients are chosen so that the coded coefficients in a one-way layout are the differences between the means of the second and first levels, the third and second levels, and so on. This makes most sense for ordered factors, but does not assume that the levels are equally spaced.
TRUE, a matrix with
n - 1columns, and the
nidentity matrix if
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition, Springer.
(A <- contr.sdif(6)) zapsmall(ginv(A))