MoTBFs (version 1.2)

forward_sampling: Forward Sampling

Description

forward_sampling() returns the conditional distribution of a target variable given a set of oberved variables. The forward sampling algorithm approximates the conditional distribution from a random sample.

Usage

forward_sampling(bn, dag, target, evi, size, force_size = T, ...)

Arguments

bn

A list of lists obtained from the function MoTBFs_Learning.

dag

An object of class "bn", representing the directed acyclic graph.

target

A character string equal to the name of the variable of interest.

evi

A data.frame containing the observed variables.

size

A non-negative integer giving the number of instances to be generated.

force_size

logical indicating if the sample must be of the size indicated. As a default, it is set to TRUE.

...

Optional arguments passed on to the univMoTBF function. evalRange, nparam and maxParam can be specified. POTENTIAL_TYPE is taken from the 'bn' object.

Value

A list containing the conditional distribution of the target variable and a data.frame with the generated sample.

References

Henrion, M. (1988). Propagating uncertainty in Bayesian networks by probabilistic logic sampling. In Machine Intelligence and Pattern Recognition (Vol. 5, pp. 149-163). North-Holland.

Examples

Run this code
# NOT RUN {
## Dataset
  data("ecoli", package = "MoTBFs")
  data <- ecoli[,-c(1,9)]

## Get directed acyclic graph
  dag <- LearningHC(data)
  
## Learn bayesian network
  bn <- MoTBFs_Learning(dag, data = data, numIntervals = 4, POTENTIAL_TYPE = "MTE")
  
## Specify the evidence set and target variable
  obs <- data.frame(lip = "0.48", alm1 = 0.55, gvh = 1, stringsAsFactors=FALSE)
  node <- "alm2"
  
## Get the conditional distribution of 'node' and the generated sample
  forward_sampling(bn, dag, target = node, evi = obs, size = 10, maxParam = 15)
  
# }

Run the code above in your browser using DataLab