3. Specifying prior distributions

Matt Secrest and Isaac Gravestock

library(psborrow2)

In this article, you’ll learn how to specify prior distributions in psborrow2.

Specifying prior distributions

Because psborrow2 creates fully-parametrized Bayesian models, proper prior distributions on all parameters must be specified.

Prior distributions are needed for several parameters, depending on the analysis:

See the documentation of these functions for more information.

Types of prior distributions

The currently supported prior distributions are created with the prior_ constructors below:

For example, we can create an uninformative normal distribution by specifying a normal prior centered around 0 with a very large standard deviation:

uninformative_normal <- prior_normal(0, 10000)
uninformative_normal
# Normal Distribution
# Parameters:
#  Stan  R    Value
#  mu    mean     0
#  sigma sd   10000

See the documentation for the respective functions above for additional information.

Visualizing prior distributions

You may sometimes find it useful to visualize prior distributions. In these scenarios, you can call plot() on the prior object to visualize the distribution:

plot(uninformative_normal)
plot of chunk unnamed-chunk-3

plot of chunk unnamed-chunk-3

plot() chooses the default axes for you, but you can change these to make differences more obvious. Let’s compare a conservative gamma(0.001, 0.001) hyperprior distribution on the commensurability parameter tau to an more aggressive gamma(1, 0.001) distribution with greater density at higher values of tau (which will lead to more borrowing in a BDB analysis):

conservative_tau <- prior_gamma(0.001, 0.001)
aggressive_tau <- prior_gamma(1, 0.001)
plot(aggressive_tau, xlim = c(0, 2000), col = "blue", ylim = c(0, 1e-03))
plot(conservative_tau, xlim = c(0, 2000), col = "red", add = TRUE)
plot of chunk unnamed-chunk-4

plot of chunk unnamed-chunk-4