Facilities for easy implementation of hybrid Bayesian networks using R. Bayesian networks are directed acyclic graphs representing joint probability distributions, where each node represents a random variable and each edge represents conditionality. The full joint distribution is therefore factorized as a product of conditional densities, where each node is assumed to be independent of its non-descendents given information on its parent nodes. Since exact, closed-form algorithms are computationally burdensome for inference within hybrid networks that contain a combination of continuous and discrete nodes, particle-based approximation techniques like Markov Chain Monte Carlo are popular. We provide a user-friendly interface to constructing these networks and running inference using the 'rjags' package. Econometric analyses (maximum expected utility under competing policies, value of information) involving decision and utility nodes are also supported.
Facilities for easy implementation of hybrid Bayesian networks using R. Bayesian networks are directed acyclic graphs representing joint probability distributions, where each node represents a random variable and each edge represents conditionality. The full joint distribution is therefore factorized as a product of conditional densities, where each node is assumed to be independent of its non-desendents given information on its parent nodes. Since exact, closed-form algorithms are computationally burdensome for inference within hybrid networks that contain a combination of continuous and discrete nodes, particle-based approximation techniques like Markov Chain Monte Carlo are popular. We provide a user-friendly interface to constructing these networks and running inference using rjags. Econometric analyses (maximum expected utility under competing policies, value of information) involving decision and utility nodes are also supported.
HydeNet may be installed using
Patched versions from GitHub may be installed using
Please note that you may need to use the
ref argument in
install_github to get the latest
updates. Please visit the GitHub repository
to explore branches of the project.
The package includes a colletion of vignettes to help you get started. Use
vignette(package = "HydeNet") to see the complete listing of vignettes.
plot.HydeNetworkto accommodate changes in
pixiedustto allow better parsing of term names. This also resulted in removing the dependency on
broom(which is alright, because
factorFormulato assist in writing formulae that make use of factor levels instead of their numeric codes.
factorLevelselement in network objects and arguments in
setNode. See Issue #81
plot.HydeNetworkrelevant to changes in
DiagrammeR0.8.0. Note that the column names in custom node data frames no longer contain
nodesinstead. However, the
HydeNetfunction arguments have no changed names, in order to maintain compatibility with 0.9.0. Future versions may allow for either
nodesto be used. In custom edge data frames,
edge_toare changed to
cptobjects from being passed to JAGS models correctly.
compileDecisionModel. This allows decision networks to be compiled for absurdly large policy matrices (> 1000 policies)
statsto comply with new CRAN policies.
nodeTypespecifications to properly build in
writeJagsModel. (See Issue #72)
cptarrays from being passed to
cptarrays in the JAGS models.
factorRefelement of the compiled Hyde Networks.
dataelement, not the
mergeCustomNodesto prevent loss of custom settings
VignetteBuilderoption to the description file. For now, when reinstalling the package, use the command
devtools::install_local([directory]). If you try to build the vignettes with the package, a strange error occurs that prevents the installation. This error is related to the
WorkingWithHydeNetObjectsvignette, but I can't reproduce the error outside of the build command.
writeJagsFormulamethods are complete.
cptobjects to include in the
dataargument, allowing JAGS to compile without the user having to remember to assign the
cptobject to the data.
cptfunction is added to assist in developing multidimensional conditional probability tables.
cptInputare generics with methods for
formula. Their structure is undergoing some growing pains right now, so expect more changes in the future.
cptas the fitter for variables where the node is a factor and all parents are factors.
modelToNode.cpt. This is untested as of yet and may be buggy. Final changes are pending the finalization of the
nodeFromFormulais used to generate most likely node names from terms in model formulas that are used in functions and other transformations. For instance, when a formula has
factor(x), only the
xis used in node names. (Solves Issue #31)
matchVarsis used to reduce terms in model formulas to just the node name. (Solves Issue #26)
modelToNodethat is required by an unexported function
setNodeto retain current settings for decision and utility nodes (Issue #53)
setNodeare not validated (Issue #24).
BlackJacknetwork object to be consistent with the object defined in the Decision Nodes vignette.
broom (>= 0.3.7). This makes sure that the multinom tidiers are available.
gRbasefrom Depends: to Imports:
plot.HydeNetworkthat prevented plotting without defaults
HydeNetPlotsvignette to accommodate new plotting features.
compileDecisionModeland fixed all the bugs that popped up in doing so.
BlackJackTrain. Added documentation for it.
BlackJackdata object, which contains a
HydeNetworkobject simulating a game of black jack.
magrittr. This was done to make
dplyravailable for joining MCMC matrices returned by
compileJagsModelto accommodate compiling multiple JAGS models when a policy/decision matrix is provided.
HydePosterior, which generates posterior distributions of all of the JAGS models compiled by
HydePosteriorinto a single data frame.
compileJagsModelthat affected observed data values. (Issue #36 on GitHub).
modelToNodethat printed the node name in the first parameter, causing
compileJagsModelto fail. (Issue #35 on GitHub).
network$nodeDecision. It is a logical value indicating if the node should be considered a decision node.
compileDecisionNetworkevaluates all of the decision nodes, builds a table of all combinations of decision options, and systematically runs
compileJagsModelfor each row of that table to create a JAGS model for each combination of decisions.
setNode, but for convenience, a new function is introduced (
setDecisionNodes) to allow multiple nodes to be defined as decision nodes in one call. This is intended for use when a list of models is used to define a network.