easystats / correlation

:link: Methods for Correlation Analysis
https://easystats.github.io/correlation/
Other
435 stars 56 forks source link

running kendall tau displays as pearsons #225

Open andreifoldes opened 2 years ago

andreifoldes commented 2 years ago

Hello I want to run "kendall" correlation, but when I look at the variable in RStudio it still says Pearson?

library(correlation)

myPerms <- permn(c(1,2,3,4,5))
n = 20
data1 <- data.frame(rankOrder = unlist(myPerms[1:n]),
                 target = rep(c(1,2,3,4,5),n),
                 subject = as.factor(sort(rep(seq(1,n),5))))
c1 <- correlation(data1,method = "kendall", ranktransform = TRUE, multilevel = TRUE)

image

IndrajeetPatil commented 2 years ago

Hmm, I see the correct method if multilevel is set to FALSE (default), so it is possible that we currently don't support multilevel Kendall correlation coefficient and this is not documented properly:

library(correlation)

myPerms <- DescTools::Permn(c(1, 2, 3, 4, 5))
n <- 20
data1 <- data.frame(
  rankOrder = unlist(myPerms[1:n]),
  target = rep(c(1, 2, 3, 4, 5), n),
  subject = as.factor(sort(rep(seq(1, n), 5)))
)

correlation(data1, method = "kendall", ranktransform = TRUE) |>
  as.data.frame()
#>   Parameter1 Parameter2       tau   CI    CI_low   CI_high        z
#> 1  rankOrder     target 0.3162278 0.95 0.1927706 0.4298292 3.813886
#>              p              Method n_Obs
#> 1 0.0001367985 Kendall correlation   100

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

Need to take a closer look at the code.