lme4 (version 0.95-4)

contr.SAS: Contrast Matrices for SAS-like Results

Description

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.

See Also

contrasts, contr.treatment

Examples

Run this code
(cT <- contr.SAS(5))
all(crossprod(cT) == diag(4)) # TRUE: even orthonormal

Run the code above in your browser using DataCamp Workspace