#### Howdy, Stranger!

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

Supported by

# uniform prior?

Hi there,

I'm using the BF R-package (https://cran.r-project.org/web/packages/BayesFactor/BayesFactor.pdf) ttestBF function and am interested to use a uniform prior instead of a Cauchy (as described here http://www.lifesci.sussex.ac.uk/home/Zoltan_Dienes/inference/Bayes.htm). Does anyone know how this can be achieved?

Thanks a lot,

Lina

• Hi Lina,

You cannot use a uniform prior for this particular test, as it is improper (i.e., does not have area 1). You could entertain a bounded uniform prior with a large range, but this implies (1) the strong belief that the effect size is huge; (2) the absence of prior commitment to particular data patterns -- the model does not make (strong) predictions, which means it will receive a massive penalty for complexity.

Cheers,

E.J.

• Hi EJ,

Thanks so much for the quick reply. We are actually running some simulations and are assessing the effect of different priors on our data. How would we go about implementing this bounded uniform prior you mentioned within the Bayes Factor R package?

Thanks so much,

Lina

• I'm not sure whether it can be done, but I'll ask Richard.

Cheers,

E.J.

• There's no default way of doing it in the BayesFactor package, but it is trivial to program up in R. Here's a function. You can do a bounded Cauchy using ttestBF and the nullInterval argument, or you can use the function below to use a bounded uniform prior on the effect size delta:

bf_unif = function(t, n1, n2 = NULL, lower, upper){

neff = ifelse(is.null(n2), n1, (n1*n2)/(n1 + n2))

df = ifelse(is.null(n2), n1 - 1, n1 + n2 - 2)

mlike = integrate(function(d) dt(t, df, d * sqrt(neff))/abs(upper-lower),

lower = min(lower, upper),

upper = max(lower, upper))[[1]]

return(mlike / dt(t, df))

}

t = 1.5

n1 = 30

n2 = 25

l = 0

u = 2

## bounded uniform

bf_unif(t, n1, n2, l, u)

• Amazing! Thank you so much. I will try :)

Lina