Hi, May be this helps: set.seed(232) mat1<-matrix(sample(1:100,80,replace=TRUE),ncol=8) #with 8 columns dat1<-data.frame(mat1) ?names(dat1)[1]<-"Y" ?form1<-as.formula(paste("Y~",paste(names(dat1)[2:8],collapse="+"))) #should change "8" to "400" fit.final<-lm(form1,data=dat1) fit.final #Call: #lm(formula = form1, data = dat1) # #Coefficients: #(Intercept)?????????? X2?????????? X3?????????? X4?????????? X5?????????? X6? # 143.763081??? -0.009030??? -1.844810???? 1.436647??? -0.005407??? -0.050101? #???????? X7?????????? X8? #?? 0.563285??? -1.901918? A.K. ________________________________ From: farnoosh sheikhi <farnoosh_81 at yahoo.com> To: arun <smartpink111 at yahoo.com> Sent: Thursday, November 15, 2012 6:14 PM Subject: Stepwise Hi there, I want to apply the following code fo my data with 400 predictors. I was wondering if there is an alternative way instead of typing 400 predictors for the following code. I really appreciate your help. fit0<-lm(Y~1, data= mydata) fit.final<- lm(Y~X1+X2+X3+.....+X400, data=mydata) ??? step(fit0, scope=list(lower=fit0, upper=fit.final), data=mydata, direction="forward") step(fit.final, scope=list(lower=fit.final, upper=fit0), data=mydata, direction="backward") Best,Farnoosh Sheikhi?