Hey all!
I'll keep this concise. I want to estimate a partial correlation using multiple variables (See Pcorr be- low) but include a correction for multiple comparisons like seen in the corr.test below ("adjust="BH""). Is there a package out there that allows this? I tried {pcorr} (obviously) and {corrr} which I think is just for visuals - but found nada. The code below will generate everything but I also left you all with a reprex too. Thank you all so much!
library(tidyverse)
library(ppcor)
#gendata
set.seed(123)
num_rows <- 20
num_cols <- 10
data <- matrix(rnorm(num_rows * num_cols), nrow = num_rows)
df <- as.data.frame(data) |>
set_names(c("Col1", "Col2", "Col3", "Col4", "Col5", "Col6", "Col7", "Col8", "Col9", "Col10"))
#Correlation
corr.test(df, y = NULL, use = "pairwise",method="pearson",adjust="BH",
alpha=.05,ci=TRUE,minlength=5,normal=TRUE)
#Pcorr
pcor.test(df$Col1, df$Col2, list(df$Col3, df$Col4, df$Col5, df$Col6, df$Col7, df$Col8, df$Col9, df$Col10), method = "pearson")
#Can I throw a multiple comparison correction in here ^ like "adjust="BH" in the #Correlation above?
tibble::tribble(
~Col1........Col2........Col3........Col4........Col5.......Col6........Col7........Col8........Col9.......Col10,
"1 2.19881035 -0.57397348 -0.78862197 -0.52111732 -1.66747510 -0.7152422 0.23743027 0.62418747 -0.20529926 0.03455107",
"2 1.31241298 0.61798582 -0.50219872 -0.48987045 0.73649596 -0.7526890 1.21810861 0.95900538 0.65119328 0.19023032",
"3 -0.26514506 1.10984814 1.49606067 0.04715443 0.38602657 -0.9385387 -1.33877429 1.67105483 0.27376649 0.17472640",
"4 0.54319406 0.70758835 -1.13730362 1.30019868 -0.26565163 -1.0525133 0.66082030 0.05601673 1.02467323 -1.05501704",
"5 -0.41433995 -0.36365730 -0.17905159 2.29307897 0.11814451 -0.4371595 -0.52291238 -0.05198191 0.81765945 0.47613328",
"6 -0.47624689 0.05974994 1.90236182 1.54758106 0.13403865 0.3311792 0.68374552 -1.75323736 -0.20979317 1.37857014",
"7 -0.78860284 -0.70459646 -0.10097489 -0.13315096 0.22101947 -2.0142105 -0.06082195 0.09932759 0.37816777 0.45623640",
"8 -0.59461727 -0.71721816 -1.35984070 -1.75652740 1.64084617 0.2119804 0.63296071 -0.57185006 -0.94540883 -1.13558847",
"9 1.65090747 0.88465050 -0.66476944 -0.38877986 -0.21905038 1.2366750 1.33551762 -0.97400958 0.85692301 -0.43564547",
"10 -0.05402813 -1.01559258 0.48545998 0.08920722 0.16806538 2.0375740 0.00729009 -0.17990623 -0.46103834 0.34610362",
"11 0.11924524 1.95529397 -0.37560287 0.84501300 1.16838387 1.3011760 1.01755864 1.01494317 2.41677335 -0.64704563",
"12 0.24368743 -0.09031959 -0.56187636 0.96252797 1.05418102 0.7567748 -1.18843404 -1.99274849 -1.65104890 -2.15764634",
"13 1.23247588 0.21453883 -0.34391723 0.68430943 1.14526311 -1.7267304 -0.72160444 -0.42727929 -0.46398724 0.88425082",
"14 -0.51606383 -0.73852770 0.09049665 -1.39527435 -0.57746800 -0.6015067 1.51921771 0.11663728 0.82537986 -0.82947761",
"15 -0.99250715 -0.57438869 1.59850877 0.84964305 2.00248273 -0.3520465 0.37738797 -0.89320757 0.51013255 -0.57356027",
"16 1.67569693 -1.31701613 -0.08856511 -0.44655722 0.06670087 0.7035239 -2.05222282 0.33390294 -0.58948104 1.50390061",
"17 -0.44116322 -0.18292539 1.08079950 0.17480270 1.86685184 -0.1056713 -1.36403745 0.41142992 -0.99678074 -0.77414493",
"18 -0.72306597 0.41898240 0.63075412 0.07455118 -1.35090269 -1.2586486 -0.20078102 -0.03303616 0.14447570 0.84573154",
"19 -1.23627312 0.32430434 -0.11363990 0.42816676 0.02098359 1.6844357 0.86577940 -2.46589819 -0.01430741 -1.26068288",
"-1.28471572 -0.78153649 -1.53290200 0.02467498 1.24991457 0.9113913 -0.10188326 2.57145815 -1.79028124 -0.35454240"
)