count_to_bf | R Documentation |
Computes the encompassing Bayes factor (and standard error) defined as the ratio of posterior/prior samples that satisfy the order constraints (e.g., of a polytope).
count_to_bf( posterior, prior, exact_prior, log = FALSE, beta = c(1/2, 1/2), samples = 3000 )
posterior |
a vector (or matrix) with entries (or columns)
|
prior |
a vecotr or matrix similar as for |
exact_prior |
optional: the exact prior probabability of the order constraints.
For instance, |
log |
whether to return the log-Bayes factor instead of the Bayes factor |
beta |
prior shape parameters of the beta distributions used for approximating the standard errors of the Bayes-factor estimates. The default is Jeffreys' prior. |
samples |
number of samples from beta distributions used to compute standard errors. The unconstrained (encompassing) model is the saturated baseline model that assumes a separate, independent probability for each observable frequency. The Bayes factor is obtained as the ratio of posterior/prior samples within an order-constrained subset of the parameter space. The standard error of the (stepwise) encompassing Bayes factor is estimated by sampling ratios from beta distributions, with parameters defined by the posterior/prior counts (see Hoijtink, 2011; p. 211). |
a matrix with two columns (Bayes factor and SE of approximation) and three rows:
`bf_0u`
: constrained vs. unconstrained (saturated) model
`bf_u0`
: unconstrained vs. constrained model
`bf_00'`
: constrained vs. complement of inequality-constrained model
(e.g., pi>.2 becomes pi<=.2; this assumes identical equality constraints for both models)
Hoijtink, H. (2011). Informative Hypotheses: Theory and Practice for Behavioral and Social Scientists. Boca Raton, FL: Chapman & Hall/CRC.
count_binom
, count_multinom
# vector input post <- c(count = 1447, M = 5000) prior <- c(count = 152, M = 10000) count_to_bf(post, prior) # matrix input (due to nested stepwise procedure) post <- cbind(count = c(139, 192), M = c(200, 1000)) count_to_bf(post, prior) # exact prior probability known count_to_bf( posterior = c(count = 1447, M = 10000), exact_prior = 1 / factorial(4) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.