Sets Contrasts for a Factor
Usage
C(object, contr, how.many)
Arguments
object
|
a factor or ordered factor
|
contr
|
which contrasts to use. Can be a matrix with one row for
each level of the factor or a suitable function like
contr.poly or a character string giving the name of the function
|
how.many
|
the number of contrasts to set, by default one less
than nlevels(object).
|
Description
Sets the "contrasts" attribute for the factor.Details
For compatibility with S, contr can be treatment,
helmert, sum or poly (without quotes) as shorthand
for contr.treatment and so on.Value
The factor with the "contrasts" attribute set.Author(s)
B.D. RipleySee Also
contrastsExamples
data(warpbreaks)
attach(warpbreaks)
tens <- C(tension, poly, 1)
attributes(tens)
detach()
## tension SHOULD be an ordered factor, but as it is not we can use
aov(breaks ~ wool + tens + tension, data=warpbreaks)
data(esoph) # following on from help(esoph)
model3 <- glm(cbind(ncases, ncontrols) ~ agegp + C(tobgp,, 1) +
C(alcgp,, 1), data = esoph, family = binomial())
summary(model3)