grf-labs / policytree

Policy learning via doubly robust empirical welfare maximization over trees
https://grf-labs.github.io/policytree/
MIT License
76 stars 15 forks source link

Can policy_tree handle missing values in covariate space (X)? #139

Open njawadekar opened 2 years ago

njawadekar commented 2 years ago

I am using policytree, version 1.2.0, and I am specifically trying to implement policy learning on the doubly robust reward estimates derived from an honest causal forest (GRF package). While I believe that the GRF package can handle missing covariates (X), see info at link here, it appears that policy_tree cannot handle missing values, is that correct?

When I try running the following code, I get the error, "Covariate matrix X contains missing values". However, I did not get any error when running the causal forest on the same dataset. Please assist - thanks!

Compute doubly robust reward estimates from causal forest

Gamma.matrix <- double_robust_scores(causalf) head(Gamma.matrix)

Fit a depth 2 tree on a random training subset of my sample

N = as.numeric(length(Y)) train <- sample(1:N, 3000) opt.tree <- policy_tree(X[train, ], Gamma.matrix[train, ], depth = 2) This is where the error arose opt.tree

erikcs commented 2 years ago

Hi @njawadekar, Sorry, policy_tree currently does not support missing X's. You could fit it using the non-missing units.

subset <- complete.cases(X)
tree <- policy_tree(X[subset, ], Gamma.matrix[subset, ])