[R] stepAIC problem

Hiroto Miyoshi h_m_ at po.harenet.ne.jp
Sun Oct 5 14:46:04 CEST 2003


Dear R-users

I have a probelm running stepAIC in R1.7.1
I wrote a program which used stepAIC as a part of it,
and it worked fine while I was using the previous version of
R1.7.0. However, I found the program did not work any more.
Now, R produces a message which tells
"Error in as.data.frame.default(data) :
can't coerce function into a data.frame" every time I
run the part of stepAIC.
Even the following small program shows the same problem.
Is stepAIC of the new version altered?
Could anyone help me please?

--small example
> library(MASS)
> x1<-runif(100)
> x2<-runif(100)
> x3<-runif(100)
> x4<-runif(100)
> x5<-runif(100)
> y<-x1+x2+x3+runif(100)
> t<-data.frame(y=y,x1=x1,x2=x2,x3=x3,x4=x4,x5=x5)
> x<-lm(y~x1+x2+x3+x4+x5,data=t)
> stepAIC(x)
Start:  AIC= -247.61
 y ~ x1 + x2 + x3 + x4 + x5

       Df Sum of Sq      RSS      AIC
- x5    1 3.747e-06    7.456 -249.608
- x4    1     0.026    7.483 -249.254
<none>                 7.456 -247.609
- x1    1     4.866   12.322 -199.375
- x2    1     8.182   15.639 -175.543
- x3    1     8.597   16.054 -172.922
Error in as.data.frame.default(data) : can't coerce function into a
data.frame

---------------------------
Hiroto Miyoshi (三好弘人)
h_m_ at po.harenet.ne.jp




More information about the R-help mailing list