Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Plotting Robustness Check in R

I am using the BayesFactor package to calculate Bayes factors of inclusion on some mixed-effect linear models. Jasp has the really cool functionality of plotting the prior robustness check like so:

Is there currently a nifty R function/package to do this, or close to this in R?

• I am not sure but I'll ask Richard.

E.J.

• Not by default, but it is easy in R. Here's some example code, using sapply.

# Data for the example:

set.seed(111)

x = rnorm(20)

y = rnorm(20) + .7

library(BayesFactor)

## With default

default_bf = as.vector(ttestBF(x,y))

## equal intervals on log scale from 1/3 to 3 times the default

r_values = exp(seq(log(1/3), log(3), len = 20)) * sqrt(2)/2

bfs = sapply(r_values, function(r) as.vector(ttestBF(x,y, rscale = r)))

plot(r_values, bfs, ty='l', log = 'xy', las = 1,

ylab = "Bayes factor", xlab = "Prior scale")

abline(v = sqrt(2)/2, lty=2)