Skip to content
Prev 246904 / 398506 Next

Step command failing for lm function

I think I just figured it out.

x is a matrix.
l <- lm(y ~ x) works for generating a model, but fails.  (It considers x
as a single item to add/remove for step.)

Step does work if I use a data.frame

foo <- cbind(y,x)

l <- lm(y ~ ., data=foo)

Now step(l) works.

I guess R doesn't look at the "x" in the first version to iterate
through the different variable.  It does, however iterate when the "."
is used in a formula.
On 1/10/11 1:13 AM, Joshua Wiley wrote: