I have a list of regression models, but I would like to run stepwise with forward method. I tried to modify this function with lapply, but it doesn't really work..
I have a data
test<-data.frame(X1=rnorm(50,mean=50,sd=10),
X2=rnorm(50,mean=5,sd=1.5),
X3=rnorm(50,mean=200,sd=25))
test$X1[10]<-5
test$X2[10]<-5
test$X3[10]<-530
I run regression models
varlist <- names(test)
models <- lapply(varlist, function(x) {
lm(substitute(i~., list(i = as.name(x))), data = data
})
And then run stepwise..
lapply(models, function(x){step(x,direction="forward")})
However, it doesn't affect my modification of stepwise methods- forward.. How I could modify built in function on lapply?
Thank you so much in advance.