Closed jdutch27 closed 9 years ago
Rather than putting this into setNode
, I wrote setNodeModels
. This will accept one or more model objects and apply the settings to the appropriate nodes in one pass.
As discussed in issue #7, setNode
is pretty inflexibly written to deal with one node at a time, and to extend it to take a single model object and work properly is probably a fairly sizable headache. This is probably a smoother approach.
There is an issue with (I think) modelToNode(). The output of writeNetworkModel in my "bag of models" example seems to be incorrect. All of the distributions in the JAGS code have "
g1 <- lm(wells ~ 1, data=PE) g2 <- glm(pe ~ wells, data=PE, family="binomial") g3 <- lm(d.dimer ~ pe + pregnant, data=PE) g4 <- xtabs(~ pregnant, data=PE) g5 <- glm(angio ~ pe, data=PE, family="binomial") g6 <- glm(treat ~ d.dimer + angio, data=PE, family="binomial") g7 <- glm(death ~ pe + treat, data=PE, family="binomial")
bagOfModels <- list(g1,g2,g3,g4,g5,g6,g7)
bagNet <- HydeNetwork(bagOfModels) writeNetworkModel(bagNet, pretty=TRUE)
This has been resolved.
HydeNetwork.list() is awesome.
It would be equally beneficial to be able to apply modelToNode() for individual nodes. I think this is as simple as making a network object argument to the modelToNode methods (set to NULL). By default the function will work as-is, i.e., as called from HydeNetwork.list(). But if the user feeds a network object to the method, it will:
1) check that indeed the argument is of class 'HydeNetwork' 2) check that the name of the response variable in the 'model' argument is actually the name of a node in the network 3) check all.equal(sort(unique(names_of_variables_in_regression_equation))), sort(unique(names_of_parents_in_network_object))) 4) set all the list elements for that node within the HydeNetwork object and return an updated object.
Thoughts on its usefulness?