使用`proportionBF`进行单样本比例检验(两级以上)

using `proportionBF` to carry out one-sample proportion test (more than two levels)

我想为原假设为-

的单样本比例检验计算贝叶斯因子

The proportions for the levels for the nominal variable are not different from the theoretical proportions

我知道如何使用 BayesFactor 包中的 proportionBF 在存在两个比例时执行此操作,零假设是两个级别的可能性相同 (p = 0.5)。这相当于 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

但是我不知道当有两个以上的比例时如何做这个分析,相当于stats::chisq.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

如何使用 BayesFactor 包计算此测试的贝叶斯因子?

(P.S。如果不可能,我也有兴趣了解任何其他可以做同样事情的包。)

BayesFactor 的作者在这里回答了这个问题: https://gist.github.com/richarddmorey/a4cd3a2051f373db917550d67131dba4