plot_beta_binomial function

Plot a Beta-Binomial Bayesian Model

Plot a Beta-Binomial Bayesian Model

Consider a Beta-Binomial Bayesian model for parameter π\pi with a Beta(alpha, beta) prior on π\pi and Binomial likelihood with n trials and y successes. Given information on the prior (alpha and data) and data (y and n), this function produces a plot of any combination of the corresponding prior pdf, scaled likelihood function, and posterior pdf. All three are included by default.

plot_beta_binomial( alpha, beta, y = NULL, n = NULL, prior = TRUE, likelihood = TRUE, posterior = TRUE )

Arguments

  • alpha, beta: positive shape parameters of the prior Beta model
  • y: observed number of successes
  • n: observed number of trials
  • prior: a logical value indicating whether the prior model should be plotted
  • likelihood: a logical value indicating whether the scaled likelihood should be plotted
  • posterior: a logical value indicating whether posterior model should be plotted

Returns

a ggplot

Examples

plot_beta_binomial(alpha = 1, beta = 13, y = 25, n = 50) plot_beta_binomial(alpha = 1, beta = 13, y = 25, n = 50, posterior = FALSE)