set_bin_prior {revdbayes} | R Documentation |
Construction of a prior distribution for a binomial probability p
Description
Constructs a prior distribution for use as the argument bin_prior
in
rpost
or in binpost
. The user can choose
from a list of in-built priors or specify their own prior function,
returning the log of the prior density, using an R function
and arguments for hyperparameters.
Usage
set_bin_prior(
prior = c("jeffreys", "laplace", "haldane", "beta", "mdi", "northrop"),
...
)
Arguments
prior |
Either
|
... |
Further arguments to be passed to the user-supplied or in-built
prior function. For the latter this is only relevant if
|
Details
Binomial priors. The names of the binomial priors set using
bin_prior
are:
-
"jeffreys"
: the Jeffreys beta(1/2, 1/2) prior. -
"laplace"
: the Bayes-Laplace beta(1, 1) prior. -
"haldane"
: the Haldane beta(0, 0) prior. -
"beta"
: a beta(\alpha, \beta
) prior. The argumentab
is a vector containingc
(\alpha, \beta
). The default isab = c(1, 1)
. -
"mdi"
: the MDI prior\pi(p) = 1.6186 p^p (1-p)^{1-p}
, for0 < p < 1.
-
"northrop"
: the improper prior\pi(p)=\{-\ln(1-p)\}^{-1}(1-p)^{-1}
, for0 < p < 1.
Apart from the last two priors these are all beta distributions.
Value
A list of class "binprior"
. The first component is the
name of the input prior. Apart from the MDI prior this will be "beta",
in which case the other component of the list is a vector of length two
giving the corresponding values of the beta parameters.
See Also
binpost
for sampling from a binomial posterior
distribution.
Examples
bp <- set_bin_prior(prior = "jeffreys")
# Setting the Jeffreys prior by hand
beta_prior_fn <- function(p, ab) {
return(stats::dbeta(p, shape1 = ab[1], shape2 = ab[2], log = TRUE))
}
jeffreys <- set_bin_prior(beta_prior_fn, ab = c(1 / 2, 1 / 2))