staged_tree_prior {stCEG}R Documentation

Apply Priors to a Staged Tree for Visualization

Description

This function applies prior distributions to a staged tree, adjusting priors and calculating the mean and variance of the Dirichlet distributions for each node. The function also generates a visualization using the visNetwork package, showing the tree with additional information like prior distributions, means, and variances.

Usage

staged_tree_prior(
  staged_tree_obj,
  prior_table,
  level_separation = 1500,
  node_distance = 250,
  label_type = "priors"
)

Arguments

staged_tree_obj

A list containing a staged tree object with the components "nodes" and "edges".

prior_table

A data frame with columns "Colour", "Level", and "Prior", containing prior distributions for each stage.

level_separation

A numeric value determining the separation between levels in the hierarchical layout of the tree. Default is 1000.

node_distance

A numeric value for the distance between nodes. Default is 300.

label_type

A string indicating the label type for edges. It can be one of "names", "priors", or "priormeans". Default is "names".

Details

Value

A visNetwork object that displays the staged tree with adjusted prior distributions and additional information in the tooltips.

Examples

data <- homicides
event_tree <- create_event_tree(data, columns = c(1,2,4,5), "both")
coloured_tree <- ahc_colouring(event_tree)
# cannot run this whole chunk as one, as specify_priors needs user input
tree_priors <- specify_priors(coloured_tree, prior_type = "Uniform", ask_edit = FALSE)
staged_tree <- staged_tree_prior(coloured_tree, tree_priors)
staged_tree


[Package stCEG version 0.1.0 Index]