如何从PanelOLS导入entity_effects和time_effects?

问题描述 投票:0回答:1

当我运行代码时:

from linearmodels.panel import PanelOLS, PooledOLS
from linearmodels.panel import EntityEffects, TimeEffects

我收到错误:

ImportError: cannot import name 'EntityEffects' from 'linearmodels.panel' (/opt/anaconda3/lib/python3.9/site-packages/linearmodels/panel/__init__.py)

我正在尝试使用PanelOLS控制实体效果和时间效果,如下所示。

model_with_entity_and_time_pcse = PanelOLS.from_formula(f'{dependent_variable} ~ {" + ".join(independent_variables)}', data=df_final, entity_effects=True, time_effects=True).fit(cov_type='kernel')

你能帮我导入函数吗?

python panel-data linearmodels
1个回答
0
投票

ImportError:无法从“linearmodels.panel”导入名称“EntityEffects”(/opt/anaconda3/lib/python3.9/site-packages/linearmodels/panel/init.py)

此错误清楚地表明 EntityEffects 不是 Linearmodels 包的一部分。

从线性模型.面板导入PanelOLS,PooledOLS

from Linearmodels.panel import EntityEffects, TimeEffects // 删除这一行

EntityEffects、TimeEffects 不是线性模型包的一部分。因此删除该行即可消除此错误。

© www.soinside.com 2019 - 2024. All rights reserved.