R: Iterated Bayesian Model Averaging variable selection for...
iBMA
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.
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.
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