Learn R Programming

stCEG (version 0.1.0)

specify_priors: 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
)

Value

A data frame containing the updated nodes data with the specified priors and their means.

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:

  • "Uniform": Assigns a Uniform (1,1) prior based on the outgoing edges.

  • "Phantom": Calculates a Phantom Individuals prior by initialising an alpha based on the maximum number of outgoing edges in the tree and dividing that evenly throughout the tree.

  • "Custom": Allows the user to manually specify the prior values for each node.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab