Skip to content

Step function

2 messages · Matt Pocernich, Thomas Lumley

#
I am having problem using the step function for a linear regression model.  I've created an initial model containing only the intercept.  Then using the step function, I've selected three variables to be considered for the model.
Analysis of Variance Table

Response: MEDV
           Df Sum Sq Mean Sq F value Pr(>F)
Residuals 505  42716      85
Start:  AIC= 2246.51 
 MEDV ~ 1 

Error in eval(expr, envir, enclos) : Object "MEDV" not found
I am not clear as to why the MEDV object ( the variable I am trying to predict) is not found.  I receive an identical message using the command > step(x0.lm).  

I am using R version 1.1.1.  I can run all the examples successfully.  Also, I realize that there are differences in the algorithms, but I can run the code above  on Splus version 5.  

Thanks 

Matt Pocernich 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20001129/2f219ad5/attachment.html
#
On Wed, 29 Nov 2000, Matt Pocernich wrote:

            
This is a bug, I think.  The problem is that the data frame is called
x. If it were called something else there wouldn't be a problem, so the
workaround is to change the name of your data frame.


Looking at traceback() the problem is that the data frame `x' is being
searched for in the environment of add1.lm by model.frame.lm().  In most
cases it doesn't find it there and goes back to the global environment,
but if the data frame is called `x' (or one of 17 other things) it finds
the wrong thing in environment(add1.lm).

In R1.1.1 I'm not sure what can be done about this -- model.frame.lm
doesn't know where to find `x' and there isn't a general solution.  In
R1.2 we have more information and should be able to look in
environment(formula(lmobject)), but we aren't doing that yet.

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._