synth_runner包中的pre_limit_mult stata不起作用

时间:2018-04-28 13:03:41

标签: stata

我想用预处理RMSPE省略安慰剂,这比我的治疗单位高2倍。 但是,当我使用带有pre_limit_mult(2)的synth_runner命令并完全按照他们在论文中给出的示例时,每个安慰剂仍然包含在图表中。有谁知道问题可能是什么?

1 个答案:

答案 0 :(得分:1)

以下是MCVE的示例。

如帮助文件中所述,如果该状态的匹配质量(通过治疗前根均方预测误差测量),则pre_limit_mult(K)将从推理中排除安慰剂状态,大于K倍处理单元的匹配质量。这不会改变哪些安慰剂线被绘制,它只会降低p值。

但是,你可以放弃那些你不想在图中显示的那样:

use "smoking.dta", clear
tsset state year

local K = 2 // pre_limit_mult factor

/* all 38 placebos */
synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), trunit(3) trperiod(1989) gen_vars
di e(n_pl)              // The number of placebo averages used for comparison
di e(avg_pre_rmspe_p)   // The proportion of placebos that have a pre-treatment RMSPE at least as large as the average of the treated units
single_treatment_graphs
graph export "raw_all.pdf", name(raw) replace
drop pre_rmspe post_rmspe lead effect cigsale_synth

/* same as above, but p-values change when we exclude 17 states */
synth_runner cigsale beer(1984(1)1988) lnincome(1972(1)1988) retprice age15to24 cigsale(1988) cigsale(1980) cigsale(1975), trunit(3) trperiod(1989) gen_vars pre_limit_mult(`K')
di e(n_pl)              // The number of placebo averages used for comparison
di e(avg_pre_rmspe_p)   // The proportion of placebos that have a pre-treatment RMSPE at least as large as the average of the treated units
single_treatment_graphs
graph export "raw_all2.pdf", name(raw) replace

/* exclude 17 states from graph */
preserve
    sum pre_rmspe if state=="California":state, meanonly
    gen in_sample = cond(pre_rmspe < = r(mean)*`K',1,0)
    distinct state if in_sample == 1 // CA is counted as in sample, so this matches 21 above
    drop if in_sample == 0
    single_treatment_graphs
    graph export "raw_limited.pdf", name(raw) replace
restore

另一种方法是为图形命令编写一个包装器,为您执行此操作并接受if选项。如果你计划做很多事情,可能值得你努力。

您可能需要ssc install distinct,因为这是用户编写的命令。