[R] Help with contrast settings in glm and lm

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 17 13:14:24 CET 2000


> Date: Fri, 14 Jan 2000 12:14:21 +0100 (CET)
> From: Jesús María Frías Celayeta <iosu at ensia.inra.fr>
> 	I am trying to validate some R code that we have been porting from
> S (ellipse library) and now we are on the step of trying with some
> examples to see if the code gives the same results as in S. I have
> received some results from S-PLUS 4.5 help examples and I have some
> trouble reproducing them. Apparently S+ uses helbert contrasts in
> categorical variables as a default and R uses contrasts based in
> orthogonal polynomials. However, in R there exists contr.helmert and I
> would like to actually set R in a way that a regression procedure will use
> helmert type contrasts (as in S+), in order to have the same results. 
> 
> 	Is there a way to change the default contrasts used in regression
> (lm and glm) so that after it the regression uses those contrasts? I have
> tried options() with no too much sucess. I am probably loosing some page
> in the manual, so just in the case I excuse myself in advance. 

You need

options(contrasts=c("contr.helmert", "contr.poly"))

but you have been changing the wrong one.  The first is for unordered
factors, the second for ordered factors. The R help page does not say so, and
should: I have altered it to give the details and include this example.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list