R-beta: a bug in the lm function ?

Thomas Lumley thomas at biostat.washington.edu
Fri Dec 19 18:44:05 CET 1997

On Fri, 19 Dec 1997, Kung-Sik Chan wrote:
> I ran a function called BoxCox, taken from the book by Venables and
> Ripley, for checking the need for power transformation. This function
> works fine using the version 0.50 of R, but gives an error message
> with version 0.60.
> The lm function in version 0.60 is different from that in version 0.50.
> Is there a bug in the new lm function?

> >  BoxCox(lm(log.O2UP~BOD+TKN+TS+TVS+COD,data=alr222a))
> Error in terms.default(formula, data = data) : unused argument to function

No, there is a bug in terms.default(). The generic terms() function
accepts a number of arguments controlling how terms objects are
constructed. As terms.default() just extracts a terms object that is
already present it doesn't use these arguments. However, it hasn't been
written to ignore them.  A fix is to redefine terms.default() to ignore
these arguments

	terms.default<-function (x,...) x$terms

In the future it may be desirable to change terms.default so that it
recomputes the terms object if the other arguments are present, in case
they are different from the original versions.  

Thomas Lumley
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :

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 mailing list