情趣做爱

swing raw sex5 一张图里画出5种异质性稳妥DID的平行趋势与动态效应的齐备code和示例

第四色官网

你的位置:情趣做爱 > 第四色官网 > swing raw sex5 一张图里画出5种异质性稳妥DID的平行趋势与动态效应的齐备code和示例


swing raw sex5 一张图里画出5种异质性稳妥DID的平行趋势与动态效应的齐备code和示例

发布日期:2025-07-04 00:39    点击次数:133

swing raw sex5 一张图里画出5种异质性稳妥DID的平行趋势与动态效应的齐备code和示例

swing raw sex5

图片

图片

接着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 版权所有