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

`install.packages("HydeNet")`

Patched versions from GitHub may be installed using

setRepositories(ind=1:2)devtools::install_github("nutterb/HydeNet")

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.

- Added methods for survreg models. The predicted value returned is the predicted survival time.
- Made changes to unit tests to accommodate new version of
`testthat`

- Replaced dependency on
`ArgumentCheck`

to`checkmate`

- Code formatting changes.

- Added dependency to
`pixiedust`

to allow better parsing of term names. This also resulted in removing the dependency on`broom`

(which is alright, because`pixiedust`

depends on`broom`

.

- Expanded options for specifying policy matrices (per Issue #95)

- Corrected a serious bug in how character values were handled in the
`data`

argument of`compileDecisionModel`

. - Adds
`factorFormula`

to assist in writing formulae that make use of factor levels instead of their numeric codes. - Deterministic nodes are now represented as diamonds by default.

- Implements the
`factorLevels`

element in network objects and arguments in`setNode`

. See Issue #81 - Changes to
`plot.HydeNetwork`

relevant to changes in`DiagrammeR`

0.8.0. Note that the column names in custom node data frames no longer contain`node_id`

but use`nodes`

instead. However, the`HydeNet`

function arguments have no changed names, in order to maintain compatibility with 0.9.0. Future versions may allow for either`node_id`

or`nodes`

to be used. In custom edge data frames,`edge_from`

and`edge_to`

are changed to`from`

and`to`

, respectively.

- Minor bug fix related to creating policy matrices with nodes that don't have a 'nodeFitter' specified.

- Fixed a bug in
`compileJagsModel`

and`compileDecisionModel`

that prevented`cpt`

objects from being passed to JAGS models correctly. - Added
`nodeData`

argument to`setNode`

. - Added unit tests.

- Conversion of argument checks to using the
`ArgumentCheck`

package - Connections are closed in
`compileDecisionModel`

. This allows decision networks to be compiled for absurdly large policy matrices (> 1000 policies)

- Added imports from
`utils`

and`stats`

to comply with new CRAN policies. - Adds the functionality to allow all
`nodeType`

specifications to properly build in`writeJagsModel`

. (See Issue #72) - Incremented to version 0.9.0 for CRAN release.

- Fixed a bug preventing
`cpt`

arrays from being passed to`jags.model`

in`compileDecisionModel`

- Fixed a bug preventing bernoulli values from being passed to
`cpt`

arrays in the JAGS models.

- Streamlined the generation of the
`factorRef`

element of the compiled Hyde Networks.

This also allows all data frames in all nodes to be included to generate a complete list of factors throughout the network (previously, it only generated references for factors in the overall`data`

element, not the`nodeData`

elements.

- Incorporated minor changes for compatibility with DiagrammeR 0.7
- Minor bug fix to
`mergeCustomNodes`

to prevent loss of custom settings - Minor changes to
`HydeNetPlots`

vignette - Minor changes to
`GettingStartedWithHydeNet`

vignette. - Removed
`ObtainingPosteriorDistributions`

vignette. - Added
`VignetteBuilder`

option 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`WorkingWithHydeNetObjects`

vignette, but I can't reproduce the error outside of the build command.

`setNodeModel`

and`writeJagsFormula`

methods are complete.`writeJagsModel`

now accommodates`cpt`

objects`compileJagsNetwork`

retrieves`cpt`

objects to include in the`data`

argument, allowing JAGS to compile without the user having to remember to assign the`cpt`

object to the data.

`cpt`

function is added to assist in developing multidimensional conditional probability tables.`cpt`

and`cptInput`

are generics with methods for`list`

and`formula`

. Their structure is undergoing some growing pains right now, so expect more changes in the future.- Improvements to
`setNode`

validation. - Improvements to efficiency of
`compileDecisionModel`

. - Consolidated all data documentation into a single file.
`HydeNetwork`

chooses`cpt`

as the fitter for variables where the node is a factor and all parents are factors.- Added
`modelToNode.cpt`

. This is untested as of yet and may be buggy. Final changes are pending the finalization of the`cpt`

objects.

- An additional function called
`nodeFromFormula`

is 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`x`

is used in node names. (Solves Issue #31) - A new, unexported function called
`matchVars`

is used to reduce terms in model formulas to just the node name. (Solves Issue #26) - An additional argument is used in
`writeJagsModel`

and`modelToNode`

that is required by an unexported function`matchVars`

. - Changed behavior of
`setNode`

to retain current settings for decision and utility nodes (Issue #53) - Added a message to indicate that character strings defining parameters
in
`setNode`

are not validated (Issue #24). - Updated
`BlackJack`

network object to be consistent with the object defined in the Decision Nodes vignette. - Now Imports on
`broom (>= 0.3.7)`

. This makes sure that the multinom tidiers are available.

- Moved
`gRbase`

from Depends: to Imports: - Repaired a bug in
`plot.HydeNetwork`

that prevented plotting without defaults - Updated the
`HydeNetPlots`

vignette to accommodate new plotting features.

- Revamped plotting utilities to make use of the DiagrammeR package. This makes the full range of GraphViz available for use.

- Implemented policy matrices into
`compileDecisionModel`

and fixed all the bugs that popped up in doing so. - Changed the name of the Black Jack training data from
`bjdata`

to`BlackJackTrain`

. Added documentation for it. - Completed Documentation.

- Adds functionality to customize plot defaults.
- Adds functionality to customize nodes in plots.
- Added the
`BlackJack`

data object, which contains a`HydeNetwork`

object simulating a game of black jack. - Included a vignette showing off the use of plotting methods.

- Fixes Issue #10 dealing with utility nodes not being properly initialized and set.

- Added a new dependency on package
`dplyr`

and`magrittr`

. This was done to make`dplyr`

available for joining MCMC matrices returned by`coda.samples`

. - Modified
`compileJagsModel`

to accommodate compiling multiple JAGS models when a policy/decision matrix is provided. - Added the function
`HydePosterior`

, which generates posterior distributions of all of the JAGS models compiled by`HydePosterior`

. - Added a print function for the output of
`HydePosterior`

- Added a function to bind all of the MCMC output from
`HydePosterior`

into a single data frame. - Addressed a bug in
`compileJagsModel`

that affected observed data values. (Issue #36 on GitHub). - Addressed a bug in
`modelToNode`

that printed the node name in the first parameter, causing`compileJagsModel`

to fail. (Issue #35 on GitHub).

- The primary additions to this developmental change are the addition of
decision nodes. Each node now has a new descriptor (found in
`network$nodeDecision`

. It is a logical value indicating if the node should be considered a decision node. - The behavior of decision nodes is exactly like all other nodes in every
respect
*until*you call the`compileDecisionNetwork`

function.

`compileDecisionNetwork`

evaluates all of the decision nodes, builds a table of all combinations of decision options, and systematically runs`compileJagsModel`

for each row of that table to create a JAGS model for each combination of decisions. - Decision nodes can be defined in
`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. - Various bugs have been corrected that were uncovered while testing conditional logic nodes (this is not a formal feature of HydeNet, but can be done. A vignette describing their use will be built later)
- Additional bugs have been corrected while uncovered during the testing of decision node features.