plot_gamma_poisson function

Plot a Gamma-Poisson Bayesian Model

Plot a Gamma-Poisson Bayesian Model

Consider a Gamma-Poisson Bayesian model for rate parameter λ\lambda with a Gamma(shape, rate) prior on λ\lambda and a Poisson likelihood for the data. Given information on the prior (shape and rate) and data (the sample size n and sum_y), 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_gamma_poisson( shape, rate, sum_y = NULL, n = NULL, prior = TRUE, likelihood = TRUE, posterior = TRUE )

Arguments

  • shape: non-negative shape parameter of the Gamma prior
  • rate: non-negative rate parameter of the Gamma prior
  • sum_y: sum of observed data values for the Poisson likelihood
  • n: number of observations for the Poisson likelihood
  • 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_gamma_poisson(shape = 100, rate = 20, sum_y = 39, n = 6) plot_gamma_poisson(shape = 100, rate = 20, sum_y = 39, n = 6, posterior = FALSE)