Last chance! 50% off unlimited learning
Sale ends in
gdensity(x, n = 512, plot = TRUE, addons = "zles", addons.lwd = 1.5, ...)
bms
). "zles"
. Specifies which additional information should be added to the plot via low-level commands (see 'Details' below). TRUE
(default), the density is plotted; if FALSE
then gdensity
only returns the estimated posterior density without plotting. addons
. Cf. argument lwd
in par
plot.default
with sensible defaultsgdensity
returns an object of the class density
detailing the posterior mixture density of the shrinkage factor.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.
density.bma
for computing coefficient densities, bms
for creating bma objects, density
for the general method Check http://bms.zeugner.eu for additional help.
data(datafls)
mm=bms(datafls,g="hyper=UIP")
gdensity(mm) # default plotting
# the grey bars represent expected shrinkage factors of the individual models
gdensity(mm,addons="lzfes")
# #plotting the median 'm' and the posterior mean and bounds based on MCMC results:
gdensity(mm,addons="zSEm",addons.lwd=2)
# plot the posterior shrinkage density only for the very best model
gdensity(mm[1],addons="esz")
#using the calculated density for other purposes...
dd=gdensity(mm,plot=FALSE)
plot(dd)
Run the code above in your browser using DataLab