gdensity {BMS} R Documentation

## Posterior Density of the Shrinkage Factor

### Description

Calculates the mixture marginal posterior density for the shrinkage factor (g/(1+g)) from a BMA object under the hyper-g prior and plots it

### Usage

gdensity(x, n = 512, plot = TRUE, addons = "zles", addons.lwd = 1.5, ...)


### Arguments

 x A bma object (see bms). n The integer number of equally spaced points at which the density is to be estimated. see 'Details' below plot logical. If TRUE (default), the density is plotted; if FALSE then gdensity only returns the estimated posterior density without plotting. addons character, defaulting to "zles". Specifies which additional information should be added to the plot via low-level commands (see 'Details' below). addons.lwd scalar, default 1.5. Line width to be used for the low-level plotting commands specified by addons. Cf. argument lwd in par ... Additional arguments for plot.default with sensible defaults

### Details

The function gdensity estimates and plots the posterior density for the shrinkage factor g/(1+g)
This is evidently only possible if the shrinkage factor if not fixed, i.e. if the bma object x was estimated with a hyper-g prior - cf. argument g in bms
The density is based only on the best models retained in the bma object x, cf. argument nmodel in bms
A note on argument n: The points at which the density is estimated start at max(0,E-5*SD), where E and SD are the expected value and standard deviation of the shrinkage factor, respectively. For plotting the entire domain (0,1) use xlim=c(0,1) as an argument for gdensity.

The argument addons specifies what additional information should be added to the plot(s) via the low-level commands lines and legend:
"e" for the posterior expected value (EV) of the shrinkage factor,
"s" for 2 times posterior standard deviation (SD) bounds,
"m" for the posterior median,
"f" for posterior expected values of the individual models whom the density is averaged over,
"z" for a zero line, "l" for including a legend
The following two are only possible if the bma object collected statistics on shrinkage, cf. argument g.stats in bms "E" for posterior expected value under MCMC frequencies (see argument exact in coef.bma),
"S" for the corresponding 2 times standard deviation bounds (MCMC),

Any combination of these letters will give the desired result. Use addons="" for not using any of these.

### Value

gdensity returns an object of the class density detailing the posterior mixture density of the shrinkage factor.

### Note

The computed marginal posterior density is a Bayesian Model Averaging mixture of the marginal posterior densities of the shrinkage factor under individual models. The accuracy of the result therefore depends on the number of 'best' models contained in x (cf. argument nmodel in bms).

Correspondingly, the posterior EV and SD specified by addons="es" are based on 'best' model likelihoods ('exact') and are conditional on inclusion.

The low-level commands enacted by the argument addons rely on colors of the palette: color 2 for "e" and "s", color 3 for "m", color 8 for "f", color 4 for "E" and "S". The default colors may be changed by a call to palette.

density.bma for computing coefficient densities, bms for creating bma objects, density for the general method

### Examples



data(datafls)
mm=bms(datafls,g="hyper=UIP")

gdensity(mm) # default plotting

# the grey bars represent expected shrinkage factors of the individual models

# #plotting the median 'm' and the posterior mean and bounds based on MCMC results: