plot_hist {BayesFBHborrow}R Documentation

Plot histogram from MCMC samples

Description

Plots a histogram of the given discrete MCMC samples

Usage

plot_hist(
  samples,
  title = "",
  xlab = "Values",
  ylab = "Frequency",
  color = "black",
  fill = "blue",
  binwidth = 0.05,
  scale_x = FALSE
)

Arguments

samples

data.frame containing the discrete MCMC samples

title

title of the plot, default is none

xlab

x-label of the plot, default is "Values"

ylab

y-label of the plot, default is "Frequency"

color

outline color for the bars, default is "black"

fill

fill color, default is "blue"

binwidth

width of the histogram bins, default is 0.5

scale_x

option to scale the x-axis, suitable for discrete samples, default is FALSE

Value

a ggplot2 object

Examples

data(weibull_cc, package = "BayesFBHborrow")

# Set your tuning parameters
tuning_parameters <- list("Jmax" = 5,
                          "pi_b" = 0.5,
                          "cprop_beta" = 0.5)
                          
# run the MCMC sampler
out <- BayesFBHborrow(weibull_cc, NULL, tuning_parameters, 
                      initial_values = NULL,
                      iter = 10, warmup_iter = 1)

# Plot the frequency of the number of split points, J with a histogram
time_grid <- seq(0, max(weibull_cc$tte), length.out = 2000)
gg <- plot_hist(out$out_fixed$J, title = "Example histogram of J",
                scale_x = TRUE)

[Package BayesFBHborrow version 1.0.1 Index]