R-beta: a suggestion for constraints

Thomas Lumley thomas at biostat.washington.edu
Fri Sep 4 17:55:50 CEST 1998


On Fri, 4 Sep 1998, Jim Lindsey wrote:

> One small thing that would be very nice for baseline-constraint (R
> calls them treatment for some reason) factor variables would be an
> option to specify which category is baseline. This would be extremely
> useful in experimental contexts, especially medicine. For the moment,

I actually agree here. There seem to be two possibilities. One is to make
it easy to use as.factor() to create factors with code 1 being whatever
level you want. The other is to make it easy to use contrasts by providing
a contr.treatment(baseline) function that creates treatment contrasts with
the specified baseline level, so you could do
glm(outcome~trt,contrasts=list(trt=contr.treatment("PL"))

The first seems a more natural solution to this specific problem, as we
have a natural baseline category and the problem is that as.factor doesn't
know that. In fact the function to change is factor(), which does all the
work of factor creation.  I have a draft version of factor(,baseline=)
but I would like to test it some more (and see if other people think it is
a good idea).  I would personally prefer to call the argument 'reference'
rather than 'baseline' but I don't really care all that much.

BTW, R calls it "contr.treatment" because S does. You could easily define
an alias "contr.whatever.you.like" for it using the .Alias() function.

	-thomas


Thomas Lumley
Asst Professor, Biostatistics, Box 357232
University of Washington, Seattle, WA 98195-7232








-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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