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

Encounter ValueError when using FamaMacBeth... #427

Open
Cheungki opened this issue Apr 28, 2022 · 8 comments
Open

Encounter ValueError when using FamaMacBeth... #427

Cheungki opened this issue Apr 28, 2022 · 8 comments

Comments

@Cheungki
Copy link

Thanks for your attention. I got the error "ValueError: Model cannot be estimated. All blocks of time-series observations are rank
deficient, and so it is not possible to estimate any cross-sectional regressions." when using FamaMacBeth model to do regression on my own dataset.

Here is my codes:

df = pd.read_csv('result/Exreturn.csv', parse_dates=['Month'])
df['code'] = '000001'
df = df.set_index(['code', 'Month'])
mod = FamaMacBeth(df['Exreturn_Level_High'], sm.add_constant(df[['MKT', 'SMB', 'HML', 'RMW', 'CMA']]))

The dataset is organized as followed:
data

Thanks a lot:)

@ksolarski
Copy link

@Cheungki rank deficiency means that one of the independent variables can be written as a linear combination of other independent variables. I cannot investigate it properly without accessing your data, but based on my finance knowledge, my best guess would be that market portfolio (MKT) can be created using a combination of other portfolios. Is there any way you could share the data?

@bashtage
Copy link
Owner

bashtage commented May 3, 2022

As @kapa112 said, it is really hard to tell without the data. Can you share the data somehow? The error indicates that you model is singular. When using FMB it must be the case that the X variables have some cross-sectional variation. This rules out some types of variables that only change with time (e.g., a dummy variable for the year). These are never needed since FMB behaves as-if time effects are included.

@Su-luoya
Copy link

I got the same error too!
image
image
image

@bashtage
Copy link
Owner

Do you variables that do not change in each cross section, for example, time dummy variables?

@Su-luoya
Copy link

But I didn't add time dummy variables...
My dependent variable is annually_return, exog variables are risk_premium(traded_value), size, BE/ME, OP, INV and LL_industry(EBITDA)

@Su-luoya
Copy link

like this
image

@bashtage
Copy link
Owner

Is risk premium a linear function of the other variables? Or is risk premium only a function of the year?

@Su-luoya
Copy link

Thanks a lot! That's the point! @bashtage

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

4 participants