extractTreeData {bartMan}R Documentation

extractTreeData

Description

Creates a list of all tree attributes for a model created by either the BART, dbarts or bartMachine packages.

Usage

extractTreeData(model, data)

Arguments

model

Model created from either the BART, dbarts or bartMachine packages.

data

a data frame used to build the BART model.

Value

A list containing the extracted and processed tree data. This list includes:

  1. Tree Data Frame: A data frame containing tree attributes.

  2. Variable Name: The names of the variables used in building the model.

  3. nMCMC: The total number of iterations (posterior draws) after burn-in.

  4. nTree: The total number of trees grown in the sum-of-trees model.

  5. nVar: The total number of covariates used in the model.

The object created by the 'extractTreeData' function encompasses these elements, facilitating detailed analysis and visualisation of BART model components.

Examples

if(requireNamespace("dbarts", quietly = TRUE)){
# Load the dbarts package to access the bart function
library(dbarts)
# Get Data
df <- na.omit(airquality)
# Create Simple dbarts Model For Regression:
set.seed(1701)
dbartModel <- bart(df[2:6], df[,1], ntree = 5, keeptrees = TRUE, nskip = 10, ndpost = 10)
# Tree Data
trees_data <- extractTreeData(model = dbartModel, data = df)
}


[Package bartMan version 0.1.0 Index]