contr.diff {ic.infer}R Documentation

Contrast function for factors with ordered values that yields increment coefficients

Description

Function contr.diff is a contrast function for factors with ordered values. Coefficients for factors formatted with contr.diff are the increments from the current level to the neighbouring lower level.

Usage

contr.diff(n, contrasts = TRUE)

Arguments

n

vector of levels or integer number of levels

contrasts

logical indicating whether contrasts should be computed

Details

The design matrix for an ordered factor formatted with contr.diff consists of ones for the current level itself and all lower levels. Thus, the estimated coefficients for each level are the estimated differences to the next lower level.

With this coding, the matrix ui in functions of package ic.infer can be chosen as the identity matrix for monotonicity constraints on the factor.

Value

a matrix with a row for each level and a column for each dummy variable (when applied to a factor in a linear model).

Author(s)

Ulrike Groemping, BHT Berlin

See Also

See also ic.test, ic.est, orlm, contrasts for other contrast functions

Examples

## mu, Sigma and covariance matrix
means <- c(3,5,2,7)
## contrast matrix
contr.diff(4)
## design matrix
X <- cbind(rep(1,4),contr.diff(4))
## estimated coefficients
solve(t(X)%*%X,t(X)%*%means)

[Package ic.infer version 1.1-7 Index]