powered by
Returns a category-weighted contrast matrix
contr.wsum(x, weights = rep.int(1.0, length(x)), sparse = FALSE)
A matrix with nlevels(x) rows and nlevels(x)- 1
nlevels(x)
nlevels(x)- 1
columns.
a factor vector
a vector of weights with the same length as x.
x
ogical indicating if the result should be sparse (of class dgCMatrix), using package Matrix.
dgCMatrix
Reto Burgin
Computes a contrast matrix similar to contr.sum. The reference category is however weighted by the sum of weights of the other categories.
contr.sum
x <- factor(rep(LETTERS[1:3], c(10, 20, 30))) contr.wsum(x) # standard call contr.wsum(x, sparse = TRUE) # using a sparse matrix
Run the code above in your browser using DataLab