bashtage / linearmodels

Additional linear models including instrumental variable and panel data models that are missing from statsmodels.
https://bashtage.github.io/linearmodels/
University of Illinois/NCSA Open Source License
930 stars 184 forks source link

How can I use FamaMacbeth #493

Closed wbzhang233 closed 1 year ago

wbzhang233 commented 1 year ago

Dear Bashtage: I'm doing ablation study on Fama-French Five Factor Model, I use FamaMacbeth to test the risk premium of five factors, but when I use a panel data with number of entities is 25, number of time period is 152, and number of factors is 5. I failed, the hints like below.

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.
 My panel data like below.
ff5_fm = lm.FamaMacbeth(fm_panel_data["rtn"], fm_panel_data["MKT", "SMB", "HML", "RMW", "CMA"])
ff5_fm_res = ff5_fm.fit(cov_type="kernel", debiased=False)
 Looking forward to your reply

--- Below is Chinese Version --- 您好!我用文中的函数进行五因子实证实验,也就是把根据市值-ROE构建的25个投资组合作为因变量,然后取了152个月的截面期数据,因子数为[MKT, SMB, HML, RMW, CMA]。但我用linearmodels里面的FamaMacbeth函数进行回归时,总是会提示

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.
bashtage commented 1 year ago

This is happening because one of the following is occurring:

(a) You have an X variable that only changes accros time but not in the cross section. FMB effectively uses time dummies and so cannot handle this case. (b) You have an X variable that is a linear combination of other X variables.