chaisemartinPackages / did_multiplegt_dyn

|| Stata | R || Estimation of event-study Difference-in-Difference (DID) estimators in designs with multiple groups and periods, and with a potentially non-binary treatment that may increase or decrease multiple times.
38 stars 8 forks source link

Multiple control variables cause an error #95

Open lbiagini75 opened 6 days ago

lbiagini75 commented 6 days ago

Dear de Chaisemartin's Staff, I am really going crazy over this error. I’ve been banging my head against it for 20 days, and in the end, I’m forced to ask for your help.

# In the following example, we use data from Favara and Imbs (2015). 
# The dataset can be downloaded from GitHub:
repo <- "chaisemartinPackages/ApplicationData/main" 
file <- "favara_imbs_did_multiplegt_dyn.dta"
url <- paste("https://raw.githubusercontent.com", repo, file, sep = "/")
favara_imbs <-  haven::read_dta(url)
favara_imbs$control_2<-0.5 * favara_imbs$Dl_hpi^2 + rnorm(1, mean = 0, sd = 0.5)

# Estimating 3 non-normalized event-study effects and two placebo 
# effects of banking deregulations on loans volume:
did_multiplegt_dyn(
  df = favara_imbs,
  outcome = "Dl_vloans_b",
  group = "county",
  time = "year",
  treatment = "inter_bra",
  controls = c("Dl_hpi","control_2"),
  effects = 2,
  placebo = 1,
  cluster = "state_n",
  graph_off = TRUE
)

the error is

Error in .subset2(x, i, exact = exact) : subscript out of bounds

This error occurs when the number of controls is greater than 1 (from 2 onwards). Thank you in advance for the help!

When I use the previous version, the error doesn't appear.

 devtools::install_version("DIDmultiplegtDYN", version = "1.0.15")