bacon: Goodman-Bacon Decomposition

Description Usage Arguments Value Examples

View source: R/bacon.R

Description

bacon() is a function that performs the Goodman-Bacon decomposition for differences-in-differences with variation in treatment timing (with or without time-varying covariates).

Usage

1
bacon(formula, data, id_var, time_var, quietly = TRUE)

Arguments

formula

an object of class "formula". Must be of the form y ~ D + controls, where y is the outcome variable, D is the binary treatment indicator, and 'controls' can be any additional control variables. Do not include the fixed effects in the formula.

data

a data.frame containing the variables in the model.

id_var

character, the name of id variable for units.

time_var

character, the name of time variable.

quietly

logical. If TRUE then bacon() does not print the summary of estimates/weights by type (e.g. Treated vs Untreated). Default is TRUE. You can also use bacon_summary() on the result to view this.

Value

If control variables are included in the formula, then an object of class "list" with three elements:

Omega

a number between 0 and 1, the weight of the within timing group coefficient

beta_hat_w

a number, the within timing group coefficient

two_by_twos

a data.frame with the covariate adjusted 2x2 estimates and weights

If not control variables are included then only the two_by_twos data.frame is returned.

Examples

1
2
3
4
5
6
7
8
9
# Castle Doctrine (Uncontrolled)
df_bacon <- bacon(l_homicide ~ post,
  data = bacondecomp::castle, id_var = "state", time_var = "year"
)

# Castle Doctrine (Controlled)
ret_bacon <- bacon(l_homicide ~ post + l_pop + l_income,
  data = bacondecomp::castle, id_var = "state", time_var = "year"
)

evanjflack/bacondecomp documentation built on Sept. 19, 2021, 8:53 a.m.