R 相关图意义

R 相关图意义,r,statistics,correlation,R,Statistics,Correlation,我不知道我应该在corrplot的代码中放入类似method=“spearman”的内容,以了解精子相关的意义 cor.mtest <- function(mat, conf.level = 0.95){ mat <- as.matrix(mat) n <- ncol(mat) p.mat <- lowCI.mat <- uppCI.mat <- matrix(NA, n, n) diag(p.mat) <- 0 diag(lowCI.mat) <

我不知道我应该在corrplot的代码中放入类似method=“spearman”的内容,以了解精子相关的意义

cor.mtest <- function(mat, conf.level = 0.95){
mat <- as.matrix(mat)
n <- ncol(mat)
p.mat <- lowCI.mat <- uppCI.mat <- matrix(NA, n, n)
diag(p.mat) <- 0
diag(lowCI.mat) <- diag(uppCI.mat) <- 1
for(i in 1:(n-1)){
for(j in (i+1):n){
tmp <- cor.test(mat[,i], mat[,j], conf.level = conf.level)
p.mat[i,j] <- p.mat[j,i] <- tmp$p.value
lowCI.mat[i,j] <- lowCI.mat[j,i] <- tmp$conf.int[1]
uppCI.mat[i,j] <- uppCI.mat[j,i] <- tmp$conf.int[2]
}
}
return(list(p.mat, lowCI.mat, uppCI.mat))
}
res1 <- cor.mtest(mtcars,0.95)
参数method=“spearman”必须传递给cor.test函数:

cor.test(mat[,i], mat[,j], conf.level = conf.level, method = ”spearman”)

有关更多详细信息,请参阅?cor.test的帮助页。

将method='spearman'添加到cor.mtest函数的参数中,这样它将成为默认值,用户可以在以后需要时更改它。您还需要在tmp中添加method=method,这不是一个非常有效的实现。然而,主要的问题是,它没有为多次测试调整p.值。