Uses Stan sampler and math library to semiparametrically fit linear and multilevel models with additive Bayesian Additive Regression Tree (BART) components.
fit40 <- stan4bart(
formula = sales ~
hdummys+tv_ads+dig_ads+prt_ads+ # linear component ("fixef")
(1|dmaseqid) + # multilevel ("ranef") #damaseqid is a factor variable
bart(. -region -coupons -hdummys -tv_ads -dig_ads -prt_ads), # use bart for other variables
verbose = -1, # suppress ALL output
# low numbers for illustration
data = train, # 8400 rows
chains = 1, iter = 100, bart_args = list(n.trees = 5,keepTrees = TRUE)) # using only 1 chain
this runs without a problem. Then I use the predict function as follows:
predict(fit40, newdata=test, type = c("ev", "ppd", "indiv.fixef", "indiv.ranef","indiv.bart"), # test data has 2520 rows
combine_chains = FALSE, # has only 1 chain, no need to combine
sample_new_levels = TRUE)
Does this have a solution? My train and test data frames have the exactly the same columns, just the number of rows are different. I read here by using a single chain we can overcome the error that comes up with number of dimensions associated with bart component.
Here is my training model:
this runs without a problem. Then I use the predict function as follows:
I get the following error:
Does this have a solution? My train and test data frames have the exactly the same columns, just the number of rows are different. I read here by using a single chain we can overcome the error that comes up with number of dimensions associated with bart component.