Created
December 16, 2019 19:04
-
-
Save arkanister/c3291d0eea36831a6ec433b5d36dde91 to your computer and use it in GitHub Desktop.
pearsonr_ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Função para o calculo do coeficiente de Pearson | |
| ## e do intervalo de confiança de Pearson. | |
| pearsonr_ci <- function(x, y, alpha = 0.05) { | |
| r <- cor(x, y) | |
| p <- cor.test(x, y)$p.value | |
| r_z <- tanh(r) | |
| se <- 1 / sqrt(length(x) - 3) | |
| z <- qnorm(1 - alpha / 2) | |
| lo_z <- r_z - z * se | |
| hi_z <- r_z + z * se | |
| lo <- tanh(lo_z) | |
| hi <- tanh(hi_z) | |
| return(c(r, p, lo, hi)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment