Bayesian Computation with R: Chosing a Beta Prior (page 23)

beta.select() to select hyperparameters a and b

Usage:

     beta.select(quantile1, quantile2)

Arguments:

quantile1: list with components p, the value of the first probability,
          and x, the value of the first quantile

quantile2: list with components p, the value of the second probability,
          and x, the value of the second quantile

Example

library(LearnBayes)
beta.a.b <- beta.select(quantile1 = list(p = 0.5, x = 0.3),     # Median is 0.3
                        quantile2 = list(p = 0.9, x = 0.5))     # 90th percentile is 0.5
beta.a.b
[1] 3.26 7.19

Plot

fun.beta.a.b <- function(x) {
    dbeta(x, beta.a.b[1], beta.a.b[2])
}

library(ggplot2)

ggplot(data = data.frame(x = 0), mapping = aes(x = x)) +
    layer(stat = "function",
          geom = "path",
          fun = fun.beta.a.b) +
    scale_x_continuous(limits = c(0, 1))

plot of chunk unnamed-chunk-3