Bayesian Model Averaging accounts for the model uncertainty inherent in the variable selection problem by averaging over the best models in the model class according to approximate posterior model probability.
bicreg(x, y, wt = rep(1, length(y)), strict = FALSE, OR = 20,
maxCol = 31, drop.factor.levels = TRUE, nbest = 150)
bicreg
returns an object of class bicreg
The function 'summary' is used to print a summary of the results. The function 'plot' is used to plot posterior distributions for the coefficients.
An object of class bicreg
is a list containing at least the following components:
the posterior probabilities of the models selected
the names of the variables
labels identifying the models selected
R2 values for the models
values of BIC for the models
the number of independent variables in each of the models
a logical matrix with one row per model and one column per variable indicating whether that variable is in the model
the posterior probability that each variable is non-zero (in percent)
the posterior mean of each coefficient (from model averaging)
the posterior standard deviation of each coefficient (from model averaging)
the posterior mean of each coefficient conditional on the variable being included in the model
the posterior standard deviation of each coefficient conditional on the variable being included in the model
matrix with one row per model and one column per variable giving the OLS estimate of each coefficient for each model
matrix with one row per model and one column per variable giving the standard error of each coefficient for each model
a logical indicating whether any variables were dropped before model averaging
a vector containing the names of those variables dropped before model averaging
residual variance for each model
the matched call that created the bicreg object
a matrix of independent variables
a vector of values for the dependent variable
a vector of weights for regression
logical. FALSE returns all models whose posterior model probability is within a factor of 1/OR of that of the best model. TRUE returns a more parsimonious set of models, where any model with a more likely submodel is eliminated.
a number specifying the maximum ratio for excluding models in Occam's window
a number specifying the maximum number of columns in the design matrix (including the intercept) to be kept.
logical. Indicates whether factor levels can be individually dropped in the stepwise procedure to reduce the number of columns in the design matrix, or if a factor can be dropped only in its entirety.
a value specifying the number of models of each size returned to bic.glm by the leaps algorithm. The default is 150 (replacing the original default of 10).
Original Splus code developed by Adrian Raftery (raftery@uw.edu) and revised by Chris T. Volinsky. Translation to R by Ian Painter.
Bayesian Model Averaging accounts for the model uncertainty inherent in the variable selection problem by averaging over the best models in the model class according to the approximate posterior model probabilities.
Raftery, Adrian E. (1995). Bayesian model selection in social research (with Discussion). Sociological Methodology 1995 (Peter V. Marsden, ed.), pp. 111-196, Cambridge, Mass.: Blackwells.
summary.bicreg
, print.bicreg
, plot.bicreg
library(MASS)
data(UScrime)
x<- UScrime[,-16]
y<- log(UScrime[,16])
x[,-2]<- log(x[,-2])
lma<- bicreg(x, y, strict = FALSE, OR = 20)
summary(lma)
plot(lma)
imageplot.bma(lma)
Run the code above in your browser using DataLab