View source: R/VariableEliminationFunctionsClean.R
| variableElimination | R Documentation |
Compute the posterior distribution of a variable of interest given some evidence. The variable elimination algorithm is used.
variableElimination(bn, target, evidence = NULL, elimOrder = NULL)
bn |
An object of class |
target |
A character string equal to the name of the variable of interest. |
evidence |
A |
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. |
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.