成人伦理片
你的位置:拳交 > 成人伦理片 >

中国 肛交 一张图里画出5种异质性肃穆DID的平行趋势与动态效应的好意思满code和示例

发布日期:2025-03-18 03:27    点击次数:104

中国 肛交 一张图里画出5种异质性肃穆DID的平行趋势与动态效应的好意思满code和示例

中国 肛交

巨乳风俗中国 肛交

图片

图片

接着1.最新: 2024版异质性肃穆DID最全指南! 更新太快脑袋跟不上看这里!2.不炒冷饭! 2024年最新“2”份DID使用查验清单, 前沿DID使用基本轨范指南! 今天展示一个在一张图里画出5种异质性肃穆DID形态的平行趋势与动态效应的好意思满code和示例。

该示例将指令你如安在单张图表中绘制五种不合谋略形态下的异质性肃穆双重差分谋略值(DID)。不仅展示了预先平行趋势,还揭示了动态效应的演变流程。不错直不雅地不雅察不同处理组在计谋或事件影响前后的变化趋势,从而更准确地评谋略谋或事件的因果效应。

对于平行趋势,1.平行趋势训练, 事件筹谋图绘制, 安危剂训练的保姆级身手指南!2.设施DID中的平行趋势训练,动态效应, 安危剂训练, 预期效应教程,3.平行趋势通不外, 该摄取什么形态来更好地振作平行趋势呢?4.平行趋势的明锐性训练, 末端能容忍违犯多猛进度的平行趋势,5.某经济学泰斗刊物上平行趋势若何这么, 真给我看暗昧了! 到底如何对pre-trend检测, 参谋和处理呢?6.在平行趋势训练中对计谋前后系列年份进行缩尾处理?7.三重差分DDD谋略中平行趋势训练如何操作呢?8.2篇TOP5: 刻下平行趋势训练形态有问题,新的平行趋势训练形态依然出现,9.前沿: 平行趋势莫得通过却奏效发在了AER上!10.只好4期数据, 为啥平行趋势训练时有6期呢? DID与连气儿变量交互整个如何阐明? 11.历史上首篇DID中修改平行趋势而被撤稿的TOP5著作!径直通过一个身手在一张图里画出5种异质性肃穆DID的平行趋势和计谋动态效应。模拟示例分析:事件筹谋中的因果效应谋略形态本文通过一系列形态的模拟示例,向读者展示了如何谋略事件筹谋中的因果效应。同期,先容了如何期骗event_plot号令绘制整个偏激置信区间,以直不雅展示筹谋末端。作家:Kirill Borusyak在进行推行代码之前,需要准备以下统计号令:did_imputation(Borusyak等,2021):可通过SSC平台得回。did_multiplegt(de Chaisemartin和D'Haultfoeuille,2020):不异可在SSC平台下载。eventstudyinteract(San和Abraham,2020):SSC上也有提供。csdid(Callaway和Sant'Anna,2020):SSC平台亦可下载。

图片

图片

底下的代码是上图好意思满的示例code,里面包括了我方模拟的数据,因此不错好意思满脱手下来。

