nlme (version 3.1-1)

contr.SAS: Contrast Matrices

Description

Return a matrix of contrasts corresponding to the parameterization for a factor used in SAS.

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 function is used for creating contrast matrices for use in fitting analysis of variance and regression models. The columns of the resulting matrix contain contrasts which can be used for coding a factor with n levels. The returned value contains the computed contrasts. If the argument contrasts is FALSE then a square indicator matrix is returned.

These contrasts are similar to those from contr.treatment except that they represent shifts relative to the last level of the factor, not the first level. This generates the same parameterization for a linear model as is used in SAS (see http://www.sas.com).

See Also

contr.treatment

Examples

Run this code
contr.SAS(4)

Run the code above in your browser using DataLab