Description Usage Arguments Details Value Author(s) References See Also Examples
Compute BFs for hypotheses. A kin to 'brms::hypothesis'.
1 2 |
BF |
an object returned by any of the BayesFactor modeling functions |
hypothesis |
specified hypotheses, returned from 'hyp'. |
hdi.level |
credible level |
iterations |
number of posterior iterations |
seed |
A single numeric value passed to set.seed to make results reproducible. |
index |
which BF mddel to test? (for |
nice.names |
whould the coeff names be a little nicer? (for |
... |
passed to posterior sampling function |
Please note that 'inferBF' is in alpha stages of development, and though it is suited for estimating effects (contrasts / slopes), it should not be used for estimating predicted values (due to 'BayesFactor' currently not supporting "intercept" estimation).
For directed hypotheses:
BF.v.Prior
- The change in probability of hypothesis from the prior distribution
to the posterior. Can also be thought as the BF of the restricted model vs. the
unrestricted model.
BF.v.Null
- The evidence ratio between the denominator of the BF object
and the restricted mode. Calculated as BF.v.Prior times the models BF.
BF.v.Opposite
- The BF of 'a>b'/'b>a'
Post.Prob
- Posterior probability
For undirected (point) hypotheses:
Estimate
- The median of the posterior distribution
Est.Error
- Standard error of the posterior distribution
HDI.Lower
- upper bound of HDI credible interval
HDI.Upper
- lower bound of HDI credible interval
BF
- The Savage-Dickey density ratio
A list of data.frames, for each hypothesis, that prints nicely.
Mattan S. Ben-Shachar
Wagenmakers, E. J., Lodewyckx, T., Kuriyal, H., & Grasman, R. (2010). Bayesian hypothesis testing for psychologists: A tutorial on the Savage-Dickey method. Cognitive psychology, 60(3), 158-189.
Morey, R. D., & Wagenmakers, E. J. (2014). Simple relation between Bayesian order-restricted and point-null hypothesis tests. Statistics & Probability Letters, 92, 121-124.
Morey, R. D. (2015). Multiple Comparisons with BayesFactor, Part 2 - order restrictions [Blog post]. https://richarddmorey.org/2015/01/multiple-comparisons-with-bayesfactor-part-2-order-restrictions/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | ## Not run:
# =======
# anovaBF
# =======
library(BayesFactor)
library(BFEffects)
data(puzzles)
BF <- anovaBF(RT ~ shape*color + ID, data=puzzles, whichRandom = "ID", progress = FALSE)
# If no hypotheses are passed, `inferBF` returns the paramater names:
inferBF(BF[4])
## [1] "mu" "round" "square" "color" "monochromatic"
## [6] "X1" "X2" "X3" "X4" "X5"
## [11] "X6" "X7" "X8" "X9" "X10"
## [16] "X11" "X12" "round...color" "round...monochromatic" "square...color"
## [21] "square...monochromatic" "sig2" "g_shape" "g_color" "g_ID"
## [26] "g_shape.color"
## Test a model that has two simple effects of color in each level of shape.
puzzle_hypotheses <- hyp(directed_h = (color + round...color < monochromatic + round...monochromatic) &
(color + square...color < monochromatic + square...monochromatic),
point_h = color - monochromatic)
inferBF(BF[4],puzzle_hypotheses)
## Hypotheses tested based on the model:
## RT ~ shape + color + shape:color + ID
##
## Directional Tests:
## BF.v.Prior BF.v.Null BF.v.Opposite Post.Prob
## directed_h 2.757 11.661 11.484 0.92
##
## Point Tests:
## Estimate Est.Error HDI.Lower HDI.Upper BF
## point_h -0.86 0.383 -1.576 -0.079 3.128
## ---
## HDI level: 0.95
## Point BF calculated using the Savage-Dickey method
# ============
# regressionBF
# ============
data(attitude)
BF <- regressionBF(rating ~ ., data = attitude, progress = FALSE)
# test for a positive slope for complaints and a positive slope for learning.
attitude_hypo <- hyp(complaints = complaints > 0,
attitude = learning > 0,
both = learning > 0 & complaints > 0)
inferBF(head(BF)[2], attitude_hypo)
## Hypotheses tested based on the model:
## rating ~ complaints + learning
##
## Directional Tests:
## BF.v.Prior BF.v.Null BF.v.Opposite Post.Prob
## complaints 2.008 416208.6 Inf 1.000
## attitude 1.861 385670.5 12.699 0.927
## both 3.730 773203.4 12.699 0.927
# =================
# Advanced analyses
# =================
BF <- regressionBF(rating ~ ., data = attitude, progress = FALSE)
advance_hypo <- hyp(
# privileges is not between [-0.2,0.2]
# Post.Prob is the % of posterior mass outside the ROPE
ROPE_privileges = !(privileges > -0.2 & privileges < 0.2),
# Estimate privileges
estimate_privileges = privileges,
# Estimate privileges based on a one sided prior
estimate_privileges2 = ifelse(privileges > 0,privileges,NA)
)
inferBF(BF[2], advance_hypo)
## Hypotheses tested based on the model:
## rating ~ privileges
##
## Directional Tests:
## BF.v.Prior BF.v.Null BF.v.Opposite Post.Prob
## ROPE_privileges 1.23 3.907 4.118 0.805
##
## Point Tests:
## Estimate Est.Error HDI.Lower HDI.Upper BF
## estimate_privileges 0.339 0.172 0.017 0.679 3.394
## estimate_privileges2 0.342 0.162 0.037 0.655 5.940
## ---
## HDI level: 0.95
## Point BF calculated using the Savage-Dickey method
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.