View source: R/bmult_multBfInformed.R
mult_bf_informed | R Documentation |
Evaluates informed hypotheses on multinomial parameters. These hypotheses can contain (a mixture of) inequality constraints, equality constraints, and free parameters. Informed hypothesis H_r states that category proportions obey the particular constraint. H_r can be tested against the encompassing hypothesis H_e or the null hypothesis H_0. Encompassing hypothesis H_e states that category proportions are free to vary. Null hypothesis H_0 states that category proportions are exactly equal.
mult_bf_informed( x, Hr, a = rep(1, length(x)), factor_levels = NULL, cred_level = 0.95, niter = 5000, bf_type = "LogBFer", seed = NULL, maxiter = 1000, nburnin = niter * 0.05 )
x |
numeric. Vector with data |
Hr |
string or character. Encodes the user specified informed hypothesis. Use either specified |
a |
numeric. Vector with concentration parameters of Dirichlet distribution. Must be the same length as |
factor_levels |
character. Vector with category names. Must be the same length as |
cred_level |
numeric. Credible interval for the posterior point estimates. Must be a single number between 0 and 1 |
niter |
numeric. Vector with number of samples to be drawn from truncated distribution |
bf_type |
character. The Bayes factor type. When the informed hypothesis is compared to the encompassing hypothesis,
the Bayes factor type can be |
seed |
numeric. Sets the seed for reproducible pseudo-random number generation |
maxiter |
numeric. Maximum number of iterations for the iterative updating scheme used in the bridge sampling routine. Default is 1,000 to avoid infinite loops |
nburnin |
numeric. A single value specifying the number of burn-in samples when drawing from the truncated distribution. Minimum number of burn-in samples is 10. Default is 5% of the number of samples. Burn-in samples are removed automatically after the sampling. |
The model assumes that data follow a multinomial distribution and assigns a Dirichlet distribution as prior for the model parameters (i.e., underlying category proportions). That is:
x ~ Multinomial(N, θ)
θ ~ Dirichlet(α)
List consisting of the following elements
$bf_list
gives an overview of the Bayes factor analysis:
bf_type
: string. Contains Bayes factor type as specified by the user
bf
: data.frame. Contains Bayes factors for all Bayes factor types
error_measures
: data.frame. Contains for the overall Bayes factor
the approximate relative mean-squared error re2
, the approximate coefficient of variation cv
, and the approximate percentage error percentage
logBFe_equalities
: data.frame. Lists the log Bayes factors for all independent equality constrained hypotheses
logBFe_inequalities
: data.frame. Lists the log Bayes factor for all independent inequality constrained hypotheses
$cred_level
numeric. User specified credible interval
$restrictions
list that encodes informed hypothesis for each independent restriction:
full_model
: list containing the hypothesis, parameter names, data and prior specifications for the full model.
equality_constraints
: list containing the hypothesis, parameter names, data and prior specifications for each equality constrained hypothesis.
inequality_constraints
: list containing the hypothesis, parameter names, data and prior specifications for each inequality constrained hypothesis.
In addition, in nr_mult_equal
and nr_mult_free
encodes which and how many parameters are
equality constraint or free, in boundaries
includes the boundaries of each parameter, in nineq_per_hyp
states the number of inequality constraint
parameters per independent inequality constrained hypothesis, and in direction
states the direction of
the inequality constraint.
$bridge_output
list containing output from bridge sampling function:
eval
: list containing the log prior or posterior evaluations
(q11
) and the log proposal evaluations (q12
) for the prior or posterior samples,
as well as the log prior or posterior evaluations (q21
) and the log proposal evaluations (q22
)
for the samples from the proposal distribution
niter
: number of iterations of the iterative updating scheme
logml
: estimate of log marginal likelihood
hyp
: evaluated inequality constrained hypothesis
error_measures
: list containing in re2
the approximate
relative mean-squared error for the marginal likelihood estimate, in cv
the approximate
coefficient of variation for the marginal likelihood estimate (assumes that bridge estimate is unbiased), and
in percentage
the approximate percentage error of the marginal likelihood estimate
$samples
list containing a list for prior samples and a list
of posterior samples from truncated distributions which were used to evaluate inequality constraints.
Prior and posterior samples of independent inequality constraints are again saved
in separate lists. Samples are stored as matrix of dimension nsamples x nparams
.
The following signs can be used to encode restricted hypotheses: "<"
and ">"
for inequality constraints, "="
for equality constraints,
","
for free parameters, and "&"
for independent hypotheses. The restricted hypothesis can either be a string or a character vector.
For instance, the hypothesis c("theta1 < theta2, theta3")
means
theta1
is smaller than both theta2
and theta3
The parameters theta2
and theta3
both have theta1
as lower bound, but are not influenced by each other.
The hypothesis c("theta1 < theta2 = theta3 & theta4 > theta5")
means that
Two independent hypotheses are stipulated: "theta1 < theta2 = theta3"
and "theta4 > theta5"
The restrictions on the parameters theta1
, theta2
, and theta3
do
not influence the restrictions on the parameters theta4
and theta5
.
theta1
is smaller than theta2
and theta3
theta2
and theta3
are assumed to be equal
theta4
is larger than theta5
damien2001samplingmultibridge
\insertRefgronau2017tutorialmultibridge
\insertReffruhwirth2004estimatingmultibridge
\insertRefsarafoglou2020evaluatingPreprintmultibridge
Other functions to evaluate informed hypotheses:
binom_bf_equality()
,
binom_bf_inequality()
,
binom_bf_informed()
,
mult_bf_equality()
,
mult_bf_inequality()
# data x <- c(3, 4, 10, 11, 7, 30) # priors a <- c(1, 1, 1, 1, 1, 1) # restricted hypothesis factor_levels <- c('theta1', 'theta2', 'theta3', 'theta4', 'theta5', 'theta6') Hr <- c('theta1', '<', 'theta2', '&', 'theta3', '=', 'theta4', ',', 'theta5', '<', 'theta6') output_total <- mult_bf_informed(x, Hr, a, factor_levels, seed=2020, niter=2e3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.