subgroup_tree: subgroup detection tree

Description Usage Arguments Examples

View source: R/subgroup_tree.R

Description

Fits a tree designed to aggressively seek out subsets of the data with large (or small) average treatment effects

Usage

1
subgroup_tree(response, treated, X, direction = c("max", "min"), ...)

Arguments

response

numeric outcome of interest

treated

boolean vector of treatment assignments

X

data.frame of predictors; must be either numeric or factor types

direction

"max" to search for largest treatment effect, "min" to search for smallest treatment effect

...

additional arguments to rpart.control, such as maxdepth, etc.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 

set.seed(123)
n = 500
p = 5
treated = sample(c(TRUE, FALSE), n, replace = TRUE)
X = as.data.frame(matrix(rnorm(n * p), n))
high_ate = X[, 1] > 0.5
response = rbinom(n, 1, ifelse(high_ate & treated, 0.9, 0.5))
max_tree = subgroup_tree(response, treated, X, 'max', maxdepth = 2,
                        minbucket = 50)
print(max_tree)

## End(Not run)

molson2/subgroupTree documentation built on Dec. 3, 2019, 10:04 p.m.