This page illustrates the use of bbandits.ado for Stata.
See Stata. To download the bbandits package including the ado file type in Stata
. net from https://rostam-afschar.de/bbandits
. net install bbandits.pkg
See Kemper and Rostam-Afschar (2024) "Earning While Learning: How to Run Batched Bandit Experiments" for more information. Check out the slides.
Example 1a: Estimate average treatment effects using batched OLS
Six call methods to enroll rice farmers from (Kasy and Sautmann, 2021):
. use "example data\kasy_sautmann_2021.dta", clear
. bbandits outcome treatment date
Example 1b: Show cumulative weights assigned by Exploration sampling
Example 2: Estimate average treatment effects using batched OLS and pooled OLS
Example 3: Monte Carlo simulation of OLS and BOLS estimates with small margin using epsilon-greedy
. bbandit_sim 1 1, monte_carlo greedy reference_arm(0) arm(1) test_value(0) n(500) eps(0.2)
Example 4: Finding best of three arms (stacked and not stacked) using Thompson sampling
download Stata code here
Example 5: Monte Carlo simulation of OLS estimates with small and large margin at batch size 20 using Thompson sampling
download Stata code here
Example 6: Monte Carlo simulation of OLS estimates with zero margin using Thompson sampling