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 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

533

Version

1.0.13

License

GPL (>= 2) | file LICENSE

Maintainer

Alberto Franzin

Last Published

October 20th, 2022

Functions in bnstruct (1.0.13)

asia_10000

Asia dataset.
bn<-

set the original BN object contained in an InferenceEngine.
belief.propagation

perform belief propagation.
BN-class

BN class definition.
asia

load Asia dataset.
asia_2_layers

load a two-layers dataset derived from the Asia dataset.
InferenceEngine-class

InferenceEngine class.
add.observations<-

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

get the BN object contained in an InferenceEngine.
BNDataset-class

BNDataset class.
cpts<-

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

get the list of conditional probability tables of a BN.
boot

get selected element of bootstrap list.
boots<-

set list of bootstrap samples of a BNDataset.
boots

get list of bootstrap samples of a BNDataset.
bootstrap

Perform bootstrap.
child_NA_5000

Child dataset.
em

expectation-maximization algorithm.
complete

Subset a BNDataset to get only complete cases.
discreteness

get status (discrete or continuous) of the variables of an object.
edge.dir.wpdag

counts the edges in a WPDAG with their directionality
dag.to.cpdag

convert a DAG to a CPDAG
data.file<-

set data file of a BNDataset.
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.
get.most.probable.values

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

set adjacency matrix of an object.
child

load Child dataset.
junction.tree

get the junction tree of an InferenceEngine.
dag

get adjacency matrix of a network.
build.junction.tree

build a JunctionTree.
imputed.data<-

add imputed data.
jt.cliques

get the list of cliques of the junction tree of an InferenceEngine.
has.imputed.data

check if a BNDataset contains impited data.
impute

Impute a BNDataset raw data with missing values.
junction.tree<-

set the junction tree of an InferenceEngine.
has.raw.data

check if a BNDataset contains raw data.
jpts<-

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

get header file of a BNDataset.
interventions

get the list of interventions of an InferenceEngine.
header.file<-

set header file of a BNDataset.
data.file

get data file of a BNDataset.
has.boots

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

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

check whether a BNDataset has bootstrap samples from imputed data or not.
jpts

get the list of joint probability tables compiled by an InferenceEngine.
marginals

compute the list of inferred marginals of a BN.
learn.structure

learn the structure of a network.
jt.cliques<-

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

return the layering of the nodes.
node.sizes

get size of the variables of an object.
node.sizes<-

set the size of variables of an object.
num.variables

get number of variables of a BNDataset.
learn.dynamic.network

learn a dynamic network (structure and parameters) of a BN from a BNDataset.
knn.impute

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

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

set number of items of a BNDataset.
raw.data<-

add raw data.
num.nodes

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

set number of variables of a BNDataset.
read.dataset

Read a dataset from file.
num.items

get number of items of a BNDataset.
read.bif

Read a network from a .bif file.
raw.data

get raw data of a BNDataset.
scoring.func

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

compute the Structural Hamming Distance between two adjacency matrices.
quantiles

get the list of quantiles of an object.
quantiles<-

set the list of quantiles of an object.
learn.params

learn the parameters of a BN.
sample.dataset

sample a BNDataset from a network of an inference engine.
learn.network

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

print a BN, BNDataset or InferenceEngine to stdout.
tune.knn.impute

tune the parameter k of the knn algorithm used in imputation.
struct.algo<-

Set the algorithm used to learn the structure of a network.
plot

plot a BN as a picture.
show

Show method for objects.
struct.algo

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

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

check if an updated BN is present in an InferenceEngine.
observations

get the list of observations of an InferenceEngine.
read.net

Read a network from a .net file.
observations<-

set the list of observations of an InferenceEngine.
num.boots

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

set number of bootstrap samples of a BNDataset.
imputed.data

get imputed data of a BNDataset.
interventions<-

set the list of interventions for an InferenceEngine.
save.to.eps

save a BN picture as .eps file.
scoring.func<-

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

get name of an object.
num.time.steps<-

set number of time steps of a BN or a BNDataset.
name<-

set name of an object.
num.time.steps

get number of time steps observed in a BN or a BNDataset.
updated.bn

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

Initialize a WPDAG from a DAG.
write_xgmml

Write a network saving it in an XGMML file.
wpdag

get the WPDAG of an object.
write.dsc

Write a network saving it in a .dsc file.
sample.row

sample a row vector of values for a network.
wpdag<-

set WPDAG of the object.
variables

get variables of an object.
updated.bn<-

set the updated BN object contained in an InferenceEngine.
variables<-

set variables of an object.