edunford / tidysynth

A tidy implementation of the synthetic control method in R
Other
98 stars 14 forks source link

Not getting correct unit of intervention #14

Closed lilitrevino closed 2 years ago

lilitrevino commented 2 years ago

I am using pretty much the exact same code as provided in the example for tidysynth, however, the graph I am receiving has the incorrect unit where the intervention occurred. The unit of intervention I assigned is "Colombia", however, it is returning "Argentina" for all graphs.

`code:

all_data <- correct_missing %>% synthetic_control(outcome = loghomicides, # outcome
          unit = Country, # unit index in the panel data
          time = Year, # time index in the panel data
          i_unit = "Colombia", # unit where the intervention occurred
          i_time = 2015, # time period when the intervention occurred
          generate_placebos=T # generate placebo synthetic controls (for inference)
                ) %>%

generate_predictor(time_window = 2005:2015,
          prison_pop = mean(logprison_population, na.rm = T),
          gini_ind = mean(loggini_index, na.rm = T),
          unemployment_log = mean(logunemployment, na.rm = T),
          serious_assault = mean(logserious_assault_rate, na.rm = T)
          ) %>%

generate_predictor(time_window = 2010,
                  homicides_2010 = loghomicides) %>%
generate_predictor(time_window = 2006,
                 homicides_2006 = loghomicides) %>%
generate_predictor(time_window = 2015,
                 homicides_2015 = loghomicides) %>%

generate_weights(optimization_window = 2005:2015, 
         margin_ipop = .02,sigf_ipop = 7,bound_ipop = 6) %>% generate_control()`

image