contr.SAS {lme4} | R Documentation |
Return a matrix of contrasts suitable for comparison with SAS output.
contr.SAS(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 functions creates contrast matrices for use in
fitting analysis of variance and regression models. It is a trivial
modification of contr.treatment
that sets the
base level to be the last level instead of the first level. The
coefficients produced when using these contrasts should be equivalent to
those produced by SAS.
A matrix with n
rows and k
columns, with k=n-1
if
contrasts
is TRUE
and k=n
if contrasts
is
FALSE
.
Chambers, J. M. and Hastie, T. J. (1992) Statistical models. Chapter 2 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
(cT <- contr.SAS(5)) all(crossprod(cT) == diag(4)) # TRUE: even orthonormal