contr.mean: Contrast Matrix for Constraints about the Mean

Description Usage Arguments Details Value See Also Examples

View source: R/util.r View source: R/contrast.r

Description

Return a matrix of contrasts for constraints about the mean.

Usage

1

Arguments

n

A vector of levels for a factor or the number of levels.

contrasts

A logical value indicating whether or not contrasts should be computed.

Details

This function corrects contr.sum to display labels properly.

Value

A matrix of computed contrasts with n rows and k columns, with k=n-1 if contrasts is TRUE and k=n if contrasts is FALSE. The columns of the resulting matrices contain contrasts which can be used for coding a factor with n levels.

See Also

contrasts, C, and contr.sum.

Examples

1
2
3
4
5
6
7
8
oldop <- options(contrasts=c("contr.sum","contra.poly"))
y <- rnorm(30)
x <- gl(3,10,labels=c("First","Second","Third"))
glm(y~x)
options(contrasts=c("contr.mean","contra.poly"))
x <- gl(3,10,labels=c("First","Second","Third"))
glm(y~x)
options(oldop)

rmutil documentation built on May 27, 2018, 5:03 p.m.