ltc-code 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ltc_code-0.2.0 → ltc_code-0.2.1}/PKG-INFO +1 -1
- {ltc_code-0.2.0 → ltc_code-0.2.1}/pyproject.toml +1 -1
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/BALANCE.do +123 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/FS.do +129 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/ITT.do +123 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/TOT.do +123 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/apps_helpers.py +2932 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/harmony.py +402 -0
- ltc_code-0.2.1/src/ltc_code/20260706_ceprscripts/main.py +629 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/README.md +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/.DS_Store +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/aspire.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/check_cmo_apps.do +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/christel_house.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/democracy_prep.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/green_dot.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/helpers.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/ilt.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/kipp_nj.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/main.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/mappings.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/rocketship.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260614_new_build_scripts_update/yes_prep.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/aspire.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/christel_house.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/democracy_prep.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/green_dot.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/ilt.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/kipp.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/kipp_nj.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/rocketship.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/20260630_census_disclosure/yes_prep.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/__init__.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/aspire.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/check_cmo_apps.do +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/christel_house.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/green_dot.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/helpers.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/june13.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/june2.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/june30.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/june5.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/june7.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/kipp_nj.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/kipp_tx.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/main.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/mappings.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/may27.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/polars_dates.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/rocketship.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/schema_mapping.py +0 -0
- {ltc_code-0.2.0 → ltc_code-0.2.1}/src/ltc_code/yes_prep.py +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
use "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\cmo_analysis.dta", clear
|
|
2
|
+
cap postclose handle
|
|
3
|
+
clear matrix
|
|
4
|
+
scalar drop _all
|
|
5
|
+
|
|
6
|
+
* Generate numeric cohort
|
|
7
|
+
destring cohort_lottery, gen(cohort_numeric)
|
|
8
|
+
|
|
9
|
+
* Create tempfile to store results
|
|
10
|
+
tempfile results
|
|
11
|
+
postfile handle str50 sample str30 depvar str30 instrument double coef double se double N_obs double N_ppl double control_mean double N_ppl_control using `results', replace
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Store local for depvars and indep vars
|
|
15
|
+
local depvars p_his
|
|
16
|
+
local instruments offer initial_offer
|
|
17
|
+
|
|
18
|
+
* Overall and CMO specific samples
|
|
19
|
+
levelsof cmo_name, local(cmos)
|
|
20
|
+
|
|
21
|
+
local cmo_census
|
|
22
|
+
foreach c of local cmos {
|
|
23
|
+
local cmo_census `"`cmo_census' "`c' (1990-2005)""'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" `cmos' `cmo_census' "'
|
|
27
|
+
* local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" "'
|
|
28
|
+
*local samples `" `cmo_census' "'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
foreach s of local samples {
|
|
32
|
+
foreach dep of local depvars {
|
|
33
|
+
foreach z of local instruments {
|
|
34
|
+
preserve
|
|
35
|
+
|
|
36
|
+
di "SAMPLE: `s'"
|
|
37
|
+
di "INSTRUMENT: `z'"
|
|
38
|
+
di "DEPVAR: `dep'"
|
|
39
|
+
|
|
40
|
+
* Filter to relevant sample
|
|
41
|
+
if "`s'" == "No Harmony" {
|
|
42
|
+
drop if cmo_name == "Harmony"
|
|
43
|
+
}
|
|
44
|
+
else if "`s'" == "Census Sample" {
|
|
45
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
46
|
+
drop if cmo_name == "Harmony"
|
|
47
|
+
}
|
|
48
|
+
else if "`s'" == "KIPP Sample" {
|
|
49
|
+
keep if inrange(cohort_numeric, 1990, 2003)
|
|
50
|
+
keep if inlist(cmo_name, "KIPP_NJ", "KIPP TX", "KIPP NC", "KIPP MA")
|
|
51
|
+
}
|
|
52
|
+
else if "`s'" == "Overall" {
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
else if strpos("`s'", " (1990-2005)") {
|
|
56
|
+
keep if cmo_name == subinstr("`s'", " (1990-2005)", "", .)
|
|
57
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
keep if cmo_name == "`s'"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
* Require all non missing regression vars
|
|
65
|
+
drop if mi(`dep') | mi(`z') | mi(cmo_name) | mi(risk_id_name) | mi(sid_cepr)
|
|
66
|
+
|
|
67
|
+
* Drop risk sets with no offer variation
|
|
68
|
+
bys risk_id_name: egen min_z = min(`z')
|
|
69
|
+
bys risk_id_name: egen max_z = max(`z')
|
|
70
|
+
keep if min_z != max_z
|
|
71
|
+
drop min_z max_z
|
|
72
|
+
count
|
|
73
|
+
di "N Remaining: `r(N)'"
|
|
74
|
+
|
|
75
|
+
if `r(N)' == 0 {
|
|
76
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
77
|
+
restore
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
* Generate weights
|
|
82
|
+
bys sid_cepr: gen ww = _N
|
|
83
|
+
gen w = 1/ww
|
|
84
|
+
|
|
85
|
+
cap areg `dep' `z' [aw=w], a(risk_id_name) cluster(sid_cepr)
|
|
86
|
+
|
|
87
|
+
* If insufficient obs post this
|
|
88
|
+
if _rc{
|
|
89
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
90
|
+
restore
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
di _b[`z']
|
|
95
|
+
|
|
96
|
+
* Store the coefficient, se, and N
|
|
97
|
+
scalar coef = _b[`z']
|
|
98
|
+
scalar se_store = _se[`z']
|
|
99
|
+
scalar N_obs = e(N)
|
|
100
|
+
|
|
101
|
+
egen tag = tag(sid_cepr) if e(sample)
|
|
102
|
+
qui count if tag
|
|
103
|
+
scalar N_ppl = r(N)
|
|
104
|
+
qui su `dep' [aw=w] if `z' == 0 & e(sample)
|
|
105
|
+
scalar control_mean = r(mean)
|
|
106
|
+
egen tag2 = tag(sid_cepr) if offer == 0 & e(sample)
|
|
107
|
+
qui count if tag2
|
|
108
|
+
scalar N_ppl_control = r(N)
|
|
109
|
+
|
|
110
|
+
post handle ("`s'") ("`dep'") ("`z'") (coef) (se_store) (N_obs) (N_ppl) (control_mean) (N_ppl_control)
|
|
111
|
+
|
|
112
|
+
restore
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
postclose handle
|
|
118
|
+
|
|
119
|
+
use `results', clear
|
|
120
|
+
sort instrument sample depvar
|
|
121
|
+
order sample instrument depvar
|
|
122
|
+
|
|
123
|
+
save "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\BALANCE\balance.dta", replace
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
use "P:\Long_Term_Charter\data\clean\new_build\cmo_apps\stata_collapsed\cmo_apps_sid.dta", clear
|
|
2
|
+
cap postclose handle
|
|
3
|
+
clear matrix
|
|
4
|
+
scalar drop _all
|
|
5
|
+
|
|
6
|
+
* Generate numeric cohort
|
|
7
|
+
destring cohort_lottery, gen(cohort_numeric)
|
|
8
|
+
|
|
9
|
+
* Create tempfile to store results
|
|
10
|
+
tempfile results
|
|
11
|
+
postfile handle str50 sample str30 depvar str30 instrument double coef double se double N_obs double N_ppl double control_mean double N_ppl_control using `results', replace
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Store local for depvars and indep vars
|
|
15
|
+
local depvars enroll enrollment_years
|
|
16
|
+
local instruments offer initial_offer
|
|
17
|
+
|
|
18
|
+
* Overall and CMO specific samples
|
|
19
|
+
levelsof cmo_name, local(cmos)
|
|
20
|
+
|
|
21
|
+
local cmo_census
|
|
22
|
+
foreach c of local cmos {
|
|
23
|
+
local cmo_census `"`cmo_census' "`c' (1990-2005)""'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" `cmos' `cmo_census' "'
|
|
27
|
+
* local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" "'
|
|
28
|
+
*local samples `" `cmo_census' "'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
foreach s of local samples {
|
|
33
|
+
foreach dep of local depvars {
|
|
34
|
+
foreach z of local instruments {
|
|
35
|
+
preserve
|
|
36
|
+
|
|
37
|
+
di "SAMPLE: `s'"
|
|
38
|
+
di "INSTRUMENT: `z'"
|
|
39
|
+
di "DEPVAR: `dep'"
|
|
40
|
+
|
|
41
|
+
* Filter to relevant sample
|
|
42
|
+
if "`s'" == "No Harmony" {
|
|
43
|
+
drop if cmo_name == "Harmony"
|
|
44
|
+
}
|
|
45
|
+
else if "`s'" == "Census Sample" {
|
|
46
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
47
|
+
drop if cmo_name == "Harmony"
|
|
48
|
+
}
|
|
49
|
+
else if "`s'" == "KIPP Sample" {
|
|
50
|
+
keep if inrange(cohort_numeric, 1990, 2003)
|
|
51
|
+
keep if inlist(cmo_name, "KIPP_NJ", "KIPP TX", "KIPP NC", "KIPP MA")
|
|
52
|
+
}
|
|
53
|
+
else if "`s'" == "Overall" {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
else if strpos("`s'", " (1990-2005)") {
|
|
57
|
+
keep if cmo_name == subinstr("`s'", " (1990-2005)", "", .)
|
|
58
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
keep if cmo_name == "`s'"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
* Require all non missing regression vars
|
|
65
|
+
drop if mi(`dep') | mi(`z') | mi(cmo_name) | mi(risk_set) | mi(sid_cepr)
|
|
66
|
+
count
|
|
67
|
+
if `r(N)' == 0 {
|
|
68
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
69
|
+
restore
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
* Drop risk sets with no offer variation
|
|
74
|
+
bys risk_set: egen min_z = min(`z')
|
|
75
|
+
bys risk_set: egen max_z = max(`z')
|
|
76
|
+
keep if min_z != max_z
|
|
77
|
+
drop min_z max_z
|
|
78
|
+
count
|
|
79
|
+
di "N Remaining: `r(N)'"
|
|
80
|
+
|
|
81
|
+
if `r(N)' == 0 {
|
|
82
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
83
|
+
restore
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
* Generate weights
|
|
88
|
+
bys sid_cepr: gen ww = _N
|
|
89
|
+
gen w = 1/ww
|
|
90
|
+
|
|
91
|
+
cap areg `dep' `z' [aw=w], a(risk_set) vce(robust)
|
|
92
|
+
|
|
93
|
+
* If insufficient obs post this
|
|
94
|
+
if _rc{
|
|
95
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
96
|
+
restore
|
|
97
|
+
continue
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
di _b[`z']
|
|
101
|
+
|
|
102
|
+
* Store the coefficient, se, and N
|
|
103
|
+
scalar coef = _b[`z']
|
|
104
|
+
scalar se_store = _se[`z']
|
|
105
|
+
scalar N_obs = e(N)
|
|
106
|
+
|
|
107
|
+
egen tag = tag(sid_cepr) if e(sample)
|
|
108
|
+
qui count if tag
|
|
109
|
+
scalar N_ppl = r(N)
|
|
110
|
+
qui su `dep' [aw=w] if `z' == 0 & e(sample)
|
|
111
|
+
scalar control_mean = r(mean)
|
|
112
|
+
egen tag2 = tag(sid_cepr) if offer == 0 & e(sample)
|
|
113
|
+
qui count if tag2
|
|
114
|
+
scalar N_ppl_control = r(N)
|
|
115
|
+
|
|
116
|
+
post handle ("`s'") ("`dep'") ("`z'") (coef) (se_store) (N_obs) (N_ppl) (control_mean) (N_ppl_control)
|
|
117
|
+
|
|
118
|
+
restore
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
postclose handle
|
|
124
|
+
|
|
125
|
+
use `results', clear
|
|
126
|
+
sort instrument sample depvar
|
|
127
|
+
order sample instrument depvar
|
|
128
|
+
|
|
129
|
+
save "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\FS\FS.dta", replace
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
use "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\cmo_analysis.dta", clear
|
|
2
|
+
cap postclose handle
|
|
3
|
+
clear matrix
|
|
4
|
+
scalar drop _all
|
|
5
|
+
|
|
6
|
+
* Generate numeric cohort
|
|
7
|
+
destring cohort_lottery, gen(cohort_numeric)
|
|
8
|
+
|
|
9
|
+
* Create tempfile to store results
|
|
10
|
+
tempfile results
|
|
11
|
+
postfile handle str50 sample str30 depvar str30 instrument double coef double se double N_obs double N_ppl double control_mean double N_ppl_control using `results', replace
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Store local for depvars and indep vars
|
|
15
|
+
local depvars att_2yr_byY2 att_4yr_byY2 att_any_byY2
|
|
16
|
+
*cmp_AA_byY6 cmp_BA_byY6 cmp_any_byY6
|
|
17
|
+
local instruments offer initial_offer
|
|
18
|
+
|
|
19
|
+
* Overall and CMO specific samples
|
|
20
|
+
levelsof cmo_name, local(cmos)
|
|
21
|
+
|
|
22
|
+
local cmo_census
|
|
23
|
+
foreach c of local cmos {
|
|
24
|
+
local cmo_census `"`cmo_census' "`c' (1990-2005)""'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" `cmos' `cmo_census' "'
|
|
28
|
+
* local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" "'
|
|
29
|
+
*local samples `" `cmo_census' "'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
foreach s of local samples {
|
|
33
|
+
foreach dep of local depvars {
|
|
34
|
+
foreach z of local instruments {
|
|
35
|
+
preserve
|
|
36
|
+
|
|
37
|
+
di "SAMPLE: `s'"
|
|
38
|
+
di "INSTRUMENT: `z'"
|
|
39
|
+
di "DEPVAR: `dep'"
|
|
40
|
+
|
|
41
|
+
* Filter to relevant sample
|
|
42
|
+
if "`s'" == "No Harmony" {
|
|
43
|
+
drop if cmo_name == "Harmony"
|
|
44
|
+
}
|
|
45
|
+
else if "`s'" == "Census Sample" {
|
|
46
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
47
|
+
drop if cmo_name == "Harmony"
|
|
48
|
+
}
|
|
49
|
+
else if "`s'" == "KIPP Sample" {
|
|
50
|
+
keep if inrange(cohort_numeric, 1990, 2003)
|
|
51
|
+
keep if inlist(cmo_name, "KIPP_NJ", "KIPP TX", "KIPP NC", "KIPP MA")
|
|
52
|
+
}
|
|
53
|
+
else if "`s'" == "Overall" {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
else if strpos("`s'", " (1990-2005)") {
|
|
57
|
+
keep if cmo_name == subinstr("`s'", " (1990-2005)", "", .)
|
|
58
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
keep if cmo_name == "`s'"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
* Require all non missing regression vars
|
|
65
|
+
drop if mi(`dep') | mi(`z') | mi(cmo_name) | mi(risk_id_name) | mi(sid_cepr)
|
|
66
|
+
|
|
67
|
+
* Drop risk sets with no offer variation
|
|
68
|
+
bys risk_id_name: egen min_z = min(`z')
|
|
69
|
+
bys risk_id_name: egen max_z = max(`z')
|
|
70
|
+
keep if min_z != max_z
|
|
71
|
+
drop min_z max_z
|
|
72
|
+
count
|
|
73
|
+
di "N Remaining: `r(N)'"
|
|
74
|
+
|
|
75
|
+
if `r(N)' == 0 {
|
|
76
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
77
|
+
restore
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
* Generate weights
|
|
82
|
+
bys sid_cepr: gen ww = _N
|
|
83
|
+
gen w = 1/ww
|
|
84
|
+
|
|
85
|
+
cap areg `dep' `z' [aw=w], a(risk_id_name) cluster(sid_cepr)
|
|
86
|
+
|
|
87
|
+
* If insufficient obs post this
|
|
88
|
+
if _rc{
|
|
89
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
90
|
+
restore
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
di _b[`z']
|
|
95
|
+
|
|
96
|
+
* Store the coefficient, se, and N
|
|
97
|
+
scalar coef = _b[`z']
|
|
98
|
+
scalar se_store = _se[`z']
|
|
99
|
+
scalar N_obs = e(N)
|
|
100
|
+
|
|
101
|
+
egen tag = tag(sid_cepr) if e(sample)
|
|
102
|
+
qui count if tag
|
|
103
|
+
scalar N_ppl = r(N)
|
|
104
|
+
qui su `dep' [aw=w] if `z' == 0 & e(sample)
|
|
105
|
+
scalar control_mean = r(mean)
|
|
106
|
+
egen tag2 = tag(sid_cepr) if offer == 0 & e(sample)
|
|
107
|
+
qui count if tag2
|
|
108
|
+
scalar N_ppl_control = r(N)
|
|
109
|
+
|
|
110
|
+
post handle ("`s'") ("`dep'") ("`z'") (coef) (se_store) (N_obs) (N_ppl) (control_mean) (N_ppl_control)
|
|
111
|
+
|
|
112
|
+
restore
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
postclose handle
|
|
118
|
+
|
|
119
|
+
use `results', clear
|
|
120
|
+
sort instrument sample depvar
|
|
121
|
+
order sample instrument depvar
|
|
122
|
+
|
|
123
|
+
save "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\ITT\ITT.dta", replace
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
use "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\cmo_analysis_wide.dta", clear
|
|
2
|
+
cap postclose handle
|
|
3
|
+
clear matrix
|
|
4
|
+
scalar drop _all
|
|
5
|
+
|
|
6
|
+
* Generate numeric cohort
|
|
7
|
+
destring cohort_lottery, gen(cohort_numeric)
|
|
8
|
+
|
|
9
|
+
* Create tempfile to store results
|
|
10
|
+
tempfile results
|
|
11
|
+
postfile handle str50 sample str30 depvar str30 instrument double coef double se double N_obs double N_ppl double control_mean double N_ppl_control using `results', replace
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Store local for depvars and indep vars
|
|
15
|
+
local depvars att_2yr_byY2 att_4yr_byY2 att_any_byY2
|
|
16
|
+
*cmp_AA_byY6 cmp_BA_byY6 cmp_any_byY6
|
|
17
|
+
local instruments offer initial_offer
|
|
18
|
+
|
|
19
|
+
* Overall and CMO specific samples
|
|
20
|
+
levelsof cmo_name, local(cmos)
|
|
21
|
+
|
|
22
|
+
local cmo_census
|
|
23
|
+
foreach c of local cmos {
|
|
24
|
+
local cmo_census `"`cmo_census' "`c' (1990-2005)""'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" `cmos' `cmo_census' "'
|
|
28
|
+
* local samples `" "No Harmony" "Overall" "Census Sample" "KIPP Sample" "'
|
|
29
|
+
*local samples `" `cmo_census' "'
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
foreach s of local samples {
|
|
33
|
+
foreach dep of local depvars {
|
|
34
|
+
foreach z of local instruments {
|
|
35
|
+
preserve
|
|
36
|
+
|
|
37
|
+
di "SAMPLE: `s'"
|
|
38
|
+
di "INSTRUMENT: `z'"
|
|
39
|
+
di "DEPVAR: `dep'"
|
|
40
|
+
|
|
41
|
+
* Filter to relevant sample
|
|
42
|
+
if "`s'" == "No Harmony" {
|
|
43
|
+
drop if cmo_name == "Harmony"
|
|
44
|
+
}
|
|
45
|
+
else if "`s'" == "Census Sample" {
|
|
46
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
47
|
+
drop if cmo_name == "Harmony"
|
|
48
|
+
}
|
|
49
|
+
else if "`s'" == "KIPP Sample" {
|
|
50
|
+
keep if inrange(cohort_numeric, 1990, 2003)
|
|
51
|
+
keep if inlist(cmo_name, "KIPP_NJ", "KIPP TX", "KIPP NC", "KIPP MA")
|
|
52
|
+
}
|
|
53
|
+
else if "`s'" == "Overall" {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
else if strpos("`s'", " (1990-2005)") {
|
|
57
|
+
keep if cmo_name == subinstr("`s'", " (1990-2005)", "", .)
|
|
58
|
+
keep if inrange(cohort_numeric, 1990, 2005)
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
keep if cmo_name == "`s'"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
* Require all non missing regression vars
|
|
65
|
+
drop if mi(`dep') | mi(`z') | mi(cmo_name) | mi(risk_set) | mi(sid_cepr)
|
|
66
|
+
|
|
67
|
+
* Drop risk sets with no offer variation
|
|
68
|
+
bys risk_set: egen min_z = min(`z')
|
|
69
|
+
bys risk_set: egen max_z = max(`z')
|
|
70
|
+
keep if min_z != max_z
|
|
71
|
+
drop min_z max_z
|
|
72
|
+
count
|
|
73
|
+
di "N Remaining: `r(N)'"
|
|
74
|
+
|
|
75
|
+
if `r(N)' == 0 {
|
|
76
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
77
|
+
restore
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
* Generate weights
|
|
82
|
+
bys sid_cepr: gen ww = _N
|
|
83
|
+
gen w = 1/ww
|
|
84
|
+
|
|
85
|
+
cap ivreghdfe `dep' (enroll = `z') [aw=w], a(risk_set) robust
|
|
86
|
+
|
|
87
|
+
* If insufficient obs post this
|
|
88
|
+
if _rc{
|
|
89
|
+
post handle ("`s'") ("`dep'") ("`z'") (.) (.) (0) (.) (.) (.)
|
|
90
|
+
restore
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
di _b[enroll]
|
|
95
|
+
|
|
96
|
+
* Store the coefficient, se, and N
|
|
97
|
+
scalar coef = _b[enroll]
|
|
98
|
+
scalar se_store = _se[enroll]
|
|
99
|
+
scalar N_obs = e(N)
|
|
100
|
+
|
|
101
|
+
egen tag = tag(sid_cepr) if e(sample)
|
|
102
|
+
qui count if tag
|
|
103
|
+
scalar N_ppl = r(N)
|
|
104
|
+
qui su enroll [aw=w] if enroll == 0 & e(sample)
|
|
105
|
+
scalar control_mean = r(mean)
|
|
106
|
+
egen tag2 = tag(sid_cepr) if offer == 0 & e(sample)
|
|
107
|
+
qui count if tag2
|
|
108
|
+
scalar N_ppl_control = r(N)
|
|
109
|
+
|
|
110
|
+
post handle ("`s'") ("`dep'") ("`z'") (coef) (se_store) (N_obs) (N_ppl) (control_mean) (N_ppl_control)
|
|
111
|
+
|
|
112
|
+
restore
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
postclose handle
|
|
118
|
+
|
|
119
|
+
use `results', clear
|
|
120
|
+
sort instrument sample depvar
|
|
121
|
+
order sample instrument depvar
|
|
122
|
+
|
|
123
|
+
save "P:\Long_Term_Charter\data\clean\new_build\cmo_analysis\TOT\TOT.dta", replace
|