Daniel-Pailanir / sdid

Synthetic Difference in Differences for Stata
GNU General Public License v3.0
72 stars 36 forks source link

synthdid(): 3200 conformability error #51

Closed gcasamat closed 12 months ago

gcasamat commented 1 year ago

Hi, I just updated the sdid package and I now get the following error: synthdid(): 3200 conformability error <istmt>: - function returned error Before updating the package, everything was working fine. After checking, it seems to be related to the use of the option vce(jackknife) (it also breaks down with the example code you provide on the sdid webpage) Thanks for your help.

zhangxian8711 commented 1 year ago

I experienced the same error when using jackknife as inference option.

Daniel-Pailanir commented 1 year ago

Hello you two, I just solved the problem. Please reinstall from github and let me know if this works for both of you.

zhangxian8711 commented 1 year ago

Thanks for your prompt response. I am still in the process of running the program using jackknife inference, the problem is that it takes forever to generate the outcome even when I limit my sample.... At least.... ten min in, no error yet. A side question, is there any rough estimates of time running sdid using jackknife inference methods? For example, if SDID estimates without inference takes around 7 min (I have a fairly large dataset, particularly the control group), how much more time should i expect if I would like to use jackknife method? My understanding with Jackknife is that, we use the same weight generated by SDID, but then get the double difference using leave-one-out sample for the entire sample. So the bulk of the time spent is to repeat the OLS process N times? This can be long when N is huuuuuuge. Do you have any suggestion on the optimal sample size that balances the tradeoff between precision and computation burden?

gcasamat commented 1 year ago

Hi, I confirm that it works fine now with the jackknife method. I however encountered an error message while using the placebo method. Here is the full traceback:

---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
/var/folders/1y/v8whblks715474p0yvpj5s9r0000gn/T/ipykernel_46194/1682810350.py in <module>
----> 1 get_ipython().run_cell_magic('stata', '', "sdid `outcome_var' cod_insee year treated, vce(`se_method') graph g2_opt(scheme(plotplainblind)) seed(123) reps(50)\n*sdid `outcome_var' cod_insee year treated, covariates(`control_varlist', projected) vce(`se_method') graph g2_opt(scheme(plotplainblind)) seed(123) reps(25)\n*sdid `outcome_var' cod_insee year treated, covariates(`control_varlist') vce(bootstrap) graph g2_opt(scheme(plotplainblind)) seed(123) reps(50)\n")

~/opt/anaconda3/envs/py310/lib/python3.10/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2417             with self.builtin_trap:
   2418                 args = (magic_arg_s, cell)
-> 2419                 result = fn(*args, **kwargs)
   2420             return result
   2421 

~/opt/anaconda3/envs/py310/lib/python3.10/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

~/opt/anaconda3/envs/py310/lib/python3.10/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

/Applications/Stata/utilities/pystata/ipython/stpymagic.py in stata(self, line, cell, local_ns)
    274             _stata.run(cell, quietly=True, inline=_config.stconfig['grshow'])
    275         else:
--> 276             _stata.run(cell, quietly=False, inline=_config.stconfig['grshow'])
    277 
    278         if '-gw' in args or '-gh' in args:

/Applications/Stata/utilities/pystata/stata.py in run(cmd, quietly, echo, inline)
    323             _stata_wrk2("qui include " + tmpf, None, False, 1)
    324         else:
--> 325             _stata_wrk2("include " + tmpf, None, False, 1)
    326 
    327     if inline:

/Applications/Stata/utilities/pystata/stata.py in _stata_wrk2(cmd, real_cmd, colon, mode)
    114                 err = callback[0]
    115                 callback.clear()
--> 116                 raise SystemError(err)
    117         except KeyboardInterrupt:
    118             outputter.done()

SystemError:                  <istmt>:  3200  conformability error
r(3200);
r(3200);
damiancclarke commented 1 year ago

Hi @gcasamat, is this still an issue with the current version of the ado? Do you have a minimum working example of this to see if it is indeed a bug that needs addressing? It seems that the call above is made from Python, so it would be useful to know if this is something to do with Python integration, or sdid natively in Stata.

gcasamat commented 1 year ago

Hi. Thanks for your reply. I do not have access to the code right now but as far as I remember I got the same error when running it in Stata directly. I will check again with the current version of the ado asap.

damiancclarke commented 1 year ago

Thanks very much! If we know there is an issue here and the characteristics of the data, we will assign it to one of us to aim to resolve. If the error still occurs and you could let us know what version of Stata you are using, that would be v useful!