cohortDD: the Cohort Discontinuity Design in R
cohortDD is an R package, written with Nicholas Mark and Lawrence L. Wu, that implements the Cohort Discontinuity Design. This page explains what the design does and shows a minimal example. The package website has the full documentation, and the source is on GitHub.
What it does
An election, a ruling, or a killing caught on video reaches everyone alive at the same date, so no unexposed group exists at that date. The cohort discontinuity design holds age fixed instead. It compares respondents of a given age in a survey taken after the event with respondents who were the same age in the surveys just before it, and it uses the trend across those earlier cohorts to project what the exposed cohort would have reported without the event.
The gap between the observed mean and the projected one is the effect on that cohort. Repeating the comparison age by age gives the response of every cohort, which shows who responded and, with later surveys, for how long.
The package needs only repeated cross-sections with a survey year, the respondent’s age, and a survey weight.
Install
# install.packages("remotes")
remotes::install_github("wenhaojiangsoc/cohortDD")
A minimal example
The example is the killing of Michael Brown in Ferguson, Missouri, on August 9, 2014, and the share of Americans who say the country spends too little on improving the conditions of Blacks, in the General Social Survey extract bundled with the package. The call below drops the 2014 interviews conducted after August 9 and estimates the response of each cohort aged 20 to 70 in 2016.
library(cohortDD)
data(gss_culture)
d <- subset(gss_culture, age <= 84 & post_ferguson14 == 0)
fit <- cdd(d, outcome = "natrace", levels = 1, # share answering "too little"
onset = 2015, # first full year after the event
wave = 2016, # first survey after it
H = 5, # surveys before the event (2006 to 2014)
order = 1, # 0 = mean of the earlier surveys, 1 = local-linear trend
b = 5, # pool ages within five years of each target age
ages = 20:70,
controls = c("factor(race)", "factor(sex)", "educ"),
reweight = c("factor(race)", "factor(sex)"))
plot_design(subset(d, year <= 2018), "natrace", onset = 2015, wave = 2016,
H = 5, from = 2000, level = 1, scale = 100)
plot_profile(fit, scale = 100, ylab = "Effect (points)")
The share saying too little was about 17 points above the extrapolated trend in 2016, and the profile is positive at every age: adults in their sixties moved as much as adults in their twenties. A comparison of the young with the old would report a difference near zero for this pattern, the same number it would report had nobody moved. The Get started article goes through this case one specification at a time.
Main functions
| Task | Functions |
|---|---|
| Estimate the effect by cohort | cdd(), summary() |
| Choose the trend and the number of earlier surveys | cdd_bandwidth(), cdd_cv() |
| Placebo dates and sensitivity | cdd_placebo(), cdd_adjust(), cdd_breakdown() |
| Age groups, cohorts followed over time, population average | cdd_groups(), cdd_popavg(), cdd_design() |
| Figures | plot_design(), plot_profile(), plot_estimates(), plot_dynamics(), plot_bandwidth() |
Documentation
The package website has a full walk-through and one article per task.
| Article | Question it answers |
|---|---|
| Get started | How do I run the design from the raw surveys to a figure? |
| The estimator and its inference | What is computed, and how are the intervals built? |
| Choosing the extrapolant and the window | Mean or trend, and how many earlier surveys? |
| Tests and falsification | Could the estimate arise without an event? |
| Visualization | Which figures does the package draw? |
| Groups, trajectories and population averages | How do I summarize by age group or follow cohorts over time? |
| Replicating a difference-in-differences | What does a young-versus-old contrast look like once each cohort is estimated? |
Reference
Jiang, Wenhao, Nicholas Mark, and Lawrence L. Wu. “Who Responds to an Unsettled Time, and for How Long? The Cohort Discontinuity Design and the Age Profile of Cultural Change.” Working paper.