[R] data level for stepwise

Constantine Frangakis cfrangak at jhsph.edu
Tue Dec 3 20:21:06 CET 2002


This may be of interest to R users.

The command step () for stepwise regression, which asks for
an object like lm(formula, data=mydata), apparently is looking for
``mydata'' in the global environment, not the environment at which
step() is called. That is, when step is called
from inside another function in which the data that step() calls has also
been updated inside that function, step() does not use the most recently
updated data, but instead looks outside the function. (This problem does
not happen for the lm function). Although the problem can be solved by
using the assign function, to avoid potential bugs it would be useful to
know which functions like step() do this.

C Frangakis




More information about the R-help mailing list