Learn R Programming

⚠️There's a newer version (1.2.0) of this package.Take me there.

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

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.0.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Alexandra Sarafoglou

Last Published

January 25th, 2021

Functions in multibridge (1.0.0)

bridge_output.bmult

Extracts bridge sampling output from object of class bmult
.computeLengthOfRemainingStick

Computes Length Of Remaining Stick
bayes_factor.bmult

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

S3 method for class 'bayes_factor.bmult'
.adjustUpperBoundForFreeParameters

Adjusts Upper Bound For Free Parameters
bridge_output

S3 method for class bridge_output.bmult
binom_bf_inequality

Computes Bayes Factors For Inequality Constrained Independent Binomial Parameters
binom_bf_equality

Computes Bayes Factors For Equality Constrained Binomial Parameters
binom_bf_informed

Evaluates Informed Hypotheses on Multiple Binomial Parameters
binom_tsampling

Samples From Truncated Beta Densities
plot.summary.bmult

Plot estimates
peas

Mendelian Laws of Inheritance
mult_tsampling

Samples From Truncated Dirichlet Density
print.summary.bmult_bridge

print method for class summary.bmult_bridge
restriction_list

S3 method for class restriction_list.bmult
print.bmult

print method for class bmult
print.summary.bmult

print method for class summary.bmult
print.bmult_bridge

Print method for class bmult_bridge
tdir_trans

Transforms Truncated Dirichlet Samples To Real Line
summary.bmult_bridge

summary method for class bmult_bridge
generate_restriction_list

Creates Restriction List Based On User Specified Informed Hypothesis
tbinom_backtrans

Backtransforms Samples From Real Line To Beta Parameters
mult_bf_inequality

Computes Bayes Factors For Inequality Constrained Multinomial Parameters
restriction_list.bmult

Extracts restriction list from an object of class bmult
mult_bf_informed

Evaluates Informed Hypotheses on Multinomial Parameters
samples

S3 method for class 'samples.bmult'
journals

Prevalence of Statistical Reporting Errors
samples.bmult

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

Transforms Truncated Beta Samples To Real Line
summary.bmult

summary method for class bmult
mult_bf_equality

Computes Bayes Factors For Equality Constrained Multinomial Parameters
lifestresses

Memory of Life Stresses
tdir_backtrans

Backtransforms Samples From Real Line To Dirichlet Parameters