Howdy, Stranger!

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

Supported by

Bayes Factors for non-parametric tests

Is there a way to get Bayes Factor for a Mann-Whitney U ?

Comments

  • Yes. Johnny has developed and implemented it. I'll ask him about the current status as far as the JASP implementation is concerned (the paper is at https://arxiv.org/abs/1712.06941)

    E.J.

  • Hi Peterose1,

    If you want to conduct the two-sample test, this is readily available in JASP. I am still in the process of implementing the one-sample versions - if you want I can link you some R-code that gives you a Bayes factor and posterior distribution.

    Cheers,

    Johnny

  • Thanks, JonnyB. We are doing a 2-sample comparison, so can use JASP.

    Regards,

    Peter

  • Hi there,

    I'm in search of R-code to output a Bayes factor with the two-sample test so as to embed it in my markdown doc. Would you mind sharing, or pointing me in this direction?

    Many thanks,

    Elise

  • Hi Elise,

    The R-code can be found on the OSF page of the corresponding article (under review atm).

    You give it the observations from the two groups (first two arguments of the function), then take the vector of 'deltaSamples' that it outputs and feed it into the giveBayesFactorZeroOne function.

    The article can be found on Arxiv (https://arxiv.org/abs/1712.06941).

    Cheers,

    Johnny

  • Dear JohnnyB,

    Thanks for supporting R codes to run Bayes Factor for a Mann-Whitney U. However, as a newbie of R and statistic, I am getting difficulties to run those codes (after loading rankSumSampler.R to R environment). Do we need to use the WinBUGS package or several packages like this to run the above codes?.

    I am appreciating you if you have the guidance in detail for newbies.

    Thank you very much and waiting for hearing from you.

  • Hi Elnino,

    What error message are you getting? The only R package you need installed is the logspline package - you can install it with install.packages("logspline"). After that all code should run. If you have any additional questions about this you can also send me an email at johnnydoorn at gmail dot com and I can help you out!

    Cheers

    Johnny

  • Dear JohnnyB.

    Thank you for your kind help. I am firstly trying with your above teaching and if there are troubles that happened, I hope that you will also help me via an E-mail as a discussion.

    I am following a paper of "Bayesian rank-based hypothesis testing for the rank sum test, the signed rank test, and Spearman's ρ" to wish to have a little paper in my field as a first paper for graduating (I am a Vietnamese Ph.D. student in National Japanese University).

    Thank you very much,

    Tan-Duc Nguyen

  • Hi Johnny,

    It's awesome that you shared the R code, but I too have some questions about how to use it.

    1. The result is always "BF01" (e.g. regardless of specific xVals or yVal input vectors), i.e. the giveBayesFactorZeroOne output BF < 1 is always evidence for difference, while BF > 1 is always evidence for equivalence, right?

    2. The usage is the same for rankSumGibbsSampler (for unpaired) and signRankGibbsSampler (for paired), so e.g. I just give either the rankSumGibbsSampler(v1, v2)$deltaSamples or signRankGibbsSampler(v1, v2)$deltaSamples for the giveBayesFactorZeroOne function? In the two R files, the giveBayesFactorZeroOne is given separately each time, but it's identical. (I see the optional parameter "paired = TRUE", but it's never actually used in that function.)

    3. How do I get BFs from spearmanGibbsSampler? It returns "rhoSamples" – can I perhaps use that as argument for the giveBayesFactorZeroOne function (in place of deltaSamples)?

    4. I suppose this is something extra, but is there perhaps some easy way to set any of these tests to be one-sided?

  • Hi Gaspar,

    1) Yes, the R-code is limited that way, in that it only does the two-sided tests.

    2) The giveBAyesFactorZeroOne is the same for both the rank sum and signed rank test, since it applies the Savage-Dickey density ratio (i.e., the ratio of the prior and posterior densities at the point of testing - 0), and both of those tests use a Cauchy prior distribution. Initially I thought it would be different, hence the argument in the function definition.

    3) you can pass the rhoSamples to the function, and specify the "corTest" argument to TRUE - then it will compute the Bayes factor for the correlation (also through the Savage-Dickey density ratio, but now with a uniform prior distribution).

    4) the nonparametric t-tests are also implemented in JASP, and there I did add the option to do one-sided testing. In JASP, you also get some nice plots of the prior/posterior distribution.

    Kind regards,

    Johnny

  • I see, great – thanks so much for the super fast reply!

  • Being a newbie in JASP, but fluent in R. I've downloaded all files from OSF link https://osf.io/gny35/. However it seems that this set of files does not contain giveBayesFactorZeroOne function. I cannot run `giveBayesFactorZeroOne(rankSumGibbsSampler(v1, v2)$deltaSamples)`. Can anyone give me a hint what am I doing wrong? Thanks!

  • Hi Pmilin,


    Did you also download and source the rankBasedCommonFunctions.R file? https://osf.io/5t4nf/

    I restructured it a bit to maintain a clearer overview of all the functions.


    Cheers

    Johnny

  • Hi Johnny,

    Yes I did and call me crazy but it does not contain contain giveBayesFactorZeroOne function!

    Help! :-)

  • Hi Pmilin,

    Oh sorry, I just realized I renamed it to "computeBayesFactorOneZero", to make it a bit more accurate. Apologies for the confusion!

    Cheers

    Johnny

  • No worries! 😂

Sign In or Register to comment.