成人视频

你的位置:成人视频 > 原神 足交 > 原神 足交

成人动漫网站 一张图里画出5种异质性适应DID的平行趋势与动态效应的无缺code和示例

发布日期:2025-06-30 06:28    点击次数:115

成人动漫网站 一张图里画出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查询 | 名家教化

本站仅提供存储工作,通盘骨子均由用户发布,如发现存害或侵权骨子,请点击举报。