bf_equality {multinomineq} | R Documentation |
Bayes Factor with Inequality and (Approximate) Equality Constraints
Description
To obtain the Bayes factor for the equality constraints C*x = d
, a
sequence of approximations abs(C*x - d) < delta
is used.
Usage
bf_equality(
k,
options,
A,
b,
C,
d,
prior = rep(1, sum(options)),
M1 = 1e+05,
M2 = 20000,
delta = 0.5^(1:8),
return_Ab = FALSE,
...
)
Arguments
k |
the number of choices for each alternative ordered by item type (e.g.
|
options |
number of observable categories/probabilities for each item
type/multinomial distribution, e.g., |
A |
a matrix with one row for each linear inequality constraint and one
column for each of the free parameters. The parameter space is defined
as all probabilities |
b |
a vector of the same length as the number of rows of |
C |
a matrix specifying the equality constraints |
d |
a vector with the same number of elements as the rows of |
prior |
the prior parameters of the Dirichlet-shape parameters.
Must have the same length as |
M1 |
number of independent samples from the encompassing model to test
whether |
M2 |
number of Gibbs-sampling iterations for each step of the approximation
of |
delta |
a vector of stepsizes that are used for the approximation. |
return_Ab |
if |
... |
further arguments passed to |
Details
First, the encompassing Bayes factor for the equality constraint A*x<b
is computed using M1
independent Dirichlet samples. Next, the equality
constraint C*x=d
is approximated by drawing samples from the model
A*x<b
and testing whether abs(C*x - d) < delta[1]
. Similarly, the
stepsize delta
is reduced step by step until abs(C*x - d) < min(delta)
.
Klugkist et al. (2010) show that this procedure provides a valid approximation
of the exact equality constraints if the step size becomes sufficiently small.
References
Klugkist, I., Laudy, O., & Hoijtink, H. (2010). Bayesian evaluation of inequality and equality constrained hypotheses for contingency tables. Psychological Methods, 15(3), 281-299. doi:10.1037/a0020137
Examples
# Equality constraints: C * x = d
d <- c(.5, .5, 0)
C <- matrix(
c(
1, 0, 0, 0, # p1 = .50
0, 1, 0, 0, # p2 = .50
0, 0, 1, -1
), # p3 = p4
ncol = 4, byrow = TRUE
)
k <- c(3, 7, 6, 4, 2, 8, 5, 5)
options <- c(2, 2, 2, 2)
bf_equality(k, options,
C = C, d = d, delta = .5^(1:5),
M1 = 50000, M2 = 5000
) # only for CRAN checks
# check against exact equality constraints (see ?bf_binom)
k_binom <- k[seq(1, 7, 2)]
bf_binom(k_binom,
n = 10, A = matrix(0), b = 0,
map = c(0, 0, 1, 1)
)