Hi - I am trying to substitute for "the_other_y" in the code below. I want y2 and y3 to be there when i is 1, y1 and y3 to be there when i is 2 and y1 and y2 to be there when i is 3. I'm sure it's to do with what format the data should be in and I've tried alldata[,-i], but it fits all the columns of alldata except i rather than each column one at a time. I've tried changing the data i.e. as.matrix or as.list but that's still not the right format. I'm sure it's a simple trick, but don't know how to search it out. Any help on how to search this as well as the solution would be greatly appreciated.
y1<-rnorm(20);y2<-rnorm(20);y3<-rnorm(20);alldata<-cbind(y1,y2,y3) library(MASS) for (i in 1:3) {mod<-lm(get(paste("y", i, sep=""))~1) stepAIC(mod, scope=list(lower=~1, upper=~the_other_y))} Thanks Paul -- View this message in context: http://r.789695.n4.nabble.com/All-other-variables-in-upper-scope-arg-for-stepAIC-tp3005183p3005183.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.