Learn R Programming

MoTBFs (version 2.0)

query: Conditional probability queries

Description

Compute conditional probability queries from a sample.

Usage

query(sample, event, evidence)

Value

The conditional probability: P(event|evidence).

Arguments

sample

A data.frame containing a sample.

event

A expression describing the event of interest

evidence

A expression describing the conditioning evidence.

Examples

Run this code
  data("ecoli", package = "MoTBFs")
  dat <- ecoli[,-c(1,4,5,9)]
  
  # Build DAG
  dag <- LearningHC(dat)
  
  # Learn BN parameters
  bn = motbf.fit(dag, dat)
 
 # Get sample from bn
 sam = sample_motbfs(bn, 50)
 
 # Compute P(mcg > 0.6 | aac < 0.8 & alm2 < 0.3)
 query(sam, event = (mcg >0.6), evidence = (aac<0.8 & alm2 <0.3))
 

Run the code above in your browser using DataLab