janboone / applied-economics

course material for the course applied economics
17 stars 21 forks source link

Statsmodel giving error - Axis must be specified when shapes of a and weights differ. #52

Closed 211sk closed 2 years ago

211sk commented 2 years ago

image

I have seen this similar issue on stackoverflow, but the context is different, and I cant find out how to fix it. The statsmodel is running, but the results are not being printed.

janboone commented 2 years ago

The error comes from numpy. Statsmodel is trying to calculate an average with weights and the shapes of the variable and the weights are not consistent. Can you check the shape of the variables in your regressions?

does ols.summary() also generate an error? If not, the problem is one of the variables in the second regression.

211sk commented 2 years ago

ols.summary() also generates the same error.

using this formula, i check for shape, merged3['Spending'].shape merged3['v2x_regime'].shape

both of the times, the shape is same, (277,)

janboone commented 2 years ago

can you send me part of your dataframe? Then I can see whether I can replicate this error.

211sk commented 2 years ago

For sending the part, I am encountering another issue. Till now I have been working by uploading the dataset on my google drive since a link for it is not available, and it is larger than 25mb, so i can't upload it on github. Is there any other way I can upload it and use for Jupyterlab?

janboone commented 2 years ago

if you cannot upload the data on github, include a link in your notebook to your google drive or to wetransfer. Then we can replicate what you have done.