Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu May 8 10:06:46 MEST 2003
On 8 May 2003, Peter Dalgaard BSA wrote:
> Torsten Hothorn <Torsten.Hothorn at rzmail.uni-erlangen.de> writes:
> > > >From model.matrix, only the number of levels is passed: src/main/model.c
> > > line 1626 (in R-devel and probably also 1.7.0).
> > Thank you! Therefore one cannot compute contrasts that depend on
> > the number of observations at each level, right? Looking at the code in
> > `contr.treatment' that handles this case: may I conclude that this is on
> > the wishlist?
> That's not what it does. It just allows you to give the vector of
> levels instead of the count. At the moment, this seems to be used only
> for labeling:
> > contr.treatment(4:1)
> 3 2 1
> 4 0 0 0
> 3 1 0 0
> 2 0 1 0
> 1 0 0 1
> Notice that C() allows a matrix argument, so even if model.matrix
> doesn't use this feature, you could still use y~C(g,contr.xxx(levs))
> in modeling.
> One place where something like this might be useful, but (one of my
> ancient gripes) isn't, is for generating polynomial contrasts over a
> non-equidistant level set.
How could one detect that? A level set is just a set of labels, in order
for an ordered factor. One needs more information as to how (or whether)
to interpret it as `non-equidistant'. Given such information (e.g. in a
"score.levels" attribute) we could do this fairly easily: but one can also
set the contrast matrix via a contrasts arg, via contrasts<-() or (more
clumsily I think given the way the model is printed) via C().
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel