Learn R Programming

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 inference and interventions.

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 >= 3.5, and depends on bitops, igraph, 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

521

Version

1.0.15

License

GPL (>= 2) | file LICENSE

Maintainer

Alberto Franzin

Last Published

January 9th, 2024

Functions in bnstruct (1.0.15)

child

load Child dataset.
boot

get selected element of bootstrap list.
build.junction.tree

build a JunctionTree.
child_NA_5000

Child dataset.
cpts

get the list of conditional probability tables of a BN.
boots<-

set list of bootstrap samples of a BNDataset.
boots

get list of bootstrap samples of a BNDataset.
bootstrap

Perform bootstrap.
complete

Subset a BNDataset to get only complete cases.
cpts<-

set the list of conditional probability tables of a network.
dag.to.cpdag

convert a DAG to a CPDAG
data.file

get data file of a BNDataset.
dag

get adjacency matrix of a network.
dag<-

set adjacency matrix of an object.
em

expectation-maximization algorithm.
data.file<-

set data file of a BNDataset.
discreteness<-

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

get status (discrete or continuous) of the variables of an object.
get.most.probable.values

compute the most probable values to be observed.
edge.dir.wpdag

counts the edges in a WPDAG with their directionality
has.boots

check whether a BNDataset has bootstrap samples or not.
header.file<-

set header file of a BNDataset.
impute

Impute a BNDataset raw data with missing values.
header.file

get header file of a BNDataset.
imputed.data<-

add imputed data.
has.raw.data

check if a BNDataset contains raw data.
has.imputed.data

check if a BNDataset contains impited data.
has.imputed.boots

check whether a BNDataset has bootstrap samples from imputed data or not.
imp.boots<-

set list of bootstrap samples from imputed data of a BNDataset.
imp.boots

get list of bootstrap samples from imputed data of a BNDataset.
junction.tree<-

set the junction tree of an InferenceEngine.
junction.tree

get the junction tree of an InferenceEngine.
knn.impute

Perform imputation of a data frame using k-NN.
jt.cliques

get the list of cliques of the junction tree of an InferenceEngine.
jpts<-

set the list of joint probability tables compiled by an InferenceEngine.
interventions

get the list of interventions of an InferenceEngine.
imputed.data

get imputed data of a BNDataset.
interventions<-

set the list of interventions for an InferenceEngine.
jt.cliques<-

set the list of cliques of the junction tree of an InferenceEngine.
jpts

get the list of joint probability tables compiled by an InferenceEngine.
name<-

set name of an object.
node.sizes

get size of the variables of an object.
name

get name of an object.
learn.structure

learn the structure of a network.
layering

return the layering of the nodes.
marginals

compute the list of inferred marginals of a BN.
node.sizes<-

set the size of variables of an object.
learn.network

learn a network (structure and parameters) of a BN from a BNDataset.
num.items

get number of items of a BNDataset.
num.time.steps<-

set number of time steps of a BN or a BNDataset.
num.nodes

get number of nodes of an object.
num.items<-

set number of items of a BNDataset.
num.boots

get number of bootstrap samples of a BNDataset.
num.variables<-

set number of variables of a BNDataset.
learn.params

learn the parameters of a BN.
num.boots<-

set number of bootstrap samples of a BNDataset.
num.time.steps

get number of time steps observed in a BN or a BNDataset.
learn.dynamic.network

learn a dynamic network (structure and parameters) of a BN from a BNDataset.
num.nodes<-

set number of nodes of an object.
num.variables

get number of variables of a BNDataset.
observations

get the list of observations of an InferenceEngine.
quantiles<-

set the list of quantiles of an object.
raw.data

get raw data of a BNDataset.
observations<-

set the list of observations of an InferenceEngine.
raw.data<-

add raw data.
plot

plot a BN as a picture.
read.bif

Read a network from a .bif file.
print

print a BN, BNDataset or InferenceEngine to stdout.
quantiles

get the list of quantiles of an object.
save.to.eps

save a BN picture as .eps file.
read.dsc

Read a network from a .dsc file.
scoring.func

Read the scoring function used to learn the structure of a network.
read.dataset

Read a dataset from file.
show

Show method for objects.
read.net

Read a network from a .net file.
shd

compute the Structural Hamming Distance between two adjacency matrices.
scoring.func<-

Set the scoring function used to learn the structure of a network.
struct.algo<-

Set the algorithm used to learn the structure of a network.
sample.dataset

sample a BNDataset from a network of an inference engine.
tune.knn.impute

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

get variables of an object.
wpdag<-

set WPDAG of the object.
test.updated.bn

check if an updated BN is present in an InferenceEngine.
sample.row

sample a row vector of values for a network.
wpdag.from.dag

Initialize a WPDAG from a DAG.
wpdag

get the WPDAG of an object.
updated.bn<-

set the updated BN object contained in an InferenceEngine.
struct.algo

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

Write a network saving it in a .dsc file.
variables<-

set variables of an object.
write_xgmml

Write a network saving it in an XGMML file.
updated.bn

get the updated BN object contained in an InferenceEngine.
asia

load Asia dataset.
belief.propagation

perform belief propagation.
asia_10000

Asia dataset.
InferenceEngine-class

InferenceEngine class.
BNDataset-class

BNDataset class.
add.observations<-

add further evidence to an existing list of observations of an InferenceEngine.
asia_2_layers

load a two-layers dataset derived from the Asia dataset.
bn

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

set the original BN object contained in an InferenceEngine.
BN-class

BN class definition.