GetMAP: Get the maximum a posteriori state

View source: R/get_map.R

GetMAPR Documentation

Get the maximum a posteriori state

Description

Get the maximum a posteriori state

Usage

GetMAP(x)

Arguments

x

A collection of unique objects or chains object.

Value

A list with the adjacency matrix for the map and it's posterior probability. It is possible for it to return multiple DAGs. The list has elements;

  • state: List of MAP DAGs.

  • log_p: Numeric vector with the log posterior probability for each state.

  • log_state_score: Numeric vector representing the log score for each state.

  • log_norm_state_score: Numeric vector representing the log of the normalised score for each state.

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)

# Get the MAP per chain. Can be helpful to compare chains.
GetMAP(results)

# Get MAP across all chains.
results |>
  FlattenChains() |>
  GetMAP()



cia documentation built on April 4, 2025, 5:23 a.m.