multibridge (version 1.1.0)

mult_bf_inequality: Computes Bayes Factors For Inequality Constrained Multinomial Parameters

Description

Computes Bayes factor for inequality constrained multinomial parameters using a bridge sampling routine. Restricted hypothesis \(H_r\) states that category proportions follow a particular trend. Alternative hypothesis \(H_e\) states that category proportions are free to vary.

Usage

mult_bf_inequality(
  samples = NULL,
  restrictions = NULL,
  x = NULL,
  Hr = NULL,
  a = rep(1, ncol(samples)),
  factor_levels = NULL,
  prior = FALSE,
  index = 1,
  maxiter = 1000,
  seed = NULL,
  niter = 5000,
  nburnin = niter * 0.05
)

Value

List consisting of the following elements:

$eval
  • q11: log prior or posterior evaluations for prior or posterior samples

  • q12: log proposal evaluations for prior or posterior samples

  • q21: log prior or posterior evaluations for samples from proposal

  • q22: log proposal evaluations for samples from proposal

$niter

number of iterations of the iterative updating scheme

$logml

estimate of log marginal likelihood

$hyp

evaluated inequality constrained hypothesis

$error_measures
  • re2: the approximate relative mean-squared error for the marginal likelihood estimate

  • cv: the approximate coefficient of variation for the marginal likelihood estimate (assumes that bridge estimate is unbiased)

  • percentage: the approximate percentage error of the marginal likelihood estimate

Arguments

samples

matrix of dimension nsamples x nparams with samples from truncated Dirichlet density

restrictions

list of class bmult_rl or of class bmult_rl_ineq as returned from generate_restriction_list that encodes inequality constraints for each independent restriction

x

numeric. Vector with data

Hr

string or character. Encodes the user specified informed hypothesis. Use either specified factor_levels or indices to refer to parameters. See ``Note'' section for details on how to formulate informed hypotheses

a

numeric. Vector with concentration parameters of Dirichlet distribution. Must be the same length as x. Default sets all concentration parameters to 1

factor_levels

character. Vector with category names. Must be the same length as x

prior

logical. If TRUE the function will ignore the data and evaluate only the prior distribution

index

numeric. Index of current restriction. Default is 1

maxiter

numeric. Maximum number of iterations for the iterative updating scheme used in the bridge sampling routine. Default is 1,000 to avoid infinite loops

seed

numeric. Sets the seed for reproducible pseudo-random number generation

niter

numeric. Vector with number of samples to be drawn from truncated distribution

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.

Details

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)$$

References

damien2001samplingmultibridge

gronau2017tutorialmultibridge

fruhwirth2004estimatingmultibridge

sarafoglou2020evaluatingPreprintmultibridge

See Also

generate_restriction_list

Other functions to evaluate informed hypotheses: binom_bf_equality(), binom_bf_inequality(), binom_bf_informed(), mult_bf_equality(), mult_bf_informed()

Examples

Run this code
# priors
a <- c(1, 1, 1, 1)

# informed hypothesis
factor_levels <- c('theta1', 'theta2', 'theta3', 'theta4')
Hr            <- c('theta1', '<',  'theta2', '<', 'theta3', '<', 'theta4')

results_prior  <- mult_bf_inequality(Hr=Hr, a=a, factor_levels=factor_levels, 
prior=TRUE, seed = 2020)
# corresponds to
cbind(exp(results_prior$logml), 1/factorial(4))

# alternative - if you have samples and a restriction list
inequalities  <- generate_restriction_list(Hr=Hr, a=a,
factor_levels=factor_levels)$inequality_constraints
prior_samples <- mult_tsampling(inequalities, niter = 2e3, 
prior=TRUE, seed = 2020)
results_prior <- mult_bf_inequality(prior_samples, inequalities, seed=2020)
cbind(exp(results_prior$logml), 1/factorial(4))

Run the code above in your browser using DataCamp Workspace