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`.

Value

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

treeDataWithObservations <- getObservations(data = my_data, treeData = my_trees)
#> Error in eval(expr, envir, enclos): object 'my_data' not found