Posterior Sampling for Inequality-Constrained Multinomial Models
Posterior Sampling for Inequality-Constrained Multinomial Models
Uses Gibbs sampling to draw posterior samples for binomial and multinomial models with linear inequality-constraints.
sampling_multinom( k, options, A, b, V, prior = rep(1, sum(options)), M =5000, start, burnin =10, progress =TRUE, cpu =1)sampling_binom( k, n, A, b, V, map =1:ncol(A), prior = c(1,1), M =5000, start, burnin =10, progress =TRUE, cpu =1)
Arguments
k: the number of choices for each alternative ordered by item type (e.g. c(a1,a2,a3, b1,b2) for a ternary and a binary item type). The length of k must be equal to the sum of options. The default k=0 is equivalent to sampling from the prior.
options: number of observable categories/probabilities for each item type/multinomial distribution, e.g., c(3,2) for a ternary and binary item.
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 x that fulfill the order constraints A*x <= b.
b: a vector of the same length as the number of rows of A.
V: 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.
prior: the prior parameters of the Dirichlet-shape parameters. Must have the same length as k.
M: number of posterior samples
start: only relevant if steps is defined or cmin>0: a vector with starting values in the interior of the polytope. If missing, an approximate maximum-likelihood estimate is used.
burnin: number of burnin samples that are discarded. Can be chosen to be small if the maxmimum-a-posteriori estimate is used as the (default) starting value.
progress: whether a progress bar should be shown (if cpu=1).
cpu: either the number of CPUs using separate MCMC chains in parallel, or a parallel cluster (e.g., cl <- parallel::makeCluster(3)). All arguments of the function call are passed directly to each core, and thus the total number of samples is M*number_cpu.
n: the number of choices per item type. If k=n=0, Bayesian inference is relies on the prior distribution only.
map: 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)
Returns
an mcmc matrix (or an mcmc.list if cpu>1) with posterior samples of the binomial/multinomial probability parameters. See mcmc) .
Details
Draws posterior samples for binomial/multinomial random utility models that assume a mixture over predefined preference orders/vertices that jointly define a convex polytope via the set of inequalities A * x < b or as the convex hull of a set of vertices V.
Myung, J. I., Karabatsos, G., & Iverson, G. J. (2005). A Bayesian approach to testing decision making axioms. Journal of Mathematical Psychology, 49, 205-225. tools:::Rd_expr_doi("10.1016/j.jmp.2005.02.004")