linearmodels icon indicating copy to clipboard operation
linearmodels copied to clipboard

Encounter ValueError when using FamaMacBeth...

Open Cheungki opened this issue 4 years ago • 8 comments

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:)

Cheungki avatar Apr 28 '22 09:04 Cheungki

@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?

ksolarski avatar Apr 30 '22 14:04 ksolarski

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.

bashtage avatar May 03 '22 12:05 bashtage

I got the same error too! image image image

Su-luoya avatar Apr 17 '23 18:04 Su-luoya

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

bashtage avatar Apr 17 '23 18:04 bashtage

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 avatar Apr 17 '23 18:04 Su-luoya

like this image

Su-luoya avatar Apr 17 '23 18:04 Su-luoya

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

bashtage avatar Apr 17 '23 20:04 bashtage

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

Su-luoya avatar Apr 18 '23 06:04 Su-luoya