iBMA {BMA} R Documentation

## Iterated Bayesian Model Averaging variable selection for generalized linear models, linear models or survival models.

### Description

This function implements the iterated Bayesian Model Averaging method for variable selection. This method works by making repeated calls to a Bayesian model averaging procedure, iterating through the variables in a fixed order. After each call to the Bayesian model averaging procedure only those variables which have posterior probability greater than a specified threshold are retained, those variables whose posterior probabilities do not meet the threshold are replaced with the next set of variables. The order in which the variables are to be considered is usually determined on the basis of the some measure of goodness of fit calculated univariately for each variable.

### Usage

```iBMA.glm(x, ...)
iBMA.bicreg(x, ...)
iBMA.surv(x, ...)

## S3 method for class 'matrix'
iBMA.glm(x, Y, wt = rep(1, nrow(X)),
thresProbne0 = 5, glm.family, maxNvar = 30,
nIter = 100, verbose = FALSE, sorted = FALSE,
factor.type = TRUE, ...)

## S3 method for class 'matrix'
iBMA.glm(x, Y, wt = rep(1, nrow(X)),
thresProbne0 = 5, glm.family, maxNvar = 30,
nIter = 100, verbose = FALSE, sorted = FALSE,
factor.type = TRUE, ...)

## S3 method for class 'iBMA.intermediate.glm'
iBMA.glm(x, nIter = NULL,
verbose = NULL, ...)

## S3 method for class 'matrix'
iBMA.bicreg(x, Y, wt = rep(1, nrow(X)),
thresProbne0 = 5, maxNvar = 30, nIter = 100,
verbose = FALSE, sorted = FALSE, ...)

## S3 method for class 'data.frame'
iBMA.bicreg(x, Y, wt = rep(1, nrow(X)),
thresProbne0 = 5, maxNvar = 30, nIter = 100,
verbose = FALSE, sorted = FALSE, ...)

## S3 method for class 'iBMA.intermediate.bicreg'
iBMA.bicreg(x,
nIter = NULL, verbose = NULL, ...)

## S3 method for class 'matrix'
iBMA.surv(x, surv.t, cens,
wt = rep(1, nrow(X)), thresProbne0 = 5,
maxNvar = 30, nIter = 100, verbose = FALSE,
sorted = FALSE, factor.type = TRUE, ...)

## S3 method for class 'data.frame'
iBMA.surv(x, surv.t, cens,
wt = rep(1, nrow(X)), thresProbne0 = 5,
maxNvar = 30, nIter = 100, verbose = FALSE,
sorted = FALSE, factor.type = TRUE, ...)

## S3 method for class 'iBMA.intermediate.surv'
iBMA.surv(x, nIter = NULL,verbose = NULL, ...)
```

### Arguments

 `x` a matrix or data.frame of independent variables, or else an object of class `iBMA.glm.intermediate`, `iBMA.bicreg.intermediate` or `iBMA.surv.intermediate` that contains the current state of an incomplete selection. `Y` a vector of values for the dependent variable. `surv.t` a vector of survival times. `cens` a vector of indicators of censoring (0=censored 1=uncensored) `wt` an optional vector of weights to be used. `thresProbne0` a number giving the probability threshold for including variables as a percent. `glm.family` glm family. `maxNvar` a number giving the maximum number of variables to be considered in a model. `nIter` a number giving the maximum number of iterations that should be run. `verbose` a logical value specifying if verbose output should be produced or not `sorted` a logical value specifying if the variables have been sorted or not. If `FALSE` then `iBMA.glm` will sort the variables prior to running any iterations. `factor.type` a logical value specifying how variables of class "factor" are handled. A factor variable with d levels is turned into (d-1) dummy variables using a treatment contrast. If 'factor.type = TRUE', models will contain either all or none of these dummy variables. If 'factor.type = FALSE', models are free to select the dummy variables independently. In this case, factor.prior.adjust determines the prior on these variables. `...` other parameters to be passed to `bic.glm`, `bicreg` or `bic.surv`

### Details

These methods can be run in a 'batch' mode by setting `nIter` to be larger than the number of variables. Alternatively, if `nIter` is set to be small, the procedure may return before all of the variables have been examined. In this case the returned result of the call will be of class 'iBMA.X.intermediate', and if iBMA.X is called with this result as the input, `nIter` more iterations will be run.

If on any iteration there are no variables that have posterior probability less than the threshold, the variable with the lowest posterior probability is dropped.

### Value

An object of either type iBMA.X, or of type iBMA.X.intermediate, where 'X' is either 'glm', 'bicreg' or 'surv'. Objects of type 'iBMA.X.intermediate' consist of a list with components for each parameter passed into iBMA.X as well as the following components:

 `sortedX ` a matrix or data.frame containing the sorted variables. `call ` the matched call. `initial.order ` the inital ordering of the variables. `nVar ` the number of variables. `currentSet` a vector specifying the set of variables currently selected. `nextVar ` the next variable to be examined `current.probne0` the posterior probabilities for inclusion for each of the variables in the current set of variables. `maxProbne0 ` the maximum posterior probability calculated for each variable `nTimes ` the number of times each variable has been included in the set of selected variables `currIter ` the current iteration number `new.vars ` the set of variables that will be added to the current set during the next iteration `first.in.model` a vector of numbers giving the iteration number that each variable was first examined in. A value of NA indicates that a variable has not yet been examined. `iter.dropped ` a vector giving the iteration number in which each variable was dropped from the current set. A value of NA indicates that a variable has not yet been dropeed.

Objects of the type iBMA.glm contain in addition to all of these elements the following components:

 `nIterations` the total number of iterations that were run `selected` the set of variables that were selected (in terms of the initial ordering of the variables) `bma` an object of type 'bic.X' containing the results of the Bayesian model averaging run on the selected set of variables.

