Stata的多元线性回归与泊松回归

1. 相关性检测

Pearson相关系数

  • correlate [varlist] [if] [in] [weight] [, correlate_options]

Spearman相关系数

  • pwcorr [varlist] [if] [in] [weight] [, pwcorr_options]
# correlate可简写为corr
corr y x1 x2 x3
pwcorr y x1 x2 x3

在这里插入图片描述

2. 多元线性回归

2.1 reg命令

regress depvar [indepvars] [if] [in] [weight] [, options]

# regression可简写为reg
reg y x1 x2 x3

在这里插入图片描述

  • 引入虚拟变量
# x4为需要引入的虚拟变量
xi: reg y x1 x2 x3 i.x4

在这里插入图片描述

  • 共线性分析
# 当 VIF > 10 则认为变量存在多重共线性
# mean VIF 小于 3.3 模型较为合理
estat vif

在这里插入图片描述

2.2 areg 命令

[R] areg – Linear regression with a large dummy-variable set
areg depvar [indepvars] [if] [in] [weight], absorb(varname) [options]

areg命令是reg命令的一个优化。有些时候我们想在回归中控制很多虚拟变量,但又不想生成虚拟变量,也不想报告虚拟变量的回归结果,那么就可以使用areg命令。areg结果与reg命令等价。
不过absorb()里只能加入一个变量,如果还需更高维度的固定效应,则需加入i.var的方式引入固定变量

areg like stars text_len sentiment polarity i.year, absorb(business_id) vce(cluster business_id)

在这里插入图片描述

  • cluster standard error
    cluster standard error是Areallano standard error,这个标准差最大的假设是截面是独立的,简单来说在大N小T的情况下,可以忽略时间序列层次上的相关性,用三明治标准差计算。robust standard error要求时间序列层次上没有相关性,只是调整了异方差
    链接:https://www.zhihu.com/question/388390329/answer/1160658265

2.3 reghdfe 命令

REGHDFE: Linear models with multi-way fixed effects and multi-way clustering
Least-square regressions (no fixed effects):
reghdfe depvar [indepvars] [if] [in] [weight] [, options]
Fixed effects regressions:
reghdfe depvar [indepvars] [if] [in] [weight] , absorb(absvars) [options]
Fixed effects regressions with group-level outcomes and individual FEs:
reghdfe depvar [indepvars] [if] [in] [weight] , absorb(absvars indvar) group(groupvar) individual(indvar) [options]

reghdfe 主要用于实现多维固定效应线性回归。在保证有效吸收多种固定效应后提高运行速度
因为是外源命令,在使用前请先下载命令包

ssc install reghdfe

命令更多介绍:REGHDFE: Linear Regressions With Multiple Fixed Effects

reghdfe like stars text_len sentiment polarity, absorb(year business_id) vce(cluster business_id)

在这里插入图片描述

参考来源:关于固定效应模型的四个Stata命令


3. 泊松回归

poisson depvar [indepvars] [if] [in] [weight] [, options]

poisson y x1 x2 x3

在这里插入图片描述

  • 关于选择负二项回归与泊松回归
  1. it’s well known that poisson estimator with robust/clustered SE (this is called pseudo ML poisson) can account for overdisperson and zero-inflated data, and
  2. negative binominal models can not account for business dummies (you can force the program to add them, but results will be wrong).
  • 11
    点赞
  • 88
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值