Closed MLunar closed 1 year ago
Hi!
you can create it from scratch the same way you can create a Bayesian network in the bnlearn package with the model2network
function. For example, this code:
net <- bnlearn::model2network(paste0("[X1_t_1][X3_t_1][X2_t_1|X1_t_1]",
"[X4_t_1|X2_t_1:X3_t_1][X1_t_0|X1_t_1]",
"[X2_t_0|X1_t_0:X1_t_1:X2_t_1]",
"[X3_t_0|X3_t_1]",
"[X4_t_0|X3_t_0:X2_t_0:X4_t_1]"))
class(net) <- c("dbn", class(net))
plot(net)
generates this network:
I use this method a lot in the dbnR tests to avoid learning a network and expending unnecesary time on that. It always has the same syntax of "[Node|Parent1,Parent2,...]". Just don't add whitespaces inside the strings, define all the nodes in the network and follow the naming convention of _t_0, _t_1, ...
Regarding the lack of a whitelist_tr
parameter, you are right, it's missing for no particular reason. It's very likely that I forgot to add it when I was coding the blacklist_tr
parameter. However, it should be very straigthforward to introduce it. I'll look into it and get back to you when I add it to the devel branch.
I've added the whitelist_tr
argument to the last version of the package in the devel branch (2d18409). With this, you should be able to force specific inter-slice arcs in the DMMHC algorithm. You can get the lastest devel version of the package with devtools
by running devtools::install_github("dkesada/dbnR", ref = "devel")
. I've also added the use of the whitelist_tr
argument to the usage_example markdown for future reference.
Wow, thank you very much for such clear and quick answer, I can obtain my ideal structure now, and the precision of the forecast in my DBN improves a lot!
I'm glad to hear it!
Hello! Can I define the network structure by myself, instead of acquiring the network through structure learning? I want to define an edge that go from one time slice to another. I find whitelist, blacklist, blacklist tr, but there is no whitelist tr ?