xuyiqing / gsynth

Generalized Synthetic Control Method
Other
131 stars 40 forks source link

Error: undefined columns selected, only when estimaror=mc #86

Open danielrojaslozano opened 1 year ago

danielrojaslozano commented 1 year ago

Hello, I'm running the following code and it works

out_mc_riot = gsynth(vacancies_pc ~ treat_riot + random_x, data = dt, estimator = 'mc', index = c("codmun","time"), force = "two-way", CV = TRUE, r = c(0, 5), se = TRUE, cl = c('codmun','coddep_month'), inference = "nonparametric", parallel = FALSE)

Then, I subset dt to select covariates and omit NAs:

dt_covariates = dt[, .(vacancies_pc,random_x,treat_riot,log_urban_pop, codmun,coddep_month,time)] %>% na.omit()

Then, I run the model with log_urban_pop:

out_mc_riot2 = gsynth(vacancies_pc ~ treat_riot + random_x + log_urban_pop, data = dt_covariates, estimator = 'mc', index = c("codmun","time"), force = "two-way", CV = TRUE, r = c(0, 5), se = TRUE, cl = c('codmun','coddep_month'), inference = "nonparametric", parallel = FALSE)

And I get: Error in [.data.frame(data, , variable) : undefined columns selected

Why is this happening? Note that I don't get the error message when estimator = 'ife' and inference = 'parametric'

Any ideas?