did_check: Assessing Assumptions for Difference-in-differences

View source: R/did-check.R

did_checkR Documentation

Assessing Assumptions for Difference-in-differences

Description

Assessing Assumptions for Difference-in-differences

Usage

did_check(
  formula,
  data,
  id_unit,
  id_time,
  design = "did",
  is_panel = TRUE,
  option = list()
)

Arguments

formula

A formula of the following form,

  • When is_panel = TRUE: y ~ treatment | x1 + x2 where treatment is a time-varying treatment indicator.

  • When is_panel = FALSE: y ~ treat_group + post_treat | x1 + x2, where treat_group is a time-invariant treatment indicator, and post_treat is an indicator that takes 1 if the observations is from the post treatment periods and zero otherwise. The order is strict.

  • Covariates are specified after the vertical bar |. When there are no covariates, the formula should be given as y ~ treatment for is_panel = TRUE and y ~ treat_group + post_treat for is_panel = FALSE.

data

A data frame.

id_unit

A variable name of unit (e.g., country name, respondent id). When is_panel = TRUE (i.e., the panel data), a variable name of the unit index should be provided. When is_panel = FALSE (i.e., the repeated cross-section data), this can be left as NULL.

id_time

A variable name of time (e.g., year).

design

The design to be used: either "did" (the standard difference-in-differences design) or "sa" (the staggered adoption design). The default is "did".

is_panel

A boolean argument. This argument should be TRUE when the dataset is panel (i.e., the same units are repeatedly observed over time); This should be FALSE when the dataset is the repeated cross-section (RCS), where different sets of units are observed at each time point.

option

A list of the following option parameters:

n_boot

The number of bootstrap iterations.

se_boot

A boolean argument. If TRUE bootstrap-based critical value is used to construct the confidence intervals. Default is TRUE. This option only affects the basic DID design.

id_cluster

A variable name of a cluster index used to conduct clustered bootstraps. If left unspecified, the unit level bootstrap will be conducted.

parallel

Use multiple cores for computing the weighting matrix. future package is used.

lead

Lead parameter. Default is 0, which estimate the instantaneous treatment effect.

Value

An object of DIDdesign_check class. It is a list object consists of placebo estimates and plots for checking the parallel trends assumption.


naoki-egami/DIDdesign documentation built on June 4, 2024, 2:59 p.m.