Learn R Programming

multibridge: Evaluating Multinomial Order Restrictions with Bridge Sampling

Evaluates hypotheses concerning the distribution of multinomial proportions using bridge sampling. The bridge sampling routine is able to compute Bayes factors for hypotheses that entail inequality constraints, equality constraints, free parameters, and a mix of all three. These hypotheses are tested against the encompassing hypothesis, that all parameters vary freely.

Installation

System requirement is the library mpfr with a version bigger than 3.0.0. To install mpfr, you need a C compiler, preferably GCC. Detailed information on how to install mpfr are available at https://www.mpfr.org/mpfr-current/mpfr.html.

On Mac you can install mpfr through the Terminal (assuming that brew is installed on your machine).

brew install mpfr

On Debian or Ubuntu you can install mpfr through the Terminal:

sudo apt-get install libmpfr-dev

You can install the released version of multibridge from CRAN with:

install.packages("multibridge")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("ASarafoglou/multibridge")

Extra Steps for Mac M1

On https://mac.r-project.org/tools/ follow the instructions for gfortran:

Example

This is a basic example which shows you how to solve a common problem:

library("multibridge")
# data
x <- c(3, 4, 10, 11, 7, 30)
# priors
a <- c(1, 1, 1, 1, 1, 1)
# category labels
factor_levels <- c('theta1', 'theta2', 
                   'theta3', 'theta4', 
                   'theta5', 'theta6')
# constrained hypothesis
Hr            <- c('theta1', '<',  'theta2', '&', 
                   'theta3', '=', 'theta4', ',', 
                   'theta5', '<', 'theta6')
output <- mult_bf_informed(x, Hr, a, factor_levels, seed=2020, niter=2e3)

m1 <- summary(output)
m1
#> Bayes factor analysis
#> 
#>  Hypothesis H_e:
#>  All parameters are free to vary.
#> 
#>  Hypothesis H_r:
#>  theta1 < theta2 & theta3 = theta4 , theta5 < theta6 
#> 
#> Bayes factor estimate LogBFer:
#> 
#> -2.4239
#> 
#> Based on 1 independent equality-constrained hypothesis
#>  and 2 independent inequality-constrained hypotheses. 
#> 
#> Relative Mean-Square Error:
#> 
#> 6.29e-05
#> 
#> Posterior Median and Credible Intervals Of Marginal Beta Distributions:
#>           alpha   beta   2.5%    50% 97.5%
#> 1 theta1 1 + 3  5 + 62 0.0158 0.0522 0.120
#> 2 theta2 1 + 4  5 + 61 0.0236 0.0664 0.140
#> 3 theta3 1 + 10 5 + 55 0.0811 0.1520 0.247
#> 4 theta4 1 + 11 5 + 54 0.0918 0.1660 0.264
#> 5 theta5 1 + 7  5 + 58 0.0507 0.1090 0.195
#> 6 theta6 1 + 30 5 + 35 0.3240 0.4360 0.553

Package dependencies

Copy Link

Version

Install

install.packages('multibridge')

Monthly Downloads

425

Version

1.2.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Alexandra Sarafoglou

Last Published

November 1st, 2022

Functions in multibridge (1.2.0)

bayes_factor.bmult

Extracts information about computed Bayes factors from object of class bmult
peas

Mendelian Laws of Inheritance
print.bmult

print method for class bmult
mult_bf_informed

Evaluates Informed Hypotheses on Multinomial Parameters
plot.summary.bmult

Plot estimates
mult_tsampling

Samples From Truncated Dirichlet Density
mult_bf_inequality

Computes Bayes Factors For Inequality Constrained Multinomial Parameters
generate_restriction_list

Creates Restriction List Based On User Specified Informed Hypothesis
journals

Prevalence of Statistical Reporting Errors
mult_bf_equality

Computes Bayes Factors For Equality Constrained Multinomial Parameters
lifestresses

Memory of Life Stresses
print.summary.bmult_bridge

print method for class summary.bmult_bridge
restriction_list

S3 method for class restriction_list.bmult
print.summary.bmult

print method for class summary.bmult
tbinom_backtrans

Backtransforms Samples From Real Line To Beta Parameters
print.bmult_bridge

Print method for class bmult_bridge
summary.bmult_bridge

summary method for class bmult_bridge
restriction_list.bmult

Extracts restriction list from an object of class bmult
samples

S3 method for class 'samples.bmult'
samples.bmult

Extracts prior and posterior samples (if applicable) from an object of class bmult
tbinom_trans

Transforms Truncated Beta Samples To Real Line
tdir_backtrans

Backtransforms Samples From Real Line To Dirichlet Parameters
summary.bmult

summary method for class bmult
tdir_trans

Transforms Truncated Dirichlet Samples To Real Line
bridge_output

S3 method for class bridge_output.bmult
.adjustUpperBoundForFreeParameters

Adjusts Upper Bound For Free Parameters
binom_tsampling

Samples From Truncated Beta Densities
bayes_factor

S3 method for class 'bayes_factor.bmult'
bridge_output.bmult

Extracts bridge sampling output from object of class bmult
binom_bf_equality

Computes Bayes Factors For Equality Constrained Binomial Parameters
.computeLengthOfRemainingStick

Computes Length Of Remaining Stick
binom_bf_informed

Evaluates Informed Hypotheses on Multiple Binomial Parameters
binom_bf_inequality

Computes Bayes Factors For Inequality Constrained Independent Binomial Parameters