在Python / Pandas中我使用了PanelOLS功能。此功能使您能够对标准错误进行聚类。例如:
PanelOLS(y=panel.Y, x=panel[['X1', 'X2'], nw_lags=10, time_effects=True,
cluster='time')
但我想按entity
以及time
标准错误进行聚类。
有没有办法这样做?如果没有,statsmodel
中的面板功能怎么样?我很难找到使用statsmodel进行Panel回归的文档。
更新
如果我控制使用newey-west滞后(nw_lags
),这不是cluster='entity'
吗?那么,如果我同时使用nw_lags
和cluster=time
,就像进行双向聚类一样?
答案 0 :(得分:0)
Thompson(2011)"标准错误的简单公式,它们通过frim和time"他描述了如何使用只允许单向聚类的命令实现双聚类。
表示由V_time
按实体聚类的方差估计值,以及V_white
按时间聚类的方差估计值和V = V_ent + V_time - V_white
的异方差性稳健估计量。然后由Picasso.with(Context).setLoggingEnabled(true);
给出双聚类标准错误。因此,您可以使用PanelOLS回归为您提供每个方差估计值,然后自己计算双聚类标准误差。