You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rpart function xpred.rpart is supposed to return predicted values from a tree under cross-validation. (I am trying to implement this along with causal tree since I'd like to choose my complexity parameter using a customized cross-validation criterion.)
However, when I use it with the output of a causalTree, it seems to predict the level of the y variable, rather than the treatment effect. An example is below:
library(rpart)
library(causalTree)
#Add y to all the y-values so that levels and treatment effects are very different
simulation.1$y <- simulation.1$y + 100
tree <- causalTree(y~ x1 + x2 + x3 + x4, data = simulation.1, treatment = simulation.1$treatment,
split.Rule = "CT", cv.option = "CT", split.Honest = T, cv.Honest = T, split.Bucket = F, xval = 5,
cp = 0, minsize = 20, propensity = 0.5)
opcp <- tree$cptable[,1][which.min(tree$cptable[,4])]
opfit <- prune(tree, opcp)
#Predicting using the tree gives treatment effects
mean( predict(opfit) )
[1] 0.9670799
#Using xpred.rpart gives levels
mean( xpred.rpart(tree,cp=opcp) )
[1] 100.3836
Any help on this (or another way of implementing custom cross-validation criteria) would be appreciated! Thanks!
The text was updated successfully, but these errors were encountered:
@susanathey I worked around this by manually doing cross-validation, i.e. constructing folds myself, training the tree in K-1 of the folds, and then predicting and calculating the loss in the Kth fold.
I think it would be nice if this could be automated better, but I don't need an immediate fix for my current purposes.
Hi there,
The rpart function xpred.rpart is supposed to return predicted values from a tree under cross-validation. (I am trying to implement this along with causal tree since I'd like to choose my complexity parameter using a customized cross-validation criterion.)
However, when I use it with the output of a causalTree, it seems to predict the level of the y variable, rather than the treatment effect. An example is below:
Any help on this (or another way of implementing custom cross-validation criteria) would be appreciated! Thanks!
The text was updated successfully, but these errors were encountered: