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

FamaMacBeth Std. Errors / T-Stats #168

Closed
matbuechner opened this issue Sep 26, 2018 · 4 comments · Fixed by #171
Closed

FamaMacBeth Std. Errors / T-Stats #168

matbuechner opened this issue Sep 26, 2018 · 4 comments · Fixed by #171

Comments

@matbuechner
Copy link

I have encountered an issue pertaining to the computation of standard errors and measures dependent on them such as t-stats and p-values in the FamaMacBeth function. On some occasions the function will produce a parameter estimate, but no error statistics. More specifically, I receive a runtime warning of the following sort:

..../linearmodels/panel/results.py:70: RuntimeWarning: invalid value encountered in sqrt

Any suggestions are very welcome :)

@bashtage
Copy link
Owner

Can you produce an example using simulated data that makes this happen? A small self-contained example makes it much easier to understand what is specifically happening.

If not, could you describe the size of the data you are using, and provide the function call the produces issues? Are you rolling through the data and it occasionally occurs when rolling?

Broadly something in the covariance matrix estimation is not positive definite. This is producing nan values which then propagate.

@matbuechner
Copy link
Author

matbuechner commented Sep 28, 2018

Unfortunately, I have not been able to produce the error with simulated data. Thus, to create a minimal example, I have disguised my data and made it accessible via this dropbox link:

https://www.dropbox.com/s/d7apc41c0pc86x3/FM_MinExampleData.pkl?dl=0

The data consists of roughly 30,000 observations, 700 entities and 50 times. The underlying panel is unbalanced. The function call is static, i.e. non-rolling.

The function call (using the pickle provided in the dropbox link) is:

import pandas as pd
import statsmodels.api as sm
from linearmodels import FamaMacBeth

#Load Sample
temp = pd.read_pickle('FM_MinExampleData.pkl')
temp.set_index(['Entity','Time'],inplace=True)

#FM Regression
fmbobj = FamaMacBeth(temp['Y'],sm.add_constant(temp[['X1','X2','X3','X4','X5','X6']]))
FMBres = fmbobj.fit(cov_type='kernel', kernel='parzen')

print(FMBres)

bashtage added a commit that referenced this issue Sep 28, 2018
Fix high-lag parzen weights

closes #170
closes #168
@bashtage
Copy link
Owner

Thanks - I found the issue, a bug (wrong place for parentheses)

bashtage added a commit that referenced this issue Sep 28, 2018
Fix high-lag parzen weights

closes #170
closes #168
@matbuechner
Copy link
Author

Fabulous! Many thanks

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

Successfully merging a pull request may close this issue.

2 participants