File size: 4,610 Bytes
caa8075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
***************************************************************
******* ESLR:Ag-Census-Plot-Level Outcomes-Extensions **********
****************************************************************

capture log close
clear
set matsize 3000
set more off


*********************
*** Load the Data ***
*********************

use "Data/censo_ag_wreform.dta", clear 

**********************
*** Label the Data ***
**********************

** Label Variables for the output:
label variable ln_agprod_pricew_crops "Agricultural Productivity (ln($/ha))"
label variable CashCrop_Share "Share of Property for Cash Crops"
label variable StapleCrop_Share "Share of Property for Staple Crops"
label variable norm_dist "Distance to Reform Threshold (ha)"
label variable own_amt "Former Owner's Cumulative Landholdings (ha)"

*********************
*** Set RD Params ***
*********************

** Baseline: Will use local linear rd with MSE optimal bandwidth
** with ses clustered at propietor level. 

local polynomial_level 1
local bandwidth_choice "mserd" 
local kernel_choice "tri" 
local cluster_level "Expropretario_ISTA"


**********************
*** CAPITAL STOCKS ***
**********************

* S16A - MDSC - Type of Capital
capture drop S16*
merge 1:1 agg_id using "./Data/censo_ag_investments.dta", gen(cap_merge)

** To Store Results:
global tflist ""
global modseq=0
global modid = 1

foreach dep_var of varlist S16A* {
	dis "`dep_var'"
	clear matrix
	** Coef Plots of Capital Stocks
	global modseq=$modseq+1
	tempfile tf$modseq 
	** Run RD: (Indicator on Prob. of Having Particular Capital Unit:
	capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level')  bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') 
	** Store Results:
	capture parmest, label idn($modseq)  idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
}

preserve
dsconcat $tflist
sort idnum
outsheet using "./Output/Temp/CapitalStocks.csv", replace comma 
restore


**********************
*** INPUT MEASURES ***
**********************

* S15B - MDSC - Type of Input
capture drop S15*
merge 1:1 agg_id using "./Data/censo_ag_inputs.dta", gen(S15B_merge)
** To Store Results:
global tflist ""
global modseq=0
global modid = 1


foreach dep_var of varlist S15B* {
	dis "`dep_var'"
	clear matrix
	** For Coef Plots:
	global modseq=$modseq+1
	tempfile tf$modseq 
	** Run RD: (Indicator on Prob. of Having Used Particular Input:
	capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level')  bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') 
	** Store Results:
	capture parmest, label idn($modseq)  idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
}

preserve
dsconcat $tflist
sort idnum
outsheet using "./Output/Temp/InputUse.csv", replace comma 
restore
drop S15B*


********************************************************************************
******************************** OTHER PRODUCTS ********************************
********************************************************************************
	
* S5B - MDSC - Minor Crops - Vegetables:
merge 1:1 agg_id using "./Data/censo_ag_minorcrops.dta", gen(S5B_merge)

** INDICATORS:
** To Store Results:
global tflist ""
global modseq=0
global modid = 1

foreach dep_var of varlist S5B* {
	dis "`dep_var'"
	clear matrix
	** For Coef Plots:
	global modseq=$modseq+1
	tempfile tf$modseq 
	** Run RD: (Indicator on Prob. of Prod a Minor Crop:
	capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level')  bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') 
	** Store Results:
	capture parmest, label idn($modseq)  idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist) 
}

preserve
dsconcat $tflist
sort idnum
outsheet using "./Output/Temp/MinorCropProduction.csv", replace comma 
restore

	
* S5B - MDSC - Minor Crops - Fruits:
merge 1:1 agg_id using "./Data/censo_ag_minorfruits.dta", gen(S8B_merge)

** INDICATORS:
** To Store Results:
global tflist ""
global modseq=0
global modid = 1

foreach dep_var of varlist S8B* {
	dis "`dep_var'"
	clear matrix
	** For Coef Plots:
	global modseq=$modseq+1
	tempfile tf$modseq 
	** Run RD: (Indicator on Prob. of Prod a Minor Crop:
	capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level')  bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') 
	** Store Results:
	capture parmest, label idn($modseq)  idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist) 
}

preserve
dsconcat $tflist
sort idnum
outsheet using "./Output/Temp/MinorFruitProduction.csv", replace comma 
restore