-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathppsynth_quicktest.do
More file actions
28 lines (28 loc) · 985 Bytes
/
Copy pathppsynth_quicktest.do
File metadata and controls
28 lines (28 loc) · 985 Bytes
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
* ppsynth_quicktest.do — 30-second smoke test on a simulated panel
* No data file needed. For the real worked example on the German
* reunification application from the paper, see ppsynth_example.do.
clear all
set seed 42
local N = 21 // 1 treated + 20 donors
local T = 23 // 15 pre + 8 post
set obs `=`N'*`T''
gen id = ceil(_n/`T')
bysort id: gen year = 2000 + _n
* two latent factors, loadings correlated across outcomes
gen f1 = rnormal()
gen f2 = rnormal()
bysort year (id): replace f1 = f1[1]
bysort year (id): replace f2 = f2[1]
gen l1 = runiform()
gen l2 = runiform()
bysort id (year): replace l1 = l1[1]
bysort id (year): replace l2 = l2[1]
* four outcomes sharing loadings up to noise
forvalues k = 1/4 {
gen y`k' = l1*f1 + l2*f2 + 0.35*runiform()*f1 + rnormal(0, .5)
}
* run: unit 1 treated from year 2016
ppsynth y1 y2 y3 y4, trunit(1) trperiod(2016) id(id) time(year)
matrix list r(gamma)
matrix list r(tau)
display "selected lambda = " r(lambda)