[R] factors in glm

John Maindonald john.maindonald at anu.edu.au
Sat Oct 23 02:46:59 CEST 1999


Peter Dalgaard wrote:

> Jim Lindsey <jlindsey at alpha.luc.ac.be> writes:
> 
> > Is there any logical reason why glm prints out the labels of factor
> > levels after variable names when baseline contrasts (contr.treatment)
> > are used but the codes for the levels when mean contrasts (contr.sum)
> > are used? Jim
> 
> Hmmm. We have in contr.sum
> 
>         cont <- array(0, c(lenglev, lenglev - 1), list(levels, 
>             NULL))
>         cont[col(cont) == row(cont)] <- 1
>         cont[lenglev, ] <- -1
> 
> I'd put list(level,levels[-lenglev]) there, but someone seems to have
> decided that it wouldn't make sense? (I would also have coded the
> value as rbind(diag(lenglev-1),-1), but that's another matter).
> 
> In the case of Helmert contrasts, one would by similar logic end up
> with the same names as for contr.treatment, which would be confusing
> (as if Helmert contrasts weren't confusing enough...!). Of course, you
> currently cannot tell the difference between .sum and .helmert - you
> only get a signal that something is "unusual".

I am not quite sure of the import of "similar logic".  For the Helmert
contrasts the levels are contrasted with a changing baseline, if that
is the way one wants to think about them.  So short of some such
scheme as 2-1, 3-12, 4-123, attaching level labels surely does not
make sense.

Treatment contrasts surely should be labeled with the level name. 

> What I'd really want is a way of labeling the summary() output with
> the kind of contrast used. Ideally, in my mind, summary.(g)lm should
> produce output like (for an age x sex interaction with age using
> contr.sum and sex using contr.treat)
> 
> age(S).sex(T)
>   0-40.M
>   41-50.M
>   51-60.M

I would support that.  Some such form of documentation should be
automatic, not reliant on the user to remember to note down each
time what contrasts were used.

An options setting migh allow different alternative forms of 
labelling.

John Maindonald               email : john.maindonald at anu.edu.au        
Statistical Consulting Unit,  phone : (6249)3998        
c/o CMA, SMS,                 fax   : (6249)5549  
John Dedman Mathematical Sciences Building
Australian National University
Canberra ACT 0200
Australia
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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