Calculate Bayes Factors and robustness regions from summary statistics.

Installation

You can install the development version from GitHub with:

Example

library(bfrr)
library(ggplot2)
library(cowplot)

First, we’ll simulate 50 data points from a normal distribution with a mean of 0.25 and SD of 1 and conduct a one-sample t-test.

Set up the test using bfrr().

Use summary(rr) to output a summary paragraph.

The likelihood of your data under the theoretical distribution N(0, 0.25) is 0.16. The likelihood of your data under the null distribution T(49) is 0.01. The Bayes Factor is 20.6; this test finds evidence for H1 with a criterion of 6. The region of theoretical model parameters that give the same conclusion is HN([-0.2, 0.9], 0.25); HN(0, [0.1, 2]).

Use plot(rr) to view a plot of your data.

plot(rr)

If your mean is 0 or you set the same number for the lower and upper bounds of a parameter’s rr_interval, that parameter won’t vary and you’ll get a graph that looks like this.

r1 <- bfrr(sample_mean = 0.25, tail = 1)
r2 <- bfrr(sample_mean = 0.25, tail = 2)
p1 <- plot(r1)
p2 <- plot(r2)

p1t <- paste0("One-tailed H1, RR = [", toString(r1$RR$sd), "]")
p2t <- paste0("Two-tailed H1, RR = [", toString(r2$RR$sd), "]")
cowplot::plot_grid(p1 + ggtitle(p1t), 
                   p2 + ggtitle(p2t), 
                   nrow = 2)