Computes the Bayes factor for product-binomial/-multinomial models with
linear order-constraints (specified via: A*x <= b or the convex hull V).
bf_binom(k, n, A, b, V, map, prior = c(1, 1), log = FALSE, ...)bf_multinom(
k,
options,
A,
b,
V,
prior = rep(1, sum(options)),
log = FALSE,
...
)
a matrix with two columns (Bayes factor and SE of approximation) and three rows:
`bf_0u`: constrained vs. unconstrained (saturated) model
`bf_u0`: unconstrained vs. constrained model
`bf_00'`: constrained vs. complement of inequality-constrained model
(e.g., pi>.2 becomes pi<=.2; this assumes identical equality constraints for both models)
vector of observed response frequencies.
the number of choices per item type.
If k=n=0, Bayesian inference is relies on the prior distribution only.
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 x that fulfill the order constraints A*x <= b.
a vector of the same length as the number of rows of A.
a matrix of vertices (one per row) that define the polytope of
admissible parameters as the convex hull over these points
(if provided, A and b are ignored).
Similar as for A, columns of V omit the last value for each
multinomial condition (e.g., a1,a2,a3,b1,b2 becomes a1,a2,b1).
Note that this method is comparatively slow since it solves linear-programming problems
to test whether a point is inside a polytope (Fukuda, 2004) or to run the Gibbs sampler.
optional: numeric vector of the same length as k with integers
mapping the frequencies k to the free parameters/columns of A/V,
thereby allowing for equality constraints (e.g., map=c(1,1,2,2)).
Reversed probabilities 1-p are coded by negative integers.
Guessing probabilities of .50 are encoded by zeros. The default assumes
different parameters for each item type: map=1:ncol(A)
a vector with two positive numbers defining the shape parameters of the beta prior distributions for each binomial rate parameter.
whether to return the log-Bayes factor instead of the Bayes factor
further arguments passed to count_binom or
count_multinom (e.g., M, steps).
number of observable categories/probabilities for each item
type/multinomial distribution, e.g., c(3,2) for a ternary and binary item.
For more control, use count_binom to specifiy how many samples
should be drawn from the prior and posterior, respectively. This is especially
recommended if the same prior distribution (and thus the same prior probability/integral)
is used for computing BFs for multiple data sets that differ only in the
observed frequencies k and the sample size n.
In this case, the prior probability/proportion of the parameter space in line
with the inequality constraints can be computed once with high precision
(or even analytically), and only the posterior probability/proportion needs
to be estimated separately for each unique vector k.
Karabatsos, G. (2005). The exchangeable multinomial model as an approach to testing deterministic axioms of choice and measurement. Journal of Mathematical Psychology, 49(1), 51-69. tools:::Rd_expr_doi("10.1016/j.jmp.2004.11.001")
Regenwetter, M., Davis-Stober, C. P., Lim, S. H., Guo, Y., Popova, A., Zwilling, C., … Messner, W. (2014). QTest: Quantitative testing of theories of binary choice. Decision, 1(1), 2-34. tools:::Rd_expr_doi("10.1037/dec0000007")
count_binom and count_multinom for
for more control on the number of prior/posterior samples and
bf_nonlinear for nonlinear order constraints.
k <- c(0, 3, 2, 5, 3, 7)
n <- rep(10, 6)
# linear order constraints:
# p1 Run the code above in your browser using DataLab