필터 지우기
필터 지우기

How do I plot a Bayesian network graph in my way?

조회 수: 12 (최근 30일)
Bezalem Eshetu Yirdaw
Bezalem Eshetu Yirdaw 2022년 9월 18일
답변: Chunru 2022년 9월 18일
Dear Matworks community,
I am working on multilevel Bayesian network using matlab, I created functions to calculate the score and get the final adjecency matrix. what I want to do is how to plot the Bayesian network using my adjecency matrix that keep the flow of multilevel structure. Assume, g1 and g2 are level 3 and level 2 clustering variables, respectivelly and I have 5 variables at level 1, i.e., (y1, y2, y3, y4 and y5). let the final adgecency matrix would be
DAG = [0 0 1 0 1 1 0; 0 0 1 1 0 0 1; 0 0 0 1 1 0 0 ; 0 0 0 0 0 1 0; 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 ; 0 0 0 0 1 1 0], assume the corresponding row and column name of this matrix is (g1,g2,y1,y2,y3,y4,y5) and the rows are parents and the columns are children. So, is there any ways to plot a DAG as shown below please. Could you provide a code or matlab toolbox to plot such kind of DAG please. I realy apreciate your answers. Thank you.

채택된 답변

Chunru
Chunru 2022년 9월 18일
DAG = [0 0 1 0 1 1 0; 0 0 1 1 0 0 1; 0 0 0 1 1 0 0 ; 0 0 0 0 0 1 0; 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 ; 0 0 0 0 1 1 0],
DAG = 7×7
0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
%assume the corresponding row and column name of this matrix is (g1,g2,y1,y2,y3,y4,y5)
nn = ["g1","g2","y1","y2","y3","y4","y5"];
G = digraph(DAG, nn);
plot(G)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by