Return a matrix of contrasts suitable for comparison with SAS output.
Usage
contr.SAS(n, contrasts = TRUE)
Arguments
n
a vector of levels for a factor, or the number of levels.
contrasts
a logical indicating whether contrasts should be
computed.
Value
A matrix with n rows and k columns, with k=n-1 if
contrasts is TRUE and k=n if contrasts is
FALSE.
Details
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.
References
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.