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

4 views (last 30 days)
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.

Accepted Answer

Chunru
Chunru on 18 Sep 2022
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)

More Answers (0)

Categories

Find more on Networks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!