估计治疗效果时出错,synth_runner

时间:2018-01-31 22:44:30

标签: stata synthetic

我使用synth_runner使用时间序列土地覆盖数据(三个时间段)来估算森林保护政策的处理效果。我想将参加保护计划(在t = 3处理)的农场与合成对照进行比较。我的数据集有大约1500个观察值,而我每个代码只使用三个协变量:

synth_runner percent_oldforest total_ha slope_mean dist_hwy, d(DID)

其中DID是一个虚拟变量,表示在上一个时间段内是否处理过。该模型需要大约15分钟才能运行,并且不断结束错误:错误估计单元363或其他单元的处理效果。

有没有办法解决为什么会出现错误以及如何识别和删除可能产生此错误的任何观察?我已将matsize增加到2000。

1 个答案:

答案 0 :(得分:2)

这个令人敬畏的命令的错误可能令人沮丧地神秘。其中一些可能与它是synth的包装器有关。

很难确定,因为我无法复制您的分析,但如果我不得不猜测它与缺失的结果数据或单位名称有关,这些数据或单位名称太长或协变量缺乏变异。可能有其他方法来获取此错误,我没有枚举。

以下是显示第一个问题的示例:

use "synth_smoking.dta", clear
xtset state year
gen byte D = (state==3 & year>=1989)
synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), d(D)
replace cigsale =. if state=="Alabama":state & year==1985
synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), d(D)

当单位名称太长时,您可能会收到类似的错误:

egen state2 = group(state state state), label
xtset state2 year
synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), d(D)

最后,如果协变量在一个时间段内对于所有单位都是常数,则同样的问题:

replace beer = 0 if year==1979
synth_runner cigsale beer(1979) beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), d(D)

所有这些产生:

Error estimating treatment effect for unit 3
invalid syntax
r(198);

如果这不能解决问题,请尝试set trace on并尝试查看错误发生的位置并将其添加到您的问题中。如果丢弃一些未经处理的观察结果,那么为了调试,这也可能会加快速度。

相关问题