Closed AnaR-Martins closed 4 years ago
Hello,
which structure learning algorithm are you using?
max.parents.layers
works only for the sm
algorithm. It is not used in mmhc
(the default one), for which you can use max.fanin
to specify the maximum number of parents for each variable.
Yes, I am using the sm algorithm.
Also regarding this issue, both max.fanin.layers
and max.parents.layers
are only for the sm, while max.parents
and max.fanin
can be used for the default algorithm mmhc
. But these last two arguments only allow to state the maximum number of parents for each node rigth? Regardless the layer and the time step? They don't allow to explicit a number of parents for each layer, or do they?
Thanks again!
max.parents.layers
and max.parents
are parameters for sm
, the first one for setting a maximum number of parents by layers, the second one for each node. max.fanin.layers
and max.fanin
do the same thing for mmhc
.
However, I think I fixed this, can you try with the latest commit?
I ran the command git clone https://github.com/sambofra/bnstruct.git
on the terminal of OSX but when I tried again in R the plot of the dbn didn't change, maybe I am doing something wrong. Could you send the latest version of the package in the format .tar.gz
please?
Here it is.
However, once you cloned the repo, it should suffice to enter the directory and run make install
.
Thank you, with the folder I got a different result, probably I am doing something wrong on the terminal. However it still results in a network with variables with more than 2 parents. The resultant network is: Do you want me to send you the data and the code?
Yes, please, I will take a look at them.
The data I'm using is the following: synth-N250 try.txt
And the code I'm running is:
dataset_Synth250 <- BNDataset(data=synth.N250.try,discreteness = rep('d',10),variables = c("X0__0" , "X1__0" , "X2__0" , "X3__0" , "X4__0" , "X0__1" , "X1__1" , "X2__1" , "X3__1" , "X4__1"), node.sizes = rep(8,10), num.time.steps=2,starts.from=0)
layers_Synth250 <- c(1,1,1,1,1,2,2,2,2,2)
matrix_parents <- matrix(0,2,2)
matrix_parents[2,1] <- 1
matrix_parents[2,2] <- 2
dbn_Synth250_sm <- learn.dynamic.network(dataset_Synth250, num.time.steps=2,algo="sm",layering=layers_Synth250,max.parents.layers=matrix_parents)
Thank you
Ok, the issue here is actually in the plot
method using Rgraphviz, I'll fix this.
The sm
algorithm finds no arc between the nodes, and the default plot
shows instead all the edges. dag(dbn_Synth250_sm)
and plot(dbn_Synth250_sm, method="qgraph")
show that the structure is empty.
Your code is fine, only there is no need to give the layering manually to separate the time steps (won't give any issue though).
Ok, thank you very much for your help! I have a last question regarding this issue. In this case, the algorithm didn't find arcs between the nodes, but is there any way to force some nodes to have a certain number of parents?
No, you can enforce specific edges using the mandatory.edges
parameter, but not unspecified edges.
I fixed the plot in the last commit, so I'm closing this issue. Again, if you encounter any other problem don't hesitate to open a new one.
Hi again,
I was learning a dynamic bayesian network (with 2 time steps and 5 variables in each) with the sm algorithm, and I defined the max.parents.layers as the matrix : 0 0 1 2 so that the variables in the second layer (ie the variables in the second time step) could have at most 1 parent from the first layer (first time step) and in total 2 parents (which implies that they can only have one parent from the same layer). However, the result I get is the following:
Am I doing any mistake? Thank you in advance!