Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Make it clearer in documentation that logBFs (not BFs) are calculated #154

Open
nadyamajeed opened this issue Jun 27, 2021 · 5 comments
Assignees

Comments

@nadyamajeed
Copy link

Just a simple request to make it clearer for people using the package for the first time—for example, in the ttestBF() documentation, it says that "This function computes Bayes factors, or samples from the posterior, for one- and two-sample designs.", which may lead users to think that the function computes BF10 instead of log-BF10. Might be especially confusing for people coming from JASP, where the default is to calculate BF10 and not log-BF10.

Example: BayesFactor::ttest.tstat(-0.39, n1=69, n2=37)
Output:

$bf
[1] -1.472996

$properror
[1] 0.0003371024

$method
[1] "quadrature"

bf = -1.472996 seems to be referring to log BF, not BF, since BF cannot be negative.

exp(-1.472996) gives the output [1] 0.2292377, which seems to be the actual value of BF10.

@yihe-61wu
Copy link

yihe-61wu commented Dec 21, 2021

A student showed me some regression results by regressionBF recently, and I was surprised to see negative Bayes factors.

I also assume log(bf) instead of bf is the output!


I'm leaving a mark here to show that more people want this issue fixed!

I've been using keywords such as, negative Bayes factor, negative bayesfactor, negative bf, in my search engine trying to find relevant discussions. I'm hoping this comment can bring people encountering similar issues here.

@richarddmorey
Copy link
Owner

A student showed me some regression results by regressionBF recently, and I was surprised to see negative Bayes factors.

I also assume log(bf) instead of bf is the output!


I'm leaving a mark here to show that more people want this issue fixed!

I've been using keywords such as, negative Bayes factor, negative bayesfactor, negative bf, in my search engine trying to find relevant discussions. I'm hoping this comment can bring people encountering similar issues here.

How did you see negative BFs from regressionBF? That function only reports BFs, not log BFs. The only way of getting log BFs out of a regressionBF function is if you go mucking about in the object structure instead of using (say) extractBF, as.vector, or as.data.frame.

@yihe-61wu
Copy link

I'm very sorry for making arbitrary assumptions in my previous comment. I know negative Bayes factor shouldn't be legal. And thus so little discussion on this can be found. And I naively thought a similar issue was encountered.

A student showed me some regression results by regressionBF recently, and I was surprised to see negative Bayes factors.
I also assume log(bf) instead of bf is the output!

I'm leaving a mark here to show that more people want this issue fixed!
I've been using keywords such as, negative Bayes factor, negative bayesfactor, negative bf, in my search engine trying to find relevant discussions. I'm hoping this comment can bring people encountering similar issues here.

How did you see negative BFs from regressionBF? That function only reports BFs, not log BFs. The only way of getting log BFs out of a regressionBF function is if you go mucking about in the object structure instead of using (say) extractBF, as.vector, or as.data.frame.

I believe we didn't do anything out-of-box that leads to this weird result. The student is trying to do a (log-)linear regression. After loading the data dataPilot, which contains a column of logat and trials, we run one and only one line:

bfT <- regressionBF(logat ~ trials, data = dataPilot)

which gives the following results:

> bfT@numerator
$trials
---
 Model:
Type: BFlinearModel, JZS
logat ~ trials 
Data types:
trials :  continuous 

> bfT@denominator
---
 Model:
Type: BFlinearModel, JZS
Intercept only 
Data types:
trials :  continuous 

> bfT@bayesFactor
              bf        error                     time        code
trials -1.137044 2.639584e-05 Wed Dec 22 09:43:43 2021 1abc8b66208

Are we reading the results in a wrong way?

I was mystified by this issue. And I'm sure it's not the student's hardware or software problem, because she sent me her script and data, and I used them to reproduce the above results. I can't share her data directly here, but if I'm reading the results correctly, and bf does mean Bayes factor, then negative Bayes factor shouldn't be possible. Although in principle the data file shouldn't be relevant, I'm going to email you her data and script (with her consent) for you to reproduce the exact problem.

Many thanks.

@richarddmorey
Copy link
Owner

Yes, this is an undocumented use of the BF object. You don't need to go looking in the object back-end; there are functions designed to give you the information you need. If you want you see the Bayes factor, you type 'bfT'. If you want to extract its value, you type 'extractBF(bfT)'.

@yihe-61wu
Copy link

Thank you!

We didn't use extractBF(), which led to the weird output and misunderstanding.


For those who are interested, after regression, the results are:

> extractBF(bfT)
              bf        error                     time         code
trials 0.3207658 2.639584e-05 Wed Dec 22 11:41:59 2021 45f857b05716
> bfT@bayesFactor
              bf        error                     time         code
trials -1.137044 2.639584e-05 Wed Dec 22 11:41:59 2021 45f857b05716

Note exp(-1.137044) = 0.3207658.


Sorry that my issue is not identical to the original request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants