Skip to contents

Simulate samples from a posterior predictive distribution for a feature \(f(g)\) a graph \(g\).

Usage

SamplePosteriorPredictiveChains(x, p_predict, ...)

Arguments

x

A cia_chain(s) object.

p_predict

A function that draws from the posterior predictive distribution of interest given an adjacency matrix representing a DAG. The function must be of the form p_predict(dag, ...) and return either a vector of numeric values.

...

Parameters to be passed to p_predict.

Value

A cia_post_chain(s) object.

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)

# Sample the edge probability.
SamplePosteriorPredictiveChains(dag_chains, function(dag) { return(dag) })
#> [[1]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    0    0    0    0    0    1    1    0    1     0     1     0     1
#>  [2,]    0    0    0    0    0    1    1    0    1     0     1     0     1
#>  [3,]    0    0    0    0    0    1    1    0    1     0     0     0     1
#>  [4,]    0    0    0    0    0    1    1    0    0     1     0     0     1
#>  [5,]    0    0    0    0    0    1    1    0    0     1     0     0     1
#>  [6,]    0    0    0    0    0    1    1    0    0     1     0     0     1
#>  [7,]    0    0    0    0    0    1    1    0    0     1     0     0     1
#>  [8,]    0    0    0    0    0    0    1    0    0     1     0     0     1
#>  [9,]    0    0    0    0    0    0    1    0    0     1     0     0     1
#> [10,]    0    0    0    0    0    0    1    0    0     1     0     0     1
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
#>  [1,]     0     0     1     0     0     1     0     0     0     1     0     1
#>  [2,]     0     0     1     0     0     1     0     0     0     1     0     1
#>  [3,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [4,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [5,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [6,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [7,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [8,]     0     0     1     0     0     1     0     0     0     0     0     0
#>  [9,]     0     0     1     0     0     1     0     0     0     0     0     0
#> [10,]     0     0     1     0     0     1     0     0     0     0     0     0
#>       [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
#>  [1,]     0     0     0     0     1     0     0     0     0     0     0
#>  [2,]     0     0     0     0     1     0     0     0     0     0     0
#>  [3,]     1     0     0     0     1     0     0     0     0     0     0
#>  [4,]     1     0     0     0     1     0     0     0     0     0     0
#>  [5,]     1     0     0     0     1     0     0     0     0     0     0
#>  [6,]     1     0     0     0     1     0     0     0     0     0     0
#>  [7,]     1     0     0     0     1     0     0     0     0     0     0
#>  [8,]     1     0     0     0     1     0     0     0     0     0     0
#>  [9,]     1     0     0     0     1     0     0     0     0     0     0
#> [10,]     1     0     0     0     1     0     0     0     0     0     0
#> attr(,"class")
#> [1] "cia_post_chain"
#> 
#> [[2]]
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,]    0    0    0    0    0    0    1    0    1     0     1     0     1
#>  [2,]    0    0    0    0    0    0    1    0    1     0     1     0     1
#>  [3,]    0    0    0    0    0    0    1    0    0     1     1     0     0
#>  [4,]    0    0    0    0    0    0    1    0    0     1     1     0     0
#>  [5,]    0    0    0    0    0    1    1    0    0     1     1     0     0
#>  [6,]    0    0    0    0    1    0    1    0    0     1     1     0     0
#>  [7,]    0    0    0    0    1    0    1    0    0     1     1     0     0
#>  [8,]    0    0    0    0    1    0    1    0    0     1     1     0     0
#>  [9,]    0    0    0    0    1    0    1    0    0     1     1     0     0
#> [10,]    0    0    0    0    0    0    1    0    0     1     1     0     0
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
#>  [1,]     0     0     1     0     0     1     0     0     0     1     0     1
#>  [2,]     0     0     1     0     0     1     0     0     0     1     0     1
#>  [3,]     0     0     0     1     0     1     0     1     0     0     0     1
#>  [4,]     0     0     0     1     0     1     0     1     0     0     0     1
#>  [5,]     0     0     0     1     0     1     0     1     0     0     0     1
#>  [6,]     0     0     0     0     1     1     0     1     0     0     0     0
#>  [7,]     0     0     0     0     1     1     0     1     0     0     0     0
#>  [8,]     0     0     0     0     1     1     0     1     0     0     0     0
#>  [9,]     0     0     0     0     1     1     0     1     0     0     0     0
#> [10,]     0     0     0     0     1     1     0     1     0     0     0     1
#>       [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
#>  [1,]     0     0     0     0     1     1     0     0     0     0     0
#>  [2,]     0     0     0     0     1     1     0     0     0     0     0
#>  [3,]     0     0     0     0     1     1     0     0     0     0     0
#>  [4,]     0     0     0     0     1     1     0     0     0     0     0
#>  [5,]     0     0     0     0     1     0     0     0     0     0     0
#>  [6,]     0     0     0     0     0     1     0     0     0     1     0
#>  [7,]     0     0     0     0     0     1     0     0     0     1     0
#>  [8,]     0     0     0     0     0     1     0     0     0     1     0
#>  [9,]     0     0     0     0     0     1     0     0     0     1     0
#> [10,]     0     0     0     0     0     1     0     0     0     1     0
#> attr(,"class")
#> [1] "cia_post_chain"
#> 
#> attr(,"class")
#> [1] "cia_post_chains"