prior creates a prior distribution.
The prior can be visualized by the plot function.
prior(
distribution,
parameters,
truncation = list(lower = -Inf, upper = Inf),
prior_weights = 1
)
prior_none(prior_weights = 1)name of the prior distribution. The possible options are
"point"for a point density characterized by a
location parameter.
"normal"for a normal distribution characterized
by a mean and sd parameters.
"lognormal"for a lognormal distribution characterized
by a meanlog and sdlog parameters.
"cauchy"for a Cauchy distribution characterized
by a location and scale parameters. Internally
converted into a generalized t-distribution with df = 1.
"t"for a generalized t-distribution characterized
by a location, scale, and df parameters.
"gamma"for a gamma distribution characterized
by either shape and rate, or shape and
scale parameters. The latter is internally converted to
the shape and rate parametrization
"invgamma"for an inverse-gamma distribution
characterized by a shape and scale parameters. The
JAGS part uses the BayesTools module distribution
dbt_invgamma(shape, scale) on the natural parameter.
"beta"for a beta distribution
characterized by an alpha and beta parameters.
"exp"for an exponential distribution
characterized by either rate or scale
parameter. The later is internally converted to
rate.
"uniform"for a uniform distribution defined on a
range from a to b
"moment"for a Johnson-Rossell moment prior characterized
by exactly one of mode or tau, an optional order
that defaults to 1, and an optional location that defaults to 0.
"invmoment"for a Johnson-Rossell inverse-moment prior
characterized by exactly one of mode or tau, a df,
an optional order that defaults to 1, and an optional
location that defaults to 0.
"dirichlet"for a Dirichlet distribution over a simplex,
whose finite nonnegative coordinates must have a finite total and roundoff
bound and sum to one within that bound,
characterized by a concentration vector alpha. Numeric entries
must be finite and at least 0.01; this is a supported-input minimum,
not a numerical guarantee. Positive expression-valued concentrations retain
their existing JAGS-only support: expression containers, including literal
elements, are not statically evaluated or validated, and R random generation
refuses them. Cumulative weight functions and ordered allocations require
numeric concentrations. Accepted sampling can still be unavailable; see
prior_functions. Two-bin cumulative JAGS initialization near
the minimum can repeatedly refuse unrepresentable interior ratios. Density
and plot methods show one beta marginal per simplex coordinate.
list of appropriate parameters for a given
distribution.
list with two elements, lower and
upper, that define the lower and upper truncation of the
distribution. Defaults to list(lower = -Inf, upper = Inf).
The truncation is automatically set to the bounds of the support.
prior odds associated with a given distribution. The value is passed into the model fitting function, which creates models corresponding to all combinations of prior distributions for each of the model parameters and sets the model priors odds to the product of its prior distributions.
prior and prior_none return an object of class 'prior'.
A named list containing the distribution name, parameters, and prior weights.
Moment and inverse-moment priors are symmetric nonlocal priors
with zero density at location. The mode parameter is the
positive distance from location to each symmetric mode; supplied
negative values are converted to their absolute value. Positional parameters
are interpreted as mode for "moment" and mode, df
for "invmoment". Use named parameters for tau, order,
location, or the inverse-moment nu alias. Positional input
always treats the first parameter as mode. For moment priors,
tau = mode^2 / (2 * order). For inverse-moment priors,
tau = mode^2 * ((df + 1) / (2 * order))^(1 / order).
Aliases "pmom", "pimom", and "inversemoment" are
accepted, and inverse-moment df may also be supplied as nu.
Native inverse-gamma, moment and inverse-moment calculations distinguish
certified finite-input tails outside logarithmic range from unavailable
arithmetic. Direct density and log-density evaluations signal
BayesTools_numerical_range_limit; unresolved calculations signal
BayesTools_numerical_unavailable. Both inherit
BayesTools_numerical_condition and retain the original input indices,
operation, family and requested scale. Truncated evaluations warn only for
points inside the declared support and truncation. Numerical tail zeros do
not declare zero probability mass or point atoms. Nonempty intervals whose
two endpoints both lose tail-log range can have unavailable normalization.
Finite-required fitting and bridge consumers refuse these range results;
natural integration may consume certified negative-infinite log tails only
after checking normalization and the required kernel and Jacobian.
Certification requires the inspected MinGW-w64 11.x x86-64 log backend,
documented Intel or AMD instruction contracts, checked floating-point modes
and a checked extended logarithmic constant. Other backends, overflowing
original nonlocal distances and uncertified coordinates remain unavailable
in this FAR regime. Constructor parameter domains and ordinary arithmetic
are unchanged.
# create a standard normal prior distribution
p1 <- prior(distribution = "normal", parameters = list(mean = 1, sd = 1))
# create a half-normal standard normal prior distribution
p2 <- prior(distribution = "normal", parameters = list(mean = 1, sd = 1),
truncation = list(lower = 0, upper = Inf))
# the prior distribution can be visualized using the plot function
# (see ?plot.prior for all options)
plot(p1)
# create nonlocal priors centered on zero
p3 <- prior("moment", list(mode = 0.5))
p4 <- prior("invmoment", list(mode = 0.5, df = 3))
# tau can be specified directly when named
p5 <- prior("pmom", list(tau = 0.125))
p6 <- prior("pimom", list(tau = 0.5, nu = 3))