### Note

The parameters `verbose` and `nIter` can be changed between sets of iterations.

The parameter `sorted` specifies if the variables should be sorted prior to iteration, if `sorted` is set to `FALSE` then the variables are sorted according to the decreasing single variable model R2 values for iBMA.bicreg or the single variable model increasing Chi-sq P-values for iBMA.glm and iBMA.surv. Subsequent reference to variables is in terms of this ordered set of variables.

It is possible to obtain degenerate results when using a large number of predictor variables in linear regression. This problem is much less common with logistic regression and survival analysis.

### Author(s)

Ka Yee Yeung, kayee@AT@u.washington.edu, Adrian Raftery raftery@AT@stat.washington.edu, Ian Painter ian.painter@AT@gmail.com

### References

Yeung, K.Y., Bumgarner, R.E. and Raftery, A.E. (2005). ‘ Bayesian Model Averaging: Development of an improved multi-class, gene selection and classification tool for microarray data.’ Bioinformatics, 21(10), 2394-2402

`bic.glm`, `bicreg`, `bic.surv`, `summary.iBMA.bicreg`, `print.iBMA.bicreg`, `orderplot.iBMA.bicreg`

### Examples

```
## Not run:
############ iBMA.glm
library("MASS")
data(birthwt)
y<- birthwt\$lo
x<- data.frame(birthwt[,-1])
x\$race<- as.factor(x\$race)
x\$ht<- (x\$ht>=1)+0
x<- x[,-9]
x\$smoke <- as.factor(x\$smoke)
x\$ptl<- as.factor(x\$ptl)
x\$ht <- as.factor(x\$ht)
x\$ui <- as.factor(x\$ui)

### add 41 columns of noise
noise<- matrix(rnorm(41*nrow(x)), ncol=41)
colnames(noise)<- paste('noise', 1:41, sep='')
x<- cbind(x, noise)

iBMA.glm.out<- iBMA.glm( x, y, glm.family="binomial",
factor.type=FALSE, verbose = TRUE,
thresProbne0 = 5 )
summary(iBMA.glm.out)

## End(Not run)

## Not run:
################## iBMA.surv
library(survival)
data(veteran)

surv.t<- veteran\$time
cens<- veteran\$status
veteran\$time<- NULL
veteran\$status<- NULL
lvet<- nrow(veteran)
invlogit<- function(x) exp(x)/(1+exp(x))
# generate random noise, 34 uniform variables
# and 10 factors each with 4 levels
X <- data.frame(matrix(runif(lvet*34), ncol=34),
matrix(letters[1:6][(rbinom(10*lvet, 3, .5))+1],
ncol = 10))
colnames(X) <- c(paste("u",1:34, sep=""),paste("C",1:10, sep=""))
veteran_plus_noise<- cbind(veteran, X)

test.iBMA.surv <- iBMA.surv(x = veteran_plus_noise,
surv.t = surv.t, cens = cens,
thresProbne0 = 5, maxNvar = 30,
factor.type = TRUE, verbose = TRUE,
nIter = 100)

test.iBMA.surv
summary(test.iBMA.surv)

## End(Not run)

## Not run:
############ iBMA.bicreg ... degenerate example
library(MASS)
data(UScrime)
UScrime\$M<- log(UScrime\$M); UScrime\$Ed<- log(UScrime\$Ed);
UScrime\$Po1<- log(UScrime\$Po1); UScrime\$Po2<- log(UScrime\$Po2);
UScrime\$LF<- log(UScrime\$LF); UScrime\$M.F<- log(UScrime\$M.F)
UScrime\$Pop<- log(UScrime\$Pop); UScrime\$NW<- log(UScrime\$NW);
UScrime\$U1<- log(UScrime\$U1); UScrime\$U2<- log(UScrime\$U2);
UScrime\$GDP<- log(UScrime\$GDP); UScrime\$Ineq<- log(UScrime\$Ineq)
UScrime\$Prob<- log(UScrime\$Prob); UScrime\$Time<- log(UScrime\$Time)
noise<- matrix(rnorm(35*nrow(UScrime)), ncol=35)
colnames(noise)<- paste('noise', 1:35, sep='')
UScrime_plus_noise<- cbind(UScrime, noise)

y<- UScrime_plus_noise\$y
UScrime_plus_noise\$y <- NULL

# run 2 iterations and examine results
iBMA.bicreg.crime <- iBMA.bicreg( x = UScrime_plus_noise,
Y = y, thresProbne0 = 5, verbose = TRUE, maxNvar = 30, nIter = 2)
summary(iBMA.bicreg.crime)
orderplot(iBMA.bicreg.crime)

## End(Not run)

## Not run:
# run from current state until completion
iBMA.bicreg.crime <- iBMA.bicreg( iBMA.bicreg.crime, nIter = 200)
summary(iBMA.bicreg.crime)
orderplot(iBMA.bicreg.crime)

## End(Not run)

set.seed(0)
x <- matrix( rnorm(50*30), 50, 30)
lp <- apply( x[,1:5], 1, sum)
iBMA.bicreg.ex <- iBMA.bicreg( x = x,  Y = lp, thresProbne0 = 5, maxNvar = 20)

explp <- exp(lp)
prob <- explp/(1+explp)
y=rbinom(n=length(prob),prob=prob,size=1)
iBMA.glm.ex <- iBMA.glm( x = x, Y = y, glm.family = "binomial",
factor.type = FALSE, thresProbne0 = 5, maxNvar = 20)

cat("\n\n CAUTION: iBMA.bicreg can give degenerate results when")
cat(" the number of predictor variables is large\n\n")

```

[Package BMA version 3.18.15 Index]