-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom plot function for causalTree rpart.object #27
base: master
Are you sure you want to change the base?
Conversation
update from original
Potential TODOs: (1) make p-value annotation optional if that makes sense, (2) multiple testing corrections. |
Hi, I was trying to test your code and had a couple of questions: 1. Do you intend for first column of X to be treatment variables?When calling the function using a pruned tree defined by the example code in the documentation of causalTree, (line 20: tree_with_p = plot.causalTree(opfit)), one runs into the error '$ operator is invalid for atomic vectors'. I'm using the data from 'simulation.1'. Stepping into the functions, the error appears to be coming from add.pvals - the data frame 'merged' is empty. I might be misunderstanding, but it seems like you create a new dataframe 'dat' by using the first column of X as the 'treatment' variable, and then extracts all the rows where treatment == 1 or == 0. However, as far as I can tell in causalTree the first column of X is not intended to be the treatment vector. The first column of X here is not a binary vector - (I.e. opfit$x[,1] is not all zeros or ones). Thus, when you run you run the merge, it returns nothing. Could you clarify if you intend x[,1] to be the treatment vector? 2. Do you intend for us to pass in a pruned tree?In your comments for plot.causal tree, you mention that it "takes the optimally pruned causal tree and adds pvalues." However, in the code, it appears that you prunes the tree inside the function itself. Are you intending for someone to pass a pruned tree, or does it not matter? For reference, this is the code I used to build the tree:
Let me know if I misunderstood anything about the code - thank you very much! |
Thank you for your comments and apologies for the long delay.
Apologies in advance if this wasn't very well thought out but when estimating causal effects - significance matters quite a lot and was hoping this would get us started on how to best calculate and present them. I'm also concerned about issues with the robustness of standard errors under different correlation structures. |
Great - thank you very much for clarifying that! Do you think you could edit the code to correct (1), such that it works on the example data set? It would be good to have some consistency. Other than that, it looks good - thank you for the addition! |
To address printing of p-values and number of observations at each node in #19