Skip to contents

Finding Subgroups in Treatment Effects with Conformal Trees

Usage

r2p_hte(
  data,
  target,
  treatment,
  learner,
  cv_folds = 10,
  alpha = 0.05,
  gamma = 0.1,
  lambda = 0.5,
  max_groups = 10
)

Arguments

data

(data.frame)
data set for model training and uncertainty estimation.

target

(string)
name of the target variable. The target must be a numeric variable.

treatment

(string)
name of the treatment variable. If treatment
is a factor, then the first level is treated as control and the second level as treatment indicator. If treatment
is a numeric, then zero-one encoding is assumed and "1"
treated as treatment indicator.

learner

(model_spec)
the learner for training the prediction model. See parsnip::model_spec() for details.

cv_folds

(count)
number of CV+ folds.

alpha

(proportion)
miscoverage rate.

gamma

(proportion)
regularization parameter ensuring that reduction in the impurity of the confident homogeneity is sufficiently large.

lambda

(proportion)
balance parameter, quantifying the impact of the average interval length relative to the average absolute deviation (i.e. interval size vs. within-group homogeneity)

max_groups

(count)
maximum number of subgroups.

Value

The tree.

Examples

library(tidymodels)
library(ranger)
data(bikes)
set.seed(1234)
randforest <- rand_forest() %>%
  set_mode("regression") %>%
  set_engine("ranger")
groups <- r2p_hte(
  data = bikes,
  target = "count",
  treatment = "year",
  learner = randforest,
  cv_folds = 10,
  alpha = 0.05,
  gamma = 0.2,
  lambda = 0.5,
  max_groups = 10
)
#> Error in n + 1: non-numeric argument to binary operator
groups$tree
#> Error in groups$tree: object of type 'closure' is not subsettable