mult_tsampling {multibridge} | R Documentation |
Based on specified inequality constraints, samples from truncated prior or posterior Dirichlet density.
mult_tsampling(
inequalities,
index = 1,
niter = 10000,
prior = FALSE,
nburnin = niter * 0.05,
seed = NULL
)
inequalities |
list that contains inequality constraints for each independent inequality constrained hypotheses. The list
is created in the |
index |
numeric. If multiple independent inequality constraints are specified, this index determines for which inequality constraint samples should be drawn. Must be a single value. Default is 1 |
niter |
numeric. A single value specifying the number of samples. Default is set to |
prior |
logical. If |
nburnin |
numeric. A single value specifying the number of burn-in samples when drawing from the truncated distribution. Minimum number of burn-in samples is 10. Default is 5% of the number of samples. Burn-in samples are removed automatically after the sampling. |
seed |
numeric. Sets the seed for reproducible pseudo-random number generation |
The model assumes that data follow a multinomial distribution and assigns a Dirichlet distribution as prior for the model parameters (i.e., underlying category proportions). That is:
x ~ Multinomial(N, \theta)
\theta ~ Dirichlet(\alpha)
matrix of dimension niter * nsamples
containing prior or posterior samples from truncated Dirichlet distribution.
When equality constraints are specified in the restricted hypothesis, this function samples from the conditional Dirichlet distribution given that the equality constraints hold.
Only inequality constrained parameters are sampled. Free parameters or parameters that are exclusively equality constrained will be ignored.
Damien P, Walker SG (2001). “Sampling truncated normal, beta, and gamma densities.” Journal of Computational and Graphical Statistics, 10, 206–215.
Sarafoglou A, Haaf JM, Ly A, Gronau QF, Wagenmakers EJ, Marsman M (2021). “Evaluating Multinomial Order Restrictions with Bridge Sampling.” Psychological Methods.
x <- c(200, 130, 40, 10)
a <- c(1, 1, 1, 1)
factor_levels <- c('mult1', 'mult2', 'mult3', 'mult4')
Hr <- c('mult1 > mult2 > mult3 > mult4')
# generate restriction list
inequalities <- generate_restriction_list(x=x, Hr=Hr, a=a,
factor_levels=factor_levels)$inequality_constraints
# sample from prior distribution
prior_samples <- mult_tsampling(inequalities, niter = 500, prior=TRUE)
# sample from posterior distribution
post_samples <- mult_tsampling(inequalities, niter = 500)