Learn R Programming

⚠️There's a newer version (1.0.15) of this package.Take me there.

bnstruct

R package for Bayesian Network Structure Learning from Data with Missing Values

Introduction

Bayesian Networks are a powerful tool for probabilistic inference among a set of variables, modeled using a directed acyclic graph. However, one often does not have the network, but only a set of observations, and wants to reconstruct the network that generated the data. The bnstruct package provides objects and methods for learning the structure and parameters of the network in various situations, such as in presence of missing data, for which it is possible to perform imputation (guessing the missing values, by looking at the data). The package also contains methods for learning using the Bootstrap technique. Finally, bnstruct, has a set of additional tools to use Bayesian Networks, such as methods to perform belief propagation.

In particular, the absence of some observations in the dataset is a very common situation in real-life applications such as biology or medicine, but very few software around is devoted to address these problems. bnstruct is developed mainly with the purpose of filling this void.

Installation

The latest stable version of bnstruct is available on CRAN and can be installed with

install.packages("bnstruct")

from within an R session.

The latest development version of bnstruct can be found on GitHub here.

In order to install the package, it suffices to launch R CMD INSTALL path/to/bnstruct from a terminal, or make install from within the package source folder.

Being hosted on GitHub, it is also possible to use the install_github tool from an R session:

library("devtools")
install_github("sambofra/bnstruct")

For Windows platforms, a binary executable of the latest stable version is available on CRAN.

bnstruct requires R >= 2.10, and depends on bitops, igraph, Matrix, graph and methods. Package Rgraphviz is requested in order to plot graphs, but is not mandatory.

Reference

If you bnstruct in your work, please cite it as:

Alberto Franzin, Francesco Sambo, Barbara di Camillo. "bnstruct: an R package for Bayesian Network structure learning in the presence of missing data." Bioinformatics, 2017; 33 (8): 1250-1252; Oxford University Press.

These information and a BibTeX entry can be found with

citation("bnstruct")

Copy Link

Version

Install

install.packages('bnstruct')

Monthly Downloads

428

Version

1.0.4

License

GPL (>= 2) | file LICENSE

Maintainer

Alberto Franzin

Last Published

August 31st, 2018

Functions in bnstruct (1.0.4)

cpts<-

set the list of conditional probability tables of a network.
complete

Subset a BNDataset to get only complete cases.
discreteness

get status (discrete or continuous) of the variables of an object.
discreteness<-

set status (discrete or continuous) of the variables of an object.
imp.boots

edge.dir.wpdag

counts the edges in a WPDAG with their directionality
em

expectation-maximization algorithm.
bootstrap

Perform bootstrap.
build.junction.tree

build a JunctionTree.
impute

Impute a BNDataset raw data with missing values.
boots<-

boots

cpts

get.most.probable.values

compute the most probable values to be observed.
dag<-

set adjacency matrix of an object.
has.boots

check whether a BNDataset has bootstrap samples or not.
asia_10000

Asia dataset.
asia

load Asia dataset.
dag

get adjacency matrix of a network.
has.raw.data

check if a BNDataset contains raw data.
data.file<-

header.file<-

imputed.data<-

add imputed data.
dag.to.cpdag

convert a DAG to a CPDAG
child

load Child dataset.
node.sizes<-

set the size of variables of an object.
imputed.data

get imputed data of a BNDataset.
name

get name of an object.
data.file

child_NA_5000

Child dataset.
observations

junction.tree

junction.tree<-

header.file

plot

plot a BN as a picture.
print

knn.impute

Perform imputation of a data frame using k-NN.
raw.data<-

add raw data.
has.imputed.boots

check whether a BNDataset has bootstrap samples from imputed data or not.
test.updated.bn

has.imputed.data

check if a BNDataset contains impited data.
imp.boots<-

jt.cliques<-

tune.knn.impute

tune the parameter k of the knn algorithm used in imputation.
layering

return the layering of the nodes.
wpdag<-

set WPDAG of the object.
wpdag

get the WPDAG of an object.
jt.cliques

learn.dynamic.network

learn.network

num.variables

observations<-

marginals

compute the list of inferred marginals of a BN.
struct.algo<-

Set the algorithm used to learn the structure of a network.
name<-

set name of an object.
learn.params

struct.algo

Read the algorithm used to learn the structure of a network.
learn.structure

learn the structure of a network.
write_xgmml

Write a network saving it in an XGMML file.
num.nodes<-

set number of nodes of an object.
num.items

raw.data

get raw data of a BNDataset.
num.boots

num.items<-

read.bif

Read a network from a .bif file.
jpts<-

scoring.func<-

Set the scoring function used to learn the structure of a network.
jpts

num.nodes

get number of nodes of an object.
scoring.func

Read the scoring function used to learn the structure of a network.
num.time.steps<-

read.net

Read a network from a .net file.
sample.dataset

sample a BNDataset from a network of an inference engine.
variables<-

set variables of an object.
sample.row

sample a row vector of values for a network.
save.to.eps

save a BN picture as .eps file.
shd

compute the Structural Hamming Distance between two adjacency matrices.
show

Show method for objects.
variables

get variables of an object.
node.sizes

get size of the variables of an object.
num.boots<-

num.time.steps

num.variables<-

read.dataset

Read a dataset from file.
read.dsc

Read a network from a .dsc file.
updated.bn

get the updated BN object contained in an InferenceEngine.
updated.bn<-

set the updated BN object contained in an InferenceEngine.
wpdag.from.dag

Initialize a WPDAG from a DAG.
write.dsc

Write a network saving it in a .dsc file.
belief.propagation

perform belief propagation.
BN-class

BN class definition.
BNDataset-class

BNDataset class.
InferenceEngine-class

InferenceEngine class.
bn

get the BN object contained in an InferenceEngine.
add.observations<-

bn<-

set the original BN object contained in an InferenceEngine.
boot

get selected element of bootstrap list.