Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid dimensions (0, 1). error #3

Closed
TheDataCoder opened this issue Feb 15, 2021 · 6 comments
Closed

Invalid dimensions (0, 1). error #3

TheDataCoder opened this issue Feb 15, 2021 · 6 comments

Comments

@TheDataCoder
Copy link

TheDataCoder commented Feb 15, 2021

Hello, thank you for your great effort!

I've got one year of daily observations for my data. There is only single co-variate and when I try to do

sc = Synth(dataset=df_trips[['value', 'MM', 'group', 'DAY_NUMBER']], outcome_var="value", 
           id_var="group", time_var="DAY_NUMBER", treatment_period=296, treated_unit='1')

I get Invalid dimensions (0, 1) error. Is there a problem with my understanding of the method?

@OscarEngelbrektson
Copy link
Owner

OscarEngelbrektson commented Feb 15, 2021

Hey @TheDataCoder,

Having a single covariate shouldn't be an issue. I just ran german_reunification.py but with only one covariate, such that
data = data[["gdp", "country", "year", "trade"]] in line 11. It worked fine.

The problem might be caused by the pip-installable version of the package being a little outdated. I just pushed the latest version of SyntheticControlMethods to pypi so try pip install --upgrade SyntheticControlMethods.

If that doesn't solve the issue, could you please send me your entire stack trace so that I can get a better understanding of what exactly is causing the problem? If you are ok with it, sending the dataset so that I can run your code would also be helpful.

@TheDataCoder
Copy link
Author

@OscarEngelbrektson,

I've tried reinstalling it in the new environment, but still got the same result. I can send you the dataset, and if it works fine on your side I'll send you the stack trace. Should I send you an email?

@OscarEngelbrektson
Copy link
Owner

@TheDataCoder,

Alright, I'll try to run on my machine. Preferably attach the dataset to this thread, but if you prefer, send it to me personally in an email.

@TheDataCoder
Copy link
Author

I've attached the file, please check if it works fine on your side.

data.xlsx

@OscarEngelbrektson
Copy link
Owner

Hey @TheDataCoder,

The issue is that you only have a treated unit in your dataset, i.e. you don't have any control units. The synthetic control method attempts to find a weighted average of control units that resembles the treated unit, this does not work if there are no control units in the dataset.

For clarity, your dataset looks like this:

value MM group DAY_NUMBER
1331 -0.3358 1 0
1126 0.848815 1 1
1740 -0.4435 1 2
1886 -0.22811 1 3

The problem is that all rows have value 1 in the column "group".
In your call sc = Synth(...,id_var="group",...,treated_unit='1'), Synth will look for all other values for id_var and use them as the control group, but it throws an error because it never found any.

If you are looking for some more resources on how the Synthetic Control method works here are some tips:

  • This is a very short and accessible article that covers the basic intuition. However, some of the details are outdated or innaccurate.
  • If you want a deeper understanding, this paper by the original authors or the Synthetic Control method, Abadie, Diamond and Hainmueller is great.

@TheDataCoder
Copy link
Author

Thank you, it finally worked! I initially though that groups for reference would be synthetically generated using the moving window. I remember reading about that concept and thought it was realized here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants