Skip to contents

This article applies the design to a case with a published estimate and a single survey before the event, the simplest setting in which it can be used. The case is the killing of George Floyd on May 25, 2020 and its effect on how safe the police make people feel, in the Cooperative Election Study (CES). Keskintürk (2026) studied it with a difference-in-differences between respondents aged 29 or younger in 2020 and older respondents, among non-Hispanic Whites. The analysis here uses the same sample and item, estimates the response of every cohort, and recovers his contrast as one difference within the profile. The Get started article explains each argument on a case with five pre-event surveys; with one, most of those choices are not available, and this article shows what remains.

The data

ces_police is an extract of the CES common content with one row per non-Hispanic White respondent. The design needs three columns, which are the survey year, the age of the respondent, and a survey weight. Their default names are year, age, and weight, and the arguments year, age, and weight of cdd() accept other names.

library(cohortDD)
data(ces_police)

ces_police[1:5, c("year", "age", "cohort", "sex", "educ", "party", "weight", "unsafe")]
#>   year age cohort sex educ       party weight unsafe
#> 1 2016  47   1969   2    2 Independent  0.945  0.333
#> 2 2016  22   1994   2    2 Independent  0.767  0.667
#> 3 2016  34   1982   2    5    Democrat  1.206  0.333
#> 4 2016  54   1962   1    2  Republican  1.112  0.333
#> 5 2016  25   1991   2    1 Independent  2.288  0.333

The outcome is unsafe, the answer to “Do the police make you feel safe?”. It runs from 0 (mostly safe) to 1 (mostly unsafe) in steps of one third, which is the coding of Keskintürk (2026). The item was asked in 2016, 2020, and 2022, and cdd() drops respondents with a missing outcome before it counts surveys.

with(subset(ces_police, !is.na(unsafe)), table(year))
#> year
#>  2016  2020  2022 
#> 44284 42627 39425

The shock onset is 2020. The first exposed survey is the 2020 survey, fielded four to five months after the killing, so k = 0. The 2022 survey observes the same cohorts at k = 2.

There is one pre-shock survey, 2016. One survey gives one point of the cohort trend and no slope, so the local-linear fit is not available. The only extrapolant is the kernel mean with H = 1: the counterfactual for a cohort in 2020 is the mean of respondents who were the same age in 2016. This assumes that the item did not drift at fixed age between 2016 and 2020, and the section on drift below returns to that assumption.

Look at the raw means first

At a fixed age, the gap between the 2020 mean and the 2016 mean is the estimate before any adjustment.

d <- subset(ces_police, !is.na(unsafe))
d$age_group <- cut(d$age, c(17, 29, 44, 59, 74), labels = c("18-29", "30-44", "45-59", "60-74"))
raw <- sapply(split(d, d$year), function(x)
  sapply(split(x, x$age_group), function(g) weighted.mean(g$unsafe, g$weight)))
round(raw, 3)
#>        2016  2020  2022
#> 18-29 0.261 0.361 0.393
#> 30-44 0.229 0.299 0.336
#> 45-59 0.186 0.180 0.238
#> 60-74 0.145 0.136 0.165

Respondents under 45 report feeling less safe in 2020 than respondents of the same age did in 2016, and respondents over 45 report about the same. By 2022 every age group is above its 2016 level.

plot_design() draws the same comparison for all ages pooled.

plot_design(ces_police, "unsafe", onset = 2020, wave = 2020, H = 1,
            lo = 20, hi = 70, digits = 3) +
  ggplot2::labs(y = "Police make me feel unsafe (0-1)")
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic?

Mean of the unsafe item by survey year, with the 2016 mean carried forward to 2020 as the counterfactual.

The filled point is the 2016 mean among respondents aged 20 to 70, and the shaded region marks the pre-shock survey. The dotted segment carries that mean forward to 2020, the grey point is the counterfactual, and the arrow is the gap between the observed 2020 mean and the counterfactual. The open points are the observed means after the shock.

