multibridge (version 1.1.0)

binom_tsampling: Samples From Truncated Beta Densities

Description

Based on specified inequality constraints, samples from truncated prior or posterior beta densities.

Usage

binom_tsampling(
  inequalities,
  index = 1,
  niter = 10000,
  prior = FALSE,
  nburnin = niter * 0.05,
  seed = NULL
)

Value

matrix of dimension niter * nsamples containing samples from truncated beta distributions.

Arguments

inequalities

list that contains inequality constraints for each independent inequality constrained hypotheses. The list is created in the generate_restriction_list function

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 \(10,000\)

prior

logical. If TRUE ignores the data that are encoded in inequalities and thus samples from the prior distribution. Default is FALSE.

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

Details

The model assumes that the data in x (i.e., \(x_1, ..., x_K\)) are the observations of \(K\) independent binomial experiments, based on \(n_1, ..., n_K\) observations. Hence, the underlying likelihood is the product of the \(k = 1, ..., K\) individual binomial functions: $$(x_1, ... x_K) ~ \prod Binomial(N_k, \theta_k)$$ Furthermore, the model assigns a beta distribution as prior to each model parameter (i.e., underlying binomial proportions). That is: $$\theta_k ~ Beta(\alpha_k, \beta_k)$$

References

damien2001samplingmultibridge

See Also

generate_restriction_list

Examples

Run this code
x <- c(200, 130, 40, 10)
n <- c(200, 200, 200, 200)
a <- c(1, 1, 1, 1)
b <- c(1, 1, 1, 1)
factor_levels <- c('binom1', 'binom2', 'binom3', 'binom4')
Hr <- c('binom1 > binom2 > binom3 > binom4')

# generate restriction list
inequalities <- generate_restriction_list(x=x, n=n, Hr=Hr, a=a, b=b, 
factor_levels=factor_levels)$inequality_constraints

# sample from prior distribution
prior_samples <- binom_tsampling(inequalities, niter = 500, 
prior=TRUE)
# sample from posterior distribution
post_samples <- binom_tsampling(inequalities, niter = 500)

Run the code above in your browser using DataLab