-
Notifications
You must be signed in to change notification settings - Fork 10
/
scpi_illustration-multi.do
100 lines (71 loc) · 4.07 KB
/
scpi_illustration-multi.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
******************************************************************************************
** SCPI Stata Package
** Do-file for Empirical Illustration - Multiple Treated Unit
** Authors: Matias D. Cattaneo, Yingjie Feng, Filippo Palomba and Rocio Titiunik
******************************************************************************************
******************************************************************************************
** net install scpi, from(https://raw.githubusercontent.com/nppackages/scpi/master/stata) replace
******************************************************************************************
clear all
set more off
set linesize 80
******************************************************************************************
******************************************************************************************
** MULTIPLE TREATED UNITS
******************************************************************************************
******************************************************************************************
use "scpi_germany.dta", clear
* Create a second placebo treated unit
replace status = 1 if country == "Italy" & year >= 1992
******************************************************************************************
** prepare data - one feature, cointegrated data, unit-time treatment effect
******************************************************************************************
global coint "True"
global consta "True"
global covs "constant, trend"
scdatamulti gdp trade, dfname("python_scdatamulti") ///
id(country) outcome(gdp) time(year) treatment(status) cointegrated($coint) ///
constant($consta) covadj($covs)
scest, dfname("python_scdatamulti") name(simplex)
scplotmulti, scest
scpi, dfname("python_scdatamulti") name(simplex) sims(200)
* plot series
scplotmulti, uncertainty("gaussian") ptype("series")
* plot treatment effects
scplotmulti, uncertainty("gaussian") ptype("treatment") joint
******************************************************************************************
** prepare data - one feature, cointegrated data, average unit post-treatment effect
******************************************************************************************
* note that you can flexibly specify options for different treated units!
global coint "(Italy: True) (West Germany: False)"
global consta "(Italy: True) (West Germany: False)"
global covs "(Italy: constant, trend) (West Germany: constant, trend; constant, trend)"
scdatamulti (Italy: gdp trade) (West Germany: gdp infrate), dfname("python_scdatamulti") ///
id(country) outcome(gdp) time(year) treatment(status) cointegrated($coint) ///
constant($consta) covadj($covs) effect("unit")
scest, dfname("python_scdatamulti") name(simplex)
scplotmulti, scest
scpi, dfname("python_scdatamulti") name(simplex) sims(200)
* plot series
scplotmulti, uncertainty("gaussian") ptype("series")
* plot treatment effects
scplotmulti, uncertainty("gaussian") ptype("treatment") joint
******************************************************************************************
** prepare data - one feature, cointegrated data, average treatment effect on the treated
******************************************************************************************
global coint "(Italy: True) (West Germany: False)"
global consta "(Italy: True) (West Germany: False)"
global covs "(Italy: constant, trend) (West Germany: constant, trend; constant, trend)"
scdatamulti (Italy: gdp trade) (West Germany: gdp infrate), dfname("python_scdatamulti") ///
id(country) outcome(gdp) time(year) treatment(status) cointegrated($coint) ///
constant($consta) covadj($covs) effect("time")
scest, dfname("python_scdatamulti") name(simplex)
scplotmulti, scest
scpi, dfname("python_scdatamulti") name(simplex) sims(200)
* plot series
scplotmulti, uncertainty("gaussian") ptype("series")
* plot treatment effects
scplotmulti, uncertainty("gaussian") ptype("treatment") joint
erase "python_scdatamulti.obj"
erase "__scest__output.obj"
erase "__scpi__output.obj"