[Rd] under certain conditions, model.matrix appears to lack one (PR#647)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Mon, 28 Aug 2000 08:28:59 +0200 (MET DST)


On Sun, 27 Aug 2000 rnassar@duke.edu wrote:

> Dear R Team,
> 
> # Summary of the problem: setting contrasts as 
>    > contrasts(g) <- contr.treatment 
> or > contrasts(g) <- matrix(c(1,-1,0),ncol=1)
> (i.e. without quotes around `contr.treatment' or `contr.sum', etc.)
> and fitting an lm model without an intercept results in a model matrix
> that lacks one column.

Right, but first is not allowed by (?contrasts)

     ctr: either a matrix whose columns give coefficients for contrasts
          in the levels of `x', or the (quoted) name of a function
          which computes such matrices.

and the second is arguably correct: you chose to use only two columns.
However, the behaviour is different in the development version, 
which does not code x in models such as this, and so does not
have the problem.

That is not precisely what S does, but seems a sane way of interpreting the
contradictory information given (which is that you don't want an intercept
and that you only want two columns for the coding matrix for x!  That
applies to the function case too: there the coding matrix is evaluated
before knowing if contrast are required, that is using argument contrasts =
FALSE).

-- 
Brian D. Ripley,                  ripley@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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._