combineDummy function

Update Dummy Variable Names

Update Dummy Variable Names

This function updates the var column in the structure component of the trees list, replacing dummy variable names derived from factor variables with their original factor variable names.

combineDummy(trees)

Arguments

  • trees: A list containing at least two components: data and structure. data should be a dataframe, and structure a dataframe that includes a var column.

Returns

The modified trees list with updated var column entries in trees$structure.

Details

The function first identifies factor variables in trees$data, then checks each entry in trees$structure$var for matches with these factor variables. If a match is found, indicating a dummy variable, the entry is replaced with the original factor variable name.

Examples

if(requireNamespace("dbarts", quietly = TRUE)){ # Load the dbarts package to access the bart function library(dbarts) # Create Simple dbarts Model with Dummies set.seed(1701) dbartModel <- bart(iris[2:5], iris[,1], ntree = 5, keeptrees = TRUE, nskip = 10, ndpost = 10) # Tree Data trees_data <- extractTreeData(model = dbartModel, data = iris) combined_trees <- combineDummy(trees = trees_data) }
  • Maintainer: Alan Inglis
  • License: GPL (>= 2)
  • Last published: 2024-07-24

Useful links