correlation icon indicating copy to clipboard operation
correlation copied to clipboard

Is Bayesian Kendall's tau working as expected?

Open jmgirard opened this issue 3 years ago • 3 comments

Based on my reading of the below code, if you set bayesian = TRUE and method = "kendall" then you get routed to .cor_test_bayes(method = "kendall") from L256 of cor_test() and then method = "pearson" on L24 of cor_test_bayes() without ever rank-transforming the data. Unless I am missing something, this is just calculating Pearson correlations on the untransformed data and calling them Kendall's tau correlations.

https://github.com/easystats/correlation/blob/73471db03fe91accf9f32c102dfa5041c26564dc/R/cor_test.R#L233-L268

https://github.com/easystats/correlation/blob/73471db03fe91accf9f32c102dfa5041c26564dc/R/cor_test_bayes.R#L16-L26

Example:

correlation::correlation(mtcars[, 1:3], bayesian = TRUE, method = "kendall")
#> # Correlation Matrix (kendall-method)
#> 
#> Parameter1 | Parameter2 |   rho |         95% CI |      pd | % in ROPE |        BF |         Prior
#> --------------------------------------------------------------------------------------------------
#> mpg        |        cyl | -0.80 | [-0.90, -0.64] | 100%*** |        0% | > 1000*** | Beta (3 +- 3)
#> mpg        |       disp | -0.79 | [-0.90, -0.65] | 100%*** |        0% | > 1000*** | Beta (3 +- 3)
#> cyl        |       disp |  0.86 | [ 0.74,  0.93] | 100%*** |        0% | > 1000*** | Beta (3 +- 3)
#> 
#> Observations: 32

Created on 2021-12-20 by the reprex package (v2.0.1)

jmgirard avatar Dec 20 '21 20:12 jmgirard

I think you might be right 🙈

IndrajeetPatil avatar Dec 21 '21 11:12 IndrajeetPatil

A decent approach might be to use the BBcor package as the backend here? https://github.com/donaldrwilliams/bbcor/

bwiernik avatar Dec 21 '21 16:12 bwiernik

yes i think we should fall back to BBcor to support more bayesian correlations types

DominiqueMakowski avatar Jan 09 '22 17:01 DominiqueMakowski