########################################################################################### #iterative ########################################################################################### iterative.bicreg.se <- function (x, y, maxVars, threshold = 1, adaptive.threshold =1, wt = rep(1, length(y)), strict = FALSE, OR = 20, maxCol = maxVars+1, drop.factor.levels = TRUE, nbest = 10){ ## consider maxVars at a time in traditional bma ## drop variables with probne0 < threhsold / probne0 < (min(probne0) +threshold) ### rank X matrix temp <- NULL for(i in 1:ncol(x)) temp <- c(temp , summary(lm(y~x[,i]))$r.squared) x2 <- x[, rev(order(temp))] this.x <- x2[ , 1:maxVars ] x2 <- x2[ , -c(1:maxVars )] loop<-function(){ bicreg.call <-function() bicreg.se(this.x, y, wt = wt, strict = strict, OR=OR, maxCol = maxCol, drop.factor.levels=drop.factor.levels, nbest=nbest) # while we have variables left to be processed. adapt.dropped <- NULL while(ncol(x2)>0){ # traditional bma model <- bicreg.call() # drop varaibles dropme <- which(model$probne0 < threshold ) # adaptive threshold if(length(dropme)==0){ dropme <- which(model$probne0 < min(model$probne0 + adaptive.threshold)) print(paste(model$namesx[dropme], "with probne0 = ", model$probne0[dropme], "dropped in adaptive threshold step")) adapt.dropped <- c(adapt.dropped, model$namesx[dropme]) } # update variables to consider this.x<-this.x[ , -c(dropme)] if(ncol(x2)