Examples for Prior Distributions

library(bayesrules)
library(tidyverse)

Language / notes about nomenclature

Beta Prior

Review the beta distribution

Suppose we are looking at binary outcomes; we want to put a prior on \(\pi = P[Y=1]\), meaning \(\pi \in [0, 1]\).

The Beta model (often used to describe the variability in \(\pi\)) has shape parameters \(\alpha > 0\) and \(\beta > 0\), and these are the shape hyperparameters.

\[\pi \sim \text{Beta}\left(\alpha, \beta \right),\]

The Beta model’s pdf is

\[f\left( \pi \right) = \frac{\Gamma \left( \alpha + \beta \right)}{\Gamma \left( \alpha \right) \Gamma \left( \beta \right)} \pi^{\alpha-1} (1-\pi)^{\beta-1},\]

  • Note the following:

    • \(\Gamma\left( z \right) = \int_{0}^{\infty} x^{z-1} e^{-y} dx\)

    • \(\Gamma\left( z + 1 \right) = z \Gamma\left( z \right)\)

    • if \(z\in \mathbb{Z}^+\), then \(\Gamma\left( z \right) = (z-1)!\)

Let’s play with plotting the Beta distribution.

plot_beta(5, 5)

plot_beta(15, 15)

plot_beta(30, 30)

plot_beta(2, 5)

plot_beta(5, 2)

plot_beta(2,1)

Jillian is a soccer player who, throughout her career in competitive soccer, has probability 0.5 of scoring when she attempts. However, her coach suspects that she’s getting better. Her coach begins keeping tabs and is going to ask us to analyze the data. While we wait for them to complete data collection, we can go ahead and decide on the prior distribution.

Thinking about our original exploration of the Beta distribution,

plot_beta(5, 5)

plot_beta(15, 15)

plot_beta(30, 30)

The above distributions are centered at 0.5, we just need to decide on which is best for our analysis. What should we choose?

Suppose we are estimating the population proportion of children with vanishing white matter disease, a rare disease. What should our prior be?

Normal Prior

Review the normal distribution

Suppose we are now examining a continuous outcome. Let \(Y\) be a continuous random variable that can take any value in \(\mathbb{R}\); i.e., \(Y \in \left(-\infty, \infty\right)\).

Let us assume that the variability in \(Y\) can be represented by the normal distribution with mean parameter \(\mu \in \mathbb{R}\) and standard deviation parameter \(\sigma \in \mathbb{R}^+\).

\[Y \sim N\left(\mu, \sigma^2\right)\]

The normal model’s pdf is

\[f(y) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left\{-\frac{\left(y - \mu\right)^2}{2\sigma^2} \right\}\]

  • Note: \(\sigma\) provides a sense of scale for \(Y\); approximately 95% of \(Y\) values will be within 2 standard deviations.

    • i.e., \(\mu \pm 2 \sigma\)

What happens as variability increases?

plot_normal(0, 1) + ylim(0,0.5)

plot_normal(0, 10) + ylim(0,0.5)

plot_normal(0, 100) + ylim(0,0.5)

What happens as variability decreases?

plot_normal(0, 1) + ylim(0, 1)

plot_normal(0, 0.75) + ylim(0, 1)

plot_normal(0, 0.5) + ylim(0, 1)

A new Introduction to Biostatistics instructor believes that exam grades should follow a normal distribution. Construct the following priors; remember to keep the y-axis on the same scale for all graphs.

A prior with \(\mu=75\) and high variability:

A prior with \(\mu=75\) and medium variability:

A prior with \(\mu=75\) and low variability:

Let \(\mu\) be the average 5 p.m. temperature in Pensacola. Dr. Seals believes that Pensacola is hot year round, so she believes that the average temperature is probably around 85 degrees Fahrenheit. However, you are skeptical that it is hot all year, so let’s come up with a prior for this.