Skip to contents

Plot the score trace

Usage

PlotScoreTrace(
  chains,
  attribute = "log_score",
  n_burnin = 0,
  same_plot = TRUE,
  col = NULL,
  ...
)

Arguments

chains

MCMC chains.

attribute

Name of attribute to plot. Default is "log_score".

n_burnin

Number of steps to remove as burnin.

same_plot

Whether to plot on the same figure or on multiple figures.

col

A string representing a color for a single chain or a vector of strings to cycle through for multiple chains.

...

Extra parameters to pass to the plot and graphics::line functions.

Value

No return value. Called to produce a base R trace plot.

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)

# Plot partition score trace.
PlotScoreTrace(results, type = 'l')


# Plot DAG score trace.
dag_chains <- PartitiontoDAG(results, scorer)
PlotScoreTrace(dag_chains, type = 'l')