I used following code to create correlation matrix and generate pvalue. How do I create adjusted pvalue for each correlation?
library(corrplot)
#Running correlation
M = cor(mtcars)
#identifying pvalues
testRes = cor.mtest(mtcars, conf.level = 0.95)
#creating pairwise p value
pval = as.data.frame(as.table(testRes$p))
head(pval)
output is:
Var1 Var2 Freq
<fct> <fct> <dbl>
1 mpg mpg 0.000000e+00
2 cyl mpg 6.112687e-10
3 disp mpg 9.380327e-10
4 hp mpg 1.787835e-07
5 drat mpg 1.776240e-05
6 wt mpg 1.293959e-10
How do I calculate adjusted pvalue here and add it in the colimn after pvalue?
Actually it's just
cbind(<res>, p.adj=p.adjust(<res>$p, method='BH'))
.First the correlation p-values solution without using the corrplot package.
Now,
cbind
adj. p-values; I use the Benjamini-Hochberg aka false discovery rate (FDR) method. Also common is the"bonferroni"
method; see?p.adjust
for options.If you like pipes, you can do: