Comments (3)
That'd be great, but while we have a cor_to_ci
method, I am not sure that it is appropriate for Kendall/Spearman methods! And I am not aware of other methods to get the ci, do you know how to compute them?
Best would be to have bootstrapped CI #14 but I am not an expert of these methods 😕
from correlation.
Yeah, most of the other packages that do this indeed rely on bootstrapped CIs.
For example,
library(rcompanion)
spearmanRho(formula = wt ~ mpg, data = mtcars, ci = TRUE)
#> rho lower.ci upper.ci
#> 1 -0.886 -0.95 -0.75
rcompanion::spearmanRho
#> function (formula = NULL, data = NULL, x = NULL, y = NULL, method = "spearman",
#> ci = FALSE, conf = 0.95, type = "perc", R = 1000, histogram = FALSE,
#> digits = 3, reportIncomplete = FALSE, ...)
#> {
#> if (!is.null(formula)) {
#> x = eval(parse(text = paste0("data", "$", all.vars(formula)[1])))
#> y = eval(parse(text = paste0("data", "$", all.vars(formula)[2])))
#> }
#> if (is.null(formula)) {
#> x = x
#> y = y
#> }
#> Rho = signif(cor(x, y, method = method), digits = digits)
#> if (ci == TRUE) {
#> Data = data.frame(x, y)
#> Function = function(input, index) {
#> Input = input[index, ]
#> if (sd(Input$x) == 0 | sd(Input$y) == 0) {
#> FLAG = 1
#> return(c(NA, FLAG))
#> }
#> if (sd(Input$x) > 0 & sd(Input$y) > 0) {
#> RHO = cor(Input$x, Input$y, method = method)
#> FLAG = 0
#> return(c(RHO, FLAG))
#> }
#> }
#> Boot = boot(Data, Function, R = R)
#> BCI = boot.ci(Boot, conf = conf, type = type)
#> if (type == "norm") {
#> CI1 = BCI$normal[2]
#> CI2 = BCI$normal[3]
#> }
#> if (type == "basic") {
#> CI1 = BCI$basic[4]
#> CI2 = BCI$basic[5]
#> }
#> if (type == "perc") {
#> CI1 = BCI$percent[4]
#> CI2 = BCI$percent[5]
#> }
#> if (type == "bca") {
#> CI1 = BCI$bca[4]
#> CI2 = BCI$bca[5]
#> }
#> if (sum(Boot$t[, 2]) > 0 & reportIncomplete == FALSE) {
#> CI1 = NA
#> CI2 = NA
#> }
#> CI1 = signif(CI1, digits = digits)
#> CI2 = signif(CI2, digits = digits)
#> if (histogram == TRUE & method == "spearman") {
#> hist(Boot$t[, 1], col = "darkgray", main = "", xlab = "rho")
#> }
#> if (histogram == TRUE & method == "kendall") {
#> hist(Boot$t[, 1], col = "darkgray", main = "", xlab = "tau")
#> }
#> if (histogram == TRUE & method == "pearson") {
#> hist(Boot$t[, 1], col = "darkgray", main = "", xlab = "r")
#> }
#> }
#> if (ci == FALSE) {
#> names(Rho) = "rho"
#> }
#> if (ci == FALSE & method == "kendall") {
#> names(Rho) = "tau"
#> }
#> if (ci == FALSE & method == "pearson") {
#> names(Rho) = "r"
#> }
#> if (ci == FALSE) {
#> return(Rho)
#> }
#> if (ci == TRUE) {
#> names(Rho) = ""
#> }
#> if (ci == TRUE & method == "spearman") {
#> return(data.frame(rho = Rho, lower.ci = CI1, upper.ci = CI2))
#> }
#> if (ci == TRUE & method == "kendall") {
#> return(data.frame(tau = Rho, lower.ci = CI1, upper.ci = CI2))
#> }
#> if (ci == TRUE & method == "pearson") {
#> return(data.frame(r = Rho, lower.ci = CI1, upper.ci = CI2))
#> }
#> }
#> <bytecode: 0x0000000021b77910>
#> <environment: namespace:rcompanion>
from correlation.
Not sure how/where to add it... Should we add a method to cor_to_ci()
, and then allow for every cor_test_* to get the bootstrapped version?
from correlation.
Related Issues (20)
- Bayesian correlations not working with the latest version of `{parameters}` HOT 12
- plot method documentation missing some parameters
- subset of variables in correlation matrix
- Extend man page HOT 2
- No warnings about ties in data
- Error in Multilevel Correlation HOT 1
- Some tests are failing for R < 4.0
- CRAN check failures HOT 3
- Create GitHub release corresponding to CRAN release
- Changing aesthetics of the correlation plot HOT 2
- Costumizing priors HOT 1
- Multilevel correlation changes when more correlations are computed HOT 6
- Suggestion of new function: `cormatrix_to_excel()` HOT 4
- Factors don't always work as intended
- Multilevel rank correlation HOT 1
- refactoring the `correlation` package HOT 6
- Package version doesn't follow easystats' versioning conventions HOT 1
- Bayesian partial correlations
- bayestestR HOT 2
- X
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from correlation.