getObservations function

Get Observations Falling into Each Node

Get Observations Falling into Each Node

This function determines which observations from a given dataset fall into which nodes of a tree, based on a tree structure defined in treeData. The treeData object must include iteration, treeNum, var, and splitValue columns.

getObservations(data, treeData)

Arguments

  • data: A data frame used to build BART model.
  • treeData: A data frame representing the tree structure, including the necessary columns iteration, treeNum, var, and splitValue.

Returns

A modified version of treeData that includes two new columns: obsNode and noObs. obsNode lists the observations falling into each node, and noObs provides the count of observations for each node.

Examples

data("tree_data_example") # Create Terminal Column tree_data_example <- transform(tree_data_example, terminal = ifelse(is.na(var), TRUE, FALSE)) # Create Split Value Column tree_data_example <- transform(tree_data_example, splitValue = ifelse(terminal == FALSE, value, NA_integer_)) # get the observations getObservations(data = input_data, treeData = tree_data_example)
  • Maintainer: Alan Inglis
  • License: GPL (>= 2)
  • Last published: 2024-07-24

Useful links