I want to compute Bayes Factor for one-sample proportion test where the null hypothesis is that-
The proportions for the levels for the nominal variable are not different from the theoretical proportions
I know how to use proportionBF
from BayesFactor
package to do this when there are two proportions with the null hypothesis being that the two levels are equally likely (p = 0.5
). This is equivalent to stats::binom.test
.
# frequentist test (p-value > 0.05)
broom::tidy(stats::binom.test(x = 21, n = 44, p = 0.5))
#> # A tibble: 1 x 8
#> estimate statistic p.value parameter conf.low conf.high method
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 0.477 21 0.880 44 0.325 0.633 Exact~
#> # ... with 1 more variable: alternative <chr>
# quantifying evidence in favor of null hypothesis
library(BayesFactor)
1/ proportionBF(y = 21, N = 44, p = 0.5, rscale = 0.707)
#> Bayes factor analysis
#> --------------
#> [1] Null, p=0.5 : 3.724132 ±0.02%
#>
#> Against denominator:
#> Alternative, p0 = 0.5, r = 0.707, p =/= p0
#> ---
#> Bayes factor type: BFproportion, logistic
But I don't know how to do this analysis when there are more than two proportions, the equivalent of stats::chisq.test
(a goodness of fit test).
# frequentist test (p-value > 0.05)
table(mtcars$cyl)
#>
#> 4 6 8
#> 11 7 14
broom::tidy(stats::chisq.test(x = table(mtcars$cyl)))
#> # A tibble: 1 x 4
#> statistic p.value parameter method
#> <dbl> <dbl> <dbl> <chr>
#> 1 2.31 0.315 2 Chi-squared test for given probabilities
How can I compute Bayes Factor for this test using BayesFactor
package?
(P.S. If not possible, I'd also be interested in knowing any other package that can do the same.)