Learn R Programming

BiDAG (version 2.0.0)

sample.check: Performance assessment of sampling algorithms against a known Bayesian network

Description

This function calculates the number of true and false positives and the structural Hamming distance between a ground truth DAG and a directed graph summarising a sample of DAGs obtained from an MCMC scheme, as the posterior probability threshold is varied

Usage

sample.check(
  MCMCchain,
  truedag,
  p = c(0.99, 0.95, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2),
  pdag = TRUE,
  burnin = 0.2,
  trans = TRUE
)

Arguments

MCMCchain

an object of class MCMCres, representing the output of structure sampling function partitionMCMC or orderMCMC (the latter when parameter chainout=TRUE; see also MCMCres)

truedag

ground truth DAG which generated the data used in the search procedure; represented by an object of class graphNEL

p

(optional) a vector of numeric values between 0 and 1, defining posterior probabilities according to which the edges of assessed structures are drawn, please note very low barriers can lead to very dense structures; by default \(p=c(0.99, 0.95, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2)\)

pdag

logical, if TRUE (default) all DAGs in the MCMCchain are first converted to equivalence class (CPDAG) before the averaging

burnin

(optional) number between 0 and 1, indicates the percentage of the samples which will be the discarded as `burn-in' of the MCMC chain; the rest of the samples will be used to calculate the posterior probabilities; 0.2 by default

trans

logical, for DBNs indicates if model comparions are performed for transition structure; when trans equals FALSE the comparison is performed for initial structures of estimated models and the ground truth DBN; for usual BNs the parameter is disregarded

Value

A matrix with the number of rows equal to the number of posterior thresholds tested, and 4 columns reporting for each thresholded directed graphs the number of true positive edges (`TP'), the number of false positive edges (`FP'), the structural Hamming distance (`SHD') and the posterior threshold

Examples

Run this code
# NOT RUN {
gsim.score<-scoreparameters("bge", gsim)
# }
# NOT RUN {
mapest<-iterativeMCMC(gsim.score)
ordersample<-orderMCMC(gsim.score, MAP=FALSE, startspace=mapest$endspace)
sample.check(ordersample, gsimmat)
# }

Run the code above in your browser using DataLab