contr.sum(n, contrasts=T) contr.poly(n, contrasts=T) contr.helmert(n, contrasts=T) contr.treatment(n, contrasts=T)
contr.sum produces coefficients satisfying the constraint that their sum is zero (the traditional analysis of variance parametrization).
contr.poly creates orthogonal polynomials of degree 1, 2, etc., either on equally spaced points if n was a single number, or on the points specified by x. Columns are scaled to have norm 1.
For contr.helmert, contrast i is the difference between level i+1 and the average of levels 1:i.
In contr.treatment the contrasts are just levels 2 through n of the category.
These functions are usually not called directly, but supplied as the coding for a category in a data frame.
To set the default contrast coding, change the contrasts option.
# set contrasts to polynomial on x0 (a global dataset) contrasts(my.vble) <- function(n,contrasts=F)contr.poly(x0,contrasts)options(contrasts=c("contr.treatment", "contr.poly"))