View source: R/bmult_sampling_binom.R
binom_tsampling | R Documentation |
Based on specified inequality constraints, samples from truncated prior or posterior beta densities.
binom_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 10,000 |
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 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) ~ ∏ Binomial(N_k, θ_k)
Furthermore, the model assigns a beta distribution as prior to each model parameter (i.e., underlying binomial proportions). That is:
θ_k ~ Beta(α_k, β_k)
matrix of dimension niter * nsamples
containing samples from truncated beta distributions.
When equality constraints are specified in the restricted hypothesis, this function samples from the conditional Beta distributions given that the equality constraints hold.
Only inequality constrained parameters are sampled. Free parameters or parameters that are exclusively equality constrained will be ignored.
damien2001samplingmultibridge
generate_restriction_list
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.