For.MC3.REG {BMA}  R Documentation 
Helper function for MC3.REG
Description
Helper function for MC3.REG which implements each step of the MetropolisHastings algorithm.
Usage
For.MC3.REG(i, g, Ys, Xs, PI, K, nu, lambda, phi, outs.list)
Arguments
i 
the current iteration number. 
g 
a list containing the current state and the history of the MarkovChain. This list is in the same form as the return value (see the 'value' section below):

Ys 
the vector of scaled responses. 
Xs 
the matrix of scaled covariates. 
PI 
a hyperparameter indicating the prior probability of an outlier. The default values are 0.1 if the data set has less than 50 observations, 0.02 otherwise. 
K 
a hyperparameter indicating the outlier inflation factor 
nu 
regression hyperparameter. Default value is 2.58 if r2 for the full model is less than 0.9 or 0.2 if r2 for the full model is greater than 0.9. 
lambda 
regression hyperparameter. Default value is 0.28 if r2 for the full model is less than 0.9 or 0.1684 if r2 for the full model is greater than 0.9. 
phi 
regression hyperparameter. Default value is 2.85 if r2 for the full model is less than 0.9 or 9.2 if r2 for the full model is greater than 0.9. 
outs.list 
a vector of all potential outlier locations
(e.g. 
Details
This function implements a single MetropolisHastings step, choosing a proposal model, calculating the Bayes Factor between the current model and proposal model, and updating the current model to the proposal model if the step results in an update.
Value
a list containing the current state and the history of the MarkovChain, with components
flag 
a 0/1 number specifying whether the previous MetropolisHastings step resulted in a changed state or not. 
big.list 
a matrix containing the history of the MarkovChain. Each row represents a unique model (combination of variables and outliers). The first column is the set of variables in the model (in binary form), the second column is the set of outliers in the model (in binary form), the third column is the logposterior for the model (up to a constant) and the fourth column is the number of times that model has been visited. 
M0.var 
a logical vector specifying the variables in the current model. 
M0.out 
a logical vector specifying the outliers in the current model. 
M0.1 
a number representing the variables in the current model in binary form. 
M0.2 
a number represnting the outliers in the current model in binary form. 
outcnt 
the number of potential outliers 
Note
The implementation here differs from the Splus implentation. The Splus implementation uses global variables to contain the state of the current model and the history of the MarkovChain. This implentation passes the current state and history to the function and then returns the updated state.
Author(s)
Jennifer Hoeting jennifer.hoeting@gmail.com with the assistance of Gary Gadbury. Translation from Splus to R by Ian Painter ian.painter@gmail.com.
References
Bayesian Model Averaging for Linear Regression Models Adrian E. Raftery, David Madigan, and Jennifer A. Hoeting (1997). Journal of the American Statistical Association, 92, 179191.
A Method for Simultaneous Variable and Transformation Selection in Linear Regression Jennifer Hoeting, Adrian E. Raftery and David Madigan (2002). Journal of Computational and Graphical Statistics 11 (485507)
A Method for Simultaneous Variable Selection and Outlier Identification in Linear Regression Jennifer Hoeting, Adrian E. Raftery and David Madigan (1996). Computational Statistics and Data Analysis, 22, 251270
Earlier versions of these papers are available via the World Wide Web using the url: https://www.stat.colostate.edu/~jah/papers/
See Also
MC3.REG
, MC3.REG.choose
, MC3.REG.logpost