You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用allsynth实现含未处理供体的交错合成控制的变量定义错误

交错合成控制(allsynth)使用未处理单位作供体的报错解决与方法疑问

研究背景与方法设计

  • 采用交错合成控制方法(参考Ben-Michael等,2021;Cao & Lu,2019),模仿Wiltshire(2021)的研究框架,估计亚马逊在意大利建立物流中心的政策效应
  • 核心设计差异:使用未处理单位作为供体池(该策略参考Chava等,2022),原因是意大利全部市政与亚马逊选址的市政存在关键特征差异,常规对照组设置不适用
  • 已完成Callaway Sant'Anna方法分析且结果稳定,现尝试通过allsynth命令验证结果,并获取因果异质性相关指标

报错详情

最初使用allsynth时,因供体单位包含处理期标识报错;修改代码将供体的处理年份变量year_op设为缺失值、生成面板分组变量synthpanel后,仍出现如下错误:

variable __00000D already defined

Stata运行日志

preserve

.         xtset synthpanel year 

Panel variable: synthpanel (unbalanced)
 Time variable: year, 2006 to 2020
         Delta: 1 unit

.         drop if year < 2010 
(3,994 observations deleted)

.         drop if year_op == 2011 
(103 observations deleted)

.         replace year_op = . if year < year_op 
(7,750 real changes made, 7,750 to missing)

. allsynth p_wages, bcorrect(merge) keep(synth_amazon, replace) stacked(trunits(
> open_yet) trperiods(year_op) clear figure (classic bcorrect))
**variable __00000D already defined**
r(110);

end of do-file

Trace关键片段

east 2 donor pool (untreated) units"
    exit 198
    }
    }
  - if "`_Entry'" == "trperiods" {
  = if "trperiods" == "trperiods" {
  - qui gen `_trP' = `s2'
  = qui gen __00000D = year_op
**variable __00000D already defined**
    qui recode `_trP' (0=.)
    local trP "`s2'"
    }

现有代码

egen synthpanel = group(cid id open_yet)
preserve
    xtset synthpanel year 
    drop if year < 2010 
    drop if year_op == 2011 
    replace year_op = . if year < year_op 
allsynth p_wages, bcorrect(merge) keep(synth_amazon, replace) stacked(trunits(open_yet) trperiods(year_op) clear figure (classic bcorrect))
restore 

核心需求

  • 解决__00000D already defined的报错问题,确保allsynth命令可正常运行
  • 确认“以未处理单位作为供体池”的交错合成控制策略是否具备学术新颖性
  • 明确该方法应用过程中需要注意的统计事项

内容的提问来源于stack exchange,提问作者Jacopo Tramontano

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 16:45:33