evanjflack / bacondecomp

Bacon-Goodman decomposition for differences-in-differences with variation in treatment timing.
Other
46 stars 16 forks source link

"Unbalanced panel" in panel data #81

Closed PromiseKamanga closed 2 years ago

PromiseKamanga commented 2 years ago

I just downloaded the package from GitHub today and I got the "unbalanced panel" error. I am using panel data that involves bilateral trade values of multiple countries. As such I have duplicate "country-year" combinations because I observe a country's trade with all its partners in a given year over several year. Could that explain the error? Do you have a suggestion on how I should proceed?

Here is the code I run:

         dots_bacon <- bacon(export_fob ~ policy_switch | interaction(exporter, importer) + interaction(exporter, year) + 
                                    interaction(importer, year),
                                   data = my_df, id_var = "exporter",  time_var = "year")

Just for context, my variable of interest (policy_switch) is a dummy identifying subsequent to a policy change. The rest are pairs of fixed effects.

kylebutts commented 2 years ago

Hi Promise,

Sorry for the delay (christmas time). So the bacon decomposition involves group and time fixed effects (Two-way fixed effects). You are using three interacted fixed effect, so the program is not designed for this setting. I would recommend looking at https://github.com/kylebutts/did2s or https://github.com/kylebutts/didimputation which allows for estimation of the model you propose