discreteStatesFromBN: Get the states of all discrete nodes from a MoTFB-BN

View source: R/Inference.R

discreteStatesFromBNR Documentation

Get the states of all discrete nodes from a MoTFB-BN

Description

This function returns the states of all discrete nodes from a list obtained from MoTBFs_Learning.

Usage

discreteStatesFromBN(bn, dag)

Arguments

bn

A list of lists obtained from MoTBFs_Learning.

dag

A network of class "bn".

Value

discreteStatesFromBN returns a list of length equal to the number of discrete nodes in the network. Each element of the list corresponds to a node and contains a character vector indicating the states of the node.

Examples


## Create a dataset
  # Continuous variables
  x <- rnorm(100)
  y <- rnorm(100)
  
  # Discrete variable
  z <- sample(letters[1:2],size = 100, replace = TRUE)
  
  data <- data.frame(C1 = x, C2 = y, D1 = z, stringsAsFactors = FALSE)
  
## Get DAG
  dag <- LearningHC(data)

## Learn a BN
  bn <- MoTBFs_Learning(dag, data, POTENTIAL_TYPE = "MTE")

## Get the states of the discrete nodes

  discreteStatesFromBN(bn, dag)

MoTBFs documentation built on April 18, 2022, 5:06 p.m.