Estimate the effect by age

cdd() repeats this comparison at each target age.

fit <- cdd(ces_police, outcome = "unsafe",
           onset = 2020,       # shock onset t0
           wave  = 2020,       # exposed survey
           H     = 1,          # number of pre-shock surveys (only 2016 exists)
           b     = 2,          # age half-width: pool ages a - 2 to a + 2
           order = 0,          # 0 = kernel mean, 1 = local-linear fit
           ages  = 20:70,      # target ages in the exposed survey
           continuous = TRUE,  # treat the 0-1 scale as a numeric outcome
           controls = c("factor(sex)", "factor(educ)"),
           reweight = "factor(sex)")

The arguments have the following roles.

  • onset and wave give the onset year and the year of the exposed survey. Surveys taken before onset are pre-shock surveys.
  • H is the number of pre-shock surveys used, counted back from the most recent one. Here there is one, 2016.
  • b is the age half-width. For target age 30 and b = 2 the estimate uses respondents aged 28 to 32 in every survey. A wider band lowers the variance and averages the effect over more cohorts. The CES has about 800 exposed respondents per single year of age, so a narrow band is enough. A survey the size of the General Social Survey needs b = 5.
  • order selects the extrapolant. order = 0 is the kernel mean, a weighted average of the pre-shock surveys. order = 1 is the local-linear fit, a weighted regression line through the pre-shock surveys evaluated at the exposed survey. It needs at least two pre-shock surveys.
  • continuous = TRUE analyses the outcome as a number. Without it the outcome is treated as categorical, each level is analysed as a 0/1 indicator, and levels selects which ones.
  • controls lists covariates that enter the fit additively. The counterfactual is then evaluated at the covariate values of the exposed respondents.
  • reweight lists time-invariant covariates used to hold the composition of each cohort fixed across surveys by inverse-probability weighting.

Read the output

The result is a data frame with one row per target age.

