Questions tagged [bnlearn]

bnlearn is an R package for learning the graphical structure of Bayesian networks, estimate their parameters and perform some useful inference.

bnlearn is an R package for learning the graphical structure of Bayesian networks, estimate their parameters and perform some useful inference. To get started and install the latest development snapshot type

install.packages(​"http://www.bnlearn.com/releases/​bnlearn_latest.tar.gz") in your R console.

Package webpage: http://www.bnlearn.com/

89 questions
1
vote
1 answer

simulating data with bayesian network in R using own specification

Say I have a simple DAG representing a confounding variable X = Smoking, a treatment T and outcome Y = Death such that: T ~ X Y ~ T + X Is it possible to produce a synthetic dataset of say 1m observations that follows some specified conditional…
chrisjacques
  • 635
  • 1
  • 5
  • 17
1
vote
1 answer

How do I represent domain knowledge information with bnlearn

I am learning about Dynamic Bayesian Network models using the R package bnlearn. To this end, I am following this paper where they impose certain constraints in the form of 6 layers (Table 1 in the paper): 1 Gender, age at ALS onset 2 Onset…
1
vote
0 answers

bn.fit INTEGER() can only be applied to an 'integer', not a 'double'

I'm trying to train a Bayesian network with a mixed model. wl <- matrix(c("DR", "DT", "LN", "DL", "DL", "DT"), ncol = 2, byrow = TRUE) bl <- matrix(c("DT", "D", "DT", "DR", "DT", "DL", "DT", "FT", "DT", "FS", "DT", "FC", "DT", "FA", "DT", "LN",…
P_O
  • 435
  • 6
  • 16
1
vote
0 answers

Calculation of log-likelihood in bnlearn

I have created a Bayesian network model using the library bnlearn. I would like to calculate the log-likelihood of the model. Could you please let me know how can I do this? Sample code for creation of model: bn = bn.fit(net, train) nationprob =…
user15984416
1
vote
1 answer

Interpreting 'catnet' package's cnProb output for a catnetwork object

I am new to Bayesian Networks. I am trying to use catnet package in R, however, I am having difficulty understanding the output of cnProb() function. For instance, here is a new catnetwork object: cnet_test <- cnNew( nodes = c("a", "b", "c"), …
RforResearch
  • 401
  • 8
  • 16
1
vote
1 answer

Bayesian networks 'catnet' package cnPlot returning null

I am working with Bayesian Networks for the first time and I am using Catnet package in R. The reason being my data is full of categorical variables and a lot of missing data too. I tried the simple example posted elsewhere in StackOverflow just to…
RforResearch
  • 401
  • 8
  • 16
1
vote
0 answers

How to get r to run bnlearn mc-x2 test?

I'm attempting to perform two versions of Pearson's X2 test on a network. Here is the code i'm running: library(bnlearn) library(Rgraphviz) library(gRain) library(graph) library(grid) library(snow) dag <- empty.graph(names(alarm)) modelstring(dag)…
1
vote
0 answers

Why does function: Score return error: unable to find an inherited method for function ‘score’ for signature ‘"bn"’

I want to show the score for a Bayesian network. I'm not yet experienced in correcting errors that occur, so I hope that someone here knows how to solve it. Here is the code I'm…
1
vote
1 answer

Using cpquery function for several pairs from dataset

I am relatively beginner in R and trying to figure out how to use cpquery function for bnlearn package for all edges of DAG. First of all, I created a bn object, a network of bn and a table with all…
Alex Popov
  • 15
  • 1
  • 7
1
vote
0 answers

Bnlearn out of memory

I'm running into memory issues using the bnlearn package's structure learning algorithms. Specifically, I notice that score based methods (e.g. hc and tabu) use LOTS of memory--especially when given a non-empty starting network. Memory usage…
John
  • 11
  • 1
1
vote
0 answers

Compute unconditional probabilities in Bayesian Newtork

Can bnlearn package compute the unconditional probabilities of each node? For example, in a simple case, if we have three nodes A,S ---> E: library(bnlearn) dag <- empty.graph(nodes = c("A", "S", "E")) dag <- set.arc(dag, from = "A", to = "E") dag…
1
vote
1 answer

What loss function in cross-validation should I use with R package BNlearn for my data?

New to StackOverflow and R. I have a question regarding the different loss functions for cross-validation that are provided in R package BNlearn and which one I should use. I have continuous data (example below) with 32 rows and 8 columns, each…
Lucius
  • 11
  • 1
1
vote
1 answer

How to use custom score functions in bnlearn version 4.6?

bnlearn 4.6 has support for custom decomposable scores according to the changelog. I can't figure out how to use it though. I've tried net <- hc(df, score = "custom") and it gives me Error in check.custom.score.function(fun = extra.args$fun):…
elbord77
  • 311
  • 1
  • 2
  • 11
1
vote
0 answers

Getting level from factor column in data frame based on numeric range

I'm trying to get the level of a number based on where it is in the range of values of a factor column in a dataframe. library(bnlearn) i <- iris idata4 <- i[,c(1:4)] #only first four columns, which are continuous diris <- discretize(idata4, method…
Oleg
  • 303
  • 2
  • 14
1
vote
0 answers

bnlearn: Extract probabilitiy estimates from network continuous predictors and discrete outcome

I am trying to make a classification network where I need to predict a categorical/discrete outcome based on a large number of continuous predictor variables. I can predict the class after learning the model, but is there a way to extract the…
DrPineapple
  • 321
  • 1
  • 4
  • 13