如何在python中运行固定效应回归

问题描述

我想用大学的固定效应和年份的固定效应进行回归。

# Import the packages
import pandas as pd
from linearmodels import PanelOLS
import statsmodels.api as sm


# Load the data
data = pd.read_csv(r"https://raw.githubusercontent.com/LOST-STATS/LOST-STATS.github.io/master/Model_Estimation/Data/Fixed_Effects_in_Linear_Regression/scorecard.csv")

# Set the index for fixed effects
data = data.set_index(['inst_name','year'])

# Calculate and drop the NA Values
data['prop_working'] = data['count_working']/(data['count_working'] + data['count_not_working'])
data = data.dropna(subset=['earnings_med','prop_working'])


# Regression
FE = PanelOLS(data.earnings_med,data['prop_working'],entity_effects = True,time_effects=True)
print(FE.fit(cov_type = 'clustered',time_effects=True))

然而,估计值与在 R 中使用 felm 相同,但标准差远小于 R 中的值。估计值应该在 21876 左右,标准差应该在 1669 左右

我想知道如何编辑它以便他们至少可以得到相似的结果......

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)