Learn R Programming

vcrpart (version 0.2-3)

contr.wsum: Contrast matrices

Description

Returns a category-weighted contrast matrix

Usage

contr.wsum(x, weights = rep.int(1.0, length(x)))

Arguments

x
a factor vector
weights
a vector of weights with the same length as x.

Value

  • A matrix with nlevels(x) rows and nlevels(x)- 1 columns.

Details

Computes a contrast matrix similar to contr.sum. The contrast for the last category are however weighted by the sum of weights of each category.

See Also

contr.sum

Examples

Run this code
x <- factor(rep(LETTERS[1:3], c(10, 20, 30)))
contr.wsum(x)

Run the code above in your browser using DataLab