Skip to content

Commit 52addd3

Browse files
authored
Merge pull request #19 from UChicago-pol-methods/vignettes
Update estimates graphs layout. Add brief description to data[[1]]
2 parents f254f7a + f7d01ca commit 52addd3

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

DESCRIPTION

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ Package: banditsCI
22
Title: Bandit-Based Experiments and Policy Evaluation
33
Version: 1.0.0
44
Authors@R: c(
5-
person("Molly", "Offer-Westort", email = "mollyow@uchicago.edu", role = c("aut", "cre", "cph")),
6-
person("Yinghui", "Zhou", email = "yz4690@columbia.edu", role = c("aut")))
5+
person("Molly", "Offer-Westort", email = "mollyow@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-2787-9919")),
6+
person("Yinghui", "Zhou", email = "yz4690@columbia.edu", role = c("aut")),
7+
person("Zhan", "Ruohan", email = "rhzhan@ust.hk", role = c("aut"), comment = c(ORCID = "0000-0002-3426-2784")))
78
Description: Provides functions for conducting frequentist inference on adaptively generated data. The methods implemented are based on Zhan et al. (2021) <arXiv:2106.02029> and Hadad et al. (2021) <arXiv:1911.02768>. For illustration, several functions for simulating non-contextual and contextual adaptive experiments using Thompson sampling are also supplied.
8-
License: GPL (>= 3)
9+
License: GPL (>= 3) + file LICENSE
910
Encoding: UTF-8
1011
RoxygenNote: 7.2.3
1112
URL: https://github.com/UChicago-pol-methods/banditsCI, https://uchicago-pol-methods.github.io/banditsCI/

vignettes/banditsCI.Rmd

+15-6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ data from a pilot (this code is not evaluated here).
5454
# data <- generate_bandit_data(xs = xs, y = y, noise_std = 0.5)
5555
```
5656

57+
Components of data[[1]]:
58+
59+
- `ys`: outcomes vector of shape [A];
60+
61+
- `xs`: covariates of shape [A, p]. The value in xs [i, j] represents the j-th
62+
covariate of the i-th observation;
63+
64+
- `muxs`: true best arm for each context of shape [A, K]. The value in muxs [i, j] represents the predicted outcome or expected reward if the i-th observation is assigned to the j-th treatment arm.
65+
5766
## For the contextual case.
5867
We run a contextual bandit experiment using our `run_experiment()` function.
5968
The algorithm used here is a version of linear Thompson sampling.
@@ -187,7 +196,7 @@ True mean values are represented by the dashed red line.
187196
```{r contextual_means_plot, fig.width=7, fig.height=5, out.width = "45%"}
188197
op <- par()
189198
190-
par(mar = c(5,11,4,2) + 0.1)
199+
par(mar = c(5,16,4,2) + 0.1)
191200
192201
# set some plotting parameters across plots
193202
xmin <- min(unlist(lapply(out_full, `[`, TRUE, "estimate")), na.rm = TRUE) -
@@ -262,7 +271,7 @@ supported in the original source. We can do non-contextual two-point estimation
262271
when calculating separate adaptive weights for contrasts, however we recommend
263272
using other estimation procedures in contextual adaptive settings.
264273
```{r contextual_ATEs_plot1, fig.width=7, fig.height=5, out.width = "45%"}
265-
par(mar = c(5,11,4,2) + 0.1)
274+
par(mar = c(5,16,4,2) + 0.1)
266275
267276
# set some plotting parameters across plots
268277
xmin <- min(unlist(lapply(out_full_te1, `[`, TRUE, "estimate")), na.rm = TRUE) -
@@ -299,7 +308,7 @@ suppressWarnings(par(op))
299308
2. In the second approach, we implement adaptive weighting on treatment and control
300309
scores separately, and then take the difference.
301310
```{r contextual_ATEs_plot2, fig.width=7, fig.height=5, out.width = "45%"}
302-
par(mar = c(5,11,4,2) + 0.1)
311+
par(mar = c(5,16,4,2) + 0.1)
303312
304313
# set some plotting parameters across plots
305314
xmin <- min(unlist(lapply(out_full_te2, `[`, TRUE, "estimate")), na.rm = TRUE) -
@@ -396,7 +405,7 @@ True mean values are represented by the dashed red line.
396405
```{r noncontextual_means_plot, fig.width=7, fig.height=5, out.width = "45%"}
397406
op <- par()
398407
399-
par(mar = c(5,11,4,2) + 0.1)
408+
par(mar = c(5,16,4,2) + 0.1)
400409
401410
# set some plotting parameters across plots
402411
xmin <- min(unlist(lapply(out_full, `[`, TRUE, "estimate"))) -
@@ -463,7 +472,7 @@ out_full_te2 <- output_estimates(
463472
1. First take the difference in AIPW scores, and then conduct adaptive
464473
weighting.
465474
```{r noncontextual_ATEs_plot1, fig.width=7, fig.height=5, out.width = "45%"}
466-
par(mar = c(5,11,4,2) + 0.1)
475+
par(mar = c(5,16,4,2) + 0.1)
467476
468477
# set some plotting parameters across plots
469478
xmin <- min(unlist(lapply(out_full_te1, `[`, TRUE, "estimate")), na.rm = TRUE) -
@@ -500,7 +509,7 @@ suppressWarnings(par(op))
500509
2. Or implement adaptive weighting on treatment and control
501510
scores separately, and then take the difference.
502511
```{r noncontextual_ATEs_plot2, fig.width=7, fig.height=5, out.width = "45%"}
503-
par(mar = c(5,11,4,2) + 0.1)
512+
par(mar = c(5,16,4,2) + 0.1)
504513
505514
# set some plotting parameters across plots
506515
xmin <- min(unlist(lapply(out_full_te2, `[`, TRUE, "estimate")), na.rm = TRUE) -

0 commit comments

Comments
 (0)