hypothesis | R Documentation |
Returns posterior probabilities and Bayes Factors for flexible hypotheses involving
model parameters. The documentation for the argument hypotheses
below
shows examples of how to specify hypotheses, and read worked examples on the mcp website.
For directional hypotheses, hypothesis`` executes the hypothesis string in a
tidybayes“ environment and summerises the proportion of samples where
the expression evaluates to TRUE. For equals-hypothesis, a Savage-Dickey
ratio is computed. Savage-Dickey requires a prior too, so remember
mcp(..., sample = "both")
. This function is heavily inspired by the
'hypothesis' function from the 'brms' package.
hypothesis(fit, hypotheses, width = 0.95, digits = 3)
fit |
An |
hypotheses |
String representation of a logical test involving model parameters. Takes R code that evaluates to TRUE or FALSE in a vectorized way. Directional hypotheses are specified using <, >, <=, or >=.
Hypotheses can also test equality using the equal sign (=). This runs a
Savage-Dickey test, i.e., the proportion by which the probability density
has increased from the prior to the posterior at a given value. Therefore,
it requires
|
width |
Float. The width of the highest posterior density interval (between 0 and 1). |
digits |
a non-null value for digits specifies the minimum number of significant digits to be printed in values. The default, NULL, uses getOption("digits"). (For the interpretation for complex numbers see signif.) Non-integer values will be rounded down, and only values greater than or equal to 1 and no greater than 22 are accepted. |
A data.frame with a row per hypothesis and the following columns:
hypothesis
is the hypothesis; often re-arranged to test against zero.
mean
is the posterior mean of the left-hand side of the hypothesis.
lower
is the lower bound of the (two-sided) highest-density interval of width width
.
upper
is the upper bound of ditto.
p
Posterior probability.
For "=" (Savage-Dickey), it is the BF converted to p.
For directional hypotheses, it is the proportion of samples that returns TRUE.
BF
Bayes Factor in favor of the hypothesis.
For "=" it is the Savage-Dickey density ratio.
For directional hypotheses, it is p converted to odds.
Jonas Kristoffer Lindeløv jonas@lindeloev.dk
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.