## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse=TRUE,comment="#>")

## -----------------------------------------------------------------------------
library(evalHTE)
set.seed(91)
n <- 120
score <- rnorm(n)  # a prespecified rule in this simulated example
D <- sample(rep(0:1, each=n/2))
Y <- rnorm(n) + D*(1+score)
band <- URATE(D, score, Y, alpha=.1, L=1000, seed=801)
k <- band$selected
data.frame(n_selected=k,proportion=band$p[k],effect=band$rate[k],
           lower=band$lower[k])

## ----fig.width=6, fig.height=4------------------------------------------------
plot_CI(band)

## -----------------------------------------------------------------------------
X <- score + rnorm(n)
composition <- URATE(NULL, score, X, adjustment="difference", side="upper",
                     alpha=.1, L=1000, seed=2801)
c(estimate=composition$rate[k],upper=composition$upper[k])

## ----eval=FALSE---------------------------------------------------------------
# fit <- estimate_hte(treatment="D",form=Y ~ D + X,data=training_and_evaluation,
#                     algorithms="causal_forest",split_ratio=.4,ngates=5)
# result <- evaluate_hte(fit,alpha=.1,L=50000,seed=801)
# summary(result)
# plot_CI(result)

