import numpy as np
from statsmodels.datasets import grunfeld
data = grunfeld.load_pandas().data
data.year = data.year.astype(np.int64)
# MultiIndex, entity - time
data = data.set_index(['firm','year'])
from linearmodels import PanelOLS
mod = PanelOLS(data.invest, data[['value','capital']], entity_effect=True)
res = mod.fit(cov_type='clustered', cluster_entity=True)
1条答案
按热度按时间h6my8fg21#
创建
linearmodels
包是为了将statsmodels
扩展到panelOLS
(请参阅https://github.com/bashtage/linearmodels)。下面是包文档中的示例:最佳丹尼尔