Now that we have extract nighttime lights values from the previous notebook, we are ready for modeling. We will compare the mini-grid sites to the dark area sites using a Difference in Difference analysis for staggered treatment timing. We will use the Callaway & Sant’Anna (2020) Difference in Difference analysis for a staggered treatment. The original paper can be found here. An online tutorial can be found here.

did-example
did-example

Table of Contents

Load Packages

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   4.0.0     ✔ tibble    3.2.1
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(did)
library(lubridate)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE

Read in the Dark Area Data, Clean, Re-export

# read in data
africa_dark_df <- read_csv("data/dark_africa/nighttime_dark_gdf.csv")
## Rows: 4854 Columns: 122
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (2): geometry, type
## dbl (120): 20140101, 20140201, 20140301, 20140401, 20140501, 20140601, 20140...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# convert to sf
africa_dark_sf <- st_as_sf(africa_dark_df, wkt = "geometry", crs = 4326)

# add a column date_commissioned equal to December 1, 2013
africa_dark_sf <- africa_dark_sf %>%
    mutate(date_commissioned = as.Date("2013-12-01"))

# glimpse
# glimpse(africa_dark_sf)

# visualize the sf with ggplot geom_sf with different colors for type
ggplot(africa_dark_sf) +
    geom_sf(aes(color = type)) +
    labs(title = "Dark Area Points Sampled for Controls", x = "Longitude", y = "Latitude") +
    theme_bw()

# export sf
saveRDS(africa_dark_sf, "data/dark_africa/africa_dark_sf.rds")

Read in the Mini-Grid Data

# read in data
africa_minigrid_df <- read_csv("data/cluber/nighttime_cluber_gdf.csv")
## New names:
## Rows: 719 Columns: 130
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (6): geometry, country, developer, site_name, source, status dbl (123): ...1,
## 20140101, 20140201, 20140301, 20140401, 20140501, 20140601... date (1):
## date_commissioned
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
# glimpse(africa_minigrid_df)

# convert to sf with latitude and longitude columns into geometry
africa_minigrid_sf <- st_as_sf(africa_minigrid_df, coords = c("longitude", "latitude"), crs = 4326)

# glimpse(africa_minigrid_sf)
# drop the columns country, customers, developer, site_name, source, and status
africa_minigrid_sf <- africa_minigrid_sf %>%
    select(-country, -customers, -developer, -site_name, -source, -status)

# add a column "type" with value "minigrid"
africa_minigrid_sf <- africa_minigrid_sf %>%
    mutate(type = "minigrid")

# visualize the sf with ggplot geom_sf with different colors for type
ggplot(africa_minigrid_sf) +
    geom_sf(aes(color = type)) +
    labs(title = "Mini-Grid Points for Treatment", x = "Longitude", y = "Latitude") +
    theme_bw()

# export sf
saveRDS(africa_minigrid_sf, "data/dark_africa/africa_minigrid_sf.rds")

Merge the Dark Area and Mini-Grid Data

# read in the 2 sfs
africa_dark_sf <- readRDS("data/dark_africa/africa_dark_sf.rds")
africa_minigrid_sf <- readRDS("data/dark_africa/africa_minigrid_sf.rds")
# glimpse(africa_minigrid_sf)
# merge the dfs
africa_sf <- bind_rows(africa_minigrid_sf, africa_dark_sf)
# glimpse(africa_sf)
rm(africa_minigrid_sf, africa_dark_sf)

# rename Map to landcover
africa_sf <- africa_sf %>%
    mutate(landcover = as.factor(Map))
# drop Map column
africa_sf <- africa_sf %>%
    select(-Map)
# set type to factor
africa_sf$type <- as.factor(africa_sf$type)

# drop the first column ...1
africa_sf <- africa_sf %>%
    select(-1)
# create an id column with an integer for each row
africa_sf <- africa_sf %>%
    mutate(id = as.factor(as.integer(row_number())))

# glimpse(africa_sf)

# visualize the sf with ggplot geom_sf with different colors for type
ggplot(africa_sf) +
    geom_sf(aes(color = type)) +
    labs(title = "Dark Area and Mini-Grid Points", x = "Longitude", y = "Latitude") +
    theme_bw()

# export combined sf
saveRDS(africa_sf, "data/dark_africa/africa_sf.rds")

Melt the Dataset

# read in the sf
africa_sf <- readRDS("data/dark_africa/africa_sf.rds")

# convert to df without geometry
africa_df <- st_drop_geometry(africa_sf)
rm(africa_sf)

# melt the df, keep the date_commissioned, type, landcover, and id columns
africa_df_melt <- africa_df %>%
    pivot_longer(cols = c(-date_commissioned, -type, -landcover, -id), names_to = "image_date", values_to = "image_value")
rm(africa_df)
# add dashes to the image_date column instead of 20140101 to 2014-01-01
africa_df_melt <- africa_df_melt %>%
    mutate(image_date = str_replace(image_date, "(\\d{4})(\\d{2})(\\d{2})", "\\1-\\2-\\3"))

# convert image_date to date
africa_df_melt$image_date <- as.Date(africa_df_melt$image_date)

# glimpse
# glimpse(africa_df_melt)

# export df to csv
write_csv(africa_df_melt, "data/dark_africa/africa_df_melt.csv")
# export sf to rds
saveRDS(africa_df_melt, "data/dark_africa/africa_df_melt.rds")

Visualize Raw Data

# read in data
africa_df_melt <- readRDS("data/dark_africa/africa_df_melt.rds")
# glimpse(africa_df_melt)

# # exclude type "built"
africa_df_melt <- africa_df_melt %>%
    filter(type != "built")

# # exclude type "minigrid"
# africa_df_melt <- africa_df_melt %>%
#     filter(type != "minigrid")

# plot a histogram of image values with log(x) and log(y) scale
# color by log(x) in a linear scale
africa_df_melt %>%
    ggplot(aes(x = image_value)) +
    geom_histogram(bins = 100) +
    scale_x_log10() +
    scale_y_log10() +
    labs(title = "Histogram of Image Values", x = "Image Value", y = "Count") +
    theme_bw()
## Warning in transformation$transform(x): NaNs produced
## Warning in scale_x_log10(): log-10 transformation introduced infinite values.
## Warning: Removed 74245 rows containing non-finite outside the scale range
## (`stat_bin()`).
## Warning in scale_y_log10(): log-10 transformation introduced infinite values.

# create a line plot of image values over time colored by id
africa_df_melt %>%
    ggplot(aes(x = image_date, y = image_value, color = id)) +
    geom_line() +
    labs(title = "Image Values Over Time", x = "Image Date", y = "Image Value") +
    theme_bw() + 
    scale_y_log10()+
    # hide legend
    theme(legend.position = "none")
## Warning in transformation$transform(x): NaNs produced
## Warning in transformation$transform(x): log-10 transformation introduced
## infinite values.
## Warning: Removed 1426 rows containing missing values or values outside the scale range
## (`geom_line()`).

# create a smooth plot of image values by over time colored by type
africa_df_melt %>%
    ggplot(aes(x = image_date, y = image_value, color = type)) +
    geom_smooth() +
    labs(title = "Brightness Over Time by Type", x = "Image Date", y = "Image Value") +
    theme_bw()
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Look at Variances

# read in data
africa_df_melt <- readRDS("data/dark_africa/africa_df_melt.rds")
africa_df <- africa_df_melt

# calculate the standard deviation of all data points
sd_all <- sd(africa_df$image_value)
mean_all <- mean(africa_df$image_value)
min_all <- min(africa_df$image_value)
max_all <- max(africa_df$image_value)
median_all <- median(africa_df$image_value)

# calculate the standard deviation by type
africa_df_stats <- africa_df %>%
    group_by(type) %>%
    summarize(
        sd = sd(image_value),
        mean = mean(image_value),
        min = min(image_value),
        max = max(image_value),
        median = median(image_value)
    )

print(africa_df_stats)
## # A tibble: 6 × 6
##   type        sd  mean    min     max median
##   <fct>    <dbl> <dbl>  <dbl>   <dbl>  <dbl>
## 1 built    8.31  5.29  -0.248 280.     2.18 
## 2 desert   0.126 0.193 -0.392   0.592  0.206
## 3 jungle   0.151 0.158 -0.460   4.05   0.151
## 4 minigrid 1.96  0.555 -0.413  72.3    0.235
## 5 ocean    0.143 0.172 -0.349   1.03   0.172
## 6 rural    0.960 0.203 -0.490 141.     0.181
# visualize as box and whisker plot
africa_df %>%
    ggplot(aes(x = type, y = image_value, fill = type)) +
    geom_boxplot() +
    labs(title = "Box and Whisker Plot of Image Values by Type", x = "Type", y = "Image Value") +
    # set ylim to -1, 3
    ylim(-0.25, 0.75) +
    theme_bw()
## Warning: Removed 67869 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

> print(dark_df_stats)

type sd mean min max median 1 built 8.31 5.29 -0.248 280. 2.18 2 desert 0.126 0.193 -0.392 0.592 0.206 3 jungle 0.151 0.158 -0.460 4.05 0.151 4 minigrid 1.96 0.555 -0.413 72.3 0.235 5 ocean 0.143 0.172 -0.349 1.03 0.172 6 rural 0.960 0.203 -0.490 141. 0.181 ~ Takeaways: 1. Built is way brighter than the other types by a factor of 10 2. Rural has a much higher variance than the other types, likely because it has many different land cover types 3. Ocean has the lowest mean at 0.149, median of 1.57 4. Jungle has the second lowerst mean at 0.157, median of 0.151 5. Desert has the lowest variance at 0.123 compared to ocean at 1.34 and jungle at 0.151

Outliers

Import Data & Calculate Medians & IQRs by ID

# read in data
africa_df_melt <- readRDS("data/dark_africa/africa_df_melt.rds")
# glimpse(africa_df_melt)
df <- africa_df_melt

# find the median for each id, put it into a new column
df$median <- ave(df$image_value, df$id, FUN = median)
# find the upper 75% quartile for each id, put it into a new column
df$q3 <- ave(df$image_value, df$id, FUN = function(x) quantile(x, 0.75))
# find the lower 25% quartile for each id, put it into a new column
df$q1 <- ave(df$image_value, df$id, FUN = function(x) quantile(x, 0.25))
# calculate the IQR for each id, put it into a new column
df$IQR <- df$q3 - df$q1
# calculate the top whisker for each id, put it into a new column
df$top_whisker <- df$q3 + 1.5 * df$IQR
# calculate the bottom whisker for each id, put it into a new column
df$bottom_whisker <- df$q1 - 1.5 * df$IQR

# glimpse(df)

# convert any image_value that is above the top whisker to the top whisker
df <- df %>%
    mutate(image_value = ifelse(image_value > top_whisker, top_whisker, image_value))
# convert any image_value that is below the bottom whisker to the bottom whisker
df <- df %>%
    mutate(image_value = ifelse(image_value < bottom_whisker, bottom_whisker, image_value))

# drop the columns median, q1, q3, IQR, top_whisker, and bottom_whisker
df <- df %>%
    select(-median, -q1, -q3, -IQR, -top_whisker, -bottom_whisker)

# export 
saveRDS(df, "data/dark_africa/africa_df_melt_clean.rds")

Re-visualize Data After Cleaning Outliers

# read in data
africa_df_melt_clean <- readRDS("data/dark_africa/africa_df_melt_clean.rds")
df <- africa_df_melt_clean

# plot a histogram of image values with log(x) and log(y) scale
# color by log(x) in a linear scale
df %>%
    ggplot(aes(x = image_value)) +
    geom_histogram(bins = 100) +
    scale_x_log10() +
    scale_y_log10() +
    labs(title = "Histogram of Image Values", x = "Image Value", y = "Count") +
    theme_bw()
## Warning in transformation$transform(x): NaNs produced
## Warning in scale_x_log10(): log-10 transformation introduced infinite values.
## Warning: Removed 76710 rows containing non-finite outside the scale range
## (`stat_bin()`).
## Warning in scale_y_log10(): log-10 transformation introduced infinite values.

# create a line plot of image values over time colored by id
df %>%
    ggplot(aes(x = image_date, y = image_value, color = type)) +
    geom_line() +
    labs(title = "Image Values Over Time", x = "Image Date", y = "Image Value") +
    theme_bw() + 
    # hide legend
    theme(legend.position = "none")

# plot the data with geom_smooth
dark_smooth_plot <- df %>%
    filter(type != "built") %>%
    ggplot(aes(x = image_date, y = image_value, color = type)) +
    geom_smooth() +
    labs(title = "Nighttime Brightness Value Over Time by Site Type for CLUB-ER Sites", x = "Image Date", y = "Image Value") +
    theme_bw() +
    theme(text = element_text(size = 20, family = "serif")) +
    theme(legend.position = "bottom")
dark_smooth_plot
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

ggsave("figures/dark_africa/dark_smooth_plot.png", dark_smooth_plot, width = 16, height = 8, units = "in", dpi = 300)
## `geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'

Difference in Difference Analysis

Data Requirements

  • There must be a unit-specific identifier variable that does not vary over time. Here that is site_name.
  • There must be a time variable. Here that is image_date.
  • There must be a group variable, which is usually the period when an individual first becomes treated. For units that are never treated, this variable should be set to 0! Here, we’ll group by the date_commissioned variable.
  • The variables must be of numeric class. Note: this analysis can be run without control sites! Worth re-running on the CLUB-ER dataset.

