contr.SAS {nlme}R Documentation

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.

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).

Value

A matrix with n rows and k columns, with k=n-1 if contrasts is TRUE and k=n if contrasts is FALSE.

Author(s)

Jose Pinheiro jcp@research.bell-labs.com, Douglas Bates bates@stat.wisc.edu

See Also

contr.treatment

Examples

contr.SAS(4)

[Package Contents]