Flatten a cia_chains object into a single cia_chain object. This is helpful for when you want to calculate a feature across using all samples across the cia_chains.
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)
FlattenChains(results)[1:3]
#> $state
#> $state[[1]]
#> partition node
#> 1 1 B
#> 2 2 D
#> 3 2 E
#> 4 3 F
#> 5 4 C
#> 6 5 A
#>
#> $state[[2]]
#> partition node
#> 1 1 B
#> 2 2 D
#> 3 2 E
#> 4 3 F
#> 5 4 C
#> 6 5 A
#>
#> $state[[3]]
#> partition node
#> 1 1 B
#> 2 2 E
#> 3 3 F
#> 4 4 C
#> 5 5 D
#> 6 6 A
#>
#>
#> $log_score
#> [1] -24277.48 -24277.48 -24206.99
#>
#> $proposal_info
#> $proposal_info[[1]]
#> $proposal_info[[1]]$proposal_used
#> [1] "swap_adjacent"
#>
#>
#> $proposal_info[[2]]
#> $proposal_info[[2]]$proposal_used
#> [1] "node_move"
#>
#>
#> $proposal_info[[3]]
#> $proposal_info[[3]]$proposal_used
#> [1] "node_move"
#>
#>
#>
#> $mcmc_info
#> $mcmc_info[[1]]
#> $mcmc_info[[1]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[1]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[1]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[1]]$jac
#> [1] 0
#>
#> $mcmc_info[[1]]$mhr
#> [1] 71.44873
#>
#>
#> $mcmc_info[[2]]
#> $mcmc_info[[2]]$accept
#> [1] FALSE
#>
#> $mcmc_info[[2]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[2]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[2]]$jac
#> [1] 0
#>
#> $mcmc_info[[2]]$mhr
#> [1] -89.68627
#>
#>
#> $mcmc_info[[3]]
#> $mcmc_info[[3]]$accept
#> [1] TRUE
#>
#> $mcmc_info[[3]]$white_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[3]]$black_obeyed
#> [1] TRUE
#>
#> $mcmc_info[[3]]$jac
#> [1] -0.1823216
#>
#> $mcmc_info[[3]]$mhr
#> [1] 70.48358
#>
#>
#>
#> attr(,"class")
#> [1] "cia_chain"