#create a covariance matrix
set.seed(1234)
V=rWishart(1,10,diag(5))[,,1]
cov2cor(V)
[,1] [,2] [,3] [,4] [,5]
[1,] 1.00000000 0.1169636 0.2236465 -0.2667448 0.04351447
[2,] 0.11696358 1.0000000 -0.2260988 -0.3425368 0.64837326
[3,] 0.22364648 -0.2260988 1.0000000 -0.1883763 -0.22484960
[4,] -0.26674477 -0.3425368 -0.1883763 1.0000000 -0.50315007
[5,] 0.04351447 0.6483733 -0.2248496 -0.5031501 1.00000000
#give it names
colnames(V)=c("MY","gain","longevity","SCS","pietin")
rownames(V)=c("MY","gain","longevity","SCS","pietin")
#plot
require(corrplot)
corrplot.mixed(cor(V),col=gray.colors(10))
No comments:
Post a Comment