# histBMA: A function for histograms-like representations of objects of... In BayesVarSel: Bayes Factors, Model Choice and Variable Selection in Linear Models

 histBMA R Documentation

## A function for histograms-like representations of objects of class `bma.coeffs`

### Description

The columns in `bma.coeffs` are simulations of the model averaged posterior distribution. This normally is a mixture of a discrete (at zero) and several continuous distributions. This plot provides a convenient graphical summary of such distributions.

### Usage

``````histBMA(
x,
covariate,
n.breaks = 100,
text = TRUE,
gray.0 = 0.6,
gray.no0 = 0.8
)
``````

### Arguments

 `x` An object of class `bma.coeffs` `covariate` The name of an explanatory variable whose accompanying coefficient is to be represented. This must be the name of one of the columns in `x` `n.breaks` The number of equally lentgh bars for the histogram `text` If set to TRUE the probability of the coefficient being zero is added in top of the bar at zero. Note: this probability is based on the models used in `bma.coeffs` (see details in that function) `gray.0` A numeric value between 0 and 1 that specifies the darkness, in a gray scale (0 is white and 1 is black) of the bar at zero `gray.no0` A numeric value between 0 and 1 that specifies the darkness, in a gray scale (0 is white and 1 is black) of the bars different from zero

### Details

This function produces a histogram but with the peculiarity that the zero values in the simulation are represented as bar centered at zero. The area of all the bars is one and of these, the area of the bar at zero (colored with `gray.0`) is, conditionally on the retained models (see details in `BMAcoeff`), the probability of that coefficient be exactly zero. This number is included in the top of the zero bar if `text` is set to TRUE.

### Author(s)

Gonzalo Garcia-Donato and Anabel Forte

Maintainer: <anabel.forte@uv.es>

See `BMAcoeff`. Also see `Bvs` and `GibbsBvs` for creating objects of the class `BMAcoeff`.

### Examples

``````

## Not run:

#Analysis of Crime Data
data(UScrime)

crime.Bvs<- Bvs(formula= y ~ ., data=UScrime, n.keep=1000)
crime.Bvs.BMA<- BMAcoeff(crime.Bvs, n.sim=10000)
#the best 1000 models are used in the mixture

#Observe the bimodality of the coefficient associated with regressor M
histBMA(crime.Bvs.BMA, "M")

#Note 1:
#The value in top of the bar at zero (0.251 in this case) is the probability of beta_M is
#zero conditional on a model space containing the 1000 models used in the mixture. This value
#should be closed to the exact value
#1-crime.Bvs\$inclprob["M"]
#which in this case is 0.2954968
#if n.keep above is close to 2^15

#Note 2:
#The BMA posterior distribution of beta_M has two modes approximately located at 0 and 10
#If we summarize this distribution using the mean
mean(crime.Bvs.BMA[ ,"M"])
#or median
median(crime.Bvs.BMA[ ,"M"])
#we obtain values around 7 (or 7.6) which do not represent this distribution.

#With the Gibbs algorithms:
data(Ozone35)

Oz35.GibbsBvs<- GibbsBvs(formula="y~.", data=Ozone35, prior.betas="gZellner",
prior.models="Constant", n.iter=10000, init.model="Full", n.burnin=100,
time.test = FALSE)
Oz35.GibbsBvs.BMA<- BMAcoeff(Oz35.GibbsBvs, n.sim=10000)

histBMA(Oz35.GibbsBvs.BMA, "x6.x7")
#In this case (Gibbs sampling), the value in top of the bar at zero (0.366)
#basically should coincide (if n.sim is large enough)
#with the estimated complement of the inclusion probability
#1-Oz35.GibbsBvs\$inclprob["x6.x7"]
#which in this case is 0.3638

## End(Not run)

``````

BayesVarSel documentation built on March 31, 2023, 9:17 p.m.