Ab_sort {multinomineq} | R Documentation |
Sort Inequalities by Acceptance Rate
Description
Uses samples from the prior/posterior to order the inequalities by the acceptance rate.
Usage
Ab_sort(A, b, k = 0, options, M = 1000, drop_irrelevant = TRUE)
Arguments
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 |
k |
optional: number of observed frequencies (only for posterior sampling). |
options |
optional: number of options per item type/category system. Uniform sampling on [0,1] for each parameter is used if omitted. |
M |
number of samples. |
drop_irrelevant |
whether to drop irrelevant constraints for probabilities such as
|
Details
Those constraints that are rejected most often are placed at the first positions.
This can help when computing the encompassing Bayes factor and counting how many samples
satisfy the constraints (e.g., count_binom
or bf_multinom
).
Essentially, it becomes more likely that the while-loop for testing
whether the inequalities hold can stop earlier, thus making the computation faster.
The function could also be helpful to improve the efficiency of the stepwise
sampling implemented in count_binom
and count_multinom
.
First, one can use accept-reject sampling to test the first few, rejected
inequalities. Next, one can use a Gibbs sampler to draw samples conditional on the
first constraints.
Examples
### Binomial probabilities
b <- c(0, 0, .30, .70, 1)
A <- matrix(
c(
-1, 1, 0, # p1 >= p2
0, 1, -1, # p2 <= p3
1, 0, 0, # p1 <=.30
0, 1, 0, # p2 <= .70
0, 0, 1
), # p3 <= 1 (redundant)
ncol = 3, byrow = 2
)
Ab_sort(A, b)
### Multinomial probabilities
# prior sampling:
Ab_sort(A, b, options = 4)
# posterior sampling:
Ab_sort(A, b, k = c(10, 3, 2, 14), options = 4)