Description Usage Arguments Examples

View source: R/subgroup_tree.R

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

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

`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. |

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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.