variableElimination: Exact inference

View source: R/VariableEliminationFunctionsClean.R

variableEliminationR Documentation

Exact inference

Description

Compute the posterior distribution of a variable of interest given some evidence. The variable elimination algorithm is used.

Usage

variableElimination(bn, target, evidence = NULL, elimOrder = NULL)

Arguments

bn

An object of class motbf_fit, obtained from function motbf.fit.

target

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

evidence

A data.frame of one row containing the value of the observed variables. A list can also be provided.

elimOrder

The elimination order can be manually specified as a vector containing the names of the variables, in the desired order. If elimOrder is not specified, the topological order is computed.

Value

The posterior probability distribution of the target variable as an object of class univmotbf or piecewisemop if target is continuous, or a matrix if target is discrete.

Examples

## Dataset
  data("ecoli", package = "MoTBFs")
  data <- ecoli[,-c(1,9)]

## Get directed acyclic graph
  dag <- LearningHC(data)
  
## Learn bayesian network
  bn <- motbf.fit(dag, data = data, numIntervals = 4, POTENTIAL_TYPE = "MOP")
  
## Specify the evidence set and target variable
  obs <- data.frame(lip = "0.48", alm1 = 0.55, stringsAsFactors=FALSE)
  node <- "alm2" 
ve = variableElimination(bn, target = node, evidence = obs)

MoTBFs documentation built on Oct. 6, 2026, 1:06 a.m.