3
有沒有辦法使用此cor.mtest函數來計算p值多重比較(如p.adjust)?代碼從http://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.htmlR - Combine cor.mtest和p.adjust
謝謝!
cors<-cor(rel_tnum_data)
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(rel_tnum_data, 0.95)
res2 <- cor.mtest(rel_tnum_data, 0.99)
corrplot(cors, p.mat = res1[[1]], sig.level=0.05, insig="blank", cl.align="r", tl.cex=0.6, order="hclust", type="lower", tl.srt=60, cl.ratio=0.1)
'psych'包中的'corr.test'可以返回調整後的p值。 (另請參閱[這個問題](http://stackoverflow.com/questions/26574670/corrplot-shows-insignificant-correlation-coefficients-even-when-insig-blank)爲替代方法使用corr.test函數) – user20650