This function estimates synthetic difference-in-differences using the synthdid package. It offers a choice among synthdid_estimate, did_estimate, and sc_estimate methods for estimation, defaulting to synthdid_estimate. It calculates treatment effects (TEs) for each period instead of a single TE for all treated periods.

synthdid_est(
  data,
  adoption_cohort,
  subgroup = NULL,
  lags,
  leads,
  time_var,
  unit_id_var,
  treated_period_var,
  treat_stat_var,
  outcome_var,
  seed = 1,
  method = "synthdid"
)

Arguments

data

Data frame to analyze.

adoption_cohort

Cohort in data to use as treated.

subgroup

(Optional) List of IDs to use as treated subgroup.

lags

Number of lags to use pre-treatment.

leads

Number of post-treatment periods (0 for only the treatment period).

time_var

Name of the calendar time column.

unit_id_var

Name of the unit ID column.

treated_period_var

Name of the treatment time period column.

treat_stat_var

Name of the treatment indicator column.

outcome_var

Name of the outcome variable column.

seed

A numeric value for setting the random seed (only for placebo SE). Default is 1.

method

The estimation method to be used. Methods include:

  • 'did': Difference-in-Differences.

  • 'sc': Synthetic Control Method.

  • 'sc_ridge': Synthetic Control Method with Ridge Penalty. It adds a ridge regularization to the synthetic control method when estimating the synthetic control weights.

  • 'difp': De-meaned Synthetic Control Method, as proposed by Doudchenko and Imbens (2016) and Ferman and Pinto (2021).

  • 'difp_ridge': De-meaned Synthetic Control with Ridge Penalty. It adds a ridge regularizationd when estimating the synthetic control weights.

  • 'synthdid': Synthetic Difference-in-Differences, a method developed by Arkhangelsky et al. (2021) Defaults to 'synthdid'.

Value

A list containing the estimated treatment effects, standard errors, observed and predicted outcomes, synthetic control lambda weights, and counts of treated and control units.

References

Ferman, B., & Pinto, C. (2021). Synthetic controls with imperfect pretreatment fit. Quantitative Economics, 12(4), 1197-1221.

Doudchenko, Nikolay, and Guido W. Imbens. 2016. “Balancing, Regression, Difference-in-Differences and Synthetic Control Methods: A Synthesis.” NBER Working Paper 22791.

Arkhangelsky, D., Athey, S., Hirshberg, D. A., Imbens, G. W., & Wager, S. (2021). Synthetic difference-in-differences. American Economic Review, 111(12), 4088-4118.

Examples

if (FALSE) {
  library(tidyverse)
  library(causalverse)
  library(synthdid)

  data <- get_balanced_panel(
    data = fixest::base_stagg,
    adoption_cohort = 5,
    lags = 2,
    leads = 3,
    time_var = "year",
    unit_id_var = "id",
    treated_period_var = "year_treated"
  ) |>
    dplyr::mutate(treatvar = if_else(time_to_treatment >= 0, 1, 0)) |>
    dplyr::mutate(treatvar = as.integer(if_else(year_treated > (5 + 2), 0, treatvar)))

  synthdid_est(
    data,
    adoption_cohort = 5,
    lags = 2,
    leads = 3,
    time_var = "year",
    unit_id_var = "id",
    treated_period_var = "year_treated",
    treat_stat_var = "treatvar",
    outcome_var = "y"
  )
}