vdorie / bartCause

Causal Inference using Bayesian Additive Regression Trees
71 stars 10 forks source link

Access to `icate` and `ite` #17

Open bonStats opened 1 year ago

bonStats commented 1 year ago

I'm not sure how to access to icate and ite...

As far as I can tell extract(model, type = "icate") and extract(model, type = "ite") don't return the individual treatment effects, they are constant across individuals in this MWE:

library(bartCause)
source(system.file("common", "friedmanData.R", package = "bartCause"))
testData <- generateFriedmanData(100, ranef = TRUE, causal = TRUE)
test.df <- with(testData, data.frame(x, y, z, g.1))
fit_sd <- bartc(y, z, X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10,
                parametric = (1 | g.1), data = test.df,
                verbose = FALSE, seed = 5,
                commonSup.rule = "sd", commonSup.cut = 1, bart_args = list(keepTrees = TRUE))
refit_sd <- refit(fit_sd, commonSup.rule = "sd", commonSup.cut = 0.5)

extract(fit_sd, type = "icate")

Is the above code working as intended? And why?

If so, summary.bartcFit should produce the icate or ite for the CIs, is it possible to optionally output these as part of this function?

vdorie commented 1 year ago

Well, that was a silly omission on my part. z wasn't being added to the non-parametric formula for stan4bart models, so that the treatment was constant. Since that's probably a large reason to use the package, I've added it and (when applicable) the propensity score to the non-parametric component. They remain in the linear component. Should yield different results as of f84a1d1. I'll work on pushing that to CRAN in the near future.