I was wondering if there was a way to retrieve the data from a model built from the BART
package in R?
It seems to be possible using other bart packages, such as dbarts
... but I can't seem to find a way to get the original data back from a BART
model. For example, if I create some data and run a BART
and dbarts
model, like so:
library(BART)
library(dbarts)
# create data
df <- data.frame(
x = runif(100),
y = runif(100),
z = runif(100)
)
# create BART
BARTmodel <- wbart(x.train = df[,1:2],
y.train = df[,3])
# create dbarts
DBARTSmodel <- bart(x.train = df[,1:2],
y.train = df[,3],
keeptrees = TRUE)
Using the keeptrees
option in dbarts
allows me to retrieve the data using:
# retrieve data from dbarts
DBARTSmodel$fit$data@x
However, there doesn't seem to be any type of similar option when using BART
. Is it even possible to retrieve the data from a BART
model?
The
Value:
section of?wbart
suggests it doesn't return the input as part of the output, and none of the function arguments forwbart
suggest that this can be changed.Furthermore, if you look at the output of
str
, you can see that it's not present.Whereas the output of
str()
for thebart
output, while long, does contain the input: