Main Analysis: Cutoff change relative to the baseline for each department under different smoothness multiplicative factors
First, we demonstrate how to output the summary of Table 1 in Zhang et al. (2022), which includes local treatment effect estimates at the baseline cutoffs. This can be done as follows:
rdestimate_result <- rdestimate(
  data = acces,
  y = "elig",
  x = "saber11",
  c = "cutoff",
  group_name = "department"
)
print(rdestimate_result)##                 Group Sample_size Baseline_cutoff RD_Estimate   se p_value
## 1           MAGDALENA         214            -828        0.55 0.41   0.177
## 2          LA GUAJIRA         209            -824        0.57 0.31   0.062
## 3             BOLIVAR         646            -786        0.00 0.21   0.982
## 4             CAQUETA         238            -779        0.56 0.35   0.107
## 5               CAUCA         322            -774        0.02 0.78   0.977
## 6             CORDOBA         500            -764       -0.63 0.26   0.014
## 7               CESAR         211            -758        0.53 0.37   0.160
## 8               SUCRE         469            -755        0.21 0.11   0.049
## 9           ATLANTICO         448            -754        0.81 0.15   0.000
## 10             ARAUCA         214            -753       -0.70 1.11   0.526
## 11    VALLE DEL CAUCA         454            -732        0.61 0.16   0.000
## 12          ANTIOQUIA         416            -729        0.70 0.21   0.001
## 13 NORTE DE SANTANDER         233            -723       -0.08 0.43   0.858
## 14           PUTUMAYO         236            -719       -0.47 0.79   0.556
## 15             TOLIMA         347            -716        0.12 0.31   0.687
## 16              HUILA         406            -695        0.06 0.23   0.797
## 17             NARINO         463            -678        0.08 0.19   0.677
## 18       CUNDINAMARCA         403            -676        0.12 0.81   0.882
## 19          RISARALDA         263            -672        0.41 0.42   0.330
## 20            QUINDIO         215            -660       -0.03 0.11   0.824
## 21          SANTANDER         437            -632        0.74 0.25   0.003
## 22             BOYACA         362            -618        0.48 0.36   0.187
## 23   DISTRITO CAPITAL         539            -559        0.66 0.14   0.000This provides basic information, including the sample size and baseline cutoff for each group, as well as the RD treatment effect and standard error. RD treatment effects marked with an asterisk (**) are significant at the 5% level.
Next, we demonstrate how to obtain the results of Figure
2, which shows the cutoff change relative to the baseline for
each department under different smoothness multiplicative
factors (M). Due to the computational time
required, we are presenting a part of Figure 2. Learning safe cutoffs
can be done as follows:
# set seed for replication
set.seed(12345) 
# only a subset of data is used
acces_filtered <- acces[acces$department %in% c("DISTRITO CAPITAL", "MAGDALENA"), ]
# To replicate exactly, set data = acces, fold = 20 and M = c(0, 1, 2, 4)
rdlearn_result <- rdlearn(
  data = acces_filtered, 
  y = "elig", # elig
  x = "saber11", # saber11
  c = "cutoff", # cutoff
  group_name = "department",
  fold = 2,
  M = 1,
  cost = 0,
  trace = FALSE
)
summary(rdlearn_result)## ## ── Basic Information ───────────────────────────────────────────────────────────##              Group Sample_size Baseline_cutoff RD_Estimate   se p_value
## 1        MAGDALENA         214            -828        0.55 0.41   0.177
## 2 DISTRITO CAPITAL         539            -559        0.66 0.14   0.000## ## ── Safe Cutoffs and Original Cutoff ────────────────────────────────────────────##                  original M=1,C=0
## MAGDALENA            -828    -806
## DISTRITO CAPITAL     -559    -584## ## ── Numerical Difference of Cutoffs ─────────────────────────────────────────────##                  M=1,C=0
## MAGDALENA             22
## DISTRITO CAPITAL     -25## ## ── Measures of Difference ──────────────────────────────────────────────────────##      M=1,C=0
## l1  23.50000
## l2  23.54782
## max 25.00000This plot shows the cutoff changes relative to the baseline for each
department under different smoothness multiplicative factors
(M).
The main function here is rdlearn. The arguments include
data for the dataset, y for
the column name of outcome, x for the
column name of running variable, c for the
column name of cutoff, and group_name for
the column name of group. These arguments specify the
data we analyze. The fold argument specifies the
number of folds for cross-fitting.
For sensitivity analysis, the M argument specifies
the multiplicative smoothness factor and
cost specifies the treatment cost.
For an rdlearn_result object obtained by
rdlearn, we can use summary to display the RD
estimates, the obtained safe cutoffs, and the differences between the
safe and original cutoffs.
The plot function provides a clear visualization of the
safe cutoffs. Using plot(result, opt = "safe") shows
the obtained safe cutoffs, while
plot(result,opt = "dif") shows the differences
between the safe and original cutoffs.
The trace argument can be set to TRUE to
show progress during the learning process.