[1] 924
Lecture 07 - Blocking and Clustering
age
, in our case)Source: Blair et al (2023)
\[ATE = \frac{1}{N}\sum_{i=1}^N y_{i,1} - y_{i,0}\]
\[ATE = \frac{1}{J}\sum_{j=1}^J\sum_{i=1}^{N_j} \frac{y_{i,1} - y_{i,0}}{N_j} = \sum_{j=1}^J \frac{N_j}{N}ATE_j\]
\[\widehat{ATE} = \sum_{j=1}^J \frac{N_j}{N}\widehat{ATE_j}\]
set.seed(12345)
# We have 10 units
N <- 10
# y0 is the potential outcome under control
y0 <- c(0, 0, 0, 1, 1, 3, 4, 5, 190, 200)
# For each unit, the treatment effect is intrinsic
tau <- c(10, 30, 200, 90, 10, 20, 30, 40, 90, 20)
# y1 is the potential outcome under treatment
y1 <- y0 + tau
# Two blocks: a and b
block <- c("a", "a", "a", "a", "a", "a", "b", "b", "b", "b")
# Z is the treatment assignment
# (in the code we use Z instead of T)
Z <- c(0, 0, 0, 0, 1, 1, 0, 0, 1, 1)
# Y is the observed outcome
Y <- Z * y1 + (1 - Z) * y0
# The data
dat <- data.frame(Z = Z, y0 = y0, y1 = y1, tau = tau, b = block, Y = Y)
head(dat)
Z y0 y1 tau b Y
1 0 0 10 10 a 0
2 0 0 30 30 a 0
3 0 0 200 200 a 0
4 0 1 91 90 a 1
5 1 1 11 10 a 11
6 1 3 23 20 a 23
Estimate Std. Error t value Pr(>|t|) CI Lower CI Upper DF
(Intercept) 1.666667 0.9189366 1.813691 0.10728314 -0.4524049 3.785738 8
Z 131.833333 68.4173061 1.926900 0.09015082 -25.9372575 289.603924 8
Estimate Std. Error t value Pr(>|t|) CI Lower CI Upper DF
(Intercept) -32.42857 21.63212 -1.499093 0.17752759 -83.58042 18.72327 7
Z 114.78571 50.53715 2.271314 0.05736626 -4.71565 234.28708 7
blockb 102.28571 50.49783 2.025547 0.08245280 -17.12268 221.69411 7
How are they different? (The first one ignores the blocks. The second one uses a different set of weights, created using fixed effects variables or indicator/dummy variables)
And we can estimate the total ATE by adjusting the weights according to the size of the blocks:
Estimate Std. Error t value Pr(>|t|) CI Lower CI Upper DF
(Intercept) 1.95 0.250000 7.800000 0.0002340912 1.338272 2.561728 6
Z 108.25 12.530862 8.638672 0.0001325490 77.588086 138.911914 6
blockb_c 4.25 0.559017 7.602631 0.0002696413 2.882135 5.617865 6
Z:blockb_c 228.75 30.599224 7.475680 0.0002957945 153.876397 303.623603 6
Source: DeclareDesign (2018)
R
with the estimatr
package