specify_priors {stCEG} | R Documentation |
Specify Priors for a Staged Tree Object
Description
This function assigns priors to the nodes of a staged tree object. The user can choose from different types of priors, including "Uniform", "Phantom", and "Custom".
Usage
specify_priors(
staged_tree_obj,
prior_type = "Uniform",
ask_edit = TRUE,
print_colours = TRUE
)
Arguments
staged_tree_obj |
A staged tree object containing the nodes and edges data for the tree. |
prior_type |
A character string indicating the prior type. Options are:
|
ask_edit |
If TRUE, this allows you to edit priors after choosing an uninformative prior type. |
print_colours |
If TRUE, this prints a colour key for stages. Default is TRUE. |
Details
The function checks if the necessary columns and structure are present in the input staged tree object. It performs validation on the nodes' levels and ensures that no nodes with non-minimum or non-maximum levels have the colour #FFFFFF
.
For the "Uniform" and "Phantom" priors, the function calculates the priors for each node based on their outgoing edges and propagates them through connected nodes. The user can edit these priors if desired.
The "Custom" option allows the user to manually input prior values for each row. If incorrect values are provided, an error will be raised.
Value
A data frame containing the updated nodes data with the specified priors and their means.
Examples
data <- homicides
event_tree <- create_event_tree(data, columns = c(1,2,4,5), "both")
coloured_tree <- ahc_colouring(event_tree)
tree_priors <- specify_priors(coloured_tree, prior_type = "Uniform", ask_edit = FALSE)