C package:stats R Documentation _S_e_t_s _C_o_n_t_r_a_s_t_s _f_o_r _a _F_a_c_t_o_r _D_e_s_c_r_i_p_t_i_o_n: Sets the '"contrasts"' attribute for the factor. _U_s_a_g_e: C(object, contr, how.many, ...) _A_r_g_u_m_e_n_t_s: 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)'. ...: additional arguments for the function 'contr'. _D_e_t_a_i_l_s: For compatibility with S, 'contr' can be 'treatment', 'helmert', 'sum' or 'poly' (without quotes) as shorthand for 'contr.treatment' and so on. _V_a_l_u_e: The factor 'object' with the '"contrasts"' attribute set. _R_e_f_e_r_e_n_c_e_s: Chambers, J. M. and Hastie, T. J. (1992) _Statistical models._ Chapter 2 of _Statistical Models in S_ eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. _S_e_e _A_l_s_o: 'contrasts', 'contr.sum', etc. _E_x_a_m_p_l_e_s: ## reset contrasts to defaults options(contrasts=c("contr.treatment", "contr.poly")) tens <- with(warpbreaks, C(tension, poly, 1)) attributes(tens) ## tension SHOULD be an ordered factor, but as it is not we can use aov(breaks ~ wool + tens + tension, data=warpbreaks) ## show the use of ... The default contrast is contr.treatment here summary(lm(breaks ~ wool + C(tension, base=2), data=warpbreaks)) # following on from help(esoph) model3 <- glm(cbind(ncases, ncontrols) ~ agegp + C(tobgp, , 1) + C(alcgp, , 1), data = esoph, family = binomial()) summary(model3)