r.data.frame: Data frame initialization for forward sampling

View source: R/Inference.R

r.data.frameR Documentation

Data frame initialization for forward sampling

Description

The function r.data.frame() initializes a data frame with as many columns as nodes in the MoTBF-network. It also asings each column its data type, i.e., numeric or character. In the case of character columns, the states of the variable are extracted from the "bn" argument and included as levels.

Usage

r.data.frame(bn, dag)

Arguments

bn

A list of lists obtained from the function MoTBFs_Learning.

dag

An object of class "bn", representing the graph of the bayesian network.

Value

An object of class "data.frame", which contains the data type of each column and has no rows.

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")
  
## Initialize a data.frame containing 3 columns (x, y and z) with their attributes.
  r.data.frame(bn, dag)

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

Related to r.data.frame in MoTBFs...