Howdy, Stranger!

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

Supported by

Bayesian one proportion test: different results in JASP and BayesFactor package

edited October 2022 in JASP & BayesFactor

Hi,

I am trying to calculate the Bayes Factor for a one-proportion test. I have a categorical variable in which participants selected one out of three options. Where p is the proportion of people who selected the second option in this categorical variable, my hypothesis is: H0: p = 0.5 and H1: p > 1/3

I get very different results when running the test in JASP (with default priors) and when using the BayesFactor package in R (proportionBF function). For instance, BF in JASP is 0.038 but 0.30 with the BayesFactor package. Would be grateful for any insight on what might be causing this.

Many thanks!

Lewend

Comments

  • Dear Lewend,

    Can you give the specific numbers for the test? And your H0 is p = 1/3, right?

    Cheers,

    E.J.

  • Dear E.J.,

    Thank you so much and apologies for my late answer! Sorry, yes, H0 is p = 1/3. Attached is a table that contains the specific numbers. For instance, the second row shows that BF10 = 0.038. When using the BayesFactor package, I get BF10 = 0.30.

    Many thanks again!

    Kind regards,

    Lewend


  • Hi Lewend,

    Well, these are different models. JASP uses the test proposed by Jeffreys -- under H1, theta gets a uniform prior from 0 to 1. You can change that distribution by adjusting the a and b parameters of the beta distribution. In BayesFactor, the prior is a logistic distribution on the logit of theta, centered at 0.3. I like the BayesFactor specification, but it is more difficult to communicate. I do think we ought to implement it, and in such a way that it is easy to see what the specification of the prior on the logit scale means on the probability scale...

    Cheers,

    E.J.

  • Dear E.J.,

    Thank you so much for the explanation. This really helps!

    Kind regards,

    Lewend

  • I'll look into it a bit more.

    E.J.

  • Thank you! I'll stay tuned then!

    Kind regards,

    Lewend

  • OK. So first I confirm that in BayesFactor yields BF01 = 3.3 (approximately)

    #R code:

    library(BayesFactor)

    proportionBF(52,173,1/3)

    Second, the default Bayesian test in JASP gives BF01 = 7.5 (approximately). See screenshot.

    https://forum.cogsci.nl/uploads/046/RWTZ1HESB118.png There was an error displaying this embed.


    Now let's figure out what beta prior comes closest to the prior from the BayesFactor test. To do this, we use the JAGS module. Steps:

    First I'm going to deviate slightly from the BayesFactor specification and assign logit(p) a Normal distribution, centered on logit(1/3), which is log(.5). Using JAGS I'll draw from this prior and transform the samples back to the rate scale. Code:

    model{

    logit.p0 <- log(.5)

    logit.p1 ~ dnorm(logit.p0,r)

    r <- .707

    p1 <- exp(logit.p1)/(1+exp(logit.p1))

    }

    I am monitoring p1 and the MCMC samples indicate this distribution has a mean of .37 and an SD of .22:

    https://forum.cogsci.nl/uploads/530/KBZ0EU559SBD.png There was an error displaying this embed.


    I'll match these to the moments of the beta distribution and this yields a = 1.41 and b = 2.40. So now I'll return to the default test in JASP, but instead of specifying a beta(1,1) prior I'll use a beta(1.41,2.40) prior. The results:

    https://forum.cogsci.nl/uploads/960/745BGRLDW2LD.png There was an error displaying this embed.


    So now we have BF01 = 4.7. closer to 3.3 then before, but I'd like it to be a little closer still. Perhaps the beta does not quite fit to the logit-normal; or perhaps it is the fact that I used a normal instead of a logistic. Or perhaps I made a mistake!

    E.J.

  • Hi E.J.,

    Apologies again for the late answer. This is so helpful, thank you so much! Not sure why but I feel like the test in JASP is somewhat more intuitive.

    Kind regards,

    Lewend

  • Hi Lewend and E.J.,


    A couple of comments on E.J.'s implementation:

    1) logit.p1 ~ dnorm(logit.p0,r): JAGS uses the precision parameterization, not the SD parameterization.

    2) r <- .707: The default in proportionBF seems to be 0.5.

    3) If one wants to match the logistic and normal better, one could use the actual SD of the logistic which is given by: sqrt(r^2 * pi^2 / 3).

    When I adjust these things, I obtain a = 2.15 and b = 3.87 which results in BF01 = 3.729. R code below.


    library(BayesFactor)

    r <- .5

    1 / proportionBF(52,173,1/3, rscale = r)


    sd.logistic <- sqrt(r^2 * pi^2 / 3) # https://en.wikipedia.org/wiki/Logistic_distribution


    logit.p0 <- log(.5)

    logit.p1 <- rnorm(1e6, logit.p0, sd.logistic)

    p1 <- exp(logit.p1)/(1+exp(logit.p1))


    m <- mean(p1)

    s <- sd(p1)


    print(m)

    print(s)


    a <- m * (m * (1 - m) / s^2 - 1)

    b <- (1 - m) * (m * (1 - m) / s^2 - 1)


    print(a)

    print(b)


    hist(p1, probability = TRUE, breaks = 30)

    plot(function(x) dbeta(x, a, b), add = TRUE)

  • Thanks Quentin!

    E.J.

  • Hi Quentin,

    Apologies for the late reply! Thank you so much for your help and the detailed explanation!

    Kind regards,

    Lewend

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games