You can use bootstrap to calculate the confidence interval for rho:
1) Make a function to retrieve the cor.test score (do not forget to put indexes so that the load can display data):
rho <- function(x, y, indices){ rho <- cor.test(x[indices], y[indices], method = c("spearman")) return(rho$estimate) }
2) Use the boot package to download your score:
library(boot) boot.rho <- boot(x ,y=y, rho, R=1000)
3) Take the confidence interval:
boot.ci(boot.rho)
Carlos Cinelli
source share