2

我已经得到了相关系数矩阵 R 和偏相关系数矩阵 Rp,那么如何在 R 中绘制高斯图模型?

如果能推荐一些关于高斯图模型的书籍介绍就更好了,确实不知道是什么,但我首先要做的就是把它画出来。非常感谢!

#the Correlation coefficient matrix
R=c(1,0.55,0.55,0.41,0.39,0.55,1,0.61,0.49,0.44,0.55,0.61,1,0.71,
0.66,0.41,0.49,0.71,1,0.61,0.39,0.44,0.66,0.61,1)
dim(R)=c(5,5)

#the Partial correlation coefficient matrix
library("corpcor") 
Rp=cor2pcor(R)

那我怎么能画出高斯图模型呢?

4

2 回答 2

3

如果要绘制相应的图形,可以使用igraph包。

library(igraph)
g <- graph.adjacency( abs(Rp)>.1, mode="undirected", diag=FALSE )
plot(g, layout=layout.fruchterman.reingold)
于 2012-04-19T03:49:02.237 回答
2

I am not familiar with the term "Gaussian graphical model" although I feel I should be (I'll read up on it, thanks).

But to visualize (partial) correlation matrices you could use the qgraph package, which is designed to do just that. For example:

library("qgraph")
qgraph(round(Rp,5),edge.labels=TRUE)

enter image description here

Computing partial correlations are built in with the graph argument:

qgraph(round(R,5),edge.labels=TRUE,graph="concentration")

Gives the same result.

于 2012-04-19T06:03:27.900 回答