Howdy, Stranger!

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

Supported by

Extracting BFs from anovaBF or any Formal class BFBayesFactor object


I am using BayesFactor to run an ANOVA:

model<- anovaBF(dif ~ cond * exp, data=df)

The output appears in the console, but if I want to save it as an object, then the object class for this object is a "Formal class BFBayesFactor". What I need is to extract only the BF10 for a given line, so that I could save this as a row in a new dataframe (this is because I want to run the model on 1000 simulated data sets and see how many of them show an effect of a given size...).

I can get one of the slots of the Formal class object by using @ (e.g. model@bayesFactor). However, the values in the bayesFactor slot do not correspond to the values printed in the console.

How do I get access to the values that are printed in the console?

Thanks in advance,



    edited December 2019

    You can use as.vector():

    result <- anovaBF(RT ~ shape*color + ID, data = puzzles,
             whichRandom = "ID", progress = FALSE)
    #> Bayes factor analysis
    #> --------------
    #> [1] shape + ID                       : 2.840104 ±0.84%
    #> [2] color + ID                       : 2.841925 ±1.48%
    #> [3] shape + color + ID               : 11.43469 ±1.23%
    #> [4] shape + color + shape:color + ID : 4.873394 ±10.38%
    #> Against denominator:
    #>  RT ~ ID 
    #> ---
    #> Bayes factor type: BFlinearModel, JZS
    #>            shape + ID            color + ID 
    #>             2.840104             2.841925 
    #>        shape + color + ID shape + color + shape:color + ID 
    #>            11.434689             4.873394

  • This works, thank you for such a swift and helpful response!


    Now maybe you could also answer a more conceptual question?

    My own dataset gives inconclusive results for my effect of interest (BF10 = ~2).

    A reviewer asked how many participants I would have to add to cross my desired strength of evidence (BF10>3), and suggested I run simulations. I thought it makes sense to create a larger sample by creating a fake dataset with the same betas as my actual regression (which I obtained from a non-bayesian analysis):

    # Set coefficients
    alpha = -1.3091
    beta1 = .0556
    beta2 = -1.8874
    beta3 = 6.0730
    # Generate 100 trials
    A = c(rep(c(0), 50), rep(c(1), 50)) # '0' 100 times, '1' 100 times
    B = rep(c(rep(c(0), 25), rep(c(1), 25)), 2) # '0'x50, '1'x50, '0'x50, '1'x50
    e = rnorm(100, 0, sd=1) # Random noise, with standard deviation of 1
    # Generate data using the regression equation
    y = alpha + beta1*A + beta2*B + beta3*A*B + e
    # Join the variables in a data frame
    data = data.frame(cbind(A, B, y))
    # Fit a regression
    model = generalTestBF(y ~ A*B, data=data)

    Now, if I increase the number of rows in my fake data set (let's say from 100 to 300), the strength of evidence should logically increase, am I right? Or maybe it doesn't have to? Because when I do that I get more or less the same result (~700 of my fake datasets give a result around BF10~3, and the rest give a BF~2). Maybe it's my NHT logic at work and it doesn't work this way for a Bayesian analysis?

  • Generally, BFs are suppose to converge to the "truth" as N increases. So I depends what "truth" your betas are closer to, I guess.

    For determining N, you might also be interested in

  • Well, according to the references on the BDFA page (thank you!!) the evidence should become more conclusive as I increase sample size (either towards H1 or H0, but it should still change). So I must be doing something wrong somewhere.

  • Hi Naomi,

    In general, asymptotically, and on average (!), increasing sample size leads to more conclusive BFs. But for a specific data set, a BF might become less compelling as N grows (up to a point). Also, the BFs may increase (again, on average) only slowly, depending on the details of the model specification -- if the data show a whopper of an effect, evidence will initially increase steeply, but if the effect is modest the change is evidence may only be noticeable for a large increase in sample size.



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 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