fit
#> Cohort Discontinuity estimates: unsafe, onset 2020, exposed survey 2020 (k = 0), H = 1 pre-shock surveys (2016), b = 2, kernel mean, triangular kernel
#>  age cohort level        ate       se     lower     higher bb curv   n1
#>   20   2000     y  0.1073276 0.016962  0.074082  0.1405729  8   NA 2186
#>   21   1999     y  0.1078241 0.016069  0.076330  0.1393183  8   NA 2432
#>   22   1998     y  0.0995901 0.014811  0.070561  0.1286194  8   NA 2731
#>   23   1997     y  0.0965591 0.013345  0.070404  0.1227146  8   NA 2864
#>   24   1996     y  0.0949680 0.012290  0.070880  0.1190565  8   NA 3013
#>   25   1995     y  0.0914911 0.011717  0.068526  0.1144565  8   NA 3238
#>   26   1994     y  0.0918075 0.011154  0.069946  0.1136688  8   NA 3464
#>   27   1993     y  0.0970146 0.010590  0.076258  0.1177711  8   NA 3722
#>   28   1992     y  0.0985696 0.010575  0.077844  0.1192955  8   NA 3649
#>   29   1991     y  0.1054304 0.010590  0.084675  0.1261856  8   NA 3606
#>   30   1990     y  0.1134677 0.010338  0.093206  0.1337295  8   NA 3496
#>   31   1989     y  0.1140664 0.010231  0.094015  0.1341179  8   NA 3354
#>   32   1988     y  0.1173004 0.010470  0.096779  0.1378216  8   NA 3149
#>   33   1987     y  0.1237950 0.010040  0.104118  0.1434724  8   NA 3238
#>   34   1986     y  0.1143568 0.009688  0.095370  0.1333441  8   NA 3280
#>   35   1985     y  0.1040248 0.009718  0.084978  0.1230712  8   NA 3330
#>   36   1984     y  0.0952960 0.009764  0.076159  0.1144328  8   NA 3391
#>   37   1983     y  0.0830025 0.009395  0.064588  0.1014166  8   NA 3446
#>   38   1982     y  0.0662580 0.009539  0.047562  0.0849540  8   NA 3491
#>   39   1981     y  0.0541491 0.009633  0.035269  0.0730287  8   NA 3508
#>   40   1980     y  0.0365719 0.009598  0.017760  0.0553842  8   NA 3545
#>   41   1979     y  0.0371993 0.009679  0.018229  0.0561699  8   NA 3535
#>   42   1978     y  0.0256480 0.010009  0.006030  0.0452662  8   NA 3478
#>   43   1977     y  0.0215327 0.010019  0.001896  0.0411692  8   NA 3172
#>   44   1976     y  0.0257420 0.010305  0.005544  0.0459397  8   NA 2982
#>   45   1975     y  0.0248420 0.010434  0.004391  0.0452925  8   NA 2749
#>   46   1974     y  0.0139839 0.010118 -0.005846  0.0338140  8   NA 2551
#>   47   1973     y  0.0105066 0.009936 -0.008967  0.0299800  8   NA 2494
#>   48   1972     y  0.0094536 0.009826 -0.009804  0.0287112  8   NA 2773
#>   49   1971     y  0.0049963 0.009122 -0.012882  0.0228748  8   NA 2999
#>   50   1970     y -0.0001437 0.008462 -0.016730  0.0164422  8   NA 3226
#>   51   1969     y -0.0023123 0.007869 -0.017734  0.0131098  8   NA 3432
#>   52   1968     y -0.0012044 0.007810 -0.016511  0.0141023  8   NA 3572
#>   53   1967     y -0.0090962 0.007067 -0.022947  0.0047548  8   NA 3715
#>   54   1966     y -0.0201878 0.006736 -0.033390 -0.0069856  8   NA 3936
#>   55   1965     y -0.0143530 0.006376 -0.026849 -0.0018572  8   NA 4216
#>   56   1964     y -0.0168484 0.006168 -0.028938 -0.0047591  8   NA 4530
#>   57   1963     y -0.0170055 0.005674 -0.028127 -0.0058845  8   NA 4805
#>   58   1962     y -0.0122882 0.005962 -0.023974 -0.0006028  8   NA 4811
#>   59   1961     y -0.0143870 0.006353 -0.026838 -0.0019357  8   NA 4787
#>   60   1960     y -0.0181663 0.006752 -0.031400 -0.0049330  8   NA 4583
#>   61   1959     y -0.0132608 0.006681 -0.026355 -0.0001671  8   NA 4612
#>   62   1958     y -0.0171587 0.006820 -0.030526 -0.0037909  8   NA 4543
#>   63   1957     y -0.0191634 0.006870 -0.032627 -0.0056994  8   NA 4447
#>   64   1956     y -0.0084110 0.006530 -0.021209  0.0043874  8   NA 4175
#>   65   1955     y -0.0041370 0.006727 -0.017322  0.0090480  8   NA 3976
#>   66   1954     y -0.0076736 0.006981 -0.021356  0.0060092  8   NA 3713
#>   67   1953     y  0.0064047 0.006284 -0.005911  0.0187202  8   NA 3601
#>   68   1952     y  0.0046961 0.006101 -0.007262  0.0166547  8   NA 3511
#>   69   1951     y  0.0033835 0.006099 -0.008571  0.0153378  8   NA 3418
#>   70   1950     y  0.0029385 0.006006 -0.008833  0.0147098  8   NA 3486

The header repeats the settings. The columns are these.

Column Meaning
age, cohort Target age in the exposed survey and the birth cohort, wave - age.
ate Estimated effect, in units of the outcome. Here 0.10 is a rise of 0.10 on the 0-1 scale.
se Standard error. It combines the sampling variance of the exposed mean and the variance of the counterfactual.
lower, higher 95 percent confidence interval, ate plus or minus 1.96 se.
bb Bias factor. Multiplying it by a bound M on the curvature of the cohort trend gives the largest possible bias of a local-linear fit. With one pre-shock survey four years back it is 8, half the squared distance.
curv A rule-of-thumb value of M estimated from the pre-shock surveys. It cannot be estimated from one survey and is missing here, so the bias-aware interval is missing too.
n1 Number of exposed respondents in the age band.

