回归

qui xtreg flnapply Attention $control i.year,fe i(stkcd) vce(cluster ind) nonest
// fe i(stkcd) 个体固定效应 vce(cl ind) 行业层面聚类稳健标准误  nonest 有截距项?
xtreg CAR0_2 DHJrank5 i.year,fe cluster(Stkcd) r
areg CAR0_2 lagDHJ i.year,absorb(Industry) // 不显著
* Fama–MacBeth Regressions
xtfmb y x   // 不显著

滚动回归 stata

ref:
https://zhuanlan.zhihu.com/p/343408742?utm_id=0&wd=&eqid=a395af1d000328cf000000046474b091
https://www.lianxh.cn/news/4780bcf1d61c0.html?continueFlag=94bf2cb18d7027fd0d1e39561445f79f
目的:滚动计算ROA comovement
数据:个股面板季度
做法:个股每12个季度做一次回归,提取R2,缺失值不超过4
step1: 补齐所有季度日期

tsset Stkcd yq
tsfill, full
gen quarter = mod(yq,100) //yq格式200301
keep if quarter == 1 | quarter == 2 | quarter == 3 | quarter == 4
drop quarter

step2: 得到yq的连续编码
sort Stkcd yq
egen t = group(yq)
step3: 滚动回归
方法1:asreg
bys Stkcd: asreg ROA wIndROA wROA, window(t 12) minimum(8)
问题:遇到缺失值无结果,比如:

t=24时,应当仍有结果,且_Nobs应当为11。
不知道什么原因。看help文档也没有得到解答。
方法2:rangestat
rangestat (reg) ROA wIndROA wROA, interval(t -11 0) by(Stkcd)

手动截取该部分数据,一致,无上述问题。

循环回归输出结果

ref:
https://zhuanlan.zhihu.com/p/562603557?utm_id=0

# stata
forval i=0/6{
	qui xtreg y x $control i.year if Topic==`i' &(year>=2013)&(year<=2022),fe i(Industry) vce(cluster Stkcd) nonest
	loc s: di "m"`i'
	est store `s'
        }
reg2docx m0 m1 m2 m3 m4 m5 m6 using Table_LDATopics.docx, append indicate("Industry=*.Industry" "Year=*.year") ///
scalars(N r2_a) b(%9.3f) t(%7.2f) ///
title(Table 6B Topic 0/6 Baseline results(SYNwd2) sample: allA 2013-2022) ///
mtitles("Topic=0" "1" "2" "3" "4" "5" "6") 
  • reg
    reghdfe Y X $control if dum ==1, absorb(id year) vce(robust) // id & year 2 ways fixed effect
  • Panel quantile reg
    ssc install qregpd, replace
    ssc install moremata, replace
    ssc install amcmc, replace
    set seed 123
    qregpd Y X $control, id(id) fix(year) quantile(0.25) optimize(mcmc) noisy draws(1000) burn(100) arate(.5)
  • The mediating effect
    reghdfe M X $control, absorb(id year) vce(robust)
    Reghdfe Y X M $control, absorb(id year) vce(robust)
  • IV
    xtivreg2 Y $control (X =X_US) if code != "US", fe first robust
  • Progressive DID model
    reghdfe Y X_application $control, absorb(id year) vce(robust)
    Note: X_application is an dum variable (treatment/control group)
    ref:
    Ding, T., Li, H., Liu, L., Feng, K., 2024. An inquiry into the nexus between artificial intelligence and energy poverty in the light of global evidence. Energy Economics 136, 107748. https://doi.org/10.1016/j.eneco.2024.107748
posted @ 2022-11-04 16:11  Rae的笔记本  阅读(123)  评论(0)    收藏  举报