Skip to contents

Calculate pairwise edge probabilities. The posterior probability of an edge \(E\) given the data \(D\) is given by marginalising out the graph structure \(g\) over the graph space \(G\), such that $$p(E|D) = \sum_{g \in G} p(E|g)p(g|D).$$

Usage

CalculateEdgeProbabilities(x, ...)

Arguments

x

A cia_chain(s) or collection object where states are DAGs.

...

Extra parameters sent to the methods. For a dag collection you can choose to use estimated p(g|D) in two ways which can be specified using the 'method' parameter.method='sampled' for MCMC sampled frequency (which is our recommended method) or method='score' which uses the normalised scores.

Value

Matrix of edge probabilities.

Details

The posterior probability for a given graph p(g|D) is estimated in two ways which can be specified using the 'method' parameter.

Examples

data <- bnlearn::learning.test

dag <- UniformlySampleDAG(colnames(data))
partitioned_nodes <- DAGtoPartition(dag)

scorer <- CreateScorer(
  scorer = BNLearnScorer, 
  data = data
  )

results <- SampleChains(10, partitioned_nodes, PartitionMCMC(), scorer)
dag_chains <- PartitiontoDAG(results, scorer)
CalculateEdgeProbabilities(dag_chains)
#> [[1]]
#>     A   B   C   D   E   F
#> A 0.0 1.0 0.2 0.8 1.0 0.8
#> B 0.0 0.0 0.1 0.2 0.0 0.0
#> C 0.1 0.0 0.0 0.8 0.0 0.2
#> D 0.2 0.0 0.2 0.0 0.0 0.0
#> E 0.0 1.0 0.0 0.0 0.0 0.8
#> F 0.2 0.6 0.6 0.1 0.2 0.0
#> 
#> [[2]]
#>     A   B   C   D   E   F
#> A 0.0 0.7 0.0 1.0 0.0 0.3
#> B 0.3 0.0 0.0 0.0 1.0 0.7
#> C 0.7 0.2 0.0 1.0 0.0 0.0
#> D 0.0 0.0 0.0 0.0 0.0 0.0
#> E 0.3 0.0 0.0 0.5 0.0 0.5
#> F 0.0 0.3 0.1 0.2 0.5 0.0
#>