Further columns are stored and can be reached after converting to a plain data frame, for example as.data.frame(fit)$n0. The article on the estimator and its inference explains each of them.

summary() condenses the profile.

summary(fit)
#>   level ages mean_ate share_signif mean_bb mean_n1
#> 1     y   51   0.0394        0.706       8    3529

mean_ate is the average effect across the target ages and share_signif is the share of ages whose confidence interval excludes zero.

Plot the age profile

plot_profile(fit, honest = FALSE, ylab = "Effect on feeling unsafe (0-1 scale)")

Estimated effect by age in 2020 with the confidence interval.

The line is the estimated effect at each age in 2020 and the band is the 95 percent confidence interval. Cohorts in their twenties moved by about 0.10, which is 0.4 of the pre-shock standard deviation of the item (0.25). The effect is largest in the early thirties, declines steeply after 35, and is close to zero by the late forties. Cohorts older than that did not move, and those in their late fifties and early sixties moved slightly toward feeling safe. Neighbouring ages share most of their respondents because the age bands overlap, so the profile should be read as a smooth curve and not as 51 independent estimates.

Compare with the difference-in-differences

A difference-in-differences between young and old is one contrast between two parts of this profile. cdd_groups() estimates the effect for groups of cohorts, and with the two groups of Keskintürk (2026), aged 18 to 29 and 30 to 74 in 2020, their difference reproduces his estimate.

two <- data.frame(label = c("18-29", "30-74"), mid = c(23.5, 52), hw = c(5.5, 22))
g <- cdd_groups(ces_police, "unsafe", onset = 2020, wave = 2020, H = 1, order = 0,
                continuous = TRUE, groups = two, controls = c("factor(sex)", "factor(educ)"))
g[, c("group", "ate", "se", "n1")]
#>   group    ate      se    n1
#> 1 18-29 0.1014 0.00843  7058
#> 2 30-74 0.0148 0.00273 32294
diff(rev(g$ate))   # young minus old
#> [1] 0.0866

The contrast is about 0.09, close to the regression difference-in-differences on these data. The profile adds what the contrast leaves out. The older group did not move in 2020, so the contrast is almost entirely the response of the young, and the response stops near age 45 and not at 29. Moving the cut for “young” from 29 toward 44 makes the difference-in-differences larger. The article on groups, trajectories and population averages follows the same cohorts to 2022.

How much could the item have drifted?

With one pre-shock survey the estimate attributes to the shock every change at fixed age between 2016 and 2020. The unsafe item cannot show how large that change would have been without a shock. A related item can: grade_police, a grade given to the local police, was asked in 2016 and 2018, before the shock. Applying the same estimator to a pretend onset in 2018 measures two years of drift.

drift <- cdd_popavg(ces_police, "grade_police", onset = 2018, wave = 2018, H = 1, order = 0,
                    continuous = TRUE, controls = c("factor(sex)", "factor(educ)"))
drift[, c("group", "wave", "ate", "se")]
#>   group wave    ate      se
#> 1 20-70 2018 0.0258 0.00245

The grade moved by about 0.026 in two years with no shock, which is 0.11 of its standard deviation. Over four years that would be about 0.2 standard deviations, more than the population-average effect on unsafe in 2020 (0.14 standard deviations). The level of the estimates is therefore fragile. The drift was nearly the same at every age, so differences between cohorts are not affected by it: the gap of about 0.1 between cohorts in their twenties and cohorts over 45 is the robust finding. The article on tests and falsification describes these checks in general.

Next steps

Reference

Keskintürk, T. (2026). Generational imprinting: How political events shape cohorts. Social Forces. doi:10.1093/sf/soag143