easystats / parameters

:bar_chart: Computation and processing of models' parameters
https://easystats.github.io/parameters/
GNU General Public License v3.0
425 stars 36 forks source link

renaming Bayes Factor column from `BF` to `BF10` #410

Closed IndrajeetPatil closed 3 years ago

IndrajeetPatil commented 3 years ago

Since model_parameters alway returns the Bayes Factor indexing evidence in favor of the alternative over the null hypothesis (BF10), and never the reverse (BF01), I feel we should be explicit about this in the column name.

library(parameters)
library(BayesFactor)

mod <- correlationBF(mtcars$wt, mtcars$mpg)

BF10

mod
#> Bayes factor analysis
#> --------------
#> [1] Alt., r=0.333 : 13286626 ±0%
#> 
#> Against denominator:
#>   Null, rho = 0 
#> ---
#> Bayes factor type: BFcorrelation, Jeffreys-beta*

model_parameters(mod)
#> # Bayesian correlation analysis
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |              Prior |     BF |                        Method
#> --------------------------------------------------------------------------------------------------------------------
#> rho       |  -0.82 | [-0.90, -0.71] | 100% |        0% | Cauchy (0 +- 0.33) | > 1000 | Bayesian correlation analysis

BF01

1/mod
#> Bayes factor analysis
#> --------------
#> [1] Null, rho = 0 : 7.526365e-08 ±0%
#> 
#> Against denominator:
#>   Alternative, r = 0.333333333333333, rho =/= 0 
#> ---
#> Bayes factor type: BFcorrelation, Jeffreys-beta*
model_parameters(1/mod)
#> Nothing to compute for point-null models.
#> See github.com/easystats/parameters/issues/226
#> NULL

If you wonder why someone might be expecting anything other than BF10 as a default, it's because all other pieces of software (JASP, jamovi, etc.) that deal with these objects allow users to choose from these two (BF10 and BF01) options.

mattansb commented 3 years ago

There can be many other cases where the resulting BF is not a comparison to the NULL in the denominator:

library(BayesFactor)
library(parameters)

Comparing two non-null models

mod <- correlationBF(mtcars$carb, mtcars$gear, nullInterval = c(0, 1))
mod <- mod[1] / mod[2]
mod
#> Bayes factor analysis
#> --------------
#> [1] Alt., r=0.333 0<rho<1 : 11.17689 ±NA%
#> 
#> Against denominator:
#>   Alternative, r = 0.333333333333333, rho =/= 0 !(0<rho<1) 
#> ---
#> Bayes factor type: BFcorrelation, Jeffreys-beta*

model_parameters(mod) # not BF10
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> # Bayesian correlation analysis
#> 
#> Parameter | Median |       89% CI |   pd | % in ROPE |              Prior |    BF |                        Method
#> -----------------------------------------------------------------------------------------------------------------
#> rho       |   0.29 | [0.03, 0.49] | 100% |     9.58% | Cauchy (0 +- 0.33) | 11.18 | Bayesian correlation analysis

Another example:

m1 <- lmBF(mpg ~ am, mtcars)
m2 <- lmBF(mpg ~ hp, mtcars)
m3 <- lmBF(mpg ~ hp + hp, mtcars)

m2 / m1
#> Bayes factor analysis
#> --------------
#> [1] hp : 652.5196 ±0.01%
#> 
#> Against denominator:
#>   mpg ~ am 
#> ---
#> Bayes factor type: BFlinearModel, JZS
model_parameters(m2 / m1) # not BF10
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> # Bayes factors for linear models
#> 
#> # Extra Parameters
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |     BF |                          Method
#> -------------------------------------------------------------------------------------------------
#> mu        |  20.08 | [18.85, 21.16] | 100% |        0% | 652.52 | Bayes factors for linear models
#> sig2      |  15.75 | [10.18, 23.47] | 100% |        0% | 652.52 | Bayes factors for linear models
#> g         |   0.95 | [ 0.05,  5.86] | 100% |    38.02% | 652.52 | Bayes factors for linear models
#> 
#> # Fixed Effects
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |     BF |                          Method
#> -------------------------------------------------------------------------------------------------
#> hp        |  -0.06 | [-0.08, -0.05] | 100% |      100% | 652.52 | Bayes factors for linear models

The null (the less complex model) is the numerator, the alternative (more complex model) is the denominator

m1 / m3
#> Bayes factor analysis
#> --------------
#> [1] am : 0.001532521 ±0.01%
#> 
#> Against denominator:
#>   mpg ~ hp + hp 
#> ---
#> Bayes factor type: BFlinearModel, JZS
model_parameters(m1 / m3) # not BF10
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> Multiple `BFBayesFactor` models detected - posteriors are extracted from the first numerator model.
#> See help("get_parameters", package = "insight").
#> # Bayes factors for linear models
#> 
#> # Extra Parameters
#> 
#> Parameter | Median |         89% CI |   pd | % in ROPE |    BF |                          Method
#> ------------------------------------------------------------------------------------------------
#> mu        |  20.08 | [18.61, 21.45] | 100% |        0% | 0.002 | Bayes factors for linear models
#> sig2      |  25.31 | [16.03, 37.24] | 100% |        0% | 0.002 | Bayes factors for linear models
#> g         |   0.39 | [ 0.02,  2.53] | 100% |    70.46% | 0.002 | Bayes factors for linear models
#> 
#> # Fixed Effects
#> 
#> Parameter | Median |       89% CI |   pd | % in ROPE |    BF |                          Method
#> ----------------------------------------------------------------------------------------------
#> am        |   6.50 | [3.53, 9.48] | 100% |        0% | 0.002 | Bayes factors for linear models

Created on 2021-01-30 by the reprex package (v0.3.0)

IndrajeetPatil commented 3 years ago

Ah, fair enough. Wasn't even thinking of more complex models when I was thinking about this issue.

You are right, then it would be uncalled-for to default to BF10.

mattansb commented 3 years ago

That's what I'm here for 😋 - we each play our part in the circle to ~life~ easystats!

DominiqueMakowski commented 3 years ago

I'm personally not a fan of the 10/01 denomination which I find rather confusing. I remember in the (very) early days it took me some time to realize that it meant 1 vs 0 or the opposite, as I was naturally reading it as "ten"... but then maybe I'm the only one in that case 🤷

mattansb commented 3 years ago

I agree - as BFs are always comparative, and I think it is best practice to say explicitly what is being compared, the notations of BF10 BF01, BF1+ are redundant (e.g., not needed if I say "The model without a linear correlation was strongly supported by the data over the model with a positive correlation (BF = 782.1)")

Also, if we use protect_ratio = TRUE, we don't need to flip BFs to make them human readable:

insight::format_bf(0.0414, protect_ratio = TRUE)
#> [1] "BF = 1/24.15"

Created on 2021-01-31 by the reprex package (v0.3.0)

IndrajeetPatil commented 3 years ago

I agree that this nomenclature is not ideal but that's what is adopted by virtually all pioneers who have written about this topic (e.g., Wagenmakers) and the software programs that support these analyses, so you can't blame users to be used to it or even to be expecting it.

For example,

Screenshot 2021-01-31 at 08 10 02