bayestestR
bayestestR copied to clipboard
implement p-to-bf
data(iris)
model <- lm(Petal.Length ~ Sepal.Length + Species, data = iris)
bayestestR::p_to_bf(model)
#> Parameter p BF
#> 1 (Intercept) 1.005180e-11 3.693268e-10
#> 2 Sepal.Length 1.121002e-28 4.118823e-27
#> 3 Speciesversicolor 9.645641e-67 3.544035e-65
#> 4 Speciesvirginica 4.917626e-71 1.806851e-69
Created on 2022-05-16 by the reprex package (v2.0.1)
Fixed: Now returns BF10 (instead of BF01, which is what the formula in the paper give...)
This paper is essentially trying to approximate the BIC to BF approximation (relaying on how Wald tests are asymptotically LRTs)...
Here is a demo (using @bwiernik pipebind
!)
library(bayestestR)
library(pipebind)
#> Warning: package 'pipebind' was built under R version 4.1.3
m0 <- lm(mpg ~ 1, mtcars)
m1 <- lm(mpg ~ am, mtcars)
m2 <- lm(mpg ~ factor(cyl), mtcars)
bic_to_bf(BIC(m1), denominator = BIC(m0))
#> [1] 222.005
m1 |>
parameters::p_value() |>
bind(x, x[2, "p"]) |>
p_to_bf(n_obs = nrow(mtcars))
#> p BF
#> 1 0.0002850207 206.7413
bic_to_bf(BIC(m2), denominator = BIC(m0))
#> [1] 45355714
anova(m2) |>
parameters::p_value() |>
bind(x, x[1, "p"]) |>
p_to_bf(n_obs = nrow(mtcars))
#> p BF
#> 1 4.978919e-09 11835011
Created on 2022-05-17 by the reprex package (v2.0.1)
If we do decide to merge this PR, I hope we don't endorse this down the line by adding these to any outputs.
If we do decide to merge this PR, I hope we don't endorse this down the line by adding these to any outputs.
yes i agree
tbh i wouldn't call it "pseudo" it's a bit long as a name and you know... what is "pseudo" really, if all approximations are pseudo then we should pseudo a lot of stuff ^^
My thinking is that this is much more of a heuristic approximation than other approximations. And it’s a bit long for a reason 😜
If you read the paper they are using the p-value to approximate the SE to approximate the LRT to approximate for the BIC comparisons that can be used to produce BFs. That is a long chain, with many assumptions...
I think p_to_pseudo_bf()
is a good compromise...
okay i'm convinced
Codecov Report
Merging #529 (9098b03) into main (d494d36) will decrease coverage by
0.32%
. The diff coverage is0.00%
.
@@ Coverage Diff @@
## main #529 +/- ##
==========================================
- Coverage 52.94% 52.61% -0.33%
==========================================
Files 64 65 +1
Lines 4879 4909 +30
==========================================
Hits 2583 2583
- Misses 2296 2326 +30
Impacted Files | Coverage Δ | |
---|---|---|
R/p_to_bf.R | 0.00% <0.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
we should have merged this while i was onboard with p_to_pseudo_bf, now after looking back I think p_to_bf and put the dicslaimer in the title + docstrings should be enough. I mean people will at least check the title of the function ^^ wadayathink?
I mean....... No...
BF is pseudo, anyway, so p_to_bf()
includes all necessary information?
I'm open for both suggestion, i.e. renaming to p_to_pseudo_bf()
, or keep it as it is. @DominiqueMakowski do you plan to merge this before submitting bayestestR? I think it's feature complete now.
I vote pseudo 👏
I vote for keeping it as is
@easystats/core-team we need some help here...
Compromise, leave the name and change the output to say “pseudo-BF”?
Compromise, leave the name and change the output to say “pseudo-BF”?
Yeah, that's what I already did in the print method, as table header :-)
Yeah, that's what I already did
Meme lord + forward thinker nice
Now let's hope this humble offering pleases @mattansb 🙏
I'm good with it
I'll take it