== Listing 3.1: confounding and the naive difference in means ==
true ATE = 1.000; n=2000, replications=500; treated share 0.498
estimator                       mean    bias      sd    rmse
naive difference               3.285   2.285   0.128   2.288
OLS on (T, X)                  2.567   1.567   0.117   1.572
outcome regression (quad)      0.997  -0.003   0.051   0.051
IPW (true e)                   0.988  -0.012   0.268   0.268
Hajek (true e)                 0.994  -0.006   0.177   0.177
AIPW (fitted quad)             0.998  -0.002   0.052   0.052

== Listing 3.2: inverse-propensity weighting under weakening overlap ==
n=1000, replications=500, true ATE = 1.000; propensity known exactly
strength   min e   max w    ESS |  IPW bias  IPW sd Hajek sd AIPW sd
     0.3  0.2087     4.5    939 |    -0.001   0.344    0.204   0.071
     0.6  0.0651    11.6    766 |    -0.003   0.392    0.249   0.074
     1.0  0.0117    34.0    466 |     0.027   0.555    0.394   0.093
     1.5  0.0013   102.2    220 |    -0.106   1.336    0.791   0.181
     2.0  0.0001   172.7    159 |     0.003   2.761    1.130   0.370

== Listing 3.3: double robustness, correct versus misspecified nuisance models ==
n=2000, replications=500, true ATE = 1.000; entries are bias (rmse)
 propensity  outcome |     outcome reg.             IPW            AIPW
    correct  correct |    -0.002 (0.052)    0.001 (0.100)   -0.002 (0.055)
    correct    wrong |     1.568 (1.573)    0.001 (0.100)    0.000 (0.070)
      wrong  correct |    -0.002 (0.052)    1.571 (1.575)   -0.002 (0.052)
      wrong    wrong |     1.568 (1.573)    1.571 (1.575)    1.569 (1.573)

== Listing 3.4: why cross-fitting, with random forests as nuisance models ==
n=800, replications=50, true ATE = 1.000, forests with fully grown trees
AIPW variant                  bias      sd  mean se  95% CI coverage
in-sample (no splitting)     0.150   0.081    0.049             0.26
cross-fit (5 folds)         -0.227   0.189    0.223             0.88

== Listing 3.5: meta-learners against the true CATE ==
n=2000, replications=6; RMSE between estimated and true tau(x) on 5000 fresh points
 treated share  S-learner  T-learner  X-learner  const. ATE
           0.5      0.265      0.230      0.170       0.620
           0.1      0.345      0.340      0.285       0.628

== Listing 3.6: off-policy evaluation, bias and variance of DM, IPS, SNIPS, DR ==
actions K=6; true value of target policy V = 1.1099; of logging policy = 0.2539
weights pi/mu: mean 1.000, max 487.7, ESS fraction 0.131
n=1000, replications=500
estimator     mean    bias      sd    rmse
DM-lin      0.8935 -0.2164  0.0623  0.2251
DM-spec     1.1097 -0.0002  0.0550  0.0550
IPS         1.1038 -0.0061  0.1782  0.1781
SNIPS       1.1054 -0.0045  0.0828  0.0828
DR-lin      1.1078 -0.0021  0.1965  0.1963
DR-spec     1.1106  0.0007  0.0888  0.0887

== Listing 3.7: clipping the importance weights ==
n=1000, replications=500, true V = 1.1099; reward model for DR is the misspecified linear one
  clip M |  IPS bias      sd    rmse |   DR bias      sd    rmse
    none |   -0.0061  0.1782  0.1781 |   -0.0021  0.1965  0.1963
      20 |   -0.0354  0.0925  0.0990 |   -0.0176  0.0686  0.0708
      10 |   -0.0673  0.0824  0.1063 |   -0.0183  0.0648  0.0673
       5 |   -0.1515  0.0697  0.1667 |   -0.0323  0.0629  0.0706
       3 |   -0.2733  0.0576  0.2792 |   -0.0627  0.0613  0.0876
       2 |   -0.4274  0.0455  0.4298 |   -0.0987  0.0604  0.1157
       1 |   -0.7144  0.0252  0.7148 |   -0.1584  0.0605  0.1695

== Listing 3.8: confidence intervals for off-policy value, coverage by simulation ==
nominal level 0.95, replications=400, bootstrap B=200, true V = 1.1099
     n |  IPS normal SNIPS delta DR normal SNIPS boot  DR boot |  DR mean width
   100 |       0.877       0.912     0.795      0.917    0.767 |          0.759
   500 |       0.915       0.925     0.920      0.920    0.915 |          0.437
  2000 |       0.935       0.950     0.932      0.938    0.920 |          0.254

== Listing 3.9: unmeasured confounding and post-treatment adjustment ==
n=5000, replications=300; entries are the mean estimate of the ATE
(a) unmeasured confounder U, true effect 1.0; AIPW adjusts for the observed X only
 confounding of U  AIPW mean    bias
              0.0      1.000  -0.000
              0.5      1.238   0.238
              1.0      1.828   0.828
              2.0      3.433   2.433
(b) randomized T; mediator M = T + noise; collider C = T + Y + noise; true total effect 2.0
    Y = 1.0 T + 1.0 M + noise, so the effect through M is 1.0 and the direct effect is 1.0
no adjustment            estimate   1.999   (true total effect 2.000)
adjust for mediator M    estimate   0.998   (true total effect 2.000)
adjust for collider C    estimate  -0.001   (true total effect 2.000)

== Listing 3.10: logging policies that are deterministic or nearly so ==
n=2000, replications=300, true V = 1.1099; logging = epsilon-greedy around a fixed rule
 epsilon   max w  share of target mass |  IPS bias      sd |   DR bias      sd
    0.00     1.0                 0.231 |   -0.8395  0.0123 |    0.0252  0.1758
    0.02   291.2                 1.000 |    0.0253  0.4475 |    0.0015  0.2907
    0.10    58.6                 1.000 |   -0.0007  0.1934 |   -0.0064  0.1223
    0.30    19.7                 1.000 |    0.0084  0.1037 |   -0.0033  0.0709
