Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

contr.mean

Contrast Matrix for Constraints about the Mean


Description

Return a matrix of contrasts for constraints about the mean.

Usage

contr.mean(n, contrasts = TRUE)

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

Examples

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

Utilities for Nonlinear Regression and Repeated Measurements Models

v1.1.5
GPL-2
Authors
Bruce Swihart [cre, aut], Jim Lindsey [aut] (Jim created this package, Bruce is maintaining the CRAN version)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.