[R] update?

roger koenker rkoenker at uiuc.edu
Mon Jan 2 19:51:08 CET 2006

I'm having problems with environments and update() that
I expect have a simple explanation.  To illustrate, suppose
I wanted to make a very primitive Tukey one-degree-of-
freedom for nonadditivity test and naively wrote:

nonadd <- function(formula){
         f <- lm(formula)
         v <- f$fitted.values^2
         g <- update(f, . ~ . + v)

x <- rnorm(20)
y <- rnorm(20)
nonadd(y ~ x)

Evidently, update is looking in the environment producingf f and
doesn't find v, so I get:

Error in eval(expr, envir, enclos) : Object "v" not found

This may (or may not) be related to the discussion at:

but in any case I hope that someone can suggest how such
difficulties can be circumvented.

url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    rkoenker at uiuc.edu            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820

More information about the R-help mailing list