I'm trying to use the bartCause package to build an uplift model in R. Unfortunately I have trouble to integrate the data frame in the right way - error message:
$<-.data.frame`(`*tmp*`, "lift", value = c(0.159231848781688, :
replacement has 160 rows, data has 2595
Code used:
x = as.matrix(calibration[,-c(1:3)])
y = calibration$churn
z = calibration$treatment
bart = bartc(y, z, x,
method.trt = "bart",
method.rsp = "bart",
estimand="att", #average treatment effect on the treated
n.samples = 20L,
n.chains = 8L, #Integer specifying how many independent tree sets and fits should be calculated.
n.burn = 10L,
n.threads = 4L, #Integer specifying how many threads to use for parallelization
n.trees = 1000L,
keepTrees = TRUE, #necessary for prediction!
verbose = FALSE)
pred_uplift <- predict(bart, validation[,-c(1:3)], combineChains = TRUE)
pred <- pred_uplift
validation$lift <- - pred[,1] + pred[,2]
calibration data: (2595 obs. of 15 variables) enter image description here
validation data: (2595 obs. of 15 variables) enter image description here