Create a Treatment Group Variable

# read in data
africa_df_melt_clean <- readRDS("data/dark_africa/africa_df_melt_clean.rds")
df <- africa_df_melt_clean

# glimpse(df)

# pull out the earliest date
start_date <- min(df$image_date)
end_date <- max(df$image_date)
start_year <- year(start_date)
end_year <- year(end_date)
start_month <- month(start_date)
end_month <- month(end_date)

# try the years
df$year_commissioned <- year(df$date_commissioned)
df$year_image <- year(df$image_date)

# extract months
df$month_commissioned <- month(df$date_commissioned)
df$month_image <- month(df$image_date)

# convert dates into months since first image
df$group <- (df$year_commissioned - start_year) * 12 + (df$month_commissioned - start_month) + 1 # 1 indexed
df$time_period <- (df$year_image - start_year) * 12 + (df$month_image - start_month) + 1 # 1 indexed

# convert id to numeric
df$id <- as.numeric(df$id)

# plot histogram of group variable
ggplot(df, aes(x = group)) +
    geom_histogram(binwidth = 1) +
    xlim(-5, 120) +
    scale_y_log10() +
    labs(title = "Histogram of Group Variable", x = "Group", y = "Log(Count)") +
    theme_bw()
## Warning in scale_y_log10(): log-10 transformation introduced infinite values.
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_bar()`).

# export df to csv
# View(df)
saveRDS(df, "data/dark_africa/africa_df_melt_clean_for_csdind.rds")

Run the Analysis

# read in the data
africa_df_melt_clean_for_csdind <- readRDS("data/dark_africa/africa_df_melt_clean_for_csdind.rds")
df <- africa_df_melt_clean_for_csdind

# keep only types minigrid and control group, whichever that is
df <- df %>%
    filter(type == "minigrid" | type == "rural")

# add 72 to every group variable for minigrid
df$group <- ifelse(df$type == "minigrid", df$group + 72, df$group)

# run the model
# https://bcallaway11.github.io/did/reference/att_gt.html
did_control <- att_gt(
    yname = "image_value", # outcome variable
    tname = "time_period", # time variable
    idname = "id", # id variable
    gname = "group", # first treatment period variable
    data = df, # data
    control_group = "nevertreated", # set the comparison group as either "never treated" or "not yet treated"
)

# export the model results
saveRDS(did_control, "data/dark_africa/did_control_minigrid_rural_lag72.rds")

# aggregate the results
did_control_agg <- aggte(
    did_control,
    type = "dynamic", 
    na.rm = TRUE
)

# export the results
saveRDS(did_control_agg, "data/dark_africa/did_control_agg_minigrid_rural_lag72.rds")

# read in the did model results
did_control_agg <- readRDS("data/dark_africa/did_control_agg_minigrid_rural_lag72.rds")

# view the results
summary(did_control_agg)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##     ATT    Std. Error     [ 95%  Conf. Int.]  
##  0.0689        0.0253     0.0194      0.1184 *
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##        -113   0.0677     0.0621       -0.1142      0.2497  
##        -112   0.0455     0.0860       -0.2064      0.2974  
##        -111   0.0120     0.0371       -0.0965      0.1206  
##        -110   0.0466     0.0593       -0.1272      0.2205  
##        -109  -0.0562     0.0440       -0.1852      0.0729  
##        -108   0.0213     0.0486       -0.1209      0.1636  
##        -107  -0.0612     0.0489       -0.2044      0.0820  
##        -106  -0.0257     0.0181       -0.0789      0.0274  
##        -105   0.0283     0.0257       -0.0470      0.1037  
##        -104   0.0302     0.0399       -0.0867      0.1470  
##        -103  -0.0609     0.0544       -0.2203      0.0985  
##        -102  -0.0235     0.0461       -0.1586      0.1116  
##        -101   0.0215     0.0491       -0.1224      0.1655  
##        -100   0.0420     0.0290       -0.0430      0.1270  
##         -99  -0.0026     0.0479       -0.1429      0.1377  
##         -98  -0.0028     0.0383       -0.1150      0.1094  
##         -97  -0.0421     0.0450       -0.1739      0.0898  
##         -96   0.0249     0.0529       -0.1303      0.1800  
##         -95  -0.0117     0.0320       -0.1054      0.0819  
##         -94  -0.0260     0.0237       -0.0954      0.0433  
##         -93  -0.0041     0.0250       -0.0774      0.0693  
##         -92   0.1004     0.0334        0.0026      0.1982 *
##         -91  -0.0251     0.0248       -0.0978      0.0475  
##         -90  -0.0197     0.0269       -0.0986      0.0593  
##         -89   0.0060     0.0131       -0.0326      0.0445  
##         -88   0.0454     0.0234       -0.0231      0.1138  
##         -87  -0.0288     0.0372       -0.1379      0.0804  
##         -86   0.0484     0.0305       -0.0411      0.1378  
##         -85  -0.0213     0.0292       -0.1069      0.0643  
##         -84  -0.0287     0.0281       -0.1111      0.0536  
##         -83  -0.0179     0.0329       -0.1142      0.0784  
##         -82   0.0236     0.0181       -0.0293      0.0766  
##         -81  -0.0010     0.0186       -0.0555      0.0535  
##         -80   0.0156     0.0238       -0.0543      0.0854  
##         -79   0.0137     0.0385       -0.0992      0.1266  
##         -78  -0.0004     0.0279       -0.0821      0.0812  
##         -77  -0.0273     0.0158       -0.0736      0.0189  
##         -76   0.0496     0.0283       -0.0332      0.1324  
##         -75   0.0455     0.0168       -0.0037      0.0947  
##         -74  -0.0262     0.0240       -0.0967      0.0442  
##         -73  -0.0237     0.0297       -0.1107      0.0633  
##         -72  -0.0302     0.0277       -0.1113      0.0509  
##         -71  -0.0176     0.0181       -0.0705      0.0353  
##         -70  -0.0015     0.0167       -0.0504      0.0474  
##         -69   0.0114     0.0162       -0.0360      0.0589  
##         -68   0.0437     0.0235       -0.0251      0.1124  
##         -67  -0.0549     0.0313       -0.1467      0.0368  
##         -66   0.0383     0.0228       -0.0285      0.1051  
##         -65   0.0224     0.0376       -0.0877      0.1324  
##         -64   0.0432     0.0242       -0.0278      0.1142  
##         -63  -0.0547     0.0324       -0.1497      0.0402  
##         -62   0.0077     0.0248       -0.0650      0.0804  
##         -61  -0.0267     0.0243       -0.0979      0.0445  
##         -60  -0.0084     0.0206       -0.0686      0.0519  
##         -59  -0.0048     0.0127       -0.0421      0.0324  
##         -58  -0.0078     0.0144       -0.0499      0.0343  
##         -57  -0.0084     0.0210       -0.0700      0.0531  
##         -56   0.0177     0.0260       -0.0584      0.0937  
##         -55   0.0350     0.0278       -0.0465      0.1165  
##         -54  -0.0453     0.0235       -0.1142      0.0235  
##         -53   0.0523     0.0450       -0.0797      0.1842  
##         -52   0.0173     0.0378       -0.0934      0.1281  
##         -51   0.0084     0.0255       -0.0664      0.0833  
##         -50  -0.0082     0.0250       -0.0814      0.0649  
##         -49  -0.0095     0.0272       -0.0893      0.0702  
##         -48  -0.0169     0.0253       -0.0910      0.0571  
##         -47  -0.0164     0.0149       -0.0602      0.0273  
##         -46   0.0076     0.0153       -0.0373      0.0525  
##         -45  -0.0246     0.0263       -0.1018      0.0525  
##         -44  -0.0092     0.0169       -0.0588      0.0404  
##         -43   0.0680     0.0247       -0.0043      0.1404  
##         -42  -0.0711     0.0364       -0.1779      0.0357  
##         -41   0.0485     0.0278       -0.0328      0.1299  
##         -40   0.0233     0.0275       -0.0574      0.1040  
##         -39  -0.0262     0.0319       -0.1198      0.0673  
##         -38   0.0245     0.0360       -0.0810      0.1300  
##         -37  -0.0223     0.0234       -0.0909      0.0463  
##         -36  -0.0395     0.0216       -0.1028      0.0238  
##         -35   0.0158     0.0239       -0.0542      0.0857  
##         -34  -0.0216     0.0181       -0.0746      0.0314  
##         -33   0.0188     0.0224       -0.0468      0.0844  
##         -32   0.0065     0.0245       -0.0652      0.0782  
##         -31  -0.0110     0.0340       -0.1107      0.0886  
##         -30  -0.0195     0.0172       -0.0698      0.0308  
##         -29   0.0046     0.0222       -0.0605      0.0698  
##         -28   0.0442     0.0307       -0.0456      0.1341  
##         -27  -0.0140     0.0267       -0.0922      0.0642  
##         -26   0.0132     0.0162       -0.0344      0.0607  
##         -25   0.0099     0.0236       -0.0592      0.0789  
##         -24  -0.0315     0.0254       -0.1060      0.0429  
##         -23  -0.0084     0.0138       -0.0487      0.0319  
##         -22   0.0030     0.0172       -0.0473      0.0534  
##         -21   0.0263     0.0191       -0.0296      0.0822  
##         -20   0.0001     0.0218       -0.0637      0.0639  
##         -19  -0.0173     0.0322       -0.1117      0.0772  
##         -18   0.0161     0.0348       -0.0859      0.1182  
##         -17  -0.0499     0.0314       -0.1419      0.0421  
##         -16   0.0684     0.0321       -0.0255      0.1623  
##         -15  -0.0328     0.0225       -0.0987      0.0332  
##         -14   0.0593     0.0278       -0.0222      0.1408  
##         -13  -0.0161     0.0188       -0.0712      0.0391  
##         -12  -0.0779     0.0330       -0.1745      0.0188  
##         -11   0.0653     0.0177        0.0133      0.1173 *
##         -10  -0.0320     0.0173       -0.0826      0.0186  
##          -9   0.0624     0.0199        0.0040      0.1208 *
##          -8  -0.0154     0.0233       -0.0838      0.0530  
##          -7  -0.0141     0.0252       -0.0880      0.0598  
##          -6   0.0533     0.0251       -0.0202      0.1269  
##          -5  -0.0893     0.0347       -0.1910      0.0124  
##          -4   0.0347     0.0329       -0.0618      0.1312  
##          -3   0.0402     0.0204       -0.0196      0.1001  
##          -2   0.0052     0.0181       -0.0477      0.0581  
##          -1  -0.0155     0.0143       -0.0575      0.0265  
##           0  -0.0342     0.0241       -0.1047      0.0364  
##           1  -0.0268     0.0175       -0.0780      0.0244  
##           2  -0.0118     0.0150       -0.0558      0.0323  
##           3  -0.0304     0.0225       -0.0963      0.0355  
##           4  -0.0185     0.0337       -0.1171      0.0802  
##           5   0.0334     0.0313       -0.0582      0.1250  
##           6   0.0100     0.0476       -0.1295      0.1496  
##           7  -0.0197     0.0417       -0.1420      0.1026  
##           8   0.0746     0.0404       -0.0437      0.1928  
##           9   0.1243     0.0491       -0.0195      0.2680  
##          10   0.0595     0.0334       -0.0384      0.1574  
##          11   0.0267     0.0234       -0.0420      0.0953  
##          12   0.0712     0.0229        0.0041      0.1382 *
##          13   0.0097     0.0249       -0.0634      0.0827  
##          14  -0.0100     0.0235       -0.0788      0.0588  
##          15   0.0473     0.0388       -0.0663      0.1610  
##          16   0.0582     0.0516       -0.0930      0.2094  
##          17  -0.0071     0.0493       -0.1515      0.1372  
##          18   0.0405     0.0500       -0.1061      0.1871  
##          19   0.0176     0.0344       -0.0831      0.1182  
##          20   0.0146     0.0360       -0.0909      0.1201  
##          21   0.0935     0.0475       -0.0457      0.2328  
##          22   0.0797     0.0373       -0.0297      0.1891  
##          23   0.0816     0.0263        0.0044      0.1587 *
##          24   0.0793     0.0336       -0.0192      0.1778  
##          25   0.0560     0.0375       -0.0538      0.1657  
##          26   0.0395     0.0255       -0.0353      0.1143  
##          27   0.0982     0.0335        0.0002      0.1962 *
##          28   0.0493     0.0424       -0.0749      0.1735  
##          29   0.0884     0.0504       -0.0592      0.2359  
##          30   0.1783     0.0593        0.0046      0.3520 *
##          31   0.1671     0.0479        0.0266      0.3075 *
##          32   0.0888     0.0713       -0.1200      0.2977  
##          33   0.1800     0.0576        0.0111      0.3488 *
##          34   0.1765     0.0594        0.0025      0.3504 *
##          35   0.1233     0.0567       -0.0428      0.2893  
##          36   0.2173     0.0589        0.0449      0.3898 *
##          37   0.1608     0.0762       -0.0623      0.3840  
##          38   0.1877     0.0607        0.0097      0.3656 *
##          39   0.1025     0.0706       -0.1044      0.3094  
##          40   0.1497     0.0598       -0.0254      0.3247  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
# plot group-time ATTs
did_control_agg_plt <- ggdid(did_control_agg, xgap = 6) +
    labs(title = "ATTs for Mini-grid Sites vs Rural Sites with 72-Month Lag", x = "Months Since Commissioning - 72", y = "Change in Brightness") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 24, family = "serif"), legend.position = "bottom")
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_rural_lag72_wide.png", did_control_agg_plt, width = 16, height = 6, units = "in", dpi = 300)


print(did_control_agg_plt)

Compile a Table of the Aggregated Results

# read in the data
did_control_agg_minigrid_ocean <- readRDS("data/dark_africa/did_control_agg_minigrid_ocean.rds")
did_control_agg_minigrid_desert <- readRDS("data/dark_africa/did_control_agg_minigrid_desert.rds")
did_control_agg_minigrid_jungle <- readRDS("data/dark_africa/did_control_agg_minigrid_jungle.rds")
did_control_agg_minigrid_rural <- readRDS("data/dark_africa/did_control_agg_minigrid_rural.rds")
did_control_agg_minigrid_built <- readRDS("data/dark_africa/did_control_agg_minigrid_built.rds")
did_nyt_agg_minigrid <- readRDS("data/dark_africa/did_nyt_agg_minigrid.rds")

# print out summaries of each
summary(did_control_agg_minigrid_ocean)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##      ATT    Std. Error     [ 95%  Conf. Int.] 
##  -0.0129        0.0175    -0.0473      0.0215 
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##         -77   0.0361     0.0066        0.0159      0.0562 *
##         -76   0.0007     0.0752       -0.2274      0.2288  
##         -75   0.0567     0.0314       -0.0386      0.1520  
##         -74   0.1039     0.0070        0.0828      0.1250 *
##         -73  -0.1034     0.0185       -0.1595     -0.0474 *
##         -72  -0.0159     0.0174       -0.0687      0.0370  
##         -71   0.0101     0.0037       -0.0010      0.0212  
##         -70  -0.0784     0.0964       -0.3708      0.2139  
##         -69   0.0366     0.0267       -0.0445      0.1177  
##         -68  -0.0063     0.0068       -0.0270      0.0144  
##         -67  -0.0633     0.0485       -0.2104      0.0838  
##         -66   0.0265     0.0203       -0.0351      0.0881  
##         -65   0.0549     0.0130        0.0155      0.0943 *
##         -64   0.0294     0.0247       -0.0455      0.1044  
##         -63  -0.0332     0.0588       -0.2114      0.1450  
##         -62   0.0103     0.0363       -0.0997      0.1203  
##         -61   0.0127     0.0744       -0.2129      0.2383  
##         -60  -0.0409     0.0701       -0.2535      0.1717  
##         -59   0.0212     0.0451       -0.1155      0.1579  
##         -58  -0.0617     0.0264       -0.1419      0.0185  
##         -57  -0.0125     0.0329       -0.1124      0.0875  
##         -56   0.0281     0.0391       -0.0904      0.1467  
##         -55  -0.0123     0.0165       -0.0623      0.0377  
##         -54   0.0793     0.0416       -0.0470      0.2056  
##         -53   0.0410     0.0191       -0.0169      0.0988  
##         -52  -0.0924     0.0116       -0.1274     -0.0573 *
##         -51   0.0695     0.0183        0.0139      0.1250 *
##         -50   0.1679     0.0316        0.0720      0.2639 *
##         -49  -0.0460     0.0220       -0.1128      0.0207  
##         -48  -0.1162     0.0479       -0.2615      0.0290  
##         -47   0.0271     0.0206       -0.0354      0.0895  
##         -46  -0.0205     0.0154       -0.0673      0.0262  
##         -45   0.0724     0.0265       -0.0081      0.1528  
##         -44  -0.0003     0.0276       -0.0840      0.0834  
##         -43  -0.0221     0.0386       -0.1391      0.0949  
##         -42  -0.0614     0.0170       -0.1129     -0.0099 *
##         -41   0.0603     0.0301       -0.0310      0.1516  
##         -40  -0.0275     0.0421       -0.1551      0.1002  
##         -39   0.0459     0.0222       -0.0213      0.1132  
##         -38   0.1288     0.0278        0.0444      0.2132 *
##         -37  -0.0407     0.0217       -0.1064      0.0249  
##         -36  -0.0612     0.0133       -0.1014     -0.0210 *
##         -35  -0.0154     0.0150       -0.0608      0.0301  
##         -34  -0.0518     0.0129       -0.0910     -0.0126 *
##         -33   0.0156     0.0118       -0.0202      0.0514  
##         -32   0.0352     0.0211       -0.0290      0.0993  
##         -31  -0.0344     0.0260       -0.1132      0.0444  
##         -30  -0.0118     0.0233       -0.0825      0.0589  
##         -29   0.0307     0.0336       -0.0713      0.1327  
##         -28  -0.0171     0.0191       -0.0750      0.0408  
##         -27   0.0015     0.0295       -0.0880      0.0909  
##         -26   0.0618     0.0245       -0.0126      0.1361  
##         -25   0.0069     0.0228       -0.0624      0.0761  
##         -24  -0.0091     0.0262       -0.0884      0.0702  
##         -23  -0.0193     0.0163       -0.0687      0.0301  
##         -22  -0.0695     0.0194       -0.1285     -0.0106 *
##         -21   0.0155     0.0188       -0.0417      0.0726  
##         -20   0.0782     0.0189        0.0208      0.1357 *
##         -19  -0.0165     0.0162       -0.0655      0.0325  
##         -18  -0.0345     0.0189       -0.0918      0.0229  
##         -17   0.0253     0.0106       -0.0067      0.0574  
##         -16  -0.0056     0.0159       -0.0540      0.0427  
##         -15  -0.0274     0.0269       -0.1090      0.0542  
##         -14   0.1113     0.0221        0.0443      0.1783 *
##         -13   0.0261     0.0172       -0.0262      0.0784  
##         -12  -0.0763     0.0208       -0.1394     -0.0132 *
##         -11  -0.0037     0.0229       -0.0730      0.0657  
##         -10  -0.0551     0.0138       -0.0970     -0.0132 *
##          -9   0.0490     0.0146        0.0047      0.0934 *
##          -8   0.0001     0.0163       -0.0493      0.0495  
##          -7   0.0087     0.0276       -0.0751      0.0925  
##          -6  -0.0244     0.0198       -0.0844      0.0355  
##          -5   0.0298     0.0140       -0.0126      0.0722  
##          -4  -0.0002     0.0202       -0.0615      0.0610  
##          -3   0.0155     0.0138       -0.0262      0.0573  
##          -2   0.0560     0.0184        0.0002      0.1118 *
##          -1  -0.0050     0.0105       -0.0370      0.0269  
##           0  -0.0458     0.0136       -0.0872     -0.0044 *
##           1  -0.0477     0.0177       -0.1014      0.0059  
##           2  -0.1260     0.0148       -0.1708     -0.0812 *
##           3  -0.1033     0.0160       -0.1518     -0.0549 *
##           4  -0.0457     0.0141       -0.0886     -0.0028 *
##           5  -0.0933     0.0224       -0.1613     -0.0254 *
##           6  -0.0657     0.0244       -0.1398      0.0084  
##           7  -0.0341     0.0177       -0.0877      0.0196  
##           8  -0.0173     0.0191       -0.0751      0.0405  
##           9  -0.0821     0.0261       -0.1612     -0.0031 *
##          10  -0.0112     0.0153       -0.0576      0.0351  
##          11   0.0004     0.0194       -0.0583      0.0592  
##          12  -0.0594     0.0212       -0.1237      0.0048  
##          13  -0.0622     0.0224       -0.1302      0.0058  
##          14  -0.1239     0.0266       -0.2044     -0.0433 *
##          15  -0.1040     0.0178       -0.1579     -0.0502 *
##          16  -0.0734     0.0198       -0.1335     -0.0133 *
##          17  -0.0527     0.0286       -0.1394      0.0340  
##          18  -0.0825     0.0262       -0.1620     -0.0029 *
##          19  -0.0389     0.0289       -0.1267      0.0488  
##          20  -0.0507     0.0212       -0.1149      0.0135  
##          21  -0.0578     0.0258       -0.1359      0.0204  
##          22   0.0139     0.0194       -0.0449      0.0726  
##          23   0.0053     0.0185       -0.0509      0.0614  
##          24  -0.0391     0.0244       -0.1130      0.0347  
##          25  -0.0325     0.0202       -0.0939      0.0288  
##          26  -0.0725     0.0212       -0.1368     -0.0083 *
##          27  -0.1012     0.0215       -0.1663     -0.0362 *
##          28  -0.0340     0.0210       -0.0976      0.0297  
##          29  -0.0353     0.0181       -0.0902      0.0196  
##          30  -0.0740     0.0264       -0.1540      0.0059  
##          31  -0.0314     0.0201       -0.0923      0.0294  
##          32  -0.0322     0.0263       -0.1120      0.0475  
##          33  -0.0681     0.0271       -0.1502      0.0141  
##          34   0.0283     0.0239       -0.0441      0.1007  
##          35   0.0205     0.0237       -0.0514      0.0923  
##          36  -0.0326     0.0271       -0.1148      0.0496  
##          37  -0.0406     0.0250       -0.1165      0.0353  
##          38  -0.0703     0.0200       -0.1310     -0.0097 *
##          39  -0.0832     0.0239       -0.1558     -0.0107 *
##          40  -0.0166     0.0235       -0.0880      0.0548  
##          41  -0.0820     0.0250       -0.1579     -0.0060 *
##          42  -0.0764     0.0266       -0.1571      0.0044  
##          43  -0.0952     0.0275       -0.1786     -0.0118 *
##          44  -0.0363     0.0196       -0.0958      0.0232  
##          45  -0.0667     0.0273       -0.1496      0.0161  
##          46   0.0447     0.0199       -0.0157      0.1050  
##          47   0.0108     0.0277       -0.0732      0.0949  
##          48  -0.0331     0.0279       -0.1179      0.0516  
##          49  -0.0240     0.0294       -0.1133      0.0653  
##          50  -0.0699     0.0234       -0.1409      0.0011  
##          51  -0.0764     0.0263       -0.1563      0.0035  
##          52  -0.0208     0.0240       -0.0936      0.0519  
##          53  -0.0604     0.0263       -0.1401      0.0193  
##          54  -0.0309     0.0229       -0.1005      0.0387  
##          55  -0.1222     0.0297       -0.2124     -0.0321 *
##          56  -0.0456     0.0213       -0.1101      0.0188  
##          57  -0.0832     0.0227       -0.1520     -0.0145 *
##          58   0.0047     0.0292       -0.0838      0.0931  
##          59   0.0541     0.0291       -0.0342      0.1423  
##          60  -0.0671     0.0248       -0.1423      0.0081  
##          61   0.0024     0.0247       -0.0725      0.0774  
##          62  -0.0913     0.0254       -0.1684     -0.0143 *
##          63  -0.0342     0.0235       -0.1053      0.0370  
##          64  -0.0113     0.0246       -0.0859      0.0633  
##          65  -0.0543     0.0339       -0.1571      0.0485  
##          66   0.0195     0.0312       -0.0750      0.1140  
##          67  -0.1033     0.0270       -0.1852     -0.0215 *
##          68  -0.0644     0.0406       -0.1876      0.0588  
##          69  -0.0411     0.0347       -0.1463      0.0641  
##          70   0.0578     0.0354       -0.0494      0.1651  
##          71   0.0303     0.0361       -0.0792      0.1397  
##          72  -0.0265     0.0367       -0.1379      0.0848  
##          73   0.0054     0.0371       -0.1071      0.1179  
##          74  -0.0577     0.0388       -0.1753      0.0600  
##          75  -0.0610     0.0277       -0.1449      0.0229  
##          76  -0.0430     0.0356       -0.1511      0.0651  
##          77  -0.0028     0.0281       -0.0879      0.0823  
##          78  -0.0055     0.0413       -0.1306      0.1197  
##          79  -0.0814     0.0373       -0.1946      0.0318  
##          80   0.0174     0.0365       -0.0932      0.1280  
##          81   0.0518     0.0474       -0.0919      0.1956  
##          82   0.0810     0.0331       -0.0193      0.1814  
##          83   0.0420     0.0285       -0.0444      0.1283  
##          84   0.0538     0.0403       -0.0684      0.1760  
##          85   0.0306     0.0393       -0.0885      0.1497  
##          86  -0.0878     0.0373       -0.2009      0.0252  
##          87   0.0198     0.0417       -0.1067      0.1463  
##          88   0.0015     0.0475       -0.1425      0.1456  
##          89  -0.0536     0.0761       -0.2844      0.1771  
##          90   0.0373     0.0757       -0.1924      0.2669  
##          91  -0.0373     0.0608       -0.2217      0.1472  
##          92  -0.0692     0.0612       -0.2549      0.1165  
##          93   0.0148     0.0764       -0.2169      0.2464  
##          94   0.1069     0.0665       -0.0949      0.3086  
##          95   0.1038     0.0523       -0.0548      0.2624  
##          96   0.0745     0.0656       -0.1245      0.2736  
##          97   0.0759     0.0666       -0.1259      0.2778  
##          98  -0.0512     0.0540       -0.2151      0.1127  
##          99   0.0953     0.0597       -0.0857      0.2763  
##         100  -0.0077     0.0675       -0.2125      0.1972  
##         101   0.0254     0.0581       -0.1507      0.2015  
##         102   0.1859     0.0563        0.0152      0.3567 *
##         103   0.1304     0.0504       -0.0224      0.2833  
##         104  -0.0275     0.0725       -0.2474      0.1923  
##         105   0.1038     0.0639       -0.0900      0.2977  
##         106   0.2195     0.0744       -0.0063      0.4453  
##         107   0.1554     0.0597       -0.0257      0.3366  
##         108   0.2429     0.0684        0.0355      0.4504 *
##         109   0.1790     0.0703       -0.0343      0.3922  
##         110   0.1004     0.0633       -0.0917      0.2925  
##         111   0.1258     0.0711       -0.0897      0.3413  
##         112   0.1116     0.0545       -0.0537      0.2770  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
summary(did_control_agg_minigrid_desert)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##    ATT    Std. Error     [ 95%  Conf. Int.] 
##  0.034        0.0188    -0.0029       0.071 
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##         -77  -0.0008     0.0081       -0.0255      0.0239  
##         -76   0.0940     0.1456       -0.3503      0.5383  
##         -75  -0.0673     0.0024       -0.0744     -0.0601 *
##         -74  -0.0045     0.0776       -0.2414      0.2324  
##         -73  -0.0072     0.0320       -0.1048      0.0905  
##         -72   0.0175     0.0159       -0.0309      0.0659  
##         -71  -0.0067     0.0030       -0.0159      0.0025  
##         -70  -0.1137     0.0514       -0.2706      0.0433  
##         -69  -0.0345     0.0172       -0.0868      0.0179  
##         -68   0.1781     0.0236        0.1061      0.2502 *
##         -67  -0.1590     0.0277       -0.2437     -0.0744 *
##         -66   0.0699     0.0198        0.0094      0.1304 *
##         -65   0.0287     0.0173       -0.0241      0.0814  
##         -64   0.0973     0.0305        0.0043      0.1902 *
##         -63  -0.1515     0.0594       -0.3328      0.0298  
##         -62  -0.0821     0.0363       -0.1928      0.0285  
##         -61   0.0983     0.0744       -0.1286      0.3253  
##         -60  -0.0051     0.0711       -0.2221      0.2120  
##         -59   0.0086     0.0389       -0.1103      0.1274  
##         -58  -0.0691     0.0235       -0.1408      0.0026  
##         -57  -0.0735     0.0333       -0.1752      0.0283  
##         -56   0.1600     0.0546       -0.0065      0.3265  
##         -55  -0.0888     0.0163       -0.1386     -0.0389 *
##         -54   0.1248     0.0422       -0.0039      0.2535  
##         -53   0.0075     0.0201       -0.0539      0.0689  
##         -52  -0.0069     0.0113       -0.0416      0.0277  
##         -51  -0.0521     0.0187       -0.1091      0.0050  
##         -50   0.0650     0.0278       -0.0200      0.1499  
##         -49   0.0458     0.0218       -0.0207      0.1124  
##         -48  -0.0826     0.0480       -0.2291      0.0640  
##         -47   0.0120     0.0206       -0.0509      0.0749  
##         -46  -0.0459     0.0152       -0.0921      0.0004  
##         -45   0.0049     0.0250       -0.0715      0.0813  
##         -44   0.1651     0.0290        0.0767      0.2535 *
##         -43  -0.1106     0.0357       -0.2196     -0.0015 *
##         -42  -0.0173     0.0164       -0.0673      0.0327  
##         -41   0.0541     0.0302       -0.0381      0.1464  
##         -40  -0.0065     0.0418       -0.1342      0.1212  
##         -39  -0.0598     0.0226       -0.1286      0.0091  
##         -38   0.0663     0.0286       -0.0210      0.1536  
##         -37   0.0224     0.0211       -0.0419      0.0867  
##         -36  -0.0222     0.0126       -0.0607      0.0162  
##         -35  -0.0194     0.0142       -0.0628      0.0241  
##         -34  -0.0044     0.0137       -0.0462      0.0373  
##         -33  -0.0253     0.0115       -0.0604      0.0098  
##         -32   0.0628     0.0222       -0.0049      0.1306  
##         -31  -0.0720     0.0260       -0.1512      0.0073  
##         -30   0.0376     0.0231       -0.0329      0.1081  
##         -29   0.0169     0.0331       -0.0842      0.1179  
##         -28   0.0299     0.0195       -0.0296      0.0893  
##         -27  -0.0892     0.0306       -0.1825      0.0042  
##         -26  -0.0037     0.0243       -0.0777      0.0703  
##         -25   0.0476     0.0234       -0.0239      0.1190  
##         -24   0.0130     0.0249       -0.0629      0.0890  
##         -23  -0.0161     0.0160       -0.0649      0.0327  
##         -22  -0.0119     0.0202       -0.0734      0.0497  
##         -21  -0.0191     0.0191       -0.0775      0.0393  
##         -20   0.0773     0.0216        0.0114      0.1431 *
##         -19  -0.0341     0.0163       -0.0837      0.0155  
##         -18   0.0141     0.0188       -0.0431      0.0714  
##         -17   0.0134     0.0106       -0.0189      0.0457  
##         -16   0.0475     0.0151        0.0014      0.0937 *
##         -15  -0.1005     0.0277       -0.1851     -0.0160 *
##         -14   0.0152     0.0217       -0.0509      0.0813  
##         -13   0.0735     0.0170        0.0215      0.1255 *
##         -12  -0.0637     0.0219       -0.1306      0.0031  
##         -11  -0.0083     0.0239       -0.0813      0.0647  
##         -10   0.0042     0.0137       -0.0376      0.0461  
##          -9   0.0253     0.0141       -0.0177      0.0684  
##          -8   0.0077     0.0168       -0.0436      0.0590  
##          -7  -0.0122     0.0280       -0.0978      0.0733  
##          -6   0.0171     0.0211       -0.0474      0.0816  
##          -5   0.0067     0.0131       -0.0334      0.0467  
##          -4   0.0591     0.0192        0.0007      0.1176 *
##          -3  -0.0351     0.0131       -0.0752      0.0049  
##          -2  -0.0373     0.0193       -0.0963      0.0217  
##          -1   0.0223     0.0125       -0.0158      0.0604  
##           0  -0.0288     0.0137       -0.0706      0.0130  
##           1  -0.0320     0.0166       -0.0828      0.0187  
##           2  -0.0516     0.0143       -0.0953     -0.0080 *
##           3  -0.0243     0.0163       -0.0742      0.0255  
##           4   0.0136     0.0143       -0.0301      0.0572  
##           5  -0.0299     0.0222       -0.0975      0.0378  
##           6   0.0011     0.0253       -0.0760      0.0782  
##           7   0.0211     0.0169       -0.0306      0.0728  
##           8   0.0979     0.0207        0.0348      0.1611 *
##           9  -0.0172     0.0265       -0.0979      0.0635  
##          10  -0.0377     0.0156       -0.0852      0.0099  
##          11   0.0041     0.0196       -0.0558      0.0641  
##          12  -0.0418     0.0202       -0.1034      0.0198  
##          13  -0.0446     0.0224       -0.1130      0.0239  
##          14  -0.0743     0.0251       -0.1509      0.0023  
##          15  -0.0374     0.0183       -0.0933      0.0185  
##          16  -0.0058     0.0193       -0.0647      0.0531  
##          17   0.0378     0.0272       -0.0451      0.1207  
##          18  -0.0176     0.0269       -0.0996      0.0645  
##          19   0.0160     0.0303       -0.0766      0.1086  
##          20   0.0505     0.0211       -0.0140      0.1151  
##          21   0.0152     0.0252       -0.0618      0.0922  
##          22  -0.0213     0.0187       -0.0784      0.0357  
##          23   0.0062     0.0184       -0.0500      0.0624  
##          24  -0.0238     0.0234       -0.0954      0.0477  
##          25  -0.0156     0.0219       -0.0824      0.0513  
##          26  -0.0374     0.0204       -0.0997      0.0248  
##          27  -0.0056     0.0214       -0.0710      0.0599  
##          28   0.0260     0.0215       -0.0397      0.0917  
##          29   0.0679     0.0191        0.0096      0.1263 *
##          30  -0.0016     0.0270       -0.0839      0.0808  
##          31   0.0283     0.0204       -0.0338      0.0904  
##          32   0.0712     0.0240       -0.0020      0.1443  
##          33  -0.0006     0.0271       -0.0833      0.0821  
##          34  -0.0016     0.0236       -0.0736      0.0704  
##          35   0.0237     0.0235       -0.0481      0.0955  
##          36  -0.0230     0.0249       -0.0991      0.0531  
##          37  -0.0141     0.0263       -0.0943      0.0660  
##          38  -0.0340     0.0224       -0.1024      0.0344  
##          39   0.0338     0.0216       -0.0321      0.0997  
##          40   0.0327     0.0234       -0.0389      0.1042  
##          41   0.0223     0.0252       -0.0544      0.0991  
##          42  -0.0105     0.0263       -0.0908      0.0697  
##          43  -0.0104     0.0276       -0.0945      0.0737  
##          44   0.0341     0.0210       -0.0299      0.0981  
##          45  -0.0073     0.0258       -0.0860      0.0715  
##          46   0.0087     0.0200       -0.0525      0.0699  
##          47   0.0115     0.0269       -0.0706      0.0936  
##          48  -0.0184     0.0289       -0.1065      0.0698  
##          49  -0.0036     0.0303       -0.0962      0.0889  
##          50  -0.0173     0.0235       -0.0891      0.0545  
##          51   0.0454     0.0248       -0.0304      0.1212  
##          52   0.0465     0.0247       -0.0288      0.1218  
##          53   0.0435     0.0251       -0.0332      0.1202  
##          54   0.0299     0.0235       -0.0419      0.1017  
##          55  -0.0321     0.0287       -0.1196      0.0554  
##          56   0.0406     0.0212       -0.0239      0.1052  
##          57  -0.0201     0.0235       -0.0917      0.0515  
##          58  -0.0469     0.0291       -0.1357      0.0420  
##          59   0.0401     0.0280       -0.0454      0.1255  
##          60  -0.0463     0.0251       -0.1230      0.0304  
##          61   0.0168     0.0239       -0.0563      0.0898  
##          62  -0.0127     0.0265       -0.0934      0.0681  
##          63   0.0732     0.0213        0.0083      0.1381 *
##          64   0.0468     0.0270       -0.0355      0.1291  
##          65   0.0366     0.0317       -0.0601      0.1334  
##          66   0.0744     0.0322       -0.0240      0.1728  
##          67  -0.0142     0.0267       -0.0956      0.0671  
##          68   0.0233     0.0390       -0.0958      0.1425  
##          69   0.0174     0.0334       -0.0845      0.1192  
##          70  -0.0016     0.0367       -0.1136      0.1104  
##          71   0.0059     0.0362       -0.1044      0.1163  
##          72  -0.0079     0.0364       -0.1190      0.1032  
##          73   0.0123     0.0356       -0.0962      0.1209  
##          74   0.0307     0.0366       -0.0810      0.1424  
##          75   0.0305     0.0278       -0.0542      0.1152  
##          76   0.0131     0.0344       -0.0919      0.1182  
##          77   0.0855     0.0311       -0.0094      0.1803  
##          78   0.0409     0.0401       -0.0815      0.1632  
##          79   0.0179     0.0359       -0.0918      0.1275  
##          80   0.1007     0.0357       -0.0084      0.2097  
##          81   0.1083     0.0430       -0.0229      0.2394  
##          82   0.0147     0.0349       -0.0919      0.1214  
##          83   0.0116     0.0279       -0.0735      0.0966  
##          84   0.0866     0.0418       -0.0410      0.2141  
##          85   0.0348     0.0381       -0.0815      0.1512  
##          86   0.0194     0.0390       -0.0996      0.1384  
##          87   0.0923     0.0414       -0.0340      0.2186  
##          88   0.0764     0.0477       -0.0690      0.2219  
##          89   0.0598     0.0775       -0.1766      0.2963  
##          90   0.0899     0.0808       -0.1566      0.3365  
##          91   0.0700     0.0612       -0.1169      0.2569  
##          92   0.0623     0.0598       -0.1202      0.2449  
##          93   0.0891     0.0775       -0.1475      0.3257  
##          94   0.0411     0.0639       -0.1538      0.2360  
##          95   0.0750     0.0529       -0.0864      0.2364  
##          96   0.1359     0.0649       -0.0621      0.3339  
##          97   0.0970     0.0641       -0.0987      0.2927  
##          98   0.0893     0.0516       -0.0682      0.2468  
##          99   0.1560     0.0602       -0.0278      0.3398  
##         100   0.0710     0.0724       -0.1500      0.2920  
##         101   0.1054     0.0576       -0.0705      0.2812  
##         102   0.1918     0.0565        0.0195      0.3642 *
##         103   0.1738     0.0514        0.0170      0.3305 *
##         104   0.1172     0.0680       -0.0902      0.3246  
##         105   0.1356     0.0632       -0.0574      0.3286  
##         106   0.0973     0.0700       -0.1163      0.3109  
##         107   0.0702     0.0565       -0.1022      0.2426  
##         108   0.2611     0.0632        0.0682      0.4540 *
##         109   0.1609     0.0697       -0.0520      0.3737  
##         110   0.2020     0.0633        0.0088      0.3952 *
##         111   0.1132     0.0681       -0.0946      0.3210  
##         112   0.1114     0.0539       -0.0532      0.2760  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
summary(did_control_agg_minigrid_jungle)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##     ATT    Std. Error     [ 95%  Conf. Int.] 
##  0.0232         0.018     -0.012      0.0584 
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##         -77   0.0745     0.0088        0.0477      0.1013 *
##         -76  -0.0014     0.0748       -0.2301      0.2274  
##         -75   0.0912     0.0337       -0.0117      0.1941  
##         -74   0.0359     0.0786       -0.2044      0.2763  
##         -73  -0.0820     0.0181       -0.1375     -0.0265 *
##         -72   0.0051     0.0159       -0.0436      0.0538  
##         -71  -0.0025     0.0037       -0.0138      0.0088  
##         -70  -0.0668     0.0502       -0.2204      0.0867  
##         -69  -0.0161     0.0176       -0.0699      0.0377  
##         -68   0.0082     0.0365       -0.1035      0.1199  
##         -67  -0.0325     0.0287       -0.1203      0.0553  
##         -66   0.0626     0.0207       -0.0006      0.1259  
##         -65   0.0712     0.0122        0.0338      0.1085 *
##         -64   0.0168     0.0264       -0.0640      0.0976  
##         -63   0.0147     0.0623       -0.1756      0.2050  
##         -62  -0.0571     0.0349       -0.1637      0.0495  
##         -61   0.0337     0.0722       -0.1871      0.2545  
##         -60  -0.0237     0.0720       -0.2438      0.1964  
##         -59   0.0144     0.0417       -0.1130      0.1419  
##         -58  -0.0431     0.0251       -0.1199      0.0337  
##         -57  -0.0660     0.0334       -0.1680      0.0361  
##         -56   0.0450     0.0421       -0.0838      0.1737  
##         -55   0.0091     0.0195       -0.0506      0.0688  
##         -54   0.1285     0.0419        0.0005      0.2565 *
##         -53   0.0708     0.0190        0.0126      0.1289 *
##         -52  -0.0973     0.0128       -0.1365     -0.0582 *
##         -51   0.1067     0.0184        0.0504      0.1631 *
##         -50   0.1023     0.0300        0.0106      0.1940 *
##         -49  -0.0254     0.0223       -0.0935      0.0428  
##         -48  -0.0970     0.0487       -0.2457      0.0518  
##         -47   0.0167     0.0201       -0.0447      0.0782  
##         -46  -0.0065     0.0154       -0.0535      0.0404  
##         -45   0.0204     0.0257       -0.0581      0.0989  
##         -44   0.0142     0.0286       -0.0731      0.1015  
##         -43   0.0044     0.0377       -0.1107      0.1195  
##         -42  -0.0208     0.0166       -0.0714      0.0298  
##         -41   0.0314     0.0310       -0.0632      0.1260  
##         -40  -0.0588     0.0421       -0.1874      0.0697  
##         -39   0.1144     0.0219        0.0474      0.1815 *
##         -38   0.0686     0.0297       -0.0223      0.1595  
##         -37  -0.0221     0.0217       -0.0886      0.0444  
##         -36  -0.0525     0.0120       -0.0892     -0.0159 *
##         -35  -0.0100     0.0142       -0.0535      0.0336  
##         -34  -0.0197     0.0130       -0.0595      0.0200  
##         -33  -0.0365     0.0126       -0.0750      0.0019  
##         -32   0.0540     0.0213       -0.0112      0.1192  
##         -31  -0.0339     0.0255       -0.1119      0.0442  
##         -30   0.0622     0.0234       -0.0093      0.1336  
##         -29  -0.0275     0.0308       -0.1216      0.0666  
##         -28  -0.0275     0.0200       -0.0887      0.0336  
##         -27   0.0145     0.0310       -0.0802      0.1091  
##         -26   0.0655     0.0250       -0.0109      0.1419  
##         -25   0.0081     0.0215       -0.0575      0.0738  
##         -24  -0.0131     0.0262       -0.0932      0.0670  
##         -23  -0.0057     0.0164       -0.0557      0.0444  
##         -22  -0.0371     0.0201       -0.0986      0.0244  
##         -21  -0.0068     0.0170       -0.0587      0.0452  
##         -20   0.0720     0.0204        0.0096      0.1344 *
##         -19  -0.0464     0.0173       -0.0994      0.0066  
##         -18   0.0383     0.0186       -0.0185      0.0951  
##         -17  -0.0092     0.0108       -0.0423      0.0240  
##         -16  -0.0287     0.0150       -0.0746      0.0172  
##         -15  -0.0372     0.0269       -0.1195      0.0450  
##         -14   0.1444     0.0224        0.0760      0.2128 *
##         -13   0.0299     0.0166       -0.0209      0.0806  
##         -12  -0.0953     0.0226       -0.1643     -0.0264 *
##         -11   0.0218     0.0232       -0.0489      0.0926  
##         -10  -0.0271     0.0136       -0.0686      0.0145  
##          -9   0.0494     0.0144        0.0053      0.0934 *
##          -8  -0.0202     0.0166       -0.0710      0.0306  
##          -7  -0.0184     0.0282       -0.1046      0.0679  
##          -6   0.0230     0.0222       -0.0448      0.0909  
##          -5   0.0038     0.0145       -0.0406      0.0482  
##          -4  -0.0422     0.0198       -0.1027      0.0183  
##          -3   0.0017     0.0134       -0.0393      0.0426  
##          -2   0.1051     0.0193        0.0461      0.1642 *
##          -1   0.0057     0.0106       -0.0267      0.0382  
##           0  -0.0699     0.0135       -0.1111     -0.0286 *
##           1  -0.0416     0.0184       -0.0978      0.0145  
##           2  -0.1161     0.0139       -0.1587     -0.0735 *
##           3  -0.0540     0.0158       -0.1024     -0.0056 *
##           4  -0.0333     0.0153       -0.0800      0.0134  
##           5  -0.1159     0.0222       -0.1838     -0.0479 *
##           6  -0.0501     0.0252       -0.1270      0.0269  
##           7  -0.0404     0.0176       -0.0943      0.0134  
##           8  -0.0477     0.0200       -0.1089      0.0136  
##           9  -0.1450     0.0270       -0.2277     -0.0624 *
##          10  -0.0162     0.0150       -0.0621      0.0297  
##          11   0.0087     0.0186       -0.0482      0.0657  
##          12  -0.0653     0.0221       -0.1327      0.0021  
##          13  -0.0598     0.0208       -0.1235      0.0039  
##          14  -0.1213     0.0233       -0.1924     -0.0502 *
##          15  -0.0614     0.0181       -0.1167     -0.0060 *
##          16  -0.0715     0.0196       -0.1314     -0.0116 *
##          17  -0.0612     0.0265       -0.1421      0.0196  
##          18  -0.0833     0.0254       -0.1611     -0.0055 *
##          19  -0.0427     0.0309       -0.1373      0.0519  
##          20  -0.0742     0.0217       -0.1405     -0.0078 *
##          21  -0.0901     0.0248       -0.1659     -0.0143 *
##          22   0.0010     0.0193       -0.0579      0.0599  
##          23   0.0153     0.0172       -0.0374      0.0680  
##          24  -0.0436     0.0227       -0.1131      0.0260  
##          25  -0.0213     0.0199       -0.0823      0.0396  
##          26  -0.0715     0.0193       -0.1304     -0.0125 *
##          27  -0.0284     0.0208       -0.0920      0.0351  
##          28  -0.0076     0.0214       -0.0731      0.0579  
##          29  -0.0189     0.0198       -0.0793      0.0415  
##          30  -0.0603     0.0281       -0.1461      0.0255  
##          31  -0.0376     0.0205       -0.1004      0.0252  
##          32  -0.0460     0.0254       -0.1237      0.0317  
##          33  -0.0507     0.0264       -0.1315      0.0302  
##          34   0.0186     0.0218       -0.0482      0.0853  
##          35   0.0372     0.0226       -0.0318      0.1063  
##          36  -0.0355     0.0236       -0.1076      0.0366  
##          37  -0.0485     0.0250       -0.1249      0.0279  
##          38  -0.0881     0.0221       -0.1556     -0.0207 *
##          39  -0.0189     0.0228       -0.0887      0.0510  
##          40   0.0179     0.0234       -0.0537      0.0895  
##          41  -0.0555     0.0267       -0.1370      0.0261  
##          42  -0.0592     0.0265       -0.1403      0.0219  
##          43  -0.0640     0.0267       -0.1457      0.0177  
##          44  -0.0356     0.0195       -0.0953      0.0242  
##          45  -0.0185     0.0236       -0.0906      0.0535  
##          46   0.0517     0.0202       -0.0102      0.1135  
##          47   0.0199     0.0277       -0.0646      0.1045  
##          48  -0.0315     0.0297       -0.1222      0.0591  
##          49  -0.0559     0.0271       -0.1387      0.0268  
##          50  -0.0828     0.0232       -0.1538     -0.0118 *
##          51  -0.0348     0.0275       -0.1188      0.0493  
##          52   0.0455     0.0240       -0.0277      0.1187  
##          53  -0.0070     0.0254       -0.0848      0.0707  
##          54   0.0020     0.0225       -0.0667      0.0706  
##          55  -0.0513     0.0285       -0.1385      0.0359  
##          56  -0.0083     0.0210       -0.0724      0.0559  
##          57  -0.0284     0.0239       -0.1016      0.0448  
##          58   0.0119     0.0302       -0.0804      0.1041  
##          59   0.0681     0.0268       -0.0138      0.1499  
##          60  -0.0763     0.0259       -0.1556      0.0030  
##          61  -0.0391     0.0236       -0.1112      0.0330  
##          62  -0.0774     0.0253       -0.1549      0.0001  
##          63   0.0101     0.0214       -0.0551      0.0754  
##          64   0.1025     0.0257        0.0240      0.1810 *
##          65   0.0190     0.0336       -0.0836      0.1216  
##          66   0.0719     0.0313       -0.0238      0.1676  
##          67  -0.0004     0.0280       -0.0858      0.0851  
##          68  -0.0045     0.0418       -0.1322      0.1233  
##          69   0.0260     0.0331       -0.0753      0.1273  
##          70   0.0790     0.0355       -0.0296      0.1875  
##          71   0.0557     0.0365       -0.0559      0.1674  
##          72  -0.0312     0.0353       -0.1392      0.0768  
##          73  -0.0405     0.0374       -0.1547      0.0738  
##          74  -0.0308     0.0377       -0.1461      0.0846  
##          75  -0.0195     0.0282       -0.1055      0.0666  
##          76   0.0966     0.0390       -0.0226      0.2158  
##          77   0.0918     0.0268        0.0099      0.1737 *
##          78   0.0627     0.0432       -0.0693      0.1947  
##          79   0.0714     0.0363       -0.0397      0.1824  
##          80   0.1079     0.0384       -0.0095      0.2253  
##          81   0.1222     0.0424       -0.0074      0.2519  
##          82   0.1212     0.0345        0.0158      0.2266 *
##          83   0.0797     0.0286       -0.0076      0.1669  
##          84   0.0659     0.0414       -0.0607      0.1925  
##          85  -0.0092     0.0382       -0.1260      0.1075  
##          86  -0.0302     0.0378       -0.1459      0.0855  
##          87   0.0588     0.0437       -0.0749      0.1924  
##          88   0.1763     0.0446        0.0398      0.3127 *
##          89   0.0803     0.0775       -0.1566      0.3171  
##          90   0.1313     0.0763       -0.1018      0.3644  
##          91   0.1539     0.0602       -0.0300      0.3377  
##          92   0.0737     0.0622       -0.1165      0.2638  
##          93   0.0807     0.0746       -0.1474      0.3087  
##          94   0.1510     0.0662       -0.0514      0.3534  
##          95   0.1662     0.0559       -0.0047      0.3371  
##          96   0.0982     0.0642       -0.0979      0.2944  
##          97   0.0615     0.0684       -0.1474      0.2705  
##          98   0.0576     0.0531       -0.1046      0.2199  
##          99   0.1604     0.0595       -0.0214      0.3422  
##         100   0.2115     0.0698       -0.0018      0.4248  
##         101   0.1521     0.0548       -0.0155      0.3197  
##         102   0.2671     0.0596        0.0848      0.4494 *
##         103   0.2839     0.0515        0.1265      0.4414 *
##         104   0.1189     0.0714       -0.0994      0.3371  
##         105   0.1232     0.0641       -0.0728      0.3192  
##         106   0.2131     0.0746       -0.0151      0.4412  
##         107   0.2017     0.0586        0.0225      0.3809 *
##         108   0.2249     0.0650        0.0263      0.4236 *
##         109   0.1411     0.0737       -0.0840      0.3662  
##         110   0.2007     0.0679       -0.0067      0.4082  
##         111   0.1731     0.0711       -0.0441      0.3903  
##         112   0.3089     0.0547        0.1419      0.4760 *
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
summary(did_control_agg_minigrid_rural)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##     ATT    Std. Error     [ 95%  Conf. Int.] 
##  0.0421        0.0263    -0.0095      0.0937 
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band] 
##         -77   0.0419     0.0377       -0.2126      0.2965 
##         -76   0.1009     0.0734       -0.3951      0.5968 
##         -75   0.0202     0.0316       -0.1935      0.2339 
##         -74   0.0248     0.0301       -0.1784      0.2280 
##         -73  -0.1091     0.0510       -0.4539      0.2357 
##         -72   0.0385     0.0561       -0.3403      0.4174 
##         -71  -0.0347     0.0558       -0.4115      0.3421 
##         -70  -0.0674     0.0921       -0.6900      0.5552 
##         -69   0.0042     0.0278       -0.1839      0.1923 
##         -68   0.0710     0.0247       -0.0957      0.2377 
##         -67  -0.0723     0.0304       -0.2780      0.1333 
##         -66   0.0298     0.0205       -0.1088      0.1683 
##         -65   0.0525     0.0228       -0.1017      0.2067 
##         -64   0.1112     0.0352       -0.1265      0.3489 
##         -63  -0.0538     0.0598       -0.4578      0.3502 
##         -62  -0.0656     0.0374       -0.3180      0.1868 
##         -61   0.0019     0.0850       -0.5726      0.5764 
##         -60   0.0134     0.0714       -0.4693      0.4961 
##         -59  -0.0178     0.0534       -0.3790      0.3433 
##         -58  -0.0364     0.0225       -0.1881      0.1153 
##         -57  -0.0470     0.0339       -0.2763      0.1823 
##         -56   0.0869     0.0392       -0.1779      0.3517 
##         -55  -0.0142     0.0183       -0.1377      0.1094 
##         -54   0.0812     0.0435       -0.2127      0.3751 
##         -53   0.0438     0.0319       -0.1720      0.2596 
##         -52   0.0019     0.0304       -0.2034      0.2073 
##         -51   0.0378     0.0180       -0.0840      0.1596 
##         -50   0.0910     0.0301       -0.1127      0.2946 
##         -49  -0.0538     0.0505       -0.3948      0.2873 
##         -48  -0.0628     0.0547       -0.4326      0.3070 
##         -47  -0.0152     0.0540       -0.3798      0.3494 
##         -46  -0.0042     0.0170       -0.1193      0.1109 
##         -45   0.0395     0.0337       -0.1886      0.2675 
##         -44   0.0696     0.0280       -0.1193      0.2586 
##         -43  -0.0288     0.0386       -0.2896      0.2320 
##         -42  -0.0582     0.0192       -0.1878      0.0714 
##         -41   0.0414     0.0297       -0.1591      0.2419 
##         -40   0.0198     0.0440       -0.2773      0.3169 
##         -39   0.0546     0.0264       -0.1240      0.2332 
##         -38   0.0612     0.0277       -0.1263      0.2487 
##         -37  -0.0622     0.0478       -0.3849      0.2605 
##         -36  -0.0097     0.0458       -0.3194      0.3000 
##         -35  -0.0418     0.0341       -0.2725      0.1890 
##         -34   0.0020     0.0146       -0.0964      0.1004 
##         -33  -0.0221     0.0118       -0.1020      0.0578 
##         -32   0.0552     0.0254       -0.1165      0.2268 
##         -31  -0.0230     0.0264       -0.2014      0.1554 
##         -30  -0.0116     0.0223       -0.1620      0.1389 
##         -29   0.0052     0.0340       -0.2243      0.2348 
##         -28   0.0433     0.0264       -0.1351      0.2217 
##         -27  -0.0073     0.0305       -0.2134      0.1987 
##         -26   0.0241     0.0247       -0.1428      0.1909 
##         -25  -0.0229     0.0330       -0.2460      0.2002 
##         -24   0.0152     0.0355       -0.2245      0.2549 
##         -23  -0.0302     0.0226       -0.1830      0.1226 
##         -22  -0.0041     0.0195       -0.1356      0.1274 
##         -21  -0.0135     0.0185       -0.1389      0.1118 
##         -20   0.0679     0.0229       -0.0868      0.2226 
##         -19  -0.0089     0.0163       -0.1191      0.1012 
##         -18  -0.0227     0.0199       -0.1575      0.1121 
##         -17   0.0025     0.0109       -0.0709      0.0759 
##         -16   0.0495     0.0188       -0.0777      0.1767 
##         -15  -0.0312     0.0276       -0.2177      0.1553 
##         -14   0.0595     0.0211       -0.0828      0.2019 
##         -13   0.0036     0.0333       -0.2217      0.2289 
##         -12  -0.0574     0.0343       -0.2889      0.1741 
##         -11  -0.0094     0.0245       -0.1749      0.1561 
##         -10   0.0054     0.0139       -0.0883      0.0990 
##          -9   0.0275     0.0150       -0.0742      0.1292 
##          -8  -0.0129     0.0166       -0.1252      0.0993 
##          -7   0.0045     0.0275       -0.1812      0.1902 
##          -6  -0.0129     0.0212       -0.1564      0.1305 
##          -5  -0.0015     0.0146       -0.1003      0.0974 
##          -4   0.0366     0.0205       -0.1020      0.1752 
##          -3   0.0357     0.0155       -0.0693      0.1407 
##          -2   0.0117     0.0186       -0.1138      0.1373 
##          -1  -0.0250     0.0251       -0.1947      0.1447 
##           0  -0.0356     0.0189       -0.1631      0.0918 
##           1  -0.0363     0.0193       -0.1669      0.0943 
##           2  -0.0589     0.0194       -0.1904      0.0725 
##           3  -0.0430     0.0172       -0.1591      0.0732 
##           4  -0.0200     0.0152       -0.1225      0.0824 
##           5  -0.0583     0.0233       -0.2157      0.0991 
##           6  -0.0344     0.0255       -0.2068      0.1379 
##           7  -0.0213     0.0195       -0.1533      0.1108 
##           8   0.0322     0.0220       -0.1165      0.1810 
##           9  -0.0274     0.0284       -0.2191      0.1643 
##          10   0.0089     0.0258       -0.1652      0.1831 
##          11   0.0040     0.0188       -0.1231      0.1311 
##          12  -0.0443     0.0249       -0.2124      0.1237 
##          13  -0.0511     0.0231       -0.2072      0.1050 
##          14  -0.0728     0.0288       -0.2677      0.1221 
##          15  -0.0570     0.0168       -0.1703      0.0563 
##          16  -0.0582     0.0221       -0.2076      0.0913 
##          17  -0.0067     0.0282       -0.1974      0.1841 
##          18  -0.0537     0.0266       -0.2334      0.1260 
##          19  -0.0168     0.0311       -0.2269      0.1933 
##          20  -0.0107     0.0242       -0.1741      0.1527 
##          21   0.0050     0.0271       -0.1779      0.1880 
##          22   0.0213     0.0264       -0.1568      0.1995 
##          23   0.0075     0.0190       -0.1210      0.1361 
##          24  -0.0242     0.0248       -0.1921      0.1437 
##          25  -0.0172     0.0216       -0.1630      0.1285 
##          26  -0.0312     0.0248       -0.1991      0.1366 
##          27  -0.0309     0.0218       -0.1780      0.1163 
##          28  -0.0183     0.0213       -0.1624      0.1259 
##          29   0.0275     0.0207       -0.1122      0.1672 
##          30  -0.0335     0.0295       -0.2329      0.1658 
##          31   0.0040     0.0220       -0.1446      0.1526 
##          32   0.0099     0.0290       -0.1860      0.2057 
##          33  -0.0036     0.0291       -0.2006      0.1933 
##          34   0.0303     0.0267       -0.1501      0.2107 
##          35   0.0317     0.0242       -0.1319      0.1953 
##          36  -0.0145     0.0293       -0.2124      0.1833 
##          37  -0.0214     0.0269       -0.2034      0.1606 
##          38  -0.0333     0.0276       -0.2201      0.1535 
##          39   0.0038     0.0233       -0.1537      0.1612 
##          40   0.0016     0.0248       -0.1661      0.1692 
##          41  -0.0228     0.0271       -0.2061      0.1604 
##          42  -0.0331     0.0282       -0.2235      0.1573 
##          43  -0.0346     0.0291       -0.2314      0.1622 
##          44   0.0039     0.0248       -0.1634      0.1712 
##          45   0.0057     0.0264       -0.1724      0.1838 
##          46   0.0527     0.0245       -0.1131      0.2186 
##          47   0.0250     0.0273       -0.1595      0.2094 
##          48   0.0048     0.0327       -0.2158      0.2255 
##          49  -0.0123     0.0321       -0.2291      0.2046 
##          50  -0.0171     0.0299       -0.2190      0.1847 
##          51   0.0141     0.0267       -0.1666      0.1948 
##          52   0.0223     0.0229       -0.1324      0.1769 
##          53   0.0120     0.0274       -0.1734      0.1975 
##          54   0.0166     0.0254       -0.1548      0.1880 
##          55  -0.0480     0.0301       -0.2515      0.1555 
##          56   0.0226     0.0256       -0.1505      0.1958 
##          57   0.0084     0.0276       -0.1780      0.1949 
##          58   0.0078     0.0324       -0.2110      0.2266 
##          59   0.0728     0.0316       -0.1409      0.2865 
##          60  -0.0302     0.0294       -0.2287      0.1683 
##          61   0.0164     0.0311       -0.1940      0.2267 
##          62  -0.0136     0.0314       -0.2259      0.1988 
##          63   0.0520     0.0249       -0.1160      0.2199 
##          64   0.0525     0.0272       -0.1310      0.2361 
##          65   0.0241     0.0378       -0.2315      0.2798 
##          66   0.0763     0.0354       -0.1633      0.3158 
##          67  -0.0170     0.0303       -0.2217      0.1877 
##          68   0.0195     0.0400       -0.2511      0.2901 
##          69   0.0624     0.0387       -0.1990      0.3238 
##          70   0.0667     0.0364       -0.1796      0.3129 
##          71   0.0587     0.0405       -0.2148      0.3323 
##          72   0.0183     0.0429       -0.2717      0.3084 
##          73   0.0232     0.0426       -0.2643      0.3108 
##          74   0.0373     0.0396       -0.2303      0.3048 
##          75   0.0240     0.0348       -0.2109      0.2588 
##          76   0.0380     0.0389       -0.2247      0.3008 
##          77   0.0693     0.0288       -0.1251      0.2637 
##          78   0.0456     0.0446       -0.2557      0.3469 
##          79   0.0108     0.0373       -0.2415      0.2631 
##          80   0.1085     0.0395       -0.1583      0.3753 
##          81   0.1612     0.0490       -0.1701      0.4925 
##          82   0.0929     0.0387       -0.1687      0.3546 
##          83   0.0696     0.0371       -0.1814      0.3206 
##          84   0.1073     0.0462       -0.2052      0.4198 
##          85   0.0433     0.0443       -0.2563      0.3429 
##          86   0.0224     0.0430       -0.2682      0.3130 
##          87   0.0847     0.0426       -0.2035      0.3729 
##          88   0.0976     0.0509       -0.2467      0.4418 
##          89   0.0652     0.0716       -0.4184      0.5488 
##          90   0.1125     0.0785       -0.4179      0.6428 
##          91   0.0822     0.0636       -0.3475      0.5118 
##          92   0.0846     0.0623       -0.3363      0.5054 
##          93   0.1664     0.0855       -0.4113      0.7442 
##          94   0.1421     0.0712       -0.3387      0.6230 
##          95   0.1616     0.0600       -0.2437      0.5669 
##          96   0.1491     0.0733       -0.3465      0.6447 
##          97   0.1245     0.0668       -0.3269      0.5760 
##          98   0.1056     0.0585       -0.2899      0.5012 
##          99   0.1695     0.0621       -0.2502      0.5893 
##         100   0.1232     0.0704       -0.3528      0.5992 
##         101   0.1493     0.0648       -0.2884      0.5871 
##         102   0.2381     0.0833       -0.3251      0.8012 
##         103   0.2173     0.0646       -0.2193      0.6539 
##         104   0.1456     0.0748       -0.3600      0.6513 
##         105   0.2391     0.0872       -0.3500      0.8283 
##         106   0.2175     0.0874       -0.3729      0.8078 
##         107   0.1922     0.0838       -0.3742      0.7587 
##         108   0.2720     0.0852       -0.3039      0.8480 
##         109   0.2145     0.0883       -0.3820      0.8110 
##         110   0.2385     0.0706       -0.2389      0.7159 
##         111   0.1594     0.0748       -0.3463      0.6652 
##         112   0.2092     0.0633       -0.2185      0.6370 
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
summary(did_control_agg_minigrid_built)
## 
## Call:
## aggte(MP = did_control, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##      ATT    Std. Error     [ 95%  Conf. Int.]  
##  -0.8998        0.1225      -1.14     -0.6596 *
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##         -77   0.0918     0.1038       -0.2536      0.4373  
##         -76   0.4088     0.1340       -0.0369      0.8544  
##         -75  -0.4885     0.0993       -0.8187     -0.1583 *
##         -74  -0.1253     0.1163       -0.5121      0.2616  
##         -73  -0.2351     0.0869       -0.5243      0.0541  
##         -72   0.2760     0.0660        0.0566      0.4954 *
##         -71   0.1860     0.0747       -0.0623      0.4343  
##         -70  -0.0632     0.0915       -0.3676      0.2411  
##         -69  -0.4747     0.0937       -0.7865     -0.1630 *
##         -68  -0.1039     0.1133       -0.4806      0.2729  
##         -67   0.0929     0.1336       -0.3516      0.5374  
##         -66   0.1231     0.1144       -0.2574      0.5036  
##         -65   0.1063     0.0877       -0.1855      0.3980  
##         -64   0.3867     0.0985        0.0589      0.7145 *
##         -63  -0.4637     0.1193       -0.8605     -0.0670 *
##         -62  -0.2133     0.0734       -0.4575      0.0309  
##         -61  -0.1204     0.1014       -0.4578      0.2170  
##         -60   0.2638     0.0936       -0.0476      0.5751  
##         -59   0.1780     0.0753       -0.0724      0.4285  
##         -58  -0.0784     0.0748       -0.3273      0.1705  
##         -57  -0.4476     0.1022       -0.7874     -0.1077 *
##         -56  -0.1269     0.1046       -0.4749      0.2211  
##         -55   0.1058     0.1117       -0.2659      0.4775  
##         -54   0.2107     0.1097       -0.1543      0.5757  
##         -53   0.0965     0.0956       -0.2215      0.4145  
##         -52   0.2987     0.0936       -0.0127      0.6100  
##         -51  -0.4358     0.0983       -0.7628     -0.1087 *
##         -50  -0.0599     0.0773       -0.3170      0.1973  
##         -49  -0.1736     0.0804       -0.4411      0.0940  
##         -48   0.1763     0.0743       -0.0709      0.4236  
##         -47   0.1966     0.0728       -0.0455      0.4386  
##         -46  -0.0171     0.0711       -0.2537      0.2195  
##         -45  -0.4108     0.0907       -0.7125     -0.1091 *
##         -44  -0.1173     0.1074       -0.4747      0.2401  
##         -43   0.1204     0.1199       -0.2784      0.5193  
##         -42   0.0458     0.1096       -0.3188      0.4104  
##         -41   0.1067     0.0634       -0.1043      0.3176  
##         -40   0.2301     0.0828       -0.0452      0.5054  
##         -39  -0.1596     0.0725       -0.4009      0.0816  
##         -38  -0.0861     0.0614       -0.2903      0.1181  
##         -37  -0.1635     0.0713       -0.4006      0.0735  
##         -36   0.2612     0.0713        0.0239      0.4985 *
##         -35   0.1030     0.0498       -0.0625      0.2686  
##         -34  -0.1322     0.0531       -0.3089      0.0445  
##         -33  -0.2672     0.0634       -0.4782     -0.0562 *
##         -32  -0.2309     0.0702       -0.4645      0.0026  
##         -31   0.0079     0.0746       -0.2403      0.2560  
##         -30   0.1844     0.0687       -0.0443      0.4131  
##         -29   0.1134     0.0530       -0.0627      0.2896  
##         -28   0.2444     0.0669        0.0219      0.4669 *
##         -27  -0.1819     0.0817       -0.4538      0.0899  
##         -26  -0.1689     0.0586       -0.3639      0.0262  
##         -25   0.0212     0.0608       -0.1811      0.2236  
##         -24   0.2133     0.0625        0.0055      0.4211 *
##         -23   0.0968     0.0448       -0.0521      0.2458  
##         -22  -0.1741     0.0496       -0.3392     -0.0090 *
##         -21  -0.2088     0.0649       -0.4246      0.0069  
##         -20  -0.1792     0.0617       -0.3845      0.0262  
##         -19   0.0070     0.0735       -0.2374      0.2513  
##         -18   0.1241     0.0585       -0.0703      0.3185  
##         -17   0.1104     0.0398       -0.0218      0.2427  
##         -16   0.1354     0.0573       -0.0551      0.3259  
##         -15  -0.1456     0.0642       -0.3594      0.0681  
##         -14  -0.1384     0.0492       -0.3021      0.0252  
##         -13   0.0745     0.0446       -0.0739      0.2230  
##         -12   0.2665     0.0572        0.0763      0.4567 *
##         -11   0.0251     0.0386       -0.1032      0.1534  
##         -10  -0.1478     0.0424       -0.2888     -0.0068 *
##          -9  -0.2001     0.0515       -0.3715     -0.0288 *
##          -8  -0.2831     0.0606       -0.4847     -0.0816 *
##          -7   0.0049     0.0707       -0.2304      0.2401  
##          -6   0.1868     0.0565       -0.0013      0.3749  
##          -5   0.0828     0.0341       -0.0307      0.1964  
##          -4  -0.0025     0.0499       -0.1684      0.1634  
##          -3  -0.0212     0.0645       -0.2359      0.1935  
##          -2  -0.1258     0.0563       -0.3131      0.0614  
##          -1   0.0453     0.0418       -0.0939      0.1845  
##           0   0.3538     0.0594        0.1563      0.5513 *
##           1   0.3027     0.0595        0.1049      0.5005 *
##           2   0.1289     0.0652       -0.0879      0.3457  
##           3  -0.0139     0.0689       -0.2431      0.2154  
##           4  -0.2282     0.0605       -0.4294     -0.0269 *
##           5  -0.3501     0.0934       -0.6609     -0.0394 *
##           6  -0.1026     0.0918       -0.4078      0.2027  
##           7  -0.0978     0.0842       -0.3780      0.1823  
##           8  -0.1180     0.0816       -0.3893      0.1534  
##           9  -0.2159     0.0739       -0.4618      0.0300  
##          10  -0.2811     0.0554       -0.4653     -0.0968 *
##          11  -0.1993     0.0353       -0.3168     -0.0818 *
##          12   0.1873     0.0514        0.0164      0.3581 *
##          13   0.1841     0.0645       -0.0304      0.3987  
##          14   0.0252     0.0642       -0.1883      0.2386  
##          15  -0.0692     0.0676       -0.2942      0.1558  
##          16  -0.4327     0.0798       -0.6982     -0.1673 *
##          17  -0.5387     0.0992       -0.8686     -0.2088 *
##          18  -0.2516     0.1077       -0.6099      0.1066  
##          19  -0.2116     0.1027       -0.5531      0.1299  
##          20  -0.4238     0.0991       -0.7537     -0.0940 *
##          21  -0.4553     0.0900       -0.7546     -0.1560 *
##          22  -0.4705     0.0791       -0.7337     -0.2072 *
##          23  -0.2974     0.0536       -0.4759     -0.1190 *
##          24   0.0806     0.0690       -0.1488      0.3100  
##          25   0.1184     0.0759       -0.1343      0.3710  
##          26  -0.0100     0.0715       -0.2478      0.2277  
##          27  -0.2736     0.0850       -0.5565      0.0093  
##          28  -0.6353     0.1070       -0.9914     -0.2792 *
##          29  -0.6926     0.1228       -1.1012     -0.2841 *
##          30  -0.4548     0.1222       -0.8613     -0.0483 *
##          31  -0.3816     0.1146       -0.7628     -0.0004 *
##          32  -0.5852     0.1261       -1.0047     -0.1656 *
##          33  -0.7048     0.1063       -1.0583     -0.3512 *
##          34  -0.7328     0.0971       -1.0559     -0.4097 *
##          35  -0.5817     0.0844       -0.8624     -0.3009 *
##          36  -0.2222     0.0858       -0.5078      0.0634  
##          37  -0.0622     0.0939       -0.3747      0.2503  
##          38  -0.1487     0.0917       -0.4538      0.1564  
##          39  -0.5700     0.1084       -0.9305     -0.2094 *
##          40  -0.8771     0.1254       -1.2943     -0.4599 *
##          41  -1.0033     0.1342       -1.4499     -0.5568 *
##          42  -0.8376     0.1409       -1.3064     -0.3688 *
##          43  -0.6910     0.1458       -1.1761     -0.2060 *
##          44  -0.7908     0.1347       -1.2389     -0.3428 *
##          45  -1.0265     0.1340       -1.4721     -0.5808 *
##          46  -0.9780     0.1194       -1.3751     -0.5808 *
##          47  -0.8168     0.1031       -1.1597     -0.4740 *
##          48  -0.3319     0.1138       -0.7103      0.0465  
##          49  -0.2767     0.1083       -0.6370      0.0835  
##          50  -0.3470     0.1122       -0.7201      0.0261  
##          51  -0.9281     0.1340       -1.3738     -0.4823 *
##          52  -1.2204     0.1568       -1.7419     -0.6989 *
##          53  -1.3518     0.1673       -1.9085     -0.7952 *
##          54  -1.2031     0.1664       -1.7566     -0.6497 *
##          55  -0.8422     0.1512       -1.3451     -0.3393 *
##          56  -1.1068     0.1621       -1.6460     -0.5676 *
##          57  -1.3193     0.1473       -1.8092     -0.8294 *
##          58  -1.1771     0.1428       -1.6521     -0.7021 *
##          59  -1.0073     0.1149       -1.3896     -0.6250 *
##          60  -0.6895     0.1442       -1.1692     -0.2099 *
##          61  -0.4989     0.1223       -0.9056     -0.0922 *
##          62  -0.6129     0.1283       -1.0396     -0.1862 *
##          63  -1.2438     0.1465       -1.7311     -0.7566 *
##          64  -1.4500     0.1644       -1.9968     -0.9033 *
##          65  -1.6177     0.1841       -2.2300     -1.0054 *
##          66  -1.4989     0.1982       -2.1583     -0.8395 *
##          67  -1.0402     0.1582       -1.5665     -0.5138 *
##          68  -1.3778     0.1692       -1.9408     -0.8148 *
##          69  -1.5458     0.1912       -2.1818     -0.9098 *
##          70  -1.3542     0.1551       -1.8700     -0.8383 *
##          71  -1.3346     0.1478       -1.8262     -0.8430 *
##          72  -0.9386     0.1533       -1.4486     -0.4286 *
##          73  -0.7824     0.1403       -1.2491     -0.3157 *
##          74  -0.8499     0.1454       -1.3337     -0.3662 *
##          75  -1.6054     0.1774       -2.1955     -1.0152 *
##          76  -1.7304     0.1840       -2.3424     -1.1185 *
##          77  -1.8893     0.1792       -2.4853     -1.2933 *
##          78  -1.9139     0.1999       -2.5788     -1.2491 *
##          79  -1.2729     0.1883       -1.8991     -0.6466 *
##          80  -1.6021     0.2082       -2.2946     -0.9096 *
##          81  -1.7649     0.1875       -2.3886     -1.1412 *
##          82  -1.5286     0.1834       -2.1388     -0.9184 *
##          83  -1.5846     0.1530       -2.0934     -1.0758 *
##          84  -1.0748     0.1808       -1.6763     -0.4732 *
##          85  -1.0539     0.1459       -1.5392     -0.5686 *
##          86  -1.1746     0.1621       -1.7137     -0.6355 *
##          87  -1.8073     0.2014       -2.4774     -1.1373 *
##          88  -1.9380     0.2004       -2.6047     -1.2712 *
##          89  -2.0620     0.2137       -2.7729     -1.3511 *
##          90  -1.9403     0.2343       -2.7196     -1.1611 *
##          91  -1.0942     0.1995       -1.7579     -0.4304 *
##          92  -1.7877     0.2628       -2.6621     -0.9134 *
##          93  -1.7765     0.2321       -2.5487     -1.0044 *
##          94  -1.3252     0.2202       -2.0575     -0.5928 *
##          95  -1.4510     0.1833       -2.0609     -0.8412 *
##          96  -1.1598     0.2236       -1.9037     -0.4159 *
##          97  -0.9655     0.2063       -1.6518     -0.2793 *
##          98  -1.1283     0.2058       -1.8129     -0.4437 *
##          99  -1.6534     0.2257       -2.4042     -0.9026 *
##         100  -1.8269     0.2388       -2.6213     -1.0325 *
##         101  -2.1050     0.2225       -2.8451     -1.3650 *
##         102  -1.8355     0.2451       -2.6509     -1.0201 *
##         103  -0.8207     0.1976       -1.4781     -0.1633 *
##         104  -1.8654     0.2607       -2.7326     -0.9983 *
##         105  -1.6528     0.2247       -2.4002     -0.9054 *
##         106  -1.1138     0.2319       -1.8853     -0.3423 *
##         107  -1.4404     0.2053       -2.1235     -0.7574 *
##         108  -1.2958     0.2204       -2.0290     -0.5625 *
##         109  -0.8448     0.2218       -1.5827     -0.1069 *
##         110  -0.9942     0.2053       -1.6772     -0.3113 *
##         111  -1.5833     0.2261       -2.3355     -0.8311 *
##         112  -1.6121     0.2656       -2.4957     -0.7285 *
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
summary(did_nyt_agg_minigrid)
## 
## Call:
## aggte(MP = did_nyt, type = "dynamic", na.rm = TRUE)
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on event-study/dynamic aggregation:  
##      ATT    Std. Error     [ 95%  Conf. Int.] 
##  -0.0573        0.0741    -0.2026       0.088 
## 
## 
## Dynamic Effects:
##  Event time Estimate Std. Error [95% Simult.  Conf. Band]  
##         -65   0.0161     0.0262       -0.0603      0.0925  
##         -64   0.0981     0.0366       -0.0086      0.2048  
##         -63  -0.1079     0.0670       -0.3030      0.0872  
##         -62  -0.0899     0.0433       -0.2162      0.0364  
##         -61   0.0387     0.0862       -0.2125      0.2899  
##         -60   0.0345     0.0889       -0.2245      0.2934  
##         -59   0.0162     0.0525       -0.1368      0.1693  
##         -58  -0.0215     0.0314       -0.1131      0.0700  
##         -57  -0.0918     0.0392       -0.2061      0.0224  
##         -56   0.0423     0.0488       -0.1000      0.1845  
##         -55   0.0195     0.0259       -0.0560      0.0950  
##         -54   0.1228     0.0499       -0.0227      0.2683  
##         -53   0.0157     0.0333       -0.0812      0.1126  
##         -52  -0.0430     0.0291       -0.1279      0.0419  
##         -51  -0.0014     0.0301       -0.0891      0.0862  
##         -50   0.0948     0.0332       -0.0020      0.1916  
##         -49  -0.0106     0.0269       -0.0889      0.0677  
##         -48  -0.0572     0.0472       -0.1948      0.0804  
##         -47   0.0288     0.0228       -0.0377      0.0952  
##         -46   0.0084     0.0177       -0.0432      0.0599  
##         -45   0.0109     0.0308       -0.0788      0.1006  
##         -44   0.0057     0.0328       -0.0899      0.1013  
##         -43  -0.0006     0.0425       -0.1245      0.1233  
##         -42  -0.0512     0.0262       -0.1276      0.0251  
##         -41   0.0286     0.0269       -0.0499      0.1071  
##         -40  -0.0213     0.0422       -0.1444      0.1018  
##         -39   0.0544     0.0301       -0.0334      0.1422  
##         -38   0.0311     0.0358       -0.0731      0.1353  
##         -37  -0.0187     0.0264       -0.0956      0.0582  
##         -36   0.0024     0.0312       -0.0885      0.0932  
##         -35  -0.0314     0.0272       -0.1105      0.0478  
##         -34   0.0044     0.0138       -0.0360      0.0447  
##         -33  -0.0280     0.0233       -0.0958      0.0398  
##         -32  -0.0055     0.0281       -0.0873      0.0764  
##         -31  -0.0162     0.0357       -0.1202      0.0877  
##         -30   0.0059     0.0241       -0.0644      0.0762  
##         -29  -0.0076     0.0305       -0.0965      0.0812  
##         -28   0.0131     0.0248       -0.0590      0.0852  
##         -27  -0.0303     0.0285       -0.1133      0.0526  
##         -26  -0.0072     0.0251       -0.0802      0.0658  
##         -25   0.0050     0.0220       -0.0592      0.0692  
##         -24   0.0490     0.0274       -0.0308      0.1289  
##         -23  -0.0064     0.0187       -0.0609      0.0480  
##         -22  -0.0219     0.0240       -0.0920      0.0481  
##         -21   0.0003     0.0180       -0.0522      0.0528  
##         -20   0.0305     0.0195       -0.0264      0.0874  
##         -19  -0.0086     0.0168       -0.0575      0.0403  
##         -18  -0.0085     0.0161       -0.0554      0.0384  
##         -17   0.0105     0.0149       -0.0329      0.0538  
##         -16   0.0021     0.0209       -0.0588      0.0631  
##         -15  -0.0572     0.0270       -0.1360      0.0215  
##         -14   0.0370     0.0200       -0.0213      0.0953  
##         -13   0.0340     0.0205       -0.0257      0.0937  
##         -12  -0.0704     0.0288       -0.1545      0.0136  
##         -11  -0.0086     0.0332       -0.1052      0.0881  
##         -10  -0.0198     0.0333       -0.1167      0.0771  
##          -9   0.0534     0.0200       -0.0048      0.1116  
##          -8  -0.0496     0.0248       -0.1218      0.0226  
##          -7  -0.0109     0.0273       -0.0903      0.0686  
##          -6  -0.0093     0.0230       -0.0762      0.0576  
##          -5  -0.0024     0.0185       -0.0561      0.0514  
##          -4   0.0354     0.0343       -0.0645      0.1354  
##          -3   0.1243     0.0339        0.0254      0.2232 *
##          -2  -0.0525     0.0376       -0.1620      0.0569  
##          -1  -0.0726     0.0308       -0.1623      0.0170  
##           0  -0.0189     0.0294       -0.1044      0.0666  
##           1  -0.0461     0.0689       -0.2468      0.1545  
##           2  -0.0688     0.0791       -0.2994      0.1617  
##           3  -0.0530     0.0891       -0.3125      0.2066  
##           4  -0.0320     0.0865       -0.2839      0.2199  
##           5  -0.0496     0.0423       -0.1730      0.0737  
##           6  -0.0383     0.0802       -0.2720      0.1954  
##           7  -0.0797     0.1143       -0.4127      0.2533  
##           8  -0.0387     0.0846       -0.2851      0.2076  
##           9  -0.0654     0.0870       -0.3188      0.1880  
##          10   0.0013     0.0331       -0.0951      0.0977  
##          11  -0.0024     0.0219       -0.0661      0.0613  
##          12  -0.0903     0.0486       -0.2321      0.0514  
##          13  -0.1234     0.0673       -0.3196      0.0727  
##          14  -0.1390     0.0719       -0.3484      0.0704  
##          15  -0.1114     0.0787       -0.3406      0.1178  
##          16  -0.1074     0.0733       -0.3210      0.1062  
##          17  -0.0577     0.0785       -0.2865      0.1710  
##          18  -0.1048     0.0834       -0.3479      0.1382  
##          19  -0.1237     0.1017       -0.4200      0.1726  
##          20  -0.1261     0.0894       -0.3865      0.1342  
##          21  -0.0822     0.0802       -0.3158      0.1514  
##          22  -0.0136     0.0315       -0.1055      0.0782  
##          23  -0.0282     0.0315       -0.1200      0.0636  
##          24  -0.0537     0.0350       -0.1555      0.0482  
##          25  -0.1025     0.0653       -0.2927      0.0878  
##          26  -0.0840     0.0766       -0.3072      0.1391  
##          27  -0.0956     0.0807       -0.3306      0.1394  
##          28  -0.0973     0.0828       -0.3384      0.1439  
##          29  -0.0283     0.0612       -0.2065      0.1500  
##          30  -0.1031     0.0800       -0.3361      0.1300  
##          31  -0.1246     0.1109       -0.4477      0.1985  
##          32  -0.0964     0.0878       -0.3521      0.1594  
##          33  -0.1000     0.0764       -0.3226      0.1227  
##          34   0.0044     0.0345       -0.0961      0.1050  
##          35  -0.0112     0.0346       -0.1121      0.0897  
##          36  -0.1214     0.1089       -0.4385      0.1958  
##          37  -0.1757     0.1841       -0.7119      0.3605  
##          38  -0.1870     0.1952       -0.7556      0.3816  
##          39  -0.1386     0.2028       -0.7294      0.4523  
##          40  -0.1252     0.1986       -0.7036      0.4532  
##          41  -0.1250     0.1142       -0.4577      0.2078  
##          42  -0.1540     0.1921       -0.7136      0.4056  
##          43  -0.2279     0.2327       -0.9058      0.4500  
##          44  -0.2058     0.2051       -0.8032      0.3916  
##          45  -0.1841     0.1949       -0.7519      0.3837  
##          46  -0.0585     0.1092       -0.3765      0.2595  
##          47  -0.0551     0.0758       -0.2758      0.1656  
##          48  -0.0540     0.0632       -0.2381      0.1302  
##          49  -0.0677     0.1054       -0.3749      0.2394  
##          50  -0.0597     0.1115       -0.3845      0.2651  
##          51  -0.0035     0.1185       -0.3485      0.3416  
##          52  -0.0636     0.1161       -0.4017      0.2745  
##          53  -0.0443     0.0851       -0.2921      0.2035  
##          54  -0.0732     0.1111       -0.3969      0.2506  
##          55  -0.1359     0.1410       -0.5467      0.2749  
##          56  -0.1124     0.1229       -0.4704      0.2456  
##          57  -0.1271     0.1118       -0.4528      0.1986  
##          58   0.0232     0.0582       -0.1464      0.1928  
##          59   0.0153     0.0360       -0.0897      0.1203  
##          60  -0.0030     0.0331       -0.0993      0.0933  
##          61   0.0521     0.0412       -0.0679      0.1721  
##          62   0.0285     0.0531       -0.1261      0.1831  
##          63   0.0912     0.0387       -0.0215      0.2040  
##          64   0.1187     0.0366        0.0120      0.2254 *
##          65   0.0614     0.0779       -0.1657      0.2884  
##          66   0.1225     0.0709       -0.0840      0.3290  
##          67   0.0926     0.0402       -0.0245      0.2098  
##          68   0.1085     0.0539       -0.0485      0.2656  
##          69   0.0363     0.0631       -0.1474      0.2199  
##          70   0.0720     0.0502       -0.0742      0.2182  
##          71   0.0476     0.0366       -0.0591      0.1544  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Not Yet Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
# recreate the plots for each of these
did_nyt_agg_plt_minigrid <- ggdid(did_nyt_agg_minigrid, xgap = 6) +
    labs(title = "ATTs for Mini-grid Construction on Nighttime Brightness for 700+ Sites in Africa", x = "Months Since Commissioning", y = "Change in Brightness") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 24, family = "serif"), legend.position = "bottom")

did_nyt_agg_plt_minigrid_small <- ggdid(did_nyt_agg_minigrid, xgap = 6) +
    labs(title = "ATTs for Mini-grid Construction on Nighttime Brightness for 700+ Sites in Africa", x = "Months Since Commissioning", y = "Change in Brightness") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")

did_control_agg_plt_minigrid_ocean <- ggdid(did_control_agg_minigrid_ocean, xgap = 6) +
    labs(title = "Group-Time ATTs for Mini-Grid Sites vs Ocean Sites", x = "Time Period in Months", y = "ATT") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")

did_control_agg_plt_minigrid_desert <- ggdid(did_control_agg_minigrid_desert, xgap = 6) +
    labs(title = "Group-Time ATTs for Mini-Grid Sites vs Desert Sites", x = "Time Period in Months", y = "ATT") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")  

did_control_agg_plt_minigrid_jungle <- ggdid(did_control_agg_minigrid_jungle, xgap = 6) +
    labs(title = "Group-Time ATTs for Mini-Grid Sites vs Rainforest Sites", x = "Time Period in Months", y = "ATT") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")

did_control_agg_plt_minigrid_rural <- ggdid(did_control_agg_minigrid_rural, xgap = 6) +
    labs(title = "Group-Time ATTs for Mini-Grid Sites vs Rural Sites", x = "Time Period in Months", y = "ATT") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")

did_control_agg_plt_minigrid_built <- ggdid(did_control_agg_minigrid_built, xgap = 6) +
    labs(title = "Group-Time ATTs for Mini-Grid Sites vs Built Sites", x = "Time Period in Months", y = "ATT") +
    theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
    theme(text = element_text(size = 14, family = "serif"), legend.position = "none")


# show them all
print(did_control_agg_plt_minigrid_ocean)

print(did_control_agg_plt_minigrid_desert)

print(did_control_agg_plt_minigrid_jungle)

print(did_control_agg_plt_minigrid_rural)

print(did_control_agg_plt_minigrid_built)

print(did_nyt_agg_plt_minigrid)

# export
ggsave("figures/dark_africa/did_nyt_agg_plt_minigrid.png", did_nyt_agg_plt_minigrid, width = 16, height = 10, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_nyt_agg_plt_minigrid_small.png", did_nyt_agg_plt_minigrid_small, width = 6, height = 5, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_ocean.png", did_control_agg_plt_minigrid_ocean, width = 6, height = 5, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_desert.png", did_control_agg_plt_minigrid_desert, width = 6, height = 5, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_jungle.png", did_control_agg_plt_minigrid_jungle, width = 6, height = 5, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_rural.png", did_control_agg_plt_minigrid_rural, width = 6, height = 5, units = "in", dpi = 300)
ggsave("figures/dark_africa/did_control_agg_plt_minigrid_built.png", did_control_agg_plt_minigrid_built, width = 6, height = 5, units = "in", dpi = 300)

# for presentation
# ggsave("figures/dark_africa/did_nyt_agg_plt_minigrid_hires.png", did_nyt_agg_plt_minigrid, width = 12, height = 6, units = "in", dpi = 300)

Results

Comparison ATT Std. Error 95% CI (Lower) 95% CI (Upper) Sig.
Mini-Grid vs Ocean -0.0129 0.0175 -0.0473 0.0215
Mini-Grid vs Desert 0.0340 0.0188 -0.0029 0.0710
Mini-Grid vs Jungle 0.0232 0.0180 -0.0120 0.0584
Mini-Grid vs Rural 0.0421 0.0263 -0.0095 0.0937
Mini-Grid vs Built -0.8998 0.1225 -1.1400 -0.6596 *
Mini-Grid vs Not Yet Treated -0.0573 0.0741 -0.2026 0.0880

Interpretation and Conclusions

In this notebook, we have conducted a Difference in Difference analysis using the Callaway & Sant’Anna (2020) method for staggered treatment timing. We compared the nighttime lights values of mini-grid sites to various control site types, including ocean, desert, jungle, rural, and built areas. The results indicate that mini-grid sites show a statistically significant decrease in brightness compared to built areas, while comparisons with ocean, desert, jungle, and rural areas did not yield statistically significant differences. This suggests that mini-grid installations may not lead to substantial increases in nighttime brightness when compared to less developed areas, but they do show a significant difference when compared to already developed built areas. Further research could explore the underlying factors contributing to these differences and assess the broader impacts of mini-grid installations on local communities and environments.

Further Reading

This analysis was the foundation of my Master’s thesis, which is currently under review for publication. The full thesis can be found here.