vdorie / stan4bart

Uses Stan sampler and math library to semiparametrically fit linear and multilevel models with additive Bayesian Additive Regression Tree (BART) components.
40 stars 4 forks source link

Returning Trees #4

Closed jlevy44 closed 2 years ago

jlevy44 commented 2 years ago

Hi there! What are some optimal ways to return the fit tree structure (decision splits, split variables/values, conditional means, etc.) from each of the posterior draws?

I have been trying to work on accessing the sampler in C but to no avail so far. It would be nice if there was a C call that would extract the tree structure into the fitted object or a straightforward means of extracting such an object, like darts. Thanks!

vdorie commented 2 years ago

Sorry for the very slow response, but I haven't had much time to work on the project lately. I've added an extract for trees in 871edbb. For now it requires installing dbarts from github, but as soon as I can wrap up a few more things I'll be pushing to CRAN. There's a vignette on how to work with the trees here, and everything will be essentially the same except for that the stan4bart BART variable names are in bartData@x instead of fit$data@x.

jlevy44 commented 2 years ago

Great!! I'll give it a test run and get back to you.

jlevy44 commented 2 years ago

Works! Brilliant!! I'll let you know if I run into any other potential issues, but this appears to be working quite well.

I'll be in touch, may send an email sometime.