Skip to content
Prev 66762 / 398525 Next

Step error

Could anyone tell me what am I doing wrong?
+  d<-data.frame(indep)
+  form<-formula(lm(dep~.,data=d))
+ 
forward<-step(lm(dep~X1,data=d),scope=form,trace=0,direction='f')
+  return(forward) 
+ }
Error in inherits(x, "data.frame") : Object "d" not
found

Where q is a vector with the dependent variable's
values
and m is a matrix containing the values of the
independent variables.

While writing the above without a function form has no
problem, that is :
forward<-step(lm(q~X1,data=d),scope=form,trace=0,direction='f')
Call:
lm(formula = q ~ X1 + X2 + X5, data = d)

Coefficients:
(Intercept)           X1           X2           X5  
    -15.798        8.765        6.774       -4.245  


Thank you in advance!
Vasilis