I am using R and have a question on correlations.
A<-data.frame(A1=c(1,2,3,4,5),B1=c(6,7,8,9,10),C1=c(11,12,13,14,15 ))
B<-data.frame(A2=c(6,7,7,10,11),B2=c(2,1,3,8,11),C2=c(1,5,16,7,8))
cor(A,B)
# ? ? ? ? ? A2 ? ? ? ?B2 ? ? ? C2
# A1 0.9481224 0.9190183 0.459588
# B1 0.9481224 0.9190183 0.459588
# C1 0.9481224 0.9190183 0.459588
I wanted to obtain the p-value for each of the correlation coefficients in the matrix. Is this possible?
I tried using rcorr
function from Hmisc package but obtain only a single p-value and not for each correlation.
A <- as.vector(t(A))
B <- as.vector(t(B))
rcorr(A, B)
x y
x 1.00 0.13
y 0.13 1.00
n= 15
P
x y
x 0.6425
y 0.6425
Similarly, I also tried using "psych" package in R to do this but unable to.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…