Skip to content
Back to formatted view

Raw Message

Message-ID: <20050330182413.87952.qmail@web25610.mail.ukl.yahoo.com>
Date: 2005-03-30T18:24:13Z
From: vasilis pappas
Subject: Step error

Could anyone tell me what am I doing wrong?

> pro<-function(indep,dep){
+  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) 
+ }
> pro(m,q)
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 :

> d<-data.frame(m)
> form<-formula(lm(q~.,data=d))
>
forward<-step(lm(q~X1,data=d),scope=form,trace=0,direction='f')
> forward

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