README.md

parental

parental provides a very lightweight directed graph object and basic manipulation tools for R, a free software environment for statistical computing and graphics. The emphasis is on representing Bayesian Networks, so the focus is on Directed Acyclic Graphs.

Basic operation

View script as file

A bn object is created by specifying the parents of each node.

x <- bn(c(2), c(), c(1, 2))
grplot(x)

Adjacency matrices can be converted to a bn using as.bn.

adj <- matrix(c(0, 0, 1, 1, 0, 0, 0, 0, 0), 3, 3)
x <- as.bn(adj)
grplot(x)

A bn object can be converted to an adjacency matrix

x <- bn(c(2), c(), c(1, 2))
as.adjacency(x)

Properties of a bn

x <- bn(c(2), c(), c(1, 2))
nNodes(x)
nEdges(x)
indegrees(x)
checkAcyclic(x)
topologicallyOrder(x)

Manipulating bn objects

x <- bn(c(2), c(), c(1, 2))

Fast, but less intuitive manipulation of bn objects

x <- bn(c(2), c(), c(1, 2))
x[[1]] <- c()
x
x[[2]] <- 1
x

Sample a BN

sampleBN(10)
sampleBN(10, maxNumberParents = 2)

An empty graph

empty(10, "bn")

Enumerate all the Bayesian Networks

enumerateBNSpace(3)

Tools for handling "routes matrices"

x <- bn(c(2), c(), c(1, 2))
routes(x)

Simulate from a bn

cpt <- list(
  as.table(array(c(0.7, 0.3), 2)), 
  as.table(array(c(0.5, 0.5, 0.2, 0.8), c(2, 2)))
)
net <- bn(c(), 1)
sim <- simulate(object = net, nsim = 1000, ptables = cpt)

Installation

Download the current version, and unzip the file. Then install in R using the following, where rjbgoudie-parental-XXXXX is the name of the unzipped directory/folder, and path/to/rjbgoudie-parental-XXXXX is the path to this folder.

install.packages("path/to/rjbgoudie-parental-XXXXX", repos = NULL, type = "source")

The package also depends on lattice, and grid, both of which are included with R.

How to cite

Goudie, R. J. B., & Mukherjee, S. (2016). A Gibbs Sampler for Learning DAGs. Journal of Machine Learning Research, 17(30), 1-39. http://jmlr.org/papers/v17/14-486.html



rjbgoudie/parental documentation built on May 27, 2019, 9:11 a.m.