sampling_multinom {multinomineq} | R Documentation |
Posterior Sampling for Inequality-Constrained Multinomial Models
Description
Uses Gibbs sampling to draw posterior samples for binomial and multinomial models with linear inequality-constraints.
Usage
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.
|
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 |
V |
a matrix of vertices (one per row) that define the polytope of
admissible parameters as the convex hull over these points
(if provided, |
prior |
the prior parameters of the Dirichlet-shape parameters.
Must have the same length as |
M |
number of posterior samples |
start |
only relevant if |
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 |
either the number of CPUs using separate MCMC chains in parallel,
or a parallel cluster (e.g., |
n |
the number of choices per item type.
If |
map |
optional: numeric vector of the same length as |
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
.
Value
an mcmc
matrix (or an mcmc.list
if cpu>1
) with
posterior samples of the binomial/multinomial probability parameters.
See mcmc
) .
References
Myung, J. I., Karabatsos, G., & Iverson, G. J. (2005). A Bayesian approach to testing decision making axioms. Journal of Mathematical Psychology, 49, 205-225. doi:10.1016/j.jmp.2005.02.004
See Also
Examples
############### binomial ##########################
A <- matrix(
c(
1, 0, 0, # x1 < .50
1, 1, 1, # x1+x2+x3 < 1
0, 2, 2, # 2*x2+2*x3 < 1
0, -1, 0, # x2 > .2
0, 0, 1
), # x3 < .1
ncol = 3, byrow = TRUE
)
b <- c(.5, 1, 1, -.2, .1)
samp <- sampling_binom(c(5, 12, 7), c(20, 20, 20), A, b)
head(samp)
plot(samp)
############### multinomial ##########################
# binary and ternary choice:
# (a1,a2 b1,b2,b3)
k <- c(15, 9, 5, 2, 17)
options <- c(2, 3)
# columns: (a1, b1,b2)
A <- matrix(
c(
1, 0, 0, # a1 < .20
0, 2, 1, # 2*b1+b2 < 1
0, -1, 0, # b1 > .2
0, 0, 1
), # b2 < .4
ncol = 3, byrow = TRUE
)
b <- c(.2, 1, -.2, .4)
samp <- sampling_multinom(k, options, A, b)
head(samp)
plot(samp)