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

  1. 相关性检测

Pearson相关系数

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

Spearman相关系数

  • pwcorr [varlist] [if] [in] [weight] [, pwcorr_options]

corr y x1 x2 x3
pwcorr y x1 x2 x3

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

2.1 reg命令

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


reg y x1 x2 x3

Stata的多元线性回归与泊松回归
  • 引入虚拟变量

xi: reg y x1 x2 x3 i.x4

Stata的多元线性回归与泊松回归
  • 共线性分析

estat vif

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

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)

Stata的多元线性回归与泊松回归
  • 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的多元线性回归与泊松回归

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

  1. 泊松回归

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

poisson y x1 x2 x3

Stata的多元线性回归与泊松回归
  • 关于选择负二项回归与泊松回归
  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).

Original: https://blog.csdn.net/weixin_46599926/article/details/123300862
Author: 羊羊猪
Title: Stata的多元线性回归与泊松回归

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/630373/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球