*群友可径直赶赴社群下载。// 生成模拟数据,Generate a complete panel of 300 units observed in 15 periodsclear alltimer clearset seed 10global T = 15global I = 300set obs `=$I*$T'gen i = int((_n-1)/$T )+1 // unit idgen t = mod((_n-1),$T )+1 // calendar periodtsset i t// Randomly generate treatment rollout years uniformly across Ei=10..16 (note that periods t>=16 would not be useful since all units are treated by then)gen Ei = ceil(runiform()*7)+$T -6 if t==1 // year when unit is first treatedbys i (t): replace Ei = Ei[1]gen K = t-Ei // "relative time", i.e. the number periods since treated (could be missing if never-treated)gen D = K>=0 & Ei!=. // treatment indicator// Generate the outcome with parallel trends and heterogeneous treatment effectsgen tau = cond(D==1, (t-12.5), 0) // heterogeneous treatment effects (in this case vary over calendar periods)gen eps = rnormal() // error termgen Y = i + 3*t + tau*D + eps // the outcome (FEs play no role since all methods control for them)//save five_estimators_data, replace//  did_imputation谋略,Estimation with did_imputation of Borusyak et al. (2021)did_imputation Y i t Ei, allhorizons pretrend(5)event_plot, default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///title("Borusyak et al. (2021) imputation estimator") xlabel(-5(1)5))estimates store bjs // storing the estimates for later// Estimation with did_multiplegt of de Chaisemartin and D'Haultfoeuille (2020)did_multiplegt Y i t D, robust_dynamic dynamic(5) placebo(5) breps(100) cluster(i) event_plot e(estimates)#e(variances), default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///title("de Chaisemartin and D'Haultfoeuille (2020)") xlabel(-5(1)5)) stub_lag(Effect_#) stub_lead(Placebo_#) togethermatrix dcdh_b = e(estimates) // storing the estimates for latermatrix dcdh_v = e(variances)// csdid谋略, Estimation with csdid of Callaway and Sant'Anna (2020)gen gvar = cond(Ei==., 0, Ei) // group variable as required for the csdid commandcsdid Y, ivar(i) time(t) gvar(gvar) notyetestat event, estore(cs) // this produces and stores the estimates at the same timeevent_plot cs, default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") xlabel(-14(1)5) ///title("Callaway and Sant'Anna (2020)")) stub_lag(Tp#) stub_lead(Tm#) together//  eventstudyinteract谋略,Estimation with eventstudyinteract of Sun and Abraham (2020)sum Eigen lastcohort = Ei==r(max) // dummy for the latest- or never-treated cohortforvalues l = 0/5 {gen L`l'event = K==`l'}forvalues l = 1/14 {gen F`l'event = K==-`l'}drop F1event // normalize K=-1 (and also K=-15) to zeroeventstudyinteract Y L*event F*event, vce(cluster i) absorb(i t) cohort(Ei) control_cohort(lastcohort)event_plot e(b_iw)#e(V_iw), default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") xlabel(-14(1)5) ///title("Sun and Abraham (2020)")) stub_lag(L#event) stub_lead(F#event) togethermatrix sa_b = e(b_iw) // storing the estimates for latermatrix sa_v = e(V_iw)//  TWFE谋略,TWFE OLS estimation (which is correct here because of treatment effect homogeneity). Some groups could be binned.reghdfe Y F*event L*event, a(i t) cluster(i)event_plot, default_look stub_lag(L#event) stub_lead(F#event) together graph_opt(xtitle("Days since the event") ytitle("OLS coefficients") xlabel(-14(1)5) ///title("OLS"))estimates store ols // saving the estimates for later// Construct the vector of true average treatment effects by the number of periods since treatmentmatrix btrue = J(1,6,.)matrix colnames btrue = tau0 tau1 tau2 tau3 tau4 tau5qui forvalues h = 0/5 {sum tau if K==`h'matrix btrue[1,`h'+1]=r(mean)}// 一张图里展示通盘谋略值的预先趋势与过后动态效应,Combine all plots using the stored estimates// Combine all plots using the stored estimatesevent_plot btrue# bjs dcdh_b#dcdh_v cs sa_b#sa_v ols, ///stub_lag(tau# tau# Effect_# Tp# L#event L#event) stub_lead(pre# pre# Placebo_# Tm# F#event F#event) plottype(scatter) ciplottype(rcap) ///together perturb(-0.325(0.13)0.325) trimlead(5) noautolegend ///graph_opt(title("Event study estimators in a simulated panel (300 units, 15 periods)", size(medlarge)) ///xtitle("Periods since the event") ytitle("Average causal effect") xlabel(-5(1)5) ylabel(0(1)3) ///legend(order(1 "True value" 2 "Borusyak et al." 4 "de Chaisemartin-D'Haultfoeuille" ///6 "Callaway-Sant'Anna" 8 "Sun-Abraham" 10 "OLS") rows(3) region(style(none))) ////// the following lines replace default_look with something more elaboratexline(-0.5, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) graphregion(color(white)) bgcolor(white) ylabel(, angle(horizontal)) ///) ///lag_opt1(msymbol(+) color(cranberry)) lag_ci_opt1(color(cranberry)) ///lag_opt2(msymbol(O) color(cranberry)) lag_ci_opt2(color(cranberry)) ///lag_opt3(msymbol(Dh) color(navy)) lag_ci_opt3(color(navy)) ///lag_opt4(msymbol(Th) color(forest_green)) lag_ci_opt4(color(forest_green)) ///lag_opt5(msymbol(Sh) color(dkorange)) lag_ci_opt5(color(dkorange)) ///lag_opt6(msymbol(Oh) color(purple)) lag_ci_opt6(color(purple)) graph export "five_estimators_example.png", replace对于多期DID或交叠DID: 1.DID有关前沿问题“计谋交错推行+堆叠DID+事件筹谋”, 附好意思满slides,2.交错(渐进)DID中, 用TWFE谋略处理效应的问题, 及Bacon解析识别谋略偏误,3.典范! 这篇AER在一图内外用了通盘DID最新施展形态, 审稿东谈主径直服了!4.最新Sun和Abraham(2020)和TWFE谋略多期或交错DID并绘制展示末端!风雅解读code!5.多期DID或渐进DID或交叠DID, 最新Stata推行号令整理如下供环球学习,6.多期DID前沿形态大参谋, e.g., 插足-退出型DID, 异质性和动态性处理效应DID, 基期选拔问题等,7.交叠DID中平行趋势训练, 事件筹谋图绘制, 安危剂训练的保姆级身手指南!8.承诺! 养分午餐联想终于登上TOP5! 交叠DID+异质性肃穆DID!9.用事件筹谋法开展计谋评估的流程, 手把手教化著作!10.从双重差分法到事件筹谋法, 双重差分铺张与需要在意的问题,11.系统梳理DID最新施展: 从多期DID的潜在问题到刻下主流贬责形态和代码! 12.设施DID中的平行趋势训练,动态效应, 安危剂训练, 预期效应教程,13.DID从经典到前沿形态的保姆级教程, 开释最好意思满数据和代码!底下这些短衔尾著作属于书册,不错储藏起来阅读,否则以后王人找不到了。

7年,计量经济圈近2000篇不重类计量著作,

可径直在公众号菜单栏搜索任何计量有关问题,

Econometrics Circle

数据系列:空间矩阵 | 工企数据 | PM2.5 | 阛阓化指数 | CO2数据 |  夜间灯光 | 官员方言  | 微不雅数据 | 里面数据计量系列:匹配形态 | 内素性 | 器具变量 | DID | 面板数据 | 常用TOOL | 中介调动 | 工夫序列 | RDD断点 | 合成范围 | 200篇合辑 | 因果识别 | 社会收集 | 空间DID数据处理:Stata | R | Python | 缺失值 | CHIP/ CHNS/CHARLS/CFPS/CGSS等 |干货系列:动力环境 | 成果筹谋 | 空间计量 | 国外经贸 | 计量软件 | 商科筹谋 | 机器学习 | SSCI | CSSCI | SSCI查询 | 名家训诫

本站仅提供存储干事,通盘实质均由用户发布,如发现存害或侵权实质,请点击举报。






    Powered by 拳交 @2013-2022 RSS地图 HTML地图

    Copyright Powered by站群 © 2013-2024