python - 如何在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', entity_effects = True, time_effects=True))
但是,估计值与在 R 中使用的相同,felm
但标准差远小于 R 中的值。估计值应在 21876 左右,标准差应在 1669 左右
我想知道如何编辑它,以便它们至少可以得到相似的结果......
解决方案
推荐阅读
- puppet - 具有多个辅助 puppetserver 上的代理的主 puppetserver 都具有相应的节点(证书设置)
- haskell - 运行函数时出错(非详尽模式)
- java - 为什么 Spring Boot 不使用自定义 ObjectMapper bean?
- c++ - 删除空格后在字符串输出中重复字母
- flutter - Flutter:预期 1 个位置参数,但找到 0 个
- wordpress - WooCommerce 的折扣规则在结帐页面上不起作用
- mysql - 为什么锁定读取忽略隔离级别?
- spring-boot - 将数据从微服务插入另一个后如何发送通知?
- python - 创建一个新列以根据其他列的值返回一个字符串
- huawei-mobile-services - 无法使用华为健康套件获取针对奥地利用户的任何数据