From tlumley at u.washington.edu  Mon Aug  4 14:49:36 2003
From: tlumley at u.washington.edu (Thomas Lumley)
Date: Mon Aug  4 22:49:32 2003
Subject: [Rd] unexpected behaviour in lm() (PR#3657)
In-Reply-To: <200308042011.h74KBrJH006556@pubhealth.ku.dk>
Message-ID: <Pine.A41.4.44.0308041340240.64952-100000@homer22.u.washington.edu>

On Mon, 4 Aug 2003 ottk@bms.com wrote:

>
> > lm(c(1:10) ~ c(1:10))
>
> Call:
> lm(formula = c(1:10) ~ c(1:10))
>
> Coefficients:
> (Intercept)
>         5.5

It's a feature. Unfortunately it's not a well documented feature.  A
variable on the right-hand side of the formula is removed if it has the
same name as the left-hand side of the formula.  This is done in
model.matrix.

It's a feature because
 - it's always been done that way
 - it allows  y~. to specify all the columns of a data frame *except* y

It needs to be documented. Unfortunately the logical place is
help(model.matrix), where no-one will look.

	-thomas


[Rd] unexpected behaviour in lm() (PR#3657)
Thomas Lumley