[Rd] lm(rnorm(1000)~rnorm(1000)) kills rw1000 (PR#476)
Thomas Lumley
thomas@biostat.washington.edu
Tue, 7 Mar 2000 11:24:06 -0800 (PST)
On Tue, 7 Mar 2000, Thomas Lumley wrote:
> On Tue, 7 Mar 2000, Prof Brian D Ripley wrote:
>
> > On Tue, 7 Mar 2000 cberry@tajo.ucsd.edu wrote:
> >
> > > It does not happen on rw0901 or rw0651 (? version number ?) on my HOME
> > > PC. Nor on R 0.90.1 under Solaris
> >
> > It does happen on R 1.0.0 on Solaris and on rw1000 on a real PC.
>
> Something strange is happening where we ensure that the response does not
> appear on the rhs of the formula.
>
> At lines 1643ff of model.c we count how many columns of the design matrix
> are needed for each model term. This count is not done if the term is the
> response, which leaves the count uninitialised.
>
> We then use this uninitialised count at 1673ff to construct the assign
> attribute.
Incidentally, this command doesn't do what the user probably thinks it
does: lm thinks that the rnorm(1000) on the lhs is the same as the one on
the rhs and drops it from the model, fitting only an intercept.
I think this is unavoidable, since model.matrix can't be expected to know
whether an arbitrary function is deterministic or random.
The work-around is
a<-rnorm(1000)
b<-rnorm(1000)
lm(a~b)
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._