mult_bf_inequality {multibridge} | R Documentation |
Computes Bayes factor for inequality constrained multinomial parameters using a bridge sampling routine.
Restricted hypothesis H_r
states that category proportions follow a particular trend.
Alternative hypothesis H_e
states that category proportions are free to vary.
mult_bf_inequality(
samples = NULL,
restrictions = NULL,
x = NULL,
Hr = NULL,
a = rep(1, ncol(samples)),
factor_levels = NULL,
prior = FALSE,
index = 1,
maxiter = 1000,
seed = NULL,
niter = 5000,
nburnin = niter * 0.05
)
samples |
matrix of dimension |
restrictions |
|
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 |
prior |
logical. If |
index |
numeric. Index of current restriction. Default is 1 |
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 |
seed |
numeric. Sets the seed for reproducible pseudo-random number generation |
niter |
numeric. Vector with number of samples to be drawn from truncated distribution |
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, \theta)
\theta ~ Dirichlet(\alpha)
List consisting of the following elements:
$eval
q11
: log prior or posterior evaluations for prior or posterior samples
q12
: log proposal evaluations for prior or posterior samples
q21
: log prior or posterior evaluations for samples from proposal
q22
: log proposal evaluations for samples from proposal
$niter
number of iterations of the iterative updating scheme
$logml
estimate of log marginal likelihood
$hyp
evaluated inequality constrained hypothesis
$error_measures
re2
: the approximate
relative mean-squared error for the marginal likelihood estimate
cv
: the approximate coefficient of variation for the marginal
likelihood estimate (assumes that bridge estimate is unbiased)
percentage
: the approximate percentage error of the marginal likelihood estimate
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
Damien P, Walker SG (2001). “Sampling truncated normal, beta, and gamma densities.” Journal of Computational and Graphical Statistics, 10, 206–215.
Gronau QF, Sarafoglou A, Matzke D, Ly A, Boehm U, Marsman M, Leslie DS, Forster JJ, Wagenmakers E, Steingroever H (2017). “A tutorial on bridge sampling.” Journal of Mathematical Psychology, 81, 80–97.
Frühwirth-Schnatter S (2004). “Estimating marginal likelihoods for mixture and Markov switching models using bridge sampling techniques.” The Econometrics Journal, 7, 143–167.
Sarafoglou A, Haaf JM, Ly A, Gronau QF, Wagenmakers EJ, Marsman M (2021). “Evaluating Multinomial Order Restrictions with Bridge Sampling.” Psychological Methods.
Other functions to evaluate informed hypotheses:
binom_bf_equality()
,
binom_bf_inequality()
,
binom_bf_informed()
,
mult_bf_equality()
,
mult_bf_informed()
# priors
a <- c(1, 1, 1, 1)
# informed hypothesis
factor_levels <- c('theta1', 'theta2', 'theta3', 'theta4')
Hr <- c('theta1', '<', 'theta2', '<', 'theta3', '<', 'theta4')
results_prior <- mult_bf_inequality(Hr=Hr, a=a, factor_levels=factor_levels,
prior=TRUE, seed = 2020)
# corresponds to
cbind(exp(results_prior$logml), 1/factorial(4))
# alternative - if you have samples and a restriction list
inequalities <- generate_restriction_list(Hr=Hr, a=a,
factor_levels=factor_levels)$inequality_constraints
prior_samples <- mult_tsampling(inequalities, niter = 2e3,
prior=TRUE, seed = 2020)
results_prior <- mult_bf_inequality(prior_samples, inequalities, seed=2020)
cbind(exp(results_prior$logml), 1/factorial(4))