[R] Error using lm(z~x+y,data)
james.lindsey at luc.ac.be
Thu Jun 21 10:16:30 CEST 2001
> Duncan Murdoch <murdoch at stats.uwo.ca> writes:
> > I don't know why one version works and the other doesn't, but I've
> > noticed problems in the past when using "data" as a variable name, and
> > in fact even the first version fails for me when I type it exactly as
> > you did.
> > I suspect the strange behaviour you saw is related to the fact that
> > data is a matrix rather than a data.frame, and indeed everything is
> > fine if I change your code to
> I got it now: The problem is that eval accept an integer as its envir
> argument (as in sys.call()) so lm and friends do too. If you pass a
> numeric object, like a matrix, the first element is extracted and
> coerced to integer. That'll explain why the behaviour changes when a
> column is multiplied by 149...
> The reason the example ever worked was that x,y,z from the global env.
> got picked up.
This is a typical example of one of the reasons why I do not trust
lm/glm. If the data argument is used, the function should look nowhere
else but in the data.frame supplied (as all my functions do with my
data objects). As it stands, one is never sure what data are actually
being analyzed. I brought this up at the first Vienna meeting, and
everyone disagreed with me.
> O__ ---- Peter Dalgaard Blegdamsvej 3
> c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
> r-help 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-help-request at stat.math.ethz.ch
r-help 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-help-request at stat.math.ethz.ch
More information about the R-help