plot_normal_normal: Plot a Normal-Normal Bayesian model

Description Usage Arguments Value Examples

Description

Consider a Normal-Normal Bayesian model for mean parameter μ with a N(mean, sd^2) prior on μ and a Normal likelihood for the data. Given information on the prior (mean and sd) and data (the sample size n, mean y_bar, and standard deviation sigma), 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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_normal_normal(
  mean,
  sd,
  sigma = NULL,
  y_bar = NULL,
  n = NULL,
  prior = TRUE,
  likelihood = TRUE,
  posterior = TRUE
)

Arguments

mean

mean of the Normal prior

sd

standard deviation of the Normal prior

sigma

standard deviation of the data, or likelihood standard deviation

y_bar

sample mean of the data

n

sample size of the data

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

Value

a ggplot

Examples

1
2
plot_normal_normal(mean = 0, sd = 3, sigma= 4, y_bar = 5, n = 3)
plot_normal_normal(mean = 0, sd = 3, sigma= 4, y_bar = 5, n = 3, posterior = FALSE)

bayesrules documentation built on Sept. 25, 2021, 9:06 a.m.