[Rd] y ~ X -1 , X a matrix

Dirk Eddelbuettel edd at debian.org
Thu Mar 18 02:41:54 CET 2010

On 17 March 2010 at 16:32, Ross Boylan wrote:
| While browsing some code I discovered a call to lm that used a formula y
| ~ X - 1, where X was a matrix.
| Looking through the documentation of formula, lm, model.matrix and maybe
| some others I couldn't find this useage (R 2.10.1).  Is it anything I
| can count on in future versions?  Is there documentation I've
| overlooked?

>From help(formula):


       In addition to ‘+’ and ‘:’, a number of other operators are useful
       in model formulae.  [...] The
       ‘-’ operator removes the specified terms, so that ‘(a+b+c)^2 -
       a:b’ is identical to ‘a + b + c + b:c + a:c’.  It can also used to
       remove the intercept term: ‘y ~ x - 1’ is a line through the
       origin.  A model with no intercept can be also specified as ‘y ~ x
       + 0’ or ‘y ~ 0 + x’.

What exactly are you questioning? That X is a matrix? That doesn't take
away from the fact that the rest is a formula.


  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!

More information about the R-devel mailing list