Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.