Commit
·
91d0f84
1
Parent(s):
128a234
add 14
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- 14/paper.pdf +3 -0
- 14/replication_package/README.pdf +3 -0
- 14/replication_package/Replication/Code/ESLR_AgHeterogeneity.do +156 -0
- 14/replication_package/Replication/Code/ESLR_Analysis_EHPM.do +113 -0
- 14/replication_package/Replication/Code/ESLR_Analysis_IVCenso.do +224 -0
- 14/replication_package/Replication/Code/ESLR_Analysis_IVCenso_Credit.do +110 -0
- 14/replication_package/Replication/Code/ESLR_Analysis_IVCenso_Other.do +163 -0
- 14/replication_package/Replication/Code/ESLR_Balance_PropLevel.R +503 -0
- 14/replication_package/Replication/Code/ESLR_CensusMigration.R +252 -0
- 14/replication_package/Replication/Code/ESLR_Digits.R +239 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_Consumption.do +54 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_Educ.do +49 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_Mig.do +32 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_PGs.do +52 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_PGsCoefPlot.R +89 -0
- 14/replication_package/Replication/Code/ESLR_EHPM_Sensitivity.do +60 -0
- 14/replication_package/Replication/Code/ESLR_ESMap.R +64 -0
- 14/replication_package/Replication/Code/ESLR_IVCenso_Commercialization.do +77 -0
- 14/replication_package/Replication/Code/ESLR_IVCenso_RDRandInf.do +254 -0
- 14/replication_package/Replication/Code/ESLR_IVCenso_RDRobustness.do +192 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_AdditionalPlots.R +406 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_Controls.R +675 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_HetPlots.R +570 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_Matching.R +580 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_NonComplierPlot.R +112 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_Power.do +43 -0
- 14/replication_package/Replication/Code/ESLR_IVCensus_RDRobustnessPlots.R +386 -0
- 14/replication_package/Replication/Code/ESLR_LatAmMaps.R +174 -0
- 14/replication_package/Replication/Code/ESLR_Master.do +136 -0
- 14/replication_package/Replication/Code/ESLR_Prop_SummStats.do +105 -0
- 14/replication_package/Replication/Code/ESLR_RDPlots_AgCensus.do +174 -0
- 14/replication_package/Replication/Code/ESLR_RDPlots_NonShares.do +180 -0
- 14/replication_package/Replication/Code/ESLR_RDPlots_PropData.do +87 -0
- 14/replication_package/Replication/Code/ESLR_RDPlots_PropDataModern_Existence.do +142 -0
- 14/replication_package/Replication/Code/ESLR_RScripts.R +115 -0
- 14/replication_package/Replication/Code/ESLR_Robustness_Existence.R +156 -0
- 14/replication_package/Replication/Code/ESLR_TemporalEV.R +360 -0
- 14/replication_package/Replication/Code/ESLR_Unbalancedness.R +976 -0
- 14/replication_package/Replication/Code/ESLR_YieldsSampleSelection.R +294 -0
- 14/replication_package/Replication/Data/Codigos.csv +3 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.dbf +3 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.prj +1 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.sbn +0 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.sbx +0 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shp +3 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shp.xml +368 -0
- 14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shx +0 -0
- 14/replication_package/Replication/Data/LR_reform_existence.dta +3 -0
- 14/replication_package/Replication/Data/Prices/Consejo Salvadoreno del Cafe/PRECIOS PAGADOS A LOS CAFICULTORES DOLARES POR 46 KILOGRAMOS DE CAFe.csv +3 -0
- 14/replication_package/Replication/Data/Prices/Consejo Salvadoreno del Cafe/precio pagado productor 30 abril 2017.pdf +3 -0
14/paper.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eecb922a14e4dd33fda0401aead2d84ae64a8974009a689105096abc05f6eb64
|
3 |
+
size 1234554
|
14/replication_package/README.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:883d4adc6ee2d7559069cd993cb2e400fd5cfe0c7013d9f2aa4c949ff6e0b68b
|
3 |
+
size 144878
|
14/replication_package/Replication/Code/ESLR_AgHeterogeneity.do
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
********************************************************************************
|
2 |
+
******************************** HETEROGENEITY *********************************
|
3 |
+
********************************************************************************
|
4 |
+
|
5 |
+
use "/Users/eduardomontero/Dropbox/Research_ElSalvador_LandReform/R/Output/ag_census_wSegmCens_all.dta", clear
|
6 |
+
destring Expropretario_ISTA, replace
|
7 |
+
replace Expropretario_ISTA = agg_id if Expropretario_ISTA==.
|
8 |
+
|
9 |
+
gen mean_med = age_mean- age_median
|
10 |
+
keep age_iqr mean_med Above500 ln_agprod ln_agprod_pricew_crops CashCrop_Share StapleCrop_Share norm_dist own_amt Expropretario_ISTA reform
|
11 |
+
|
12 |
+
**********************
|
13 |
+
*** Label the Data ***
|
14 |
+
**********************
|
15 |
+
|
16 |
+
** Label Variables for the output:
|
17 |
+
label variable ln_agprod_pricew_crops "Agricultural Revenues (ln($/ha))"
|
18 |
+
label variable ln_agprod "Agriculural Profits (ln($/ha))"
|
19 |
+
label variable CashCrop_Share "Share of Property for Cash Crops"
|
20 |
+
label variable StapleCrop_Share "Share of Property for Staple Crops"
|
21 |
+
label variable norm_dist "Distance to Reform Threshold (ha)"
|
22 |
+
label variable own_amt "Former Owner's Cumulative Landholdings (ha)"
|
23 |
+
|
24 |
+
*********************
|
25 |
+
*** Set RD Params ***
|
26 |
+
*********************
|
27 |
+
|
28 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
29 |
+
** with ses clustered at propietor level.
|
30 |
+
** Will also use two-sided MSE optimal bandwidth since big diff in density on
|
31 |
+
** both sides.
|
32 |
+
** Will use rdrobust package
|
33 |
+
|
34 |
+
local polynomial_level 1
|
35 |
+
local bandwidth_choice "mserd" // "mserd", "msecomb2" "msetwo"
|
36 |
+
local kernel_choice "tri" // "tri"
|
37 |
+
local cluster_level "Expropretario_ISTA"
|
38 |
+
local bw 100
|
39 |
+
|
40 |
+
*********************************************
|
41 |
+
*** OUTCOME - SEGM CENSALES HETEROGENEITY ***
|
42 |
+
*********************************************
|
43 |
+
|
44 |
+
** AGE Heterogeneity:
|
45 |
+
local het_var age_iqr
|
46 |
+
|
47 |
+
sum `het_var', d
|
48 |
+
local mean_agesd = `r(p50)'
|
49 |
+
dis "`mean_agesd'"
|
50 |
+
replace mean_med =`het_var'
|
51 |
+
|
52 |
+
count if mean_med <`mean_agesd' | reform==0
|
53 |
+
count if mean_med >=`mean_agesd' | reform==0
|
54 |
+
|
55 |
+
gen abovemed_het = 0
|
56 |
+
replace abovemed_het=1 if (mean_med >=`mean_agesd' & mean_med!= .)
|
57 |
+
|
58 |
+
local bw 150
|
59 |
+
gen dis_meas = age_iqr //age_sd age_iqr
|
60 |
+
replace dis_meas=0 if dis_meas==.
|
61 |
+
reg ln_agprod Above500 c.Above500#c.dis_meas norm_dist c.Above500#c.norm_dist if abs(norm_dist) < 150, cluster(Expropretario_ISTA)
|
62 |
+
|
63 |
+
|
64 |
+
rdrobust ln_agprod_pricew_crops norm_dist if (mean_med >=`mean_agesd' & mean_med!= .) | reform==0, c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
65 |
+
* outreg results
|
66 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
67 |
+
local n_clust = `r(ndistinct)'
|
68 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
69 |
+
outreg2 using "Output/Table_SegmCens_AgeHet.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
70 |
+
|
71 |
+
rdrobust ln_agprod_pricew_crops norm_dist if mean_med <`mean_agesd' | reform==0, c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
72 |
+
* outreg results
|
73 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
74 |
+
local n_clust = `r(ndistinct)'
|
75 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
76 |
+
outreg2 using "Output/Table_SegmCens_AgeHet.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
77 |
+
*/
|
78 |
+
|
79 |
+
rdrobust ln_agprod norm_dist if (mean_med >=`mean_agesd' & mean_med!= .) | reform==0, c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
80 |
+
* outreg results
|
81 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
82 |
+
local n_clust = `r(ndistinct)'
|
83 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
84 |
+
outreg2 using "Output/Table_SegmCens_AgeHet.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
85 |
+
|
86 |
+
rdrobust ln_agprod norm_dist if mean_med <`mean_agesd' | reform==0 , c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
87 |
+
* outreg results
|
88 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
89 |
+
local n_clust = `r(ndistinct)'
|
90 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
91 |
+
outreg2 using "Output/Table_SegmCens_AgeHet.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
*** TESTING COEFFICIENTS:
|
96 |
+
* 1 vs. 2:
|
97 |
+
local z = (-.430 - (-0.192))/sqrt(0.326^2 + 0.376^2)
|
98 |
+
dis 2*(1-normal(abs(`z')))
|
99 |
+
|
100 |
+
local z = (-.696 - (-0.255))/sqrt(0.411^2 + 0.504^2)
|
101 |
+
dis 2*(1-normal(abs(`z')))
|
102 |
+
|
103 |
+
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
/*gen group1 = abovemed_het ==1 // | reform==0
|
108 |
+
gen group1_Above500 = group1*Above50
|
109 |
+
|
110 |
+
reg ln_agprod_pricew_crops Above500 group1_Above500 norm_dist c.norm_dist#Above500 i.group1#c.norm_dist i.group1#c.norm_dist#Above500 if abs(norm_dist) < 150, vce(cluster Expropretario_ISTA)
|
111 |
+
lincom _b[Above500] - _b[group1_Above500]
|
112 |
+
|
113 |
+
|
114 |
+
reg ln_agprod Above500 group1_Above500 norm_dist c.norm_dist#Above500 if abs(norm_dist) < 150 , vce(cluster Expropretario_ISTA)
|
115 |
+
lincom _b[Above500] - _b[group1_Above500]*/
|
116 |
+
|
117 |
+
local bw 300
|
118 |
+
rdrobust CashCrop_Share norm_dist if mean_med >=`mean_agesd' | reform==0, c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
119 |
+
* outreg results
|
120 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
121 |
+
local n_clust = `r(ndistinct)'
|
122 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
123 |
+
outreg2 using "Output/Table_SegmCens_AgeHet2.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
124 |
+
|
125 |
+
rdrobust CashCrop_Share norm_dist if mean_med <`mean_agesd' | reform==0 , c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
126 |
+
* outreg results
|
127 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
128 |
+
local n_clust = `r(ndistinct)'
|
129 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
130 |
+
outreg2 using "Output/Table_SegmCens_AgeHet2.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
131 |
+
|
132 |
+
|
133 |
+
rdrobust StapleCrop_Share norm_dist if mean_med >=`mean_agesd' | reform==0, c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
134 |
+
* outreg results
|
135 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
136 |
+
local n_clust = `r(ndistinct)'
|
137 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
138 |
+
outreg2 using "Output/Table_SegmCens_AgeHet2.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
139 |
+
|
140 |
+
rdrobust StapleCrop_Share norm_dist if mean_med <`mean_agesd' | reform==0 , c(0) p(`polynomial_level') h(`bw' `bw') kernel(`kernel_choice') vce(cluster `cluster_level')
|
141 |
+
* outreg results
|
142 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
143 |
+
local n_clust = `r(ndistinct)'
|
144 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
145 |
+
outreg2 using "Output/Table_SegmCens_AgeHet2.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
146 |
+
*/
|
147 |
+
|
148 |
+
|
149 |
+
** Crop ones
|
150 |
+
* 1 vs. 2:
|
151 |
+
local z = (-0.493 - (-0.571))/sqrt(0.139^2 + 0.132^2)
|
152 |
+
dis 2*(1-normal(abs(`z')))
|
153 |
+
|
154 |
+
local z = (0.150 - (0.344))/sqrt(0.168^2 + 0.190^2)
|
155 |
+
dis 2*(1-normal(abs(`z')))
|
156 |
+
|
14/replication_package/Replication/Code/ESLR_Analysis_EHPM.do
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: EHPM Outcomes - RD Analysis - HH Survey ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
** Set Workspace **
|
11 |
+
cd /Users/`c(username)'/Dropbox/Research_ElSalvador_LandReform/Replication/
|
12 |
+
|
13 |
+
*********************
|
14 |
+
*** Load the Data ***
|
15 |
+
*********************
|
16 |
+
|
17 |
+
use "./Data/ehpm_incomemodule_wreform.dta", clear
|
18 |
+
|
19 |
+
capture drop ln_hh_inc_pc hh_inc_pc_real ln_hh_inc_pc_real
|
20 |
+
gen ln_hh_inc_pc = log(hh_income_pc)
|
21 |
+
gen hh_inc_pc_real = (year==2000)*hh_income_pc*71.57/100 + ///
|
22 |
+
(year==2001)*hh_income_pc*74.25/100 + (year==2004)*hh_income_pc*80.68/100 + ///
|
23 |
+
(year==2005)*hh_income_pc*84.47/100 + (year==2006)*hh_income_pc*87.88/100 + ///
|
24 |
+
(year==2007)*hh_income_pc*91.90/100 + (year==2008)*hh_income_pc*98.06/100 + ///
|
25 |
+
(year==2009)*hh_income_pc*99.10/100 + (year==2011)*hh_income_pc*105.13/100 + ///
|
26 |
+
(year==2012)*hh_income_pc*106.95/100 + (year==2013)*hh_income_pc*107.79/100
|
27 |
+
gen ln_hh_inc_pc_real = log(hh_inc_pc_real )
|
28 |
+
|
29 |
+
*********************
|
30 |
+
*** Set RD Params ***
|
31 |
+
*********************
|
32 |
+
|
33 |
+
** Baseline: Will use local linear rd with manual bandwidth (due to sample size)
|
34 |
+
** with ses clustered at propietor level.
|
35 |
+
** Will use rdrobust package
|
36 |
+
|
37 |
+
local polynomial_level 1
|
38 |
+
local cluster_level "Expropretario_ISTA"
|
39 |
+
|
40 |
+
|
41 |
+
****************************************
|
42 |
+
*** OUTCOME 1a - HH INCOME PC LEVELS ***
|
43 |
+
****************************************
|
44 |
+
|
45 |
+
** Avg HH per capita income:
|
46 |
+
|
47 |
+
local bwidth = 300
|
48 |
+
|
49 |
+
|
50 |
+
local bwidth = 300
|
51 |
+
reg hh_inc_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* sex age age2 if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
52 |
+
sum hh_income_pc if abs(norm_dist)<`bwidth'
|
53 |
+
|
54 |
+
outreg2 using "./Output/Table_Earnings.tex", replace se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
55 |
+
|
56 |
+
local bwidth = 150
|
57 |
+
reg hh_inc_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* sex age age2 if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
58 |
+
sum hh_income_pc if abs(norm_dist)<`bwidth'
|
59 |
+
outreg2 using "./Output/Table_Earnings.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
*******************************************
|
67 |
+
*** OUTCOME 1b - WAGE INCOME COMPRESSION ***
|
68 |
+
*******************************************
|
69 |
+
|
70 |
+
** IQR:
|
71 |
+
** Reg:
|
72 |
+
|
73 |
+
preserve
|
74 |
+
|
75 |
+
collapse (iqr) hh_income_pc hh_inc_pc_real (mean) norm_dist Above500, by(match_id Expropretario_ISTA i_year*) cw
|
76 |
+
local bwidth =300
|
77 |
+
|
78 |
+
reg hh_inc_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
79 |
+
sum hh_income_pc if abs(norm_dist)<`bwidth'
|
80 |
+
outreg2 using "./Output/Table_Earnings.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
81 |
+
|
82 |
+
local bwidth = 150
|
83 |
+
|
84 |
+
reg hh_inc_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
85 |
+
sum hh_income_pc if abs(norm_dist)<`bwidth'
|
86 |
+
outreg2 using "./Output/Table_Earnings.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
87 |
+
|
88 |
+
restore
|
89 |
+
|
90 |
+
|
91 |
+
****************************************
|
92 |
+
*** QUANTILE REGRESSION COEFFICIENT PLOT
|
93 |
+
****************************************
|
94 |
+
|
95 |
+
gen Above500_QPlot = Above500
|
96 |
+
label var Above500_QPlot "Quantile Estimates for: Above 500 (ha)"
|
97 |
+
|
98 |
+
drop if num_members < 5
|
99 |
+
local bwidth =150
|
100 |
+
bsqreg ln_hh_inc_pc_real Above500_QPlot norm_dist norm_dist_Above i_year1-i_year8 i_year10-i_year11 if abs(norm_dist) < `bwidth' & hh_inc_pc >0, q(.50)
|
101 |
+
set scheme lean1
|
102 |
+
grqreg Above500_QPlot, ci reps(40) qstep(.2) seed(821)
|
103 |
+
graph export "./Output/EHPM_QuantilePlot_ln_hh_inc_pc_real.pdf", replace
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
|
14/replication_package/Replication/Code/ESLR_Analysis_IVCenso.do
ADDED
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Analysis - Censo IV ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color
|
10 |
+
|
11 |
+
** Set Workspace **
|
12 |
+
cd /Users/`c(username)'/Dropbox/Research_ElSalvador_LandReform/Replication
|
13 |
+
|
14 |
+
** ssc install rdrobust; winsor2; outreg2; lpoly; cmogram; dm88_1; grqreg; gr0002_3; pdslasso; lassopack; univar; ietoolkit
|
15 |
+
|
16 |
+
*********************
|
17 |
+
*** Load the Data ***
|
18 |
+
*********************
|
19 |
+
|
20 |
+
use "Data/censo_ag_wreform.dta", clear
|
21 |
+
|
22 |
+
label var Above500 "Above 500 Ha"
|
23 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
24 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
25 |
+
|
26 |
+
*********************
|
27 |
+
*** Set RD Params ***
|
28 |
+
*********************
|
29 |
+
|
30 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
31 |
+
** with ses clustered at propietor level.
|
32 |
+
** Will use rdrobust package: net install rdrobust, from(https://sites.google.com/site/rdpackages/rdrobust/stata) replace
|
33 |
+
|
34 |
+
local polynomial_level 1
|
35 |
+
local bandwidth_choice "mserd"
|
36 |
+
local kernel_choice "tri"
|
37 |
+
local cluster_level "Expropretario_ISTA"
|
38 |
+
|
39 |
+
*********************************************
|
40 |
+
*** OUTCOME 1 - AGRICULTURAL PRODUCTIVITY ***
|
41 |
+
*********************************************
|
42 |
+
|
43 |
+
|
44 |
+
*Logs OF REVENUE:
|
45 |
+
rdrobust ln_agprod_pricew_crops norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
46 |
+
* outreg results
|
47 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
48 |
+
local n_clust = `r(ndistinct)'
|
49 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
50 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, N)
|
51 |
+
|
52 |
+
rdrobust ln_agprod_pricew_crops norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') fuzzy(reform sharpbw)
|
53 |
+
* outreg results
|
54 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
55 |
+
local n_clust = `r(ndistinct)'
|
56 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
57 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, Y)
|
58 |
+
* rdpower ln_agprod_pricew_crops norm_dist, c(0) tau(1) vce(cluster Expropretario_ISTA ) plot
|
59 |
+
|
60 |
+
**** NET OF COSTS w/o Labor costs:
|
61 |
+
rdrobust ln_agprod norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
62 |
+
* outreg results
|
63 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
64 |
+
local n_clust = `r(ndistinct)'
|
65 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
66 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, N)
|
67 |
+
|
68 |
+
rdrobust ln_agprod norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') fuzzy(reform sharpbw)
|
69 |
+
* outreg results
|
70 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
71 |
+
local n_clust = `r(ndistinct)'
|
72 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
73 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, Y)
|
74 |
+
|
75 |
+
**** TFP PRODUCTIVITY:
|
76 |
+
rdrobust ln_tfp_geo norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
77 |
+
* outreg results
|
78 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
79 |
+
local n_clust = `r(ndistinct)'
|
80 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
81 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, N)
|
82 |
+
|
83 |
+
rdrobust ln_tfp_geo norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') fuzzy(reform sharpbw)
|
84 |
+
* outreg results
|
85 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
86 |
+
local n_clust = `r(ndistinct)'
|
87 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
88 |
+
outreg2 using "Output/Table4_LogProductivity_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Fuzzy RD, Y)
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
******************************
|
93 |
+
*** OUTCOME 2 - CASH CROPS ***
|
94 |
+
******************************
|
95 |
+
|
96 |
+
rdrobust CashCrop_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
97 |
+
* outreg results
|
98 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
99 |
+
local n_clust = `r(ndistinct)'
|
100 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
101 |
+
*outreg2 using "Output/Table2_CashCrops_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
102 |
+
|
103 |
+
rdrobust CashCrop_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
104 |
+
* outreg results
|
105 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
106 |
+
local n_clust = `r(ndistinct)'
|
107 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
108 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
** Sugar Cane:
|
113 |
+
rdrobust SugarCane_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
114 |
+
* outreg results
|
115 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
116 |
+
local n_clust = `r(ndistinct)'
|
117 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
118 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
119 |
+
|
120 |
+
rdrobust SugarCane_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
121 |
+
* outreg results
|
122 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
123 |
+
local n_clust = `r(ndistinct)'
|
124 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
125 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
126 |
+
|
127 |
+
* Note: small sample means cannot compute optimal bw. Setting BW manually at level in previous regression:
|
128 |
+
rdrobust SugarCane_Yield norm_dist, c(0) p(`polynomial_level') h(`e(h_r)') b(`e(b_r)') kernel(`kernel_choice') vce(cluster `cluster_level')
|
129 |
+
* outreg results
|
130 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
131 |
+
local n_clust = `r(ndistinct)'
|
132 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
133 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
134 |
+
|
135 |
+
** Coffee:
|
136 |
+
rdrobust Coffee_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
137 |
+
* outreg results
|
138 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
139 |
+
local n_clust = `r(ndistinct)'
|
140 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
141 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
142 |
+
|
143 |
+
rdrobust Coffee_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
144 |
+
* outreg results
|
145 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
146 |
+
local n_clust = `r(ndistinct)'
|
147 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
148 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
149 |
+
|
150 |
+
rdrobust Coffee_Yield norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
151 |
+
* outreg results
|
152 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
153 |
+
local n_clust = `r(ndistinct)'
|
154 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
155 |
+
outreg2 using "Output/Table2_CashCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
156 |
+
|
157 |
+
|
158 |
+
********************************
|
159 |
+
*** OUTCOME 3 - STAPLE CROPS ***
|
160 |
+
********************************
|
161 |
+
|
162 |
+
rdrobust ConsCrop_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
163 |
+
* outreg results
|
164 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
165 |
+
local n_clust = `r(ndistinct)'
|
166 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
167 |
+
*outreg2 using "Output/Table3_ConsCrops_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
168 |
+
rdrobust StapleCrop_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
169 |
+
* outreg results
|
170 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
171 |
+
local n_clust = `r(ndistinct)'
|
172 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
173 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
174 |
+
|
175 |
+
** Maize:
|
176 |
+
|
177 |
+
rdrobust Maize_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
178 |
+
* Check this. Strange since rd plot is so strong.
|
179 |
+
* outreg results
|
180 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
181 |
+
local n_clust = `r(ndistinct)'
|
182 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
183 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
184 |
+
|
185 |
+
rdrobust Maize_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
186 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
187 |
+
local n_clust = `r(ndistinct)'
|
188 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
189 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
190 |
+
|
191 |
+
rdrobust Maize_Yield norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
192 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
193 |
+
local n_clust = `r(ndistinct)'
|
194 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
195 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
196 |
+
|
197 |
+
** Beans:
|
198 |
+
|
199 |
+
rdrobust Beans_Indicator norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') // fuzzy(reform)
|
200 |
+
* outreg results
|
201 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
202 |
+
local n_clust = `r(ndistinct)'
|
203 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
204 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
205 |
+
|
206 |
+
rdrobust Beans_Share norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level') // fuzzy(reform)
|
207 |
+
* outreg results
|
208 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
209 |
+
local n_clust = `r(ndistinct)'
|
210 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
211 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
212 |
+
|
213 |
+
|
214 |
+
* Note: Following Cannot Compute Optimal BW Above: rdrobust Beans_Yield norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
215 |
+
* Setting BW manually at level in previous regression:
|
216 |
+
rdrobust Beans_Yield norm_dist, c(0) p(`polynomial_level') b(`e(h_r)') h(`e(b_r)') kernel(`kernel_choice') vce(cluster `cluster_level')
|
217 |
+
* outreg results
|
218 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
219 |
+
local n_clust = `r(ndistinct)'
|
220 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
221 |
+
outreg2 using "Output/Table3_ConsCrops_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
222 |
+
|
223 |
+
|
224 |
+
|
14/replication_package/Replication/Code/ESLR_Analysis_IVCenso_Credit.do
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Analysis - Censo IV ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color
|
10 |
+
|
11 |
+
** Set Workspace **
|
12 |
+
cd /Users/`c(username)'/Dropbox/Research_ElSalvador_LandReform/Replication
|
13 |
+
|
14 |
+
** ssc install rdrobust; winsor2; outreg2; lpoly; cmogram; dm88_1; grqreg; gr0002_3; pdslasso; lassopack; univar; ietoolkit
|
15 |
+
|
16 |
+
*********************
|
17 |
+
*** Load the Data ***
|
18 |
+
*********************
|
19 |
+
|
20 |
+
use "Data/censo_ag_wreform.dta", clear
|
21 |
+
|
22 |
+
label var Above500 "Above 500 Ha"
|
23 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
24 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
25 |
+
|
26 |
+
*********************
|
27 |
+
*** Set RD Params ***
|
28 |
+
*********************
|
29 |
+
|
30 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
31 |
+
** with ses clustered at propietor level.
|
32 |
+
** Will use rdrobust package: net install rdrobust, from(https://sites.google.com/site/rdpackages/rdrobust/stata) replace
|
33 |
+
|
34 |
+
local polynomial_level 1
|
35 |
+
local bandwidth_choice "mserd" // "mserd", "msecomb2" "msetwo"
|
36 |
+
local kernel_choice "tri"
|
37 |
+
local cluster_level "Expropretario_ISTA"
|
38 |
+
|
39 |
+
|
40 |
+
********************************************************************************
|
41 |
+
******************************** CREDIT ACCESS *********************************
|
42 |
+
********************************************************************************
|
43 |
+
|
44 |
+
|
45 |
+
*********************
|
46 |
+
*** CREDIT ACCESS ***
|
47 |
+
*********************
|
48 |
+
|
49 |
+
* S18A - Credit Indicator S18P01; Credit Approved S18P02; Oportuna Appoval S18P03
|
50 |
+
* S18B - Credit Source; Destino (type of production or capital)
|
51 |
+
merge 1:1 agg_id using "./Data/censo_ag_credit.dta", gen(S18A_merge) // S18A Vars.
|
52 |
+
|
53 |
+
** Credit:
|
54 |
+
gen Credit_Applied = S18P01
|
55 |
+
rdrobust Credit_Applied norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
56 |
+
* outreg results
|
57 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
58 |
+
local n_clust = `r(ndistinct)'
|
59 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
60 |
+
outreg2 using "./Output/Table_Credit_agg.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
61 |
+
|
62 |
+
|
63 |
+
** Credit Timely:
|
64 |
+
gen Credit_Timely = S18P03
|
65 |
+
replace Credit_Timely = . if S18P03==-2
|
66 |
+
rdrobust Credit_Timely norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
67 |
+
* outreg results
|
68 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
69 |
+
local n_clust = `r(ndistinct)'
|
70 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
71 |
+
outreg2 using "./Output/Table_Credit_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
72 |
+
|
73 |
+
***************************
|
74 |
+
*** CREDIT SOURCE + USE ***
|
75 |
+
***************************
|
76 |
+
|
77 |
+
merge 1:1 agg_id using "./Data/censo_ag_credittype.dta", gen(S18B_merge) // S18B Vars.
|
78 |
+
|
79 |
+
** Credit From State Bank:
|
80 |
+
rdrobust S18BBANCOESTATAL norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
81 |
+
* outreg results
|
82 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
83 |
+
local n_clust = `r(ndistinct)'
|
84 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
85 |
+
outreg2 using "./Output/Table_Credit_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
86 |
+
|
87 |
+
** Credit From Private Bank:
|
88 |
+
rdrobust S18BBANCOPRIVADO norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
89 |
+
* outreg results
|
90 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
91 |
+
local n_clust = `r(ndistinct)'
|
92 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
93 |
+
outreg2 using "./Output/Table_Credit_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
94 |
+
|
95 |
+
** Credit From Credit Coop:
|
96 |
+
rdrobust S18BCOOPERATIVA norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
97 |
+
* outreg results
|
98 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
99 |
+
local n_clust = `r(ndistinct)'
|
100 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
101 |
+
outreg2 using "./Output/Table_Credit_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
102 |
+
|
103 |
+
** Credit From ONG:
|
104 |
+
rdrobust S18BONG norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
105 |
+
* outreg results
|
106 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
107 |
+
local n_clust = `r(ndistinct)'
|
108 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
109 |
+
outreg2 using "./Output/Table_Credit_agg.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
110 |
+
|
14/replication_package/Replication/Code/ESLR_Analysis_IVCenso_Other.do
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
***************************************************************
|
2 |
+
******* ESLR:Ag-Census-Plot-Level Outcomes-Extensions **********
|
3 |
+
****************************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
|
11 |
+
*********************
|
12 |
+
*** Load the Data ***
|
13 |
+
*********************
|
14 |
+
|
15 |
+
use "Data/censo_ag_wreform.dta", clear
|
16 |
+
|
17 |
+
**********************
|
18 |
+
*** Label the Data ***
|
19 |
+
**********************
|
20 |
+
|
21 |
+
** Label Variables for the output:
|
22 |
+
label variable ln_agprod_pricew_crops "Agricultural Productivity (ln($/ha))"
|
23 |
+
label variable CashCrop_Share "Share of Property for Cash Crops"
|
24 |
+
label variable StapleCrop_Share "Share of Property for Staple Crops"
|
25 |
+
label variable norm_dist "Distance to Reform Threshold (ha)"
|
26 |
+
label variable own_amt "Former Owner's Cumulative Landholdings (ha)"
|
27 |
+
|
28 |
+
*********************
|
29 |
+
*** Set RD Params ***
|
30 |
+
*********************
|
31 |
+
|
32 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
33 |
+
** with ses clustered at propietor level.
|
34 |
+
|
35 |
+
local polynomial_level 1
|
36 |
+
local bandwidth_choice "mserd"
|
37 |
+
local kernel_choice "tri"
|
38 |
+
local cluster_level "Expropretario_ISTA"
|
39 |
+
|
40 |
+
|
41 |
+
**********************
|
42 |
+
*** CAPITAL STOCKS ***
|
43 |
+
**********************
|
44 |
+
|
45 |
+
* S16A - MDSC - Type of Capital
|
46 |
+
capture drop S16*
|
47 |
+
merge 1:1 agg_id using "./Data/censo_ag_investments.dta", gen(cap_merge)
|
48 |
+
|
49 |
+
** To Store Results:
|
50 |
+
global tflist ""
|
51 |
+
global modseq=0
|
52 |
+
global modid = 1
|
53 |
+
|
54 |
+
foreach dep_var of varlist S16A* {
|
55 |
+
dis "`dep_var'"
|
56 |
+
clear matrix
|
57 |
+
** Coef Plots of Capital Stocks
|
58 |
+
global modseq=$modseq+1
|
59 |
+
tempfile tf$modseq
|
60 |
+
** Run RD: (Indicator on Prob. of Having Particular Capital Unit:
|
61 |
+
capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
62 |
+
** Store Results:
|
63 |
+
capture parmest, label idn($modseq) idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
|
64 |
+
}
|
65 |
+
|
66 |
+
preserve
|
67 |
+
dsconcat $tflist
|
68 |
+
sort idnum
|
69 |
+
outsheet using "./Output/Temp/CapitalStocks.csv", replace comma
|
70 |
+
restore
|
71 |
+
|
72 |
+
|
73 |
+
**********************
|
74 |
+
*** INPUT MEASURES ***
|
75 |
+
**********************
|
76 |
+
|
77 |
+
* S15B - MDSC - Type of Input
|
78 |
+
capture drop S15*
|
79 |
+
merge 1:1 agg_id using "./Data/censo_ag_inputs.dta", gen(S15B_merge)
|
80 |
+
** To Store Results:
|
81 |
+
global tflist ""
|
82 |
+
global modseq=0
|
83 |
+
global modid = 1
|
84 |
+
|
85 |
+
|
86 |
+
foreach dep_var of varlist S15B* {
|
87 |
+
dis "`dep_var'"
|
88 |
+
clear matrix
|
89 |
+
** For Coef Plots:
|
90 |
+
global modseq=$modseq+1
|
91 |
+
tempfile tf$modseq
|
92 |
+
** Run RD: (Indicator on Prob. of Having Used Particular Input:
|
93 |
+
capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
94 |
+
** Store Results:
|
95 |
+
capture parmest, label idn($modseq) idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
|
96 |
+
}
|
97 |
+
|
98 |
+
preserve
|
99 |
+
dsconcat $tflist
|
100 |
+
sort idnum
|
101 |
+
outsheet using "./Output/Temp/InputUse.csv", replace comma
|
102 |
+
restore
|
103 |
+
drop S15B*
|
104 |
+
|
105 |
+
|
106 |
+
********************************************************************************
|
107 |
+
******************************** OTHER PRODUCTS ********************************
|
108 |
+
********************************************************************************
|
109 |
+
|
110 |
+
* S5B - MDSC - Minor Crops - Vegetables:
|
111 |
+
merge 1:1 agg_id using "./Data/censo_ag_minorcrops.dta", gen(S5B_merge)
|
112 |
+
|
113 |
+
** INDICATORS:
|
114 |
+
** To Store Results:
|
115 |
+
global tflist ""
|
116 |
+
global modseq=0
|
117 |
+
global modid = 1
|
118 |
+
|
119 |
+
foreach dep_var of varlist S5B* {
|
120 |
+
dis "`dep_var'"
|
121 |
+
clear matrix
|
122 |
+
** For Coef Plots:
|
123 |
+
global modseq=$modseq+1
|
124 |
+
tempfile tf$modseq
|
125 |
+
** Run RD: (Indicator on Prob. of Prod a Minor Crop:
|
126 |
+
capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
127 |
+
** Store Results:
|
128 |
+
capture parmest, label idn($modseq) idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
|
129 |
+
}
|
130 |
+
|
131 |
+
preserve
|
132 |
+
dsconcat $tflist
|
133 |
+
sort idnum
|
134 |
+
outsheet using "./Output/Temp/MinorCropProduction.csv", replace comma
|
135 |
+
restore
|
136 |
+
|
137 |
+
|
138 |
+
* S5B - MDSC - Minor Crops - Fruits:
|
139 |
+
merge 1:1 agg_id using "./Data/censo_ag_minorfruits.dta", gen(S8B_merge)
|
140 |
+
|
141 |
+
** INDICATORS:
|
142 |
+
** To Store Results:
|
143 |
+
global tflist ""
|
144 |
+
global modseq=0
|
145 |
+
global modid = 1
|
146 |
+
|
147 |
+
foreach dep_var of varlist S8B* {
|
148 |
+
dis "`dep_var'"
|
149 |
+
clear matrix
|
150 |
+
** For Coef Plots:
|
151 |
+
global modseq=$modseq+1
|
152 |
+
tempfile tf$modseq
|
153 |
+
** Run RD: (Indicator on Prob. of Prod a Minor Crop:
|
154 |
+
capture rdrobust `dep_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
155 |
+
** Store Results:
|
156 |
+
capture parmest, label idn($modseq) idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
|
157 |
+
}
|
158 |
+
|
159 |
+
preserve
|
160 |
+
dsconcat $tflist
|
161 |
+
sort idnum
|
162 |
+
outsheet using "./Output/Temp/MinorFruitProduction.csv", replace comma
|
163 |
+
restore
|
14/replication_package/Replication/Code/ESLR_Balance_PropLevel.R
ADDED
@@ -0,0 +1,503 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##################################################################
|
2 |
+
#### El Salvador - Land Reform - Prop Level Geographical Covs ####
|
3 |
+
##################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
|
8 |
+
require(foreign)
|
9 |
+
require(ggplot2)
|
10 |
+
require(rgdal)
|
11 |
+
require(rgeos)
|
12 |
+
require(RColorBrewer) # creates nice color schemes
|
13 |
+
require(maptools) # loads sp library too
|
14 |
+
require(scales) # customize scales
|
15 |
+
require(gridExtra) # mutiple plots
|
16 |
+
require(plyr) # join function
|
17 |
+
require(dplyr)
|
18 |
+
require(mapproj) # projection tools
|
19 |
+
require(raster) # raster tools
|
20 |
+
require(animation) # Saving GIFs
|
21 |
+
require(tidyr)
|
22 |
+
require(readstata13)
|
23 |
+
require(haven)
|
24 |
+
require(gstat) # interpolation tools
|
25 |
+
require(ncdf4)
|
26 |
+
require(Hmisc)
|
27 |
+
require(lubridate)
|
28 |
+
library(lmtest)
|
29 |
+
library(sandwich)
|
30 |
+
library(dotwhisker) # coef plots
|
31 |
+
library(broom)
|
32 |
+
require(stringr)
|
33 |
+
require(readxl)
|
34 |
+
require(rmapshaper)
|
35 |
+
require(extrafont)
|
36 |
+
require(ggmap)
|
37 |
+
require(exactextractr) # faster extract
|
38 |
+
require(sf) # faster extract
|
39 |
+
require(elevatr) # elevation data
|
40 |
+
require(rdrobust)
|
41 |
+
require(stringdist)
|
42 |
+
|
43 |
+
############## LOAD DATA ################
|
44 |
+
|
45 |
+
## Read in Data:
|
46 |
+
|
47 |
+
# Load the Property-Level Data:
|
48 |
+
prop_data <- read.dta(file="./Data/prop_data.dta")
|
49 |
+
# dta file Created in R, ESLR_CleanPropertyData.R
|
50 |
+
|
51 |
+
prop_data <- mutate(prop_data, norm_dist = Total_Propretario - 500.00,
|
52 |
+
Above500 = ifelse(norm_dist>0,1,0))
|
53 |
+
|
54 |
+
|
55 |
+
# Load the Canton Shapefile:
|
56 |
+
cantons <- readOGR(dsn="./Data/", layer="cantons_wCodigos")
|
57 |
+
|
58 |
+
############## CALCULATE GEO COVS ###############
|
59 |
+
|
60 |
+
# Projections:
|
61 |
+
wgs84_proj <- "+proj=longlat +ellps=WGS84 +datum=WGS84" # WGS 1984
|
62 |
+
mercator <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs" # Project to mercator to calculate distance in meters
|
63 |
+
|
64 |
+
## GEOGRAPHIC BALANCE:
|
65 |
+
|
66 |
+
# BUFFER SIZE:
|
67 |
+
buffer_size <- 2500
|
68 |
+
|
69 |
+
# PREP SHAPEFILES:
|
70 |
+
cantons_wCovariates <- as(cantons,"sf")
|
71 |
+
cantons_wCovariates <- st_transform(cantons_wCovariates, st_crs(mercator))
|
72 |
+
|
73 |
+
# SUITABILITY FOR DIFFERENT CROPS
|
74 |
+
# Export Crops: Coffee, Sugar Cane and Cotton (though cotton no longer produced there)
|
75 |
+
# Internal Crops: Maiz, Beans, Sorghum, maybe Rice
|
76 |
+
# COFFEE:
|
77 |
+
# Read in Rasters:
|
78 |
+
path_to_suit_coffee <- "./Data/crop_suit/coffeelo.tif"
|
79 |
+
coffee_suit <- raster(paste(path_to_suit_coffee,"",sep=""))
|
80 |
+
|
81 |
+
# Merge to CANTONS:
|
82 |
+
|
83 |
+
cantons_wCovariates$canton_coffee_suit <- exact_extract(coffee_suit,
|
84 |
+
cantons_wCovariates,
|
85 |
+
'median')
|
86 |
+
|
87 |
+
# SUGAR CANE:
|
88 |
+
# Read in Rasters:
|
89 |
+
path_to_suit_sugarcane <- "./Data/crop_suit/sugarcanelo.tif"
|
90 |
+
sugarcane_suit <- raster(paste(path_to_suit_sugarcane,"",sep=""))
|
91 |
+
|
92 |
+
# Merge to CANTONS:
|
93 |
+
cantons_wCovariates$sugarcane_suit <- exact_extract(sugarcane_suit,
|
94 |
+
cantons_wCovariates,
|
95 |
+
'median')
|
96 |
+
# COTTON:
|
97 |
+
# Read in Rasters:
|
98 |
+
path_to_suit_cotton <- "./Data/crop_suit/cottonlo.tif"
|
99 |
+
cotton_suit <- raster(paste(path_to_suit_cotton,"",sep=""))
|
100 |
+
|
101 |
+
# Merge to CANTONS:
|
102 |
+
cantons_wCovariates$cotton_suit <- exact_extract(cotton_suit,
|
103 |
+
cantons_wCovariates,
|
104 |
+
'median')
|
105 |
+
|
106 |
+
# Non-Export:
|
107 |
+
# Maize:
|
108 |
+
# Read in Rasters:
|
109 |
+
path_to_suit_maiz <- "./Data/crop_suit/maizelo.tif"
|
110 |
+
miaze_suit <- raster(paste(path_to_suit_maiz,"",sep=""))
|
111 |
+
|
112 |
+
|
113 |
+
# Merge to CANTONS:
|
114 |
+
cantons_wCovariates$miaze_suit <- exact_extract(miaze_suit,
|
115 |
+
cantons_wCovariates,
|
116 |
+
'median')
|
117 |
+
|
118 |
+
# Beans:
|
119 |
+
# Read in Rasters:
|
120 |
+
path_to_suit_beans <- "./Data/crop_suit/phaseolusbeanlo.tif"
|
121 |
+
bean_suit <- raster(paste(path_to_suit_beans,"",sep=""))
|
122 |
+
|
123 |
+
|
124 |
+
# Merge to CANTONS:
|
125 |
+
cantons_wCovariates$bean_suit <- exact_extract(bean_suit,
|
126 |
+
cantons_wCovariates,
|
127 |
+
'median')
|
128 |
+
# Sorghum:
|
129 |
+
# Read in Rasters:
|
130 |
+
path_to_suit_sorghum <- "./Data/crop_suit/sorghumlo.tif"
|
131 |
+
sorghum_suit <- raster(paste(path_to_suit_sorghum,"",sep=""))
|
132 |
+
|
133 |
+
|
134 |
+
# Merge to CANTONS:
|
135 |
+
cantons_wCovariates$sorghum_suit <- exact_extract(sorghum_suit,
|
136 |
+
cantons_wCovariates,
|
137 |
+
'median')
|
138 |
+
# Rice:
|
139 |
+
# Read in Rasters:
|
140 |
+
path_to_suit_rice <- "./Data/crop_suit/wetricelo.tif" # indricelo.tif
|
141 |
+
rice_suit <- raster(paste(path_to_suit_rice,"",sep=""))
|
142 |
+
|
143 |
+
|
144 |
+
# Merge to CANTONS:
|
145 |
+
cantons_wCovariates$rice_suit <- exact_extract(rice_suit,
|
146 |
+
cantons_wCovariates,
|
147 |
+
'median')
|
148 |
+
# Precipitation:
|
149 |
+
path_rain <- "./Data/wc2.1_2.5m_prec_2000-2009/"
|
150 |
+
|
151 |
+
# Loop over 12 months and calculate mean rainfall (mm):
|
152 |
+
for (month in 1:12) {
|
153 |
+
# Convert from .adf to raster for analysis:
|
154 |
+
print(month)
|
155 |
+
x <- raster(paste(path_rain,"wc2.1_2.5m_prec_2007-",
|
156 |
+
ifelse(month%/%10==0,paste0("0",month),month),
|
157 |
+
".tif",sep=""))
|
158 |
+
rainfall <- (x)
|
159 |
+
proj4string(rainfall) <- CRS(wgs84_proj) # assign projection since empty
|
160 |
+
assign(paste("rain","_",month,sep=""), rainfall)
|
161 |
+
}
|
162 |
+
sum_rain <- (rain_1 + rain_2 + rain_3 + rain_4 + rain_5 + rain_6 + rain_7 + rain_8 + rain_9 + rain_10 + rain_11 + rain_12)
|
163 |
+
|
164 |
+
|
165 |
+
# Extract:
|
166 |
+
cantons_wCovariates$canton_mean_rain <- exact_extract(sum_rain,
|
167 |
+
cantons_wCovariates,
|
168 |
+
'median')
|
169 |
+
|
170 |
+
|
171 |
+
# Land Suitability:
|
172 |
+
# http://nelson.wisc.edu/sage/data-and-models/atlas/maps.php?datasetid=19&includerelatedlinks=1&dataset=19
|
173 |
+
path_land_suit <- "Data/suit/suit/w001001.adf"
|
174 |
+
|
175 |
+
# Convert from .adf to raster for analysis:
|
176 |
+
x <- new("GDALReadOnlyDataset", path_land_suit)
|
177 |
+
xx<-asSGDF_GROD(x)
|
178 |
+
land_suit <- raster(xx)
|
179 |
+
proj4string(land_suit) <- CRS(proj4string(cantons)) # assign projection since empty
|
180 |
+
|
181 |
+
# Extract:
|
182 |
+
cantons_wCovariates$canton_land_suit <- exact_extract(land_suit,
|
183 |
+
cantons_wCovariates,
|
184 |
+
'median')
|
185 |
+
|
186 |
+
## Elevation: ##
|
187 |
+
elev <- get_elev_raster(locations = cantons, z= 1)
|
188 |
+
|
189 |
+
# Extract:
|
190 |
+
cantons_wCovariates$canton_elev_dem_30sec <- exact_extract(elev, cantons_wCovariates,'median')
|
191 |
+
|
192 |
+
|
193 |
+
write_dta(st_drop_geometry(cantons_wCovariates), "./Output/cantons_wGeoCovariates.dta")
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
+
################# STD FUNCTIONS ###################
|
199 |
+
|
200 |
+
|
201 |
+
# STD FUNCTIONS:
|
202 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
203 |
+
{
|
204 |
+
b <- MOD$coef[1]
|
205 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
206 |
+
sx <- sd(model.dta[,c("Above500")])
|
207 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
208 |
+
beta <- b * sx/sy
|
209 |
+
return(beta)
|
210 |
+
}
|
211 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
212 |
+
{
|
213 |
+
b <- MOD$se[1]
|
214 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
215 |
+
sx <- sd(model.dta[,c("Above500")])
|
216 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
217 |
+
beta <- b * sx/sy
|
218 |
+
return(beta)
|
219 |
+
}
|
220 |
+
|
221 |
+
winsor <- function (x, fraction=.01)
|
222 |
+
{
|
223 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
224 |
+
fraction > 0.5) {
|
225 |
+
stop("bad value for 'fraction'")
|
226 |
+
}
|
227 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
228 |
+
x[ x < lim[1] ] <- NA
|
229 |
+
x[ x > lim[2] ] <- NA
|
230 |
+
x
|
231 |
+
}
|
232 |
+
|
233 |
+
################# AESTHETICS ##################
|
234 |
+
|
235 |
+
aesthetics <- list(
|
236 |
+
theme_bw(),
|
237 |
+
theme(legend.title=element_blank(),
|
238 |
+
text=element_text(family="Palatino"),
|
239 |
+
plot.background=element_rect(colour="white",fill="white"),
|
240 |
+
panel.grid.major=element_blank(),
|
241 |
+
panel.grid.minor=element_blank(),
|
242 |
+
axis.title=element_text(size=12,face="bold"),
|
243 |
+
))
|
244 |
+
|
245 |
+
|
246 |
+
################### BALANCE PLOT ####################
|
247 |
+
|
248 |
+
## Coef Plots:
|
249 |
+
alpha<- 0.05
|
250 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
251 |
+
|
252 |
+
prop_data_wgeo <- left_join(prop_data, st_drop_geometry(cantons_wCovariates),by=c("CODIGO"))
|
253 |
+
|
254 |
+
b0 <- rdrobust(y = (prop_data_wgeo$miaze_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
255 |
+
b1 <- rdrobust(y = (prop_data_wgeo$sorghum_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
256 |
+
b2 <- rdrobust(y = (prop_data_wgeo$bean_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
257 |
+
b3 <- rdrobust(y = (prop_data_wgeo$rice_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
258 |
+
b4 <- rdrobust(y = (prop_data_wgeo$cotton_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
259 |
+
b5 <- rdrobust(y = (prop_data_wgeo$sugarcane_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
260 |
+
b6 <- rdrobust(y = (prop_data_wgeo$canton_coffee_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
261 |
+
b7 <- rdrobust(y = (prop_data_wgeo$canton_elev_dem_30sec), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
262 |
+
b8 <- rdrobust(y = (prop_data_wgeo$canton_mean_rain), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
263 |
+
b9 <- rdrobust(y = (prop_data_wgeo$canton_land_suit), x=prop_data_wgeo$norm_dist,c = 0,p = 1,q=2, bwselect = "mserd", cluster=prop_data_wgeo$Expropretario_ISTA, vce="hc0")
|
264 |
+
|
265 |
+
|
266 |
+
beta_coefs <- c(lm.beta(MOD=b0, dta=prop_data_wgeo, y="miaze_suit"),
|
267 |
+
lm.beta(MOD=b1, dta=prop_data_wgeo, y="sorghum_suit"),
|
268 |
+
lm.beta(MOD=b2, dta=prop_data_wgeo, y="bean_suit"),
|
269 |
+
lm.beta(MOD=b3, dta=prop_data_wgeo, y="rice_suit"),
|
270 |
+
lm.beta(MOD=b4, dta=prop_data_wgeo, y="cotton_suit"),
|
271 |
+
lm.beta(MOD=b5, dta=prop_data_wgeo, y="sugarcane_suit"),
|
272 |
+
lm.beta(MOD=b6, dta=prop_data_wgeo, y="canton_coffee_suit"),
|
273 |
+
lm.beta(MOD=b7, dta=prop_data_wgeo, y="canton_elev_dem_30sec"),
|
274 |
+
lm.beta(MOD=b8, dta=prop_data_wgeo, y="canton_mean_rain"),
|
275 |
+
lm.beta(MOD=b9, dta=prop_data_wgeo, y="canton_land_suit"))
|
276 |
+
|
277 |
+
beta_ses <- c(lm.beta.ses(MOD=b0, dta=prop_data_wgeo, y="miaze_suit"),
|
278 |
+
lm.beta.ses(MOD=b1, dta=prop_data_wgeo, y="sorghum_suit"),
|
279 |
+
lm.beta.ses(MOD=b2, dta=prop_data_wgeo, y="bean_suit"),
|
280 |
+
lm.beta.ses(MOD=b3, dta=prop_data_wgeo, y="rice_suit"),
|
281 |
+
lm.beta.ses(MOD=b4, dta=prop_data_wgeo, y="cotton_suit"),
|
282 |
+
lm.beta.ses(MOD=b5, dta=prop_data_wgeo, y="sugarcane_suit"),
|
283 |
+
lm.beta.ses(MOD=b6, dta=prop_data_wgeo, y="canton_coffee_suit"),
|
284 |
+
lm.beta.ses(MOD=b7, dta=prop_data_wgeo, y="canton_elev_dem_30sec"),
|
285 |
+
lm.beta.ses(MOD=b8, dta=prop_data_wgeo, y="canton_mean_rain"),
|
286 |
+
lm.beta.ses(MOD=b9, dta=prop_data_wgeo, y="canton_land_suit"))
|
287 |
+
|
288 |
+
yvars<-c("Maize Suitability","Sorghum Suitability","Bean Suitability","Rice Suitability","Cotton Suitability","Sugar Cane Suitability","Coffee Suitability","Elevation","Precipitation","Land Suitability")
|
289 |
+
geo_vars <- c("miaze_suit","sorghum_suit","bean_suit","rice_suit","cotton_suit",
|
290 |
+
"sugarcane_suit", "canton_coffee_suit", "canton_elev_dem_30sec",
|
291 |
+
"canton_mean_rain","canton_land_suit")
|
292 |
+
betas <- cbind(yvars,beta_coefs,beta_ses)
|
293 |
+
ests <- cbind(geo_vars, c(b0$coef[1],b1$coef[1],b2$coef[1],b3$coef[1],b4$coef[1],b5$coef[1],b6$coef[1],b7$coef[1],b8$coef[1],b9$coef[1]),
|
294 |
+
c(b0$se[1],b1$se[1],b2$se[1],b3$se[1],b4$se[1],b5$se[1],b6$se[1],b7$coef[1],b8$se[1],b9$se[1]))
|
295 |
+
# Save estimates for un-balancedness exercise:
|
296 |
+
write_dta(as.data.frame(ests),path="./Output/balance_ests.dta")
|
297 |
+
|
298 |
+
row.names(betas)<-NULL
|
299 |
+
|
300 |
+
MatrixofModels <- as.data.frame(as.matrix(betas))
|
301 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError")
|
302 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = rev(c("Land Suitability", "Precipitation", "Elevation", "Coffee Suitability", "Sugar Cane Suitability", "Cotton Suitability", "Maize Suitability", "Bean Suitability", "Rice Suitability", "Sorghum Suitability")))# MatrixofModels$IV)
|
303 |
+
MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
304 |
+
|
305 |
+
|
306 |
+
###################
|
307 |
+
## BALANCE FIGURE:
|
308 |
+
##################
|
309 |
+
|
310 |
+
# Plot:
|
311 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
312 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
313 |
+
ylab = NULL, xlab = NULL)
|
314 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
315 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
316 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.0, alpha = 0.05)
|
317 |
+
#OutputPlot <- OutputPlot + facet_grid(~ ModelName) + coord_flip() + theme_bw() + ylab("\nStandardized Effect")
|
318 |
+
OutputPlot <- OutputPlot + coord_flip() + theme_classic() + ylab("\nStandardized Effect") +
|
319 |
+
xlab("")
|
320 |
+
|
321 |
+
# Save:
|
322 |
+
OutputPlot + scale_y_continuous(breaks = seq(-0.4, 0.4,0.1)) + aesthetics
|
323 |
+
|
324 |
+
ggsave(filename="./Output/CoefPlot_Balance_PropLevel1980.pdf",width = 6, height=4)
|
325 |
+
|
326 |
+
|
327 |
+
############################
|
328 |
+
## SELECTIVE SORTING FIGURE:
|
329 |
+
############################
|
330 |
+
|
331 |
+
require(rdd)
|
332 |
+
|
333 |
+
### FIXING X LIM & FONT:
|
334 |
+
DCdensity2 <- function (runvar, cutpoint, bin = NULL, bw = NULL, verbose = FALSE,
|
335 |
+
plot = TRUE, ext.out = FALSE, htest = FALSE, my_xlim = c(-0.5,0.5)) # my_xlim param added
|
336 |
+
{
|
337 |
+
runvar <- runvar[complete.cases(runvar)]
|
338 |
+
rn <- length(runvar)
|
339 |
+
rsd <- sd(runvar)
|
340 |
+
rmin <- min(runvar)
|
341 |
+
rmax <- max(runvar)
|
342 |
+
if (missing(cutpoint)) {
|
343 |
+
if (verbose)
|
344 |
+
cat("Assuming cutpoint of zero.\n")
|
345 |
+
cutpoint <- 0
|
346 |
+
}
|
347 |
+
if (cutpoint <= rmin | cutpoint >= rmax) {
|
348 |
+
stop("Cutpoint must lie within range of runvar")
|
349 |
+
}
|
350 |
+
if (is.null(bin)) {
|
351 |
+
bin <- 2 * rsd * rn^(-1/2)
|
352 |
+
if (verbose)
|
353 |
+
cat("Using calculated bin size: ", sprintf("%.3f",
|
354 |
+
bin), "\n")
|
355 |
+
}
|
356 |
+
l <- floor((rmin - cutpoint)/bin) * bin + bin/2 + cutpoint
|
357 |
+
r <- floor((rmax - cutpoint)/bin) * bin + bin/2 + cutpoint
|
358 |
+
lc <- cutpoint - (bin/2)
|
359 |
+
rc <- cutpoint + (bin/2)
|
360 |
+
j <- floor((rmax - rmin)/bin) + 2
|
361 |
+
binnum <- round((((floor((runvar - cutpoint)/bin) * bin +
|
362 |
+
bin/2 + cutpoint) - l)/bin) + 1)
|
363 |
+
cellval <- rep(0, j)
|
364 |
+
for (i in seq(1, rn)) {
|
365 |
+
cnum <- binnum[i]
|
366 |
+
cellval[cnum] <- cellval[cnum] + 1
|
367 |
+
}
|
368 |
+
cellval <- (cellval/rn)/bin
|
369 |
+
cellmp <- seq(from = 1, to = j, by = 1)
|
370 |
+
cellmp <- floor(((l + (cellmp - 1) * bin) - cutpoint)/bin) *
|
371 |
+
bin + bin/2 + cutpoint
|
372 |
+
if (is.null(bw)) {
|
373 |
+
leftofc <- round((((floor((lc - cutpoint)/bin) * bin +
|
374 |
+
bin/2 + cutpoint) - l)/bin) + 1)
|
375 |
+
rightofc <- round((((floor((rc - cutpoint)/bin) * bin +
|
376 |
+
bin/2 + cutpoint) - l)/bin) + 1)
|
377 |
+
if (rightofc - leftofc != 1) {
|
378 |
+
stop("Error occurred in bandwidth calculation")
|
379 |
+
}
|
380 |
+
cellmpleft <- cellmp[1:leftofc]
|
381 |
+
cellmpright <- cellmp[rightofc:j]
|
382 |
+
P.lm <- lm(cellval ~ poly(cellmp, degree = 4, raw = T),
|
383 |
+
subset = cellmp < cutpoint)
|
384 |
+
mse4 <- summary(P.lm)$sigma^2
|
385 |
+
lcoef <- coef(P.lm)
|
386 |
+
fppleft <- 2 * lcoef[3] + 6 * lcoef[4] * cellmpleft +
|
387 |
+
12 * lcoef[5] * cellmpleft * cellmpleft
|
388 |
+
hleft <- 3.348 * (mse4 * (cutpoint - l)/sum(fppleft *
|
389 |
+
fppleft))^(1/5)
|
390 |
+
P.lm <- lm(cellval ~ poly(cellmp, degree = 4, raw = T),
|
391 |
+
subset = cellmp >= cutpoint)
|
392 |
+
mse4 <- summary(P.lm)$sigma^2
|
393 |
+
rcoef <- coef(P.lm)
|
394 |
+
fppright <- 2 * rcoef[3] + 6 * rcoef[4] * cellmpright +
|
395 |
+
12 * rcoef[5] * cellmpright * cellmpright
|
396 |
+
hright <- 3.348 * (mse4 * (r - cutpoint)/sum(fppright *
|
397 |
+
fppright))^(1/5)
|
398 |
+
bw = 0.5 * (hleft + hright)
|
399 |
+
if (verbose)
|
400 |
+
cat("Using calculated bandwidth: ", sprintf("%.3f",
|
401 |
+
bw), "\n")
|
402 |
+
}
|
403 |
+
if (sum(runvar > cutpoint - bw & runvar < cutpoint) == 0 |
|
404 |
+
sum(runvar < cutpoint + bw & runvar >= cutpoint) == 0)
|
405 |
+
stop("Insufficient data within the bandwidth.")
|
406 |
+
if (plot) {
|
407 |
+
d.l <- data.frame(cellmp = cellmp[cellmp < cutpoint],
|
408 |
+
cellval = cellval[cellmp < cutpoint], dist = NA,
|
409 |
+
est = NA, lwr = NA, upr = NA)
|
410 |
+
pmin <- cutpoint - 2 * rsd
|
411 |
+
pmax <- cutpoint + 2 * rsd
|
412 |
+
for (i in 1:nrow(d.l)) {
|
413 |
+
d.l$dist <- d.l$cellmp - d.l[i, "cellmp"]
|
414 |
+
w <- kernelwts(d.l$dist, 0, bw, kernel = "triangular")
|
415 |
+
newd <- data.frame(dist = 0)
|
416 |
+
pred <- predict(lm(cellval ~ dist, weights = w, data = d.l),
|
417 |
+
interval = "confidence", newdata = newd)
|
418 |
+
d.l$est[i] <- pred[1]
|
419 |
+
d.l$lwr[i] <- pred[2]
|
420 |
+
d.l$upr[i] <- pred[3]
|
421 |
+
}
|
422 |
+
d.r <- data.frame(cellmp = cellmp[cellmp >= cutpoint],
|
423 |
+
cellval = cellval[cellmp >= cutpoint], dist = NA,
|
424 |
+
est = NA, lwr = NA, upr = NA)
|
425 |
+
for (i in 1:nrow(d.r)) {
|
426 |
+
d.r$dist <- d.r$cellmp - d.r[i, "cellmp"]
|
427 |
+
w <- kernelwts(d.r$dist, 0, bw, kernel = "triangular")
|
428 |
+
newd <- data.frame(dist = 0)
|
429 |
+
pred <- predict(lm(cellval ~ dist, weights = w, data = d.r),
|
430 |
+
interval = "confidence", newdata = newd)
|
431 |
+
d.r$est[i] <- pred[1]
|
432 |
+
d.r$lwr[i] <- pred[2]
|
433 |
+
d.r$upr[i] <- pred[3]
|
434 |
+
}
|
435 |
+
plot(d.l$cellmp, d.l$est, lty = 1, lwd = 2, col = "black", # xlim set here based on the parameter
|
436 |
+
type = "l", xlim = my_xlim, ylim = c(min(cellval[cellmp <=
|
437 |
+
pmax & cellmp >= pmin]), max(cellval[cellmp <=
|
438 |
+
pmax & cellmp >= pmin])), xlab = NA, ylab = NA,
|
439 |
+
main = NA)
|
440 |
+
lines(d.l$cellmp, d.l$lwr, lty = 2, lwd = 1, col = "black",
|
441 |
+
type = "l")
|
442 |
+
lines(d.l$cellmp, d.l$upr, lty = 2, lwd = 1, col = "black",
|
443 |
+
type = "l")
|
444 |
+
lines(d.r$cellmp, d.r$est, lty = 1, lwd = 2, col = "black",
|
445 |
+
type = "l")
|
446 |
+
lines(d.r$cellmp, d.r$lwr, lty = 2, lwd = 1, col = "black",
|
447 |
+
type = "l")
|
448 |
+
lines(d.r$cellmp, d.r$upr, lty = 2, lwd = 1, col = "black",
|
449 |
+
type = "l")
|
450 |
+
points(cellmp, cellval, type = "p", pch = 20)
|
451 |
+
}
|
452 |
+
cmp <- cellmp
|
453 |
+
cval <- cellval
|
454 |
+
padzeros <- ceiling(bw/bin)
|
455 |
+
jp <- j + 2 * padzeros
|
456 |
+
if (padzeros >= 1) {
|
457 |
+
cval <- c(rep(0, padzeros), cellval, rep(0, padzeros))
|
458 |
+
cmp <- c(seq(l - padzeros * bin, l - bin, bin), cellmp,
|
459 |
+
seq(r + bin, r + padzeros * bin, bin))
|
460 |
+
}
|
461 |
+
dist <- cmp - cutpoint
|
462 |
+
w <- 1 - abs(dist/bw)
|
463 |
+
w <- ifelse(w > 0, w * (cmp < cutpoint), 0)
|
464 |
+
w <- (w/sum(w)) * jp
|
465 |
+
fhatl <- predict(lm(cval ~ dist, weights = w), newdata = data.frame(dist = 0))[[1]]
|
466 |
+
w <- 1 - abs(dist/bw)
|
467 |
+
w <- ifelse(w > 0, w * (cmp >= cutpoint), 0)
|
468 |
+
w <- (w/sum(w)) * jp
|
469 |
+
fhatr <- predict(lm(cval ~ dist, weights = w), newdata = data.frame(dist = 0))[[1]]
|
470 |
+
thetahat <- log(fhatr) - log(fhatl)
|
471 |
+
sethetahat <- sqrt((1/(rn * bw)) * (24/5) * ((1/fhatr) +
|
472 |
+
(1/fhatl)))
|
473 |
+
z <- thetahat/sethetahat
|
474 |
+
p <- 2 * pnorm(abs(z), lower.tail = FALSE)
|
475 |
+
if (verbose) {
|
476 |
+
cat("Log difference in heights is ", sprintf("%.3f",
|
477 |
+
thetahat), " with SE ", sprintf("%.3f", sethetahat),
|
478 |
+
"\n")
|
479 |
+
cat(" this gives a z-stat of ", sprintf("%.3f", z),
|
480 |
+
"\n")
|
481 |
+
cat(" and a p value of ", sprintf("%.3f", p), "\n")
|
482 |
+
}
|
483 |
+
if (ext.out)
|
484 |
+
return(list(theta = thetahat, se = sethetahat, z = z,
|
485 |
+
p = p, binsize = bin, bw = bw, cutpoint = cutpoint,
|
486 |
+
data = data.frame(cellmp, cellval)))
|
487 |
+
else if (htest) {
|
488 |
+
structure(list(statistic = c(z = z), p.value = p, method = "McCrary (2008) sorting test",
|
489 |
+
parameter = c(binwidth = bin, bandwidth = bw, cutpoint = cutpoint),
|
490 |
+
alternative = "no apparent sorting"), class = "htest")
|
491 |
+
}
|
492 |
+
else return(p)
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
prop_subset <- prop_data[which(prop_data$Total_Propretario < 1500 & prop_data$Total_Propretario >180),]
|
497 |
+
pdf(file="./Output/McCrarySorting_PropLevel.pdf", height=6, width=9, paper = "USr", family = "Palatino")
|
498 |
+
DCdensity2(runvar = prop_subset$Total_Propretario,cutpoint = 500,plot = TRUE,verbose = TRUE, ext.out = FALSE, bw=350, my_xlim = c(200,1000))
|
499 |
+
abline(v=500,col=c("red"))
|
500 |
+
#par(family = 'sans') # the default of R
|
501 |
+
title(xlab="Cumulative Landholdings (ha)", ylab="Density")
|
502 |
+
dev.off()
|
503 |
+
|
14/replication_package/Replication/Code/ESLR_CensusMigration.R
ADDED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################################################
|
2 |
+
##### El Salvador - Migration Outcomes - Canton-Level - Pop Census #####
|
3 |
+
########################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(sandwich) # robust se's
|
26 |
+
require(zoo) # filling in
|
27 |
+
require(fuzzyjoin) # approximate string matching
|
28 |
+
require(haven)
|
29 |
+
require(stringi)
|
30 |
+
|
31 |
+
|
32 |
+
########################################
|
33 |
+
|
34 |
+
# Approximate String Matching Funtion
|
35 |
+
|
36 |
+
string_match <- function(string_to_match, options, smethod="osa") {
|
37 |
+
if(string_to_match!="") {
|
38 |
+
sdists <- stringdist(string_to_match, options, method=smethod)
|
39 |
+
ind <- which(sdists == min(sdists))
|
40 |
+
if(length(ind) != 1) {
|
41 |
+
ind <- ind[1] # Assumes first index is the most common string to match.
|
42 |
+
}
|
43 |
+
return(options[ind])
|
44 |
+
} else {
|
45 |
+
return("")
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
as.numeric.factor <- function(x) {as.numeric(levels(x))[x]} # Function to turn factor vars to numeric variables correctly.
|
50 |
+
|
51 |
+
########################################
|
52 |
+
|
53 |
+
## Read in Data:
|
54 |
+
cantons <- read_dta(file="./Output/cantons_wGeoCovariates.dta")
|
55 |
+
|
56 |
+
# Note: Data doesn't have main RD variables of interest, need to merge them in:
|
57 |
+
# Vars created in ESLR_AnalysisConflictData.R
|
58 |
+
canton_rd_vars <- read.csv(file="./Data/conflict_canton.csv", header=TRUE)
|
59 |
+
# canton_rd_vars <- read.csv(file="./R/Output/conflict_canton_subset.csv", header=TRUE)
|
60 |
+
|
61 |
+
# Keep Vars of Interest and Merge in:
|
62 |
+
canton_rd_vars <- dplyr::select(canton_rd_vars,CODIGO,num_holdings:max_above_500)
|
63 |
+
#cantons <- dplyr::select(cantons,-reform)
|
64 |
+
cantons <- left_join(cantons,canton_rd_vars, by="CODIGO")
|
65 |
+
|
66 |
+
cantons$CODIGO_NOM <- as.character(cantons$CODIGO_)
|
67 |
+
|
68 |
+
########################################
|
69 |
+
|
70 |
+
poblaccion_section <- read_sav(file = "./Data/poblacion.sav")
|
71 |
+
|
72 |
+
########################################
|
73 |
+
|
74 |
+
cantons_popcensus <- dplyr::select(poblaccion_section,
|
75 |
+
gender=S06P02,
|
76 |
+
age=S06P03A,
|
77 |
+
S06P07A, S06P08A1, S06P08A2,
|
78 |
+
DEPDSC, MUNDSC, CANDSC,
|
79 |
+
literate = S06P09,
|
80 |
+
educated = S06P10,
|
81 |
+
educ_level = S06P11A,
|
82 |
+
finished_hs = S06P11B,
|
83 |
+
S06P22)
|
84 |
+
|
85 |
+
|
86 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
87 |
+
born_same_as_mother= ifelse(S06P07A < 3,S06P07A,NA) ,
|
88 |
+
lived_canton_always = ifelse(S06P08A1 < 3,S06P08A1,NA),
|
89 |
+
lived_canton_year = ifelse(S06P08A2>0,S06P08A2,NA),
|
90 |
+
public_sector_worker = ifelse(S06P22 == 1, 1,
|
91 |
+
ifelse(is.na(S06P22) | S06P22==-2,NA, 0)),
|
92 |
+
pop = 1,
|
93 |
+
CODIGO_NOM = toupper(stri_trans_general(paste(DEPDSC, MUNDSC, CANDSC,sep=", "),"Latin-ASCII")))
|
94 |
+
|
95 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
96 |
+
born_same_as_mother= ifelse(born_same_as_mother ==2 ,0,born_same_as_mother) ,
|
97 |
+
lived_canton_always = ifelse(lived_canton_always ==2 ,0,lived_canton_always),
|
98 |
+
educ_yrs = 1*(educ_level==1)+6*(educ_level==2)+ 9*(educ_level==3)+
|
99 |
+
11*(educ_level==4)+13*(educ_level==5)+ 15*(educ_level==6)+
|
100 |
+
16*(educ_level==7)+ 17*(educ_level==8)+ 20*(educ_level==9))
|
101 |
+
|
102 |
+
cantons_popcensus <- filter(cantons_popcensus, CANDSC != "AREA URBANA")
|
103 |
+
|
104 |
+
# Summarise to make merging faster:
|
105 |
+
cantons_popcensus <- cantons_popcensus %>%
|
106 |
+
group_by(CODIGO_NOM) %>%
|
107 |
+
summarise_if(is.numeric, mean, na.rm = TRUE)
|
108 |
+
|
109 |
+
max.dist <- 15 # since there are errors in mun names + state names
|
110 |
+
|
111 |
+
# inds <- amatch(cantons_popcensus$CODIGO_NOM, cantons$CODIGO_NOM, maxDist=max.dist) # can try different maxDists and different methods (using levenstein right now as default i believe)
|
112 |
+
# # View(t(rbind(cantons_literacy$CODIGO_NOM,as.character(cantons$CODIGO_NOM[inds]))))
|
113 |
+
# cantons_popcensus$CODIGO <- cantons$CODIGO[inds]
|
114 |
+
# cantons <- left_join(cantons, cantons_popcensus, by="CODIGO")
|
115 |
+
|
116 |
+
max.dist <- 10 # since there are errors in mun names + state names
|
117 |
+
cantons <- stringdist_join(cantons, cantons_popcensus,
|
118 |
+
by = c("CODIGO_NOM" = "CODIGO_NOM"),
|
119 |
+
mode = "left",
|
120 |
+
method = "jw",
|
121 |
+
max_dist = max.dist,
|
122 |
+
distance_col = "dist")
|
123 |
+
|
124 |
+
cantons <- cantons %>%
|
125 |
+
group_by(CODIGO_NOM.x) %>%
|
126 |
+
top_n(1, -dist) %>% ungroup()
|
127 |
+
|
128 |
+
as.numeric.factor <- function(x) {as.numeric(levels(x))[x]}
|
129 |
+
as.numeric.factor.wcheck <- function(x) {if(class(x)=="factor") { return(as.numeric(levels(x))[x]) } else { return(x)}}
|
130 |
+
|
131 |
+
|
132 |
+
### Using Share Above 500
|
133 |
+
cantons$share_above500 <- cantons$num_above500/(cantons$num_above500 + cantons$num_below500)
|
134 |
+
|
135 |
+
## Same Canton Always:
|
136 |
+
b0 <- lm(lived_canton_always ~ share_above500 + gender + age + age^2 , data=cantons)
|
137 |
+
cov0 <- vcovHC(b0, type = "HC1")
|
138 |
+
robust.se0 <- sqrt(diag(cov0))
|
139 |
+
summary(b0)
|
140 |
+
|
141 |
+
## Same Canton Year:
|
142 |
+
b1 <- lm(lived_canton_year ~ share_above500 + gender + age + age^2, data=cantons)
|
143 |
+
cov1 <- vcovHC(b1, type = "HC1")
|
144 |
+
robust.se1 <- sqrt(diag(cov1))
|
145 |
+
summary(b1)
|
146 |
+
|
147 |
+
## Same Canton - Mother:
|
148 |
+
b2 <- lm(born_same_as_mother ~ share_above500 + gender + age + age^2, data=cantons)
|
149 |
+
cov2 <- vcovHC(b2, type = "HC1")
|
150 |
+
robust.se2 <- sqrt(diag(cov2))
|
151 |
+
summary(b2)
|
152 |
+
|
153 |
+
|
154 |
+
stargazer(b0,b1,b2,
|
155 |
+
type = "latex",
|
156 |
+
se = list(robust.se0, robust.se1,robust.se2),
|
157 |
+
keep = c("share_above500"),
|
158 |
+
digits = 4,
|
159 |
+
out="./Output/MigrationOutcomes_CantonLevel.tex")
|
160 |
+
|
161 |
+
|
162 |
+
########################################
|
163 |
+
|
164 |
+
## Now for highly educated sample
|
165 |
+
|
166 |
+
cantons_popcensus <- dplyr::select(poblaccion_section,
|
167 |
+
gender=S06P02,
|
168 |
+
age=S06P03A,
|
169 |
+
S06P07A, S06P08A1, S06P08A2,
|
170 |
+
DEPDSC, MUNDSC, CANDSC,
|
171 |
+
literate = S06P09,
|
172 |
+
educated = S06P10,
|
173 |
+
educ_level = S06P11A,
|
174 |
+
finished_hs = S06P11B)
|
175 |
+
|
176 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
177 |
+
born_same_as_mother= ifelse(S06P07A < 3,S06P07A,NA) ,
|
178 |
+
lived_canton_always = ifelse(S06P08A1 < 3,S06P08A1,NA),
|
179 |
+
lived_canton_year = ifelse(S06P08A2>0,S06P08A2,NA),
|
180 |
+
finished_hs = ifelse(finished_hs>0,finished_hs, NA),
|
181 |
+
CODIGO_NOM = toupper(stri_trans_general(paste(DEPDSC, MUNDSC, CANDSC,sep=", "),"Latin-ASCII")))
|
182 |
+
|
183 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
184 |
+
born_same_as_mother= ifelse(born_same_as_mother ==2 ,0,born_same_as_mother) ,
|
185 |
+
finished_hs = ifelse(finished_hs==2, 0, finished_hs),
|
186 |
+
lived_canton_always = ifelse(lived_canton_always ==2 ,0,lived_canton_always)
|
187 |
+
)
|
188 |
+
|
189 |
+
cantons_popcensus_educ <- filter(cantons_popcensus,
|
190 |
+
finished_hs==1)
|
191 |
+
|
192 |
+
cantons_popcensus_educ <- filter(cantons_popcensus_educ, CANDSC != "AREA URBANA")
|
193 |
+
|
194 |
+
# Summarise to make merging faster:
|
195 |
+
cantons_popcensus_educ <- cantons_popcensus_educ %>%
|
196 |
+
group_by(CODIGO_NOM) %>%
|
197 |
+
summarise_if(is.numeric, mean, na.rm = TRUE)
|
198 |
+
|
199 |
+
max.dist <- 15 # since there are errors in mun names + state names
|
200 |
+
|
201 |
+
cantons <- read_dta(file="./Output/cantons_wGeoCovariates.dta")
|
202 |
+
cantons <- left_join(cantons,canton_rd_vars, by="CODIGO")
|
203 |
+
|
204 |
+
cantons$CODIGO_NOM <- as.character(cantons$CODIGO_)
|
205 |
+
|
206 |
+
|
207 |
+
max.dist <- 10 # since there are errors in mun names + state names
|
208 |
+
cantons <- stringdist_join(cantons, cantons_popcensus_educ,
|
209 |
+
by = c("CODIGO_NOM" = "CODIGO_NOM"),
|
210 |
+
mode = "left",
|
211 |
+
method = "jw",
|
212 |
+
max_dist = max.dist,
|
213 |
+
distance_col = "dist")
|
214 |
+
|
215 |
+
cantons <- cantons %>%
|
216 |
+
group_by(CODIGO_NOM.x) %>%
|
217 |
+
top_n(1, -dist) %>% ungroup()
|
218 |
+
|
219 |
+
as.numeric.factor <- function(x) {as.numeric(levels(x))[x]}
|
220 |
+
as.numeric.factor.wcheck <- function(x) {if(class(x)=="factor") { return(as.numeric(levels(x))[x]) } else { return(x)}}
|
221 |
+
|
222 |
+
### Using Share Above 500
|
223 |
+
cantons$share_above500 <- cantons$num_above500/(cantons$num_above500 + cantons$num_below500)
|
224 |
+
|
225 |
+
## Same Canton Always:
|
226 |
+
b0 <- lm(lived_canton_always ~ share_above500 + gender + age + age^2 , data=cantons)
|
227 |
+
cov0 <- vcovHC(b0, type = "HC1")
|
228 |
+
robust.se0 <- sqrt(diag(cov0))
|
229 |
+
summary(b0)
|
230 |
+
|
231 |
+
## Same Canton Year:
|
232 |
+
b1 <- lm(lived_canton_year ~ share_above500 + gender + age + age^2, data=cantons)
|
233 |
+
cov1 <- vcovHC(b1, type = "HC1")
|
234 |
+
robust.se1 <- sqrt(diag(cov1))
|
235 |
+
summary(b1)
|
236 |
+
|
237 |
+
## Same Canton - Mother:
|
238 |
+
b2 <- lm(born_same_as_mother ~ share_above500 + gender + age + age^2, data=cantons)
|
239 |
+
cov2 <- vcovHC(b2, type = "HC1")
|
240 |
+
robust.se2 <- sqrt(diag(cov2))
|
241 |
+
summary(b2)
|
242 |
+
|
243 |
+
|
244 |
+
stargazer(b0,b1,b2,
|
245 |
+
type = "latex",
|
246 |
+
se = list(robust.se0, robust.se1,robust.se2),
|
247 |
+
keep = c("share_above500"),
|
248 |
+
digits = 4,
|
249 |
+
out="./Output/MigrationOutcomes_CantonLevel_CompletedHS.tex")
|
250 |
+
|
251 |
+
|
252 |
+
|
14/replication_package/Replication/Code/ESLR_Digits.R
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
###########################################################
|
2 |
+
##### ESLR - DATA MANIPULATION CHECKS - AgCensus Data #####
|
3 |
+
###########################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(RColorBrewer) # creates nice color schemes
|
10 |
+
require(scales) # customize scales
|
11 |
+
require(plyr) # join function
|
12 |
+
require(dplyr)
|
13 |
+
require(rdrobust) # rd estimation tools
|
14 |
+
require(stargazer) # format tables
|
15 |
+
require(haven)
|
16 |
+
require(readstata13)
|
17 |
+
require(TOSTER)
|
18 |
+
require(benford.analysis) # Tests for data manipulation
|
19 |
+
|
20 |
+
par(mar=c(1,1,1,1))
|
21 |
+
|
22 |
+
########################################
|
23 |
+
|
24 |
+
## Load IV Censo Agropecuario Data (with reform data):
|
25 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
26 |
+
|
27 |
+
########################################
|
28 |
+
|
29 |
+
## Making Standarized Coefficient Plots:
|
30 |
+
|
31 |
+
# Set aesthetics:
|
32 |
+
aesthetics <- list(
|
33 |
+
theme_bw(),
|
34 |
+
theme(legend.title=element_blank(),
|
35 |
+
#legend.justification=c(0,0),
|
36 |
+
#legend.position= "right", #c(1,0),
|
37 |
+
#panel.grid.minor=element_blank(),
|
38 |
+
#panel.grid.major=element_blank(),
|
39 |
+
plot.background=element_rect(colour="white",fill="white"),
|
40 |
+
panel.grid.major=element_blank(),
|
41 |
+
panel.grid.minor=element_blank(),
|
42 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
43 |
+
axis.title.y=element_text(face="bold.italic"),
|
44 |
+
axis.title.x=element_text(face="bold.italic")))
|
45 |
+
|
46 |
+
########################################
|
47 |
+
|
48 |
+
censo_ag_wreform$Maize_Qt_ap <- censo_ag_wreform$Maize_Yield * censo_ag_wreform$AREA_HECTAREA
|
49 |
+
censo_ag_wreform$Beans_Qt_ap <- censo_ag_wreform$Beans_Yield * censo_ag_wreform$AREA_HECTAREA
|
50 |
+
censo_ag_wreform$Coffee_Qt_ap <- censo_ag_wreform$Coffee_Yield * censo_ag_wreform$AREA_HECTAREA
|
51 |
+
censo_ag_wreform$SugarCane_Qt_ap <- censo_ag_wreform$SugarCane_Yield * censo_ag_wreform$AREA_HECTAREA
|
52 |
+
|
53 |
+
########################################
|
54 |
+
|
55 |
+
## Testing Bunching in the Staple Crop Output Data:
|
56 |
+
|
57 |
+
# MAIZE:
|
58 |
+
bfd.coops1 <- benford(censo_ag_wreform$Maize_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
59 |
+
bfd.haciendas1 <- benford(censo_ag_wreform$Maize_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
60 |
+
|
61 |
+
ks.test(bfd.coops1$data$data.digits,
|
62 |
+
bfd.haciendas1$data$data.digits)
|
63 |
+
|
64 |
+
bfd.coops <- benford(censo_ag_wreform$Maize_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
65 |
+
bfd.haciendas <- benford(censo_ag_wreform$Maize_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
66 |
+
|
67 |
+
ks.test(bfd.coops$data$data.digits,
|
68 |
+
bfd.haciendas$data$data.digits)
|
69 |
+
|
70 |
+
# Beans:
|
71 |
+
bfd.coops1 <- benford(censo_ag_wreform$Beans_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
72 |
+
bfd.haciendas1 <- benford(censo_ag_wreform$Beans_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
73 |
+
|
74 |
+
ks.test(bfd.coops1$data$data.digits,
|
75 |
+
bfd.haciendas1$data$data.digits)
|
76 |
+
|
77 |
+
bfd.coops <- benford(censo_ag_wreform$Beans_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
78 |
+
bfd.haciendas <- benford(censo_ag_wreform$Beans_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
79 |
+
|
80 |
+
ks.test(bfd.coops$data$data.digits,
|
81 |
+
bfd.haciendas$data$data.digits)
|
82 |
+
|
83 |
+
# Coffee:
|
84 |
+
bfd.coops1 <- benford(censo_ag_wreform$Coffee_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
85 |
+
bfd.haciendas1 <- benford(censo_ag_wreform$Coffee_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
86 |
+
|
87 |
+
ks.test(bfd.coops1$data$data.digits,
|
88 |
+
bfd.haciendas1$data$data.digits)
|
89 |
+
|
90 |
+
bfd.coops <- benford(censo_ag_wreform$Coffee_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
91 |
+
bfd.haciendas <- benford(censo_ag_wreform$Coffee_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
92 |
+
|
93 |
+
ks.test(bfd.coops$data$data.digits,
|
94 |
+
bfd.haciendas$data$data.digits)
|
95 |
+
|
96 |
+
# Sugar Cane:
|
97 |
+
bfd.coops1 <- benford(censo_ag_wreform$SugarCane_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
98 |
+
bfd.haciendas1 <- benford(censo_ag_wreform$SugarCane_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=1)
|
99 |
+
|
100 |
+
ks.test(bfd.coops1$data$data.digits,
|
101 |
+
bfd.haciendas1$data$data.digits)
|
102 |
+
|
103 |
+
bfd.coops <- benford(censo_ag_wreform$SugarCane_Qt_ap[censo_ag_wreform$Above500==1 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
104 |
+
bfd.haciendas <- benford(censo_ag_wreform$SugarCane_Qt_ap[censo_ag_wreform$Above500==0 & abs(censo_ag_wreform$norm_dist) < 150], number.of.digits=2)
|
105 |
+
|
106 |
+
ks.test(bfd.coops$data$data.digits,
|
107 |
+
bfd.haciendas$data$data.digits)
|
108 |
+
|
109 |
+
########################################
|
110 |
+
|
111 |
+
## Functions to trim (prone to huge outliers, especially when standardizing)
|
112 |
+
winsor1 <- function (x, fraction=.01)
|
113 |
+
{
|
114 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
115 |
+
fraction > 0.5) {
|
116 |
+
stop("bad value for 'fraction'")
|
117 |
+
}
|
118 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
119 |
+
x[ x < lim[1] ] <- lim[1] #lim[1] 8888
|
120 |
+
x[ x > lim[2] ] <- lim[2] #lim[2] 8888
|
121 |
+
x
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
########################################
|
126 |
+
|
127 |
+
## Differences in Bunching:
|
128 |
+
|
129 |
+
# Create indicator = 1 if ends on 0 or 5:
|
130 |
+
censo_ag_wreform <- mutate(censo_ag_wreform,
|
131 |
+
Maize_Bunch = ifelse(Maize_Qt_ap %% 10 == 0,1,0),
|
132 |
+
Beans_Bunch = ifelse(winsor1(Beans_Qt_ap,fraction = 0.025) %% 10 == 0,1,0),
|
133 |
+
Coffee_Bunch = ifelse(Coffee_Qt_ap %% 10 == 0,1,0),
|
134 |
+
Sugar_Bunch = ifelse(SugarCane_Qt_ap %% 10 == 0,1,0))
|
135 |
+
|
136 |
+
|
137 |
+
# RD - Bunching:
|
138 |
+
|
139 |
+
num_ests <- 1*4
|
140 |
+
|
141 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
142 |
+
y_var = rep(0,num_ests),
|
143 |
+
label = rep(0, num_ests))
|
144 |
+
|
145 |
+
count<-1
|
146 |
+
rdests <- rdrobust(y = (censo_ag_wreform$Maize_Bunch),
|
147 |
+
x=censo_ag_wreform$norm_dist,c = 0,p = 1,q=2,
|
148 |
+
bwselect = "mserd", cluster=censo_ag_wreform$Expropretario_ISTA)
|
149 |
+
rd_estimates[count,c("estimates")] <- rdests$coef[1]
|
150 |
+
rd_estimates[count,c("ses")] <- rdests$se[1]
|
151 |
+
rd_estimates[count,c("y_var")] <- "Maize"
|
152 |
+
rd_estimates[count,c("label")] <- paste("","Bunching at multiples of 10",sep="")
|
153 |
+
count<-count+1
|
154 |
+
|
155 |
+
rdests <- rdrobust(y = (censo_ag_wreform$Beans_Bunch),
|
156 |
+
x=censo_ag_wreform$norm_dist,c = 0,p = 1,q=2,
|
157 |
+
bwselect = "mserd", cluster=censo_ag_wreform$Expropretario_ISTA)
|
158 |
+
rd_estimates[count,c("estimates")] <- rdests$coef[1]
|
159 |
+
rd_estimates[count,c("ses")] <- rdests$se[1]
|
160 |
+
rd_estimates[count,c("y_var")] <- "Beans"
|
161 |
+
rd_estimates[count,c("label")] <- paste("","Bunching at multiples of 10",sep="")
|
162 |
+
count<-count+1
|
163 |
+
|
164 |
+
rdests <- rdrobust(y = (censo_ag_wreform$Coffee_Bunch),
|
165 |
+
x=censo_ag_wreform$norm_dist,c = 0,p = 1,q=2,
|
166 |
+
bwselect = "mserd", cluster=censo_ag_wreform$Expropretario_ISTA)
|
167 |
+
rd_estimates[count,c("estimates")] <- rdests$coef[1]
|
168 |
+
rd_estimates[count,c("ses")] <- rdests$se[1]
|
169 |
+
rd_estimates[count,c("y_var")] <- "Coffee"
|
170 |
+
rd_estimates[count,c("label")] <- paste("","Bunching at multiples of 10",sep="")
|
171 |
+
count<-count+1
|
172 |
+
|
173 |
+
rdests <- rdrobust(y = (censo_ag_wreform$Sugar_Bunch),
|
174 |
+
x=censo_ag_wreform$norm_dist,c = 0,p = 1,q=2,
|
175 |
+
bwselect = "mserd", cluster=censo_ag_wreform$Expropretario_ISTA)
|
176 |
+
rd_estimates[count,c("estimates")] <- rdests$coef[1]
|
177 |
+
rd_estimates[count,c("ses")] <- rdests$se[1]
|
178 |
+
rd_estimates[count,c("y_var")] <- "Sugar Cane"
|
179 |
+
rd_estimates[count,c("label")] <- paste("","Bunching at multiples of 10",sep="")
|
180 |
+
count<-count+1
|
181 |
+
|
182 |
+
########################################
|
183 |
+
|
184 |
+
## Making Standarized Coefficient Plots:
|
185 |
+
|
186 |
+
# Set aesthetics:
|
187 |
+
aesthetics <- list(
|
188 |
+
theme_bw(),
|
189 |
+
theme(legend.title=element_blank(),
|
190 |
+
#legend.justification=c(0,0),
|
191 |
+
#legend.position= "right", #c(1,0),
|
192 |
+
#panel.grid.minor=element_blank(),
|
193 |
+
#panel.grid.major=element_blank(),
|
194 |
+
plot.background=element_rect(colour="black",fill="white"),
|
195 |
+
panel.grid.major=element_blank(),
|
196 |
+
panel.grid.minor=element_blank(),
|
197 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
198 |
+
axis.title.y=element_text(face="bold.italic"),
|
199 |
+
axis.title.x=element_text(face="bold.italic")))
|
200 |
+
|
201 |
+
|
202 |
+
########################################
|
203 |
+
|
204 |
+
|
205 |
+
# Clean data for plotting:
|
206 |
+
alpha<- 0.05
|
207 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
208 |
+
|
209 |
+
# Find the outcome var for each regression:
|
210 |
+
data <-rd_estimates
|
211 |
+
|
212 |
+
# Replace y_var with nice names:
|
213 |
+
|
214 |
+
# Now, keep only the betas of interest:
|
215 |
+
betas <- data
|
216 |
+
dim(betas)
|
217 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
218 |
+
|
219 |
+
# Create Matrix for plotting:
|
220 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
221 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
222 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = c( "Sugar Cane",
|
223 |
+
"Coffee",
|
224 |
+
"Beans",
|
225 |
+
"Maize"))
|
226 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group) #levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
227 |
+
|
228 |
+
|
229 |
+
# Plot:
|
230 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
231 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
232 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
233 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
234 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\n RD Coefficient Estimate (Above 500 ha)") + aesthetics + xlab("")
|
235 |
+
|
236 |
+
# Save:
|
237 |
+
OutputPlot + coord_flip() #+ scale_y_continuous(breaks = seq(-1, 1,0.25))
|
238 |
+
|
239 |
+
ggsave(filename="./Output/CoefPlot_Bunching.pdf")
|
14/replication_package/Replication/Code/ESLR_EHPM_Consumption.do
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: EHPM Outcomes - RD Analysis - HH Survey ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
***************************************
|
11 |
+
*** OUTCOME - HH CONSUMPTION LEVELS ***
|
12 |
+
***************************************
|
13 |
+
|
14 |
+
use "Data/ehpm_consumptionmodule.dta", clear
|
15 |
+
|
16 |
+
gen hh_cons_pc_real = (year==2000)*hh_cons_pc*71.57/100 + ///
|
17 |
+
(year==2001)*hh_cons_pc*74.25/100 + (year==2004)*hh_cons_pc*80.68/100 + ///
|
18 |
+
(year==2005)*hh_cons_pc*84.47/100 + (year==2006)*hh_cons_pc*87.88/100 + ///
|
19 |
+
(year==2007)*hh_cons_pc*91.90/100 + (year==2008)*hh_cons_pc*98.06/100 + ///
|
20 |
+
(year==2009)*hh_cons_pc*99.10/100 + (year==2011)*hh_cons_pc*105.13/100 + ///
|
21 |
+
(year==2012)*hh_cons_pc*106.95/100 + (year==2013)*hh_cons_pc*107.79/100
|
22 |
+
winsor2 hh_cons_pc_real, replace cuts(0 98)
|
23 |
+
|
24 |
+
local cluster_level Expropretario_ISTA
|
25 |
+
local bwidth =300
|
26 |
+
|
27 |
+
reg hh_cons_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
28 |
+
sum hh_cons_pc_real if abs(norm_dist)<`bwidth'
|
29 |
+
outreg2 using "Output/Table_ConsumptionCompression.tex", replace se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
30 |
+
|
31 |
+
local bwidth = 150
|
32 |
+
reg hh_cons_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
33 |
+
sum hh_cons_pc_real if abs(norm_dist)<`bwidth'
|
34 |
+
outreg2 using "Output/Table_ConsumptionCompression.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
35 |
+
|
36 |
+
|
37 |
+
preserve
|
38 |
+
|
39 |
+
collapse (iqr) hh_cons_pc_real (mean) norm_dist Above500, by(match_id Expropretario_ISTA i_year* sex)
|
40 |
+
|
41 |
+
local bwidth =300
|
42 |
+
|
43 |
+
|
44 |
+
reg hh_cons_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
45 |
+
sum hh_cons_pc_real if abs(norm_dist)<`bwidth'
|
46 |
+
outreg2 using "Output/Table_ConsumptionCompression.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
47 |
+
|
48 |
+
local bwidth = 150
|
49 |
+
|
50 |
+
reg hh_cons_pc_real Above500 norm_dist c.norm_dist#Above500 i_year* sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
51 |
+
sum hh_cons_pc_real if abs(norm_dist)<`bwidth'
|
52 |
+
outreg2 using "Output/Table_ConsumptionCompression.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
53 |
+
|
54 |
+
restore
|
14/replication_package/Replication/Code/ESLR_EHPM_Educ.do
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: EHPM Outcomes - RD Analysis - HH Survey ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
|
11 |
+
***************************
|
12 |
+
*** OUTCOME - EDUCATION ***
|
13 |
+
***************************
|
14 |
+
|
15 |
+
|
16 |
+
use "Data/ehpm_educmodule.dta", clear
|
17 |
+
|
18 |
+
|
19 |
+
local cluster_level Expropretario_ISTA
|
20 |
+
|
21 |
+
|
22 |
+
local bwidth =300
|
23 |
+
reg educ_yrs Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' & age > 25, cluster(`cluster_level')
|
24 |
+
sum educ_yrs if abs(norm_dist)<`bwidth'
|
25 |
+
outreg2 using "Output/Table_EHPM_Educ.tex", replace se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
26 |
+
|
27 |
+
|
28 |
+
local bwidth =300
|
29 |
+
reg literate Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' & age > 25 , cluster(`cluster_level')
|
30 |
+
sum literate if abs(norm_dist)<`bwidth'
|
31 |
+
outreg2 using "Output/Table_EHPM_Educ.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
32 |
+
|
33 |
+
******************************
|
34 |
+
*** OUTCOME - AEG & Num HH ***
|
35 |
+
******************************
|
36 |
+
|
37 |
+
local cluster_level Expropretario_ISTA
|
38 |
+
|
39 |
+
local bwidth =300
|
40 |
+
reg age Above500 norm_dist c.norm_dist#Above500 i_year* sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
41 |
+
sum age if abs(norm_dist)<`bwidth'
|
42 |
+
outreg2 using "Output/Table_EHPM_Age.tex", replace se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
43 |
+
|
44 |
+
local bwidth =300
|
45 |
+
reg num_hh Above500 norm_dist c.norm_dist#Above500 i_year* sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
46 |
+
sum num_hh if abs(norm_dist)<`bwidth'
|
47 |
+
outreg2 using "Output/Table_EHPM_Age.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
48 |
+
|
49 |
+
|
14/replication_package/Replication/Code/ESLR_EHPM_Mig.do
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: EHPM Outcomes - RD Analysis - HH Survey ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
|
11 |
+
***************************
|
12 |
+
*** OUTCOME - MIGRATION ***
|
13 |
+
***************************
|
14 |
+
|
15 |
+
|
16 |
+
use "Data/ehpm_migmodule.dta", clear
|
17 |
+
local cluster_level Expropretario_ISTA
|
18 |
+
|
19 |
+
local bwidth =300
|
20 |
+
reg hh_memb_abroad Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
21 |
+
sum hh_memb_abroad if abs(norm_dist)<`bwidth'
|
22 |
+
outreg2 using "Output/Table_EHPM_Migration.tex", replace se tex nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
23 |
+
|
24 |
+
|
25 |
+
reg num_hh_memb_abroad Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
26 |
+
sum num_hh_memb_abroad if abs(norm_dist)<`bwidth'
|
27 |
+
outreg2 using "Output/Table_EHPM_Migration.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
28 |
+
|
29 |
+
|
30 |
+
reg length_recent_hh_memb_abroad Above500 norm_dist c.norm_dist#Above500 i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
31 |
+
sum length_recent_hh_memb_abroad if abs(norm_dist)<`bwidth'
|
32 |
+
outreg2 using "Output/Table_EHPM_Migration.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
14/replication_package/Replication/Code/ESLR_EHPM_PGs.do
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: EHPM Outcomes - RD Analysis - HH Survey ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
************************************
|
11 |
+
*** OUTCOME - PUBLIC GOOD ACCESS ***
|
12 |
+
************************************
|
13 |
+
|
14 |
+
use "Data/ehpm_pgmodule.dta", clear
|
15 |
+
|
16 |
+
** To Store Results + Plot in R:
|
17 |
+
global tflist ""
|
18 |
+
global modseq=0
|
19 |
+
global modid = 1
|
20 |
+
|
21 |
+
local bwidth =300
|
22 |
+
local cluster_level "Expropretario_ISTA"
|
23 |
+
|
24 |
+
** STD:
|
25 |
+
egen std_Above500 = std(Above500) if abs(norm_dist) < `bwidth'
|
26 |
+
|
27 |
+
|
28 |
+
foreach dep_var of varlist time_* {
|
29 |
+
|
30 |
+
clear matrix
|
31 |
+
|
32 |
+
global modseq=$modseq+1
|
33 |
+
tempfile tf$modseq
|
34 |
+
|
35 |
+
capture egen std_`dep_var' = std(`dep_var')
|
36 |
+
|
37 |
+
** With Survey FEs and with baseline covariates + type fixed effects
|
38 |
+
|
39 |
+
* Type FEs:
|
40 |
+
capture drop i_type_`dep_var'*
|
41 |
+
tab type_`dep_var', gen(i_type_`dep_var')
|
42 |
+
|
43 |
+
* Reg:
|
44 |
+
reg std_`dep_var' std_Above500 norm_dist c.norm_dist#c.std_Above500 i_type_`dep_var'* i_year* age age2 sex if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
45 |
+
local count = `count' + 1
|
46 |
+
capture parmest, ylabel label idn($modseq) idstr("`dep_var'") saving(`tf$modseq',replace) flist(tflist)
|
47 |
+
}
|
48 |
+
|
49 |
+
preserve
|
50 |
+
dsconcat $tflist
|
51 |
+
sort idnum
|
52 |
+
outsheet using "Output/Parmest_EHPM_PGs.csv", replace comma
|
14/replication_package/Replication/Code/ESLR_EHPM_PGsCoefPlot.R
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#######################################################
|
2 |
+
##### ESLR - COEFICIENT PLOTTING - HH SURVEY DATA #####
|
3 |
+
############# COEF PLOTS OF PG OUTCOMES ###############
|
4 |
+
#######################################################
|
5 |
+
|
6 |
+
rm(list = ls()) # Clear variables
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(RColorBrewer) # creates nice color schemes
|
10 |
+
require(scales) # customize scales
|
11 |
+
require(plyr) # join function
|
12 |
+
require(dplyr)
|
13 |
+
require(tidyr)
|
14 |
+
require(extrafont)
|
15 |
+
|
16 |
+
########################################
|
17 |
+
|
18 |
+
## Note: This file reads in the coefficient output
|
19 |
+
## and plots the coefficient estimates for the PG outcomes
|
20 |
+
|
21 |
+
########################################
|
22 |
+
|
23 |
+
# Set aesthetics:
|
24 |
+
aesthetics <- list(#guides(color=guide_colorbar(reverse=FALSE)),
|
25 |
+
#guides(fill=FALSE),
|
26 |
+
#guides(shape=FALSE),
|
27 |
+
#guides(size=FALSE),
|
28 |
+
#coord_equal(),
|
29 |
+
theme_bw(),
|
30 |
+
theme(#text=element_text(family="Palatino"),
|
31 |
+
legend.title=element_blank(),
|
32 |
+
#legend.justification=c(0,0),
|
33 |
+
#legend.position= "right", #c(1,0),
|
34 |
+
panel.grid.minor=element_blank(),
|
35 |
+
panel.grid.major=element_blank(),
|
36 |
+
#plot.background=element_rect(colour="white",fill=white),
|
37 |
+
#panel.grid.major=element_blank(),
|
38 |
+
#panel.grid.minor=element_blank(),
|
39 |
+
axis.text.y=element_text(face="bold"),
|
40 |
+
axis.title.y=element_text(face="bold")))
|
41 |
+
#axis.text=element_blank(),
|
42 |
+
#axis.ticks=element_blank(),
|
43 |
+
#panel.border = element_blank()))
|
44 |
+
|
45 |
+
Multiplier <- 1.96
|
46 |
+
|
47 |
+
########################################
|
48 |
+
|
49 |
+
# Read in parmests:
|
50 |
+
ests <- read.csv(file = "./Output/Parmest_EHPM_PGs.csv")
|
51 |
+
# Note, using the 300 ha bandwidth
|
52 |
+
|
53 |
+
########################################
|
54 |
+
|
55 |
+
# Keep only coeffients of interest:
|
56 |
+
|
57 |
+
ests <- filter(ests, parm == "std_Above500")
|
58 |
+
ests$label <- as.character(ests$label)
|
59 |
+
#ests <- ests[dim(ests)[1]:1,]
|
60 |
+
ests$idstr <- c("Bank or Credit Association","Public Phone","Internet",
|
61 |
+
"Bus Stop", "Park and/or\nSoccer Field",
|
62 |
+
"Post Office", "Market", "Health Center",
|
63 |
+
"Police Station", "Paved Road")
|
64 |
+
|
65 |
+
########################################
|
66 |
+
|
67 |
+
|
68 |
+
# Create Matrix for plotting:
|
69 |
+
MatrixofModels <- ests[c("idstr", "estimate","stderr","t","p")]
|
70 |
+
colnames(MatrixofModels) <- c("Dependent Variable", "Estimate", "StandardError", "TValue", "PValue")
|
71 |
+
MatrixofModels$`Dependent Variable` <- factor(MatrixofModels$`Dependent Variable`, levels = MatrixofModels$`Dependent Variable`)
|
72 |
+
#MatrixofModels$Legend <- c( " PCA Coefficient", rep(" Component Coefficients",dim(MatrixofModels)[1]-1))
|
73 |
+
|
74 |
+
# Plot:
|
75 |
+
OutputPlot <- qplot(`Dependent Variable`, Estimate, ymin = Estimate - Multiplier * StandardError,
|
76 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
77 |
+
ylab = NULL, xlab = NULL)
|
78 |
+
|
79 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
80 |
+
x_title <-expression(atop(bold("Dependent Variable "),italic("\n(Time to the Neearest)")))
|
81 |
+
|
82 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("Estimated Effect: Above 500 ha") +
|
83 |
+
aesthetics + xlab(x_title) + coord_flip()
|
84 |
+
|
85 |
+
OutputPlot
|
86 |
+
|
87 |
+
ggsave(filename="./Output/CoefPlot_PGDistance.pdf")
|
88 |
+
|
89 |
+
|
14/replication_package/Replication/Code/ESLR_EHPM_Sensitivity.do
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
capture log close
|
3 |
+
clear
|
4 |
+
set matsize 3000
|
5 |
+
set more off
|
6 |
+
|
7 |
+
*********************
|
8 |
+
*** Load the Data ***
|
9 |
+
*********************
|
10 |
+
|
11 |
+
use "./Data/ehpm_incomemodule_wreform.dta", clear
|
12 |
+
|
13 |
+
capture drop ln_hh_inc_pc hh_inc_pc_real ln_hh_inc_pc_real
|
14 |
+
gen ln_hh_inc_pc = log(hh_income_pc)
|
15 |
+
gen hh_inc_pc_real = (year==2000)*hh_income_pc*71.57/100 + ///
|
16 |
+
(year==2001)*hh_income_pc*74.25/100 + (year==2004)*hh_income_pc*80.68/100 + ///
|
17 |
+
(year==2005)*hh_income_pc*84.47/100 + (year==2006)*hh_income_pc*87.88/100 + ///
|
18 |
+
(year==2007)*hh_income_pc*91.90/100 + (year==2008)*hh_income_pc*98.06/100 + ///
|
19 |
+
(year==2009)*hh_income_pc*99.10/100 + (year==2011)*hh_income_pc*105.13/100 + ///
|
20 |
+
(year==2012)*hh_income_pc*106.95/100 + (year==2013)*hh_income_pc*107.79/100
|
21 |
+
gen ln_hh_inc_pc_real = log(hh_inc_pc_real )
|
22 |
+
|
23 |
+
***************************************
|
24 |
+
*** SENSITIVITY LAND/ASSET EARNINGS ***
|
25 |
+
***************************************
|
26 |
+
|
27 |
+
local count = 1
|
28 |
+
|
29 |
+
local cluster_level Expropretario_ISTA
|
30 |
+
|
31 |
+
foreach rate of numlist 0 57.17 114.15 201.13 {
|
32 |
+
|
33 |
+
capture drop asset_per_worker
|
34 |
+
gen asset_per_worker =0
|
35 |
+
replace asset_per_worker = ((`rate'*AREA_HECTAREA)/coop_size)/12 if reform==1
|
36 |
+
replace asset_per_worker = 0 if asset_per_worker==.
|
37 |
+
capture drop hh_income_pc_minus_asset
|
38 |
+
gen hh_income_pc_minus_asset = hh_inc_pc_real - asset_per_worker
|
39 |
+
|
40 |
+
local bwidth = 300
|
41 |
+
|
42 |
+
reg hh_income_pc_minus_asset Above500 norm_dist c.norm_dist#Above500 i_year* if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
43 |
+
sum hh_income_pc_minus_asset if abs(norm_dist)<`bwidth'
|
44 |
+
if(`count'==1) {
|
45 |
+
outreg2 using "./Output/Table_Earnings_Sensitivity.tex", replace se tex noobs nocons nor2 keep(Above500)addstat(Land Value,`rate', Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
46 |
+
}
|
47 |
+
else {
|
48 |
+
outreg2 using "./Output/Table_Earnings_Sensitivity.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Land Value,`rate', Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
49 |
+
}
|
50 |
+
local bwidth = 150
|
51 |
+
|
52 |
+
reg hh_income_pc_minus_asset Above500 norm_dist c.norm_dist#Above500 i_year* if abs(norm_dist) < `bwidth' , cluster(`cluster_level')
|
53 |
+
sum hh_income_pc_minus_asset if abs(norm_dist)<`bwidth'
|
54 |
+
outreg2 using "./Output/Table_Earnings_Sensitivity.tex", append se tex noobs nocons nor2 keep(Above500) addstat(Land Value,`rate', Observations, `e(N)', Clusters, `e(N_clust)', Mean Dep. Var., `r(mean)', Bandwidth, `bwidth')
|
55 |
+
|
56 |
+
*restore
|
57 |
+
|
58 |
+
local count = `count' + 1
|
59 |
+
|
60 |
+
}
|
14/replication_package/Replication/Code/ESLR_ESMap.R
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
###############################################################
|
2 |
+
#### El Salvador - Land Reform - Map of Cantons and Reform ####
|
3 |
+
###############################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(plyr) # join function
|
13 |
+
require(dplyr)
|
14 |
+
require(raster) # raster tools
|
15 |
+
require(tidyr)
|
16 |
+
require(readstata13)
|
17 |
+
require(haven)
|
18 |
+
require(exactextractr) # faster extract
|
19 |
+
require(sf) # faster extract
|
20 |
+
require(elevatr) # elevation data
|
21 |
+
require(rdrobust)
|
22 |
+
require(stringdist)
|
23 |
+
|
24 |
+
############## LOAD DATA ################
|
25 |
+
|
26 |
+
## Read in Data:
|
27 |
+
prop_data <- read.dta(file="./Data/prop_data.dta") %>% filter(reform==1, !is.na(CODIGO))
|
28 |
+
cantons <- st_read("./Data/cantons_wCodigos.shp")
|
29 |
+
|
30 |
+
# Set aesthetics:
|
31 |
+
aesthetics <- list(#guides(color=guide_colorbar(reverse=FALSE)),
|
32 |
+
#guides(fill=FALSE),
|
33 |
+
#guides(shape=FALSE),
|
34 |
+
#guides(size=FALSE),
|
35 |
+
theme_bw(),
|
36 |
+
theme(
|
37 |
+
text=element_text(family="Palatino"),
|
38 |
+
#legend.title=element_blank(),
|
39 |
+
#legend.justification=c(0,0),
|
40 |
+
#legend.position= "right", #c(1,0),
|
41 |
+
panel.border = element_blank(),
|
42 |
+
panel.grid.minor=element_blank(),
|
43 |
+
panel.grid.major=element_blank(),
|
44 |
+
axis.title.x=element_blank(),
|
45 |
+
axis.title.y=element_blank(),
|
46 |
+
axis.text=element_blank(),
|
47 |
+
axis.ticks=element_blank()))
|
48 |
+
|
49 |
+
#######################################
|
50 |
+
## MAP CANTONS THAT EXPERIENCED REFORM:
|
51 |
+
#######################################
|
52 |
+
|
53 |
+
cantons$LR <- cantons$CODIGO %in% prop_data$CODIGO
|
54 |
+
cantons$LR <- ifelse(is.na(cantons$CODIGO),FALSE,cantons$LR)
|
55 |
+
|
56 |
+
cantons_simple <- st_simplify(cantons, dTolerance=0.001, preserveTopology = TRUE)
|
57 |
+
ggplot() + geom_sf(data=cantons_simple, aes(fill=factor(LR)),size=0.1) +
|
58 |
+
aesthetics +
|
59 |
+
scale_fill_manual(name="Experienced \nLand Reform",values=c("#132B43","#56B1F7"), guide = guide_legend(reverse=TRUE), labels = c("No","Yes"))
|
60 |
+
ggsave("./Output/ESLR_ReformCantons.pdf", height=7, width=7)
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
14/replication_package/Replication/Code/ESLR_IVCenso_Commercialization.do
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Analysis - Censo IV ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color
|
10 |
+
|
11 |
+
** Set Workspace **
|
12 |
+
cd /Users/`c(username)'/Dropbox/Research_ElSalvador_LandReform/Replication
|
13 |
+
|
14 |
+
** ssc install rdrobust; winsor2; outreg2; lpoly; cmogram; dm88_1; grqreg; gr0002_3; pdslasso; lassopack; univar; ietoolkit
|
15 |
+
|
16 |
+
*********************
|
17 |
+
*** Load the Data ***
|
18 |
+
*********************
|
19 |
+
|
20 |
+
use "Data/censo_ag_wreform.dta", clear
|
21 |
+
|
22 |
+
label var Above500 "Above 500 Ha"
|
23 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
24 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
25 |
+
|
26 |
+
*********************
|
27 |
+
*** Set RD Params ***
|
28 |
+
*********************
|
29 |
+
|
30 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
31 |
+
** with ses clustered at propietor level.
|
32 |
+
local polynomial_level 1
|
33 |
+
local bandwidth_choice "mserd"
|
34 |
+
local kernel_choice "tri"
|
35 |
+
local cluster_level "Expropretario_ISTA"
|
36 |
+
|
37 |
+
|
38 |
+
**************************
|
39 |
+
*** Commercialization ****
|
40 |
+
**************************
|
41 |
+
|
42 |
+
|
43 |
+
* S20A - Commercialization
|
44 |
+
merge 1:1 agg_id using "./Data/censo_ag_commercialization.dta", gen(S20A_merge) // S20A Vars.
|
45 |
+
|
46 |
+
** Mayorista:
|
47 |
+
rdrobust MAYO norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
48 |
+
* outreg results
|
49 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
50 |
+
local n_clust = `r(ndistinct)'
|
51 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
52 |
+
outreg2 using "Output/Table_Commercialization.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
53 |
+
|
54 |
+
** Minorista:
|
55 |
+
rdrobust MINO norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
56 |
+
* outreg results
|
57 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
58 |
+
local n_clust = `r(ndistinct)'
|
59 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
60 |
+
outreg2 using "Output/Table_Commercialization.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
61 |
+
|
62 |
+
** Exported:
|
63 |
+
rdrobust EXPO norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
64 |
+
* outreg results
|
65 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
66 |
+
local n_clust = `r(ndistinct)'
|
67 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
68 |
+
outreg2 using "Output/Table_Commercialization.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
69 |
+
|
70 |
+
** Other:
|
71 |
+
rdrobust OTRO norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
72 |
+
* outreg results
|
73 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
74 |
+
local n_clust = `r(ndistinct)'
|
75 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
76 |
+
outreg2 using "Output/Table_Commercialization.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)')
|
77 |
+
|
14/replication_package/Replication/Code/ESLR_IVCenso_RDRandInf.do
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*******************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Rand. Inf. - Censo IV ***
|
3 |
+
*******************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
*ssc install rdlocrand
|
11 |
+
|
12 |
+
*********************
|
13 |
+
*** Load the Data ***
|
14 |
+
*********************
|
15 |
+
|
16 |
+
use "Data/censo_ag_wreform.dta", clear
|
17 |
+
|
18 |
+
label var Above500 "Above 500 Ha"
|
19 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
20 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
21 |
+
|
22 |
+
******************
|
23 |
+
*** Set Params ***
|
24 |
+
******************
|
25 |
+
|
26 |
+
** Robustness: We will use the randomization methods for RDs - https://sites.google.com/site/rdpackages/rdlocrand
|
27 |
+
** with ses clustered at proprietor level.
|
28 |
+
** Will also use two-sided MSE optimal bandwidth since big diff in density on
|
29 |
+
** both sides.
|
30 |
+
** Will use rdrandinf package
|
31 |
+
|
32 |
+
local polynomial_levels 0
|
33 |
+
local bandwidth_choice `" "mserd" "'
|
34 |
+
local kernel_choice `" "uniform" "triangular" "epan" "'
|
35 |
+
local kernel_choice_rdrob `" "uniform" "triangular" "epanechnikov" "'
|
36 |
+
|
37 |
+
local cluster_level "Expropretario_ISTA" // not allowed in rdlocrand: vce(cluster `cluster_level')
|
38 |
+
|
39 |
+
** Also do Local Randomization methods with rdlocrand
|
40 |
+
|
41 |
+
** Selecting Window:
|
42 |
+
global covariates canton_land_suit
|
43 |
+
|
44 |
+
|
45 |
+
**********************************************
|
46 |
+
*** OUTCOME 1A - AGRICULTURAL PRODUCTIVITY ***
|
47 |
+
**********************************************
|
48 |
+
|
49 |
+
set more off
|
50 |
+
|
51 |
+
local dep_var ln_agprod_pricew_crops
|
52 |
+
|
53 |
+
foreach pols in `polynomial_levels' {
|
54 |
+
local count = 0
|
55 |
+
*foreach band in `bandwidth_choice' {
|
56 |
+
|
57 |
+
foreach kern in `kernel_choice' {
|
58 |
+
su `dep_var' // if norm_dist < `r(wr)' & norm_dist > `r(wl)' & `dep_var' !=. & norm_dist!=.
|
59 |
+
local summ = `r(mean)'
|
60 |
+
|
61 |
+
dis "rdrandinf ln_agprod_pricew_crops norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate"
|
62 |
+
rdrandinf `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate seed(123)
|
63 |
+
|
64 |
+
* outreg results
|
65 |
+
*distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
66 |
+
local n_obs = `r(N)'
|
67 |
+
local inf_estimate = `r(obs_stat)'
|
68 |
+
local pvalue=`r(asy_pval)'
|
69 |
+
local rw = `r(wr)'
|
70 |
+
local lw = `r(wl)'
|
71 |
+
if ("`kern'"=="epan") {
|
72 |
+
local kern "epanechnikov"
|
73 |
+
}
|
74 |
+
dis "rdrobust `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') vce(cluster `cluster_level')"
|
75 |
+
rdrobust `dep_var' norm_dist, c(0) p(`pols') bwselect(`bandwidth_choice') kernel(`kern') vce(cluster `cluster_level')
|
76 |
+
if `count'==0 {
|
77 |
+
dis "outreg2 `r(obs_stat)' `r(randpval)' using, replace se tex noobs addstat(Observations, `n_obs', Mean Dep. Var., `summ', Randomization P-Value, `pvalue', Right Window, `rw', Left Window, `lw') addtext(Polynomial, `pol', Kernel, uniform, Fuzzy RD, N)"
|
78 |
+
|
79 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", replace se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate', Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
80 |
+
}
|
81 |
+
if `count'!=0 {
|
82 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", append se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
83 |
+
}
|
84 |
+
local count = 1
|
85 |
+
}
|
86 |
+
|
87 |
+
*}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
local dep_var ln_agprod
|
92 |
+
|
93 |
+
foreach pols in `polynomial_levels' {
|
94 |
+
local count = 0
|
95 |
+
*foreach band in `bandwidth_choice' {
|
96 |
+
|
97 |
+
foreach kern in `kernel_choice' {
|
98 |
+
su `dep_var' // if norm_dist < `r(wr)' & norm_dist > `r(wl)' & `dep_var' !=. & norm_dist!=.
|
99 |
+
local summ = `r(mean)'
|
100 |
+
|
101 |
+
dis "rdrandinf ln_agprod_pricew_crops norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate"
|
102 |
+
rdrandinf `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate seed(123)
|
103 |
+
|
104 |
+
* outreg results
|
105 |
+
*distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
106 |
+
local n_obs = `r(N)'
|
107 |
+
local inf_estimate = `r(obs_stat)'
|
108 |
+
local pvalue=`r(asy_pval)'
|
109 |
+
local rw = `r(wr)'
|
110 |
+
local lw = `r(wl)'
|
111 |
+
if ("`kern'"=="epan") {
|
112 |
+
local kern "epanechnikov"
|
113 |
+
}
|
114 |
+
dis "rdrobust `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') vce(cluster `cluster_level')"
|
115 |
+
rdrobust `dep_var' norm_dist, c(0) p(`pols') bwselect(`bandwidth_choice') kernel(`kern') vce(cluster `cluster_level')
|
116 |
+
if `count'==0 {
|
117 |
+
dis "outreg2 `r(obs_stat)' `r(randpval)' using, replace se tex noobs addstat(Observations, `n_obs', Mean Dep. Var., `summ', Randomization P-Value, `pvalue', , Right Window, `rw', Left Window, `lw') addtext(Polynomial, `pol', Kernel, uniform, Fuzzy RD, N)"
|
118 |
+
|
119 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", append se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate', Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
120 |
+
}
|
121 |
+
if `count'!=0{
|
122 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", append se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
123 |
+
}
|
124 |
+
local count = 1
|
125 |
+
}
|
126 |
+
|
127 |
+
*}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
local dep_var ln_tfp_geo
|
133 |
+
|
134 |
+
foreach pols in `polynomial_levels' {
|
135 |
+
local count = 0
|
136 |
+
*foreach band in `bandwidth_choice' {
|
137 |
+
|
138 |
+
foreach kern in `kernel_choice' {
|
139 |
+
su `dep_var' // if norm_dist < `r(wr)' & norm_dist > `r(wl)' & `dep_var' !=. & norm_dist!=.
|
140 |
+
local summ = `r(mean)'
|
141 |
+
|
142 |
+
dis "rdrandinf ln_agprod_pricew_crops norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate"
|
143 |
+
rdrandinf `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate seed(123)
|
144 |
+
|
145 |
+
* outreg results
|
146 |
+
*distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
147 |
+
local n_obs = `r(N)'
|
148 |
+
local inf_estimate = `r(obs_stat)'
|
149 |
+
local pvalue=`r(asy_pval)'
|
150 |
+
local rw = `r(wr)'
|
151 |
+
local lw = `r(wl)'
|
152 |
+
if ("`kern'"=="epan") {
|
153 |
+
local kern "epanechnikov"
|
154 |
+
}
|
155 |
+
dis "rdrobust `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') vce(cluster `cluster_level')"
|
156 |
+
rdrobust `dep_var' norm_dist, c(0) p(`pols') bwselect(`bandwidth_choice') kernel(`kern') vce(cluster `cluster_level')
|
157 |
+
if `count'==0 {
|
158 |
+
dis "outreg2 `r(obs_stat)' `r(randpval)' using, replace se tex noobs addstat(Observations, `n_obs', Mean Dep. Var., `summ', Randomization P-Value, `pvalue', , Right Window, `rw', Left Window, `lw') addtext(Polynomial, `pol', Kernel, uniform, Fuzzy RD, N)"
|
159 |
+
|
160 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", append se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate', Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
161 |
+
}
|
162 |
+
if `count'!=0{
|
163 |
+
outreg2 using "Output/RandInfTable1_LogProductivity`pol'.tex", append se pvalue tex noobs addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
164 |
+
}
|
165 |
+
local count = 1
|
166 |
+
}
|
167 |
+
|
168 |
+
*}
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
******************************
|
173 |
+
*** OUTCOME 2 - CASH CROPS ***
|
174 |
+
******************************
|
175 |
+
|
176 |
+
** SHARE LAND IN CASH CROPS:
|
177 |
+
set more off
|
178 |
+
local dep_var CashCrop_Share
|
179 |
+
|
180 |
+
foreach pols in `polynomial_levels' {
|
181 |
+
local count = 0
|
182 |
+
*foreach band in `bandwidth_choice' {
|
183 |
+
|
184 |
+
foreach kern in `kernel_choice' {
|
185 |
+
su `dep_var' // if norm_dist < `r(wr)' & norm_dist > `r(wl)' & `dep_var' !=. & norm_dist!=.
|
186 |
+
local summ = `r(mean)'
|
187 |
+
|
188 |
+
rdrandinf `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate seed(123)
|
189 |
+
|
190 |
+
* outreg results
|
191 |
+
*distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
192 |
+
local n_obs = `r(N)'
|
193 |
+
local inf_estimate = `r(obs_stat)'
|
194 |
+
local pvalue=`r(asy_pval)'
|
195 |
+
local rw = `r(wr)'
|
196 |
+
local lw = `r(wl)'
|
197 |
+
|
198 |
+
if ("`kern'"=="epan") {
|
199 |
+
local kern "epanechnikov"
|
200 |
+
}
|
201 |
+
rdrobust `dep_var' norm_dist, c(0) p(`pols') bwselect(`bandwidth_choice') kernel(`kern') vce(cluster `cluster_level')
|
202 |
+
|
203 |
+
if `count'==0 {
|
204 |
+
outreg2 using "Output/RandInfTable2_CropShare`pol'.tex", replace se tex noobs pvalue addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
205 |
+
}
|
206 |
+
if `count'!=0{
|
207 |
+
outreg2 using "Output/RandInfTable2_CropShare`pol'.tex", append se tex noobs pvalue addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
208 |
+
}
|
209 |
+
local count = 1
|
210 |
+
}
|
211 |
+
|
212 |
+
*}
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
********************************
|
218 |
+
*** OUTCOME 3 - STAPLE CROPS ***
|
219 |
+
********************************
|
220 |
+
|
221 |
+
** SHARE LAND IN STAPLE CROPS:
|
222 |
+
set more off
|
223 |
+
local dep_var StapleCrop_Share
|
224 |
+
|
225 |
+
foreach pols in `polynomial_levels' {
|
226 |
+
local count = 0
|
227 |
+
*foreach band in `bandwidth_choice' {
|
228 |
+
|
229 |
+
foreach kern in `kernel_choice' {
|
230 |
+
su `dep_var' // if norm_dist < `r(wr)' & norm_dist > `r(wl)' & `dep_var' !=. & norm_dist!=.
|
231 |
+
local summ = `r(mean)'
|
232 |
+
|
233 |
+
rdrandinf `dep_var' norm_dist, c(0) p(`pols') kernel(`kern') covariates($covariates) approximate seed(123)
|
234 |
+
|
235 |
+
* outreg results
|
236 |
+
*distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
237 |
+
local n_obs = `r(N)'
|
238 |
+
local inf_estimate = `r(obs_stat)'
|
239 |
+
local pvalue=`r(asy_pval)'
|
240 |
+
local rw = `r(wr)'
|
241 |
+
local lw = `r(wl)'
|
242 |
+
|
243 |
+
if ("`kern'"=="epan") {
|
244 |
+
local kern "epanechnikov"
|
245 |
+
}
|
246 |
+
rdrobust `dep_var' norm_dist, c(0) p(`pols') bwselect(`bandwidth_choice') kernel(`kern') vce(cluster `cluster_level')
|
247 |
+
|
248 |
+
outreg2 using "Output/RandInfTable2_CropShare`pol'.tex", append se tex noobs pvalue addtext(Polynomial, `pols', Kernel, "`kern'", Fuzzy RD, N) addstat(Estimate, `inf_estimate',Randomization P-Value, `pvalue', Observations, `n_obs', Mean Dep. Var., `summ', Right Window, `rw', Left Window, `lw')
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
*}
|
253 |
+
|
254 |
+
}
|
14/replication_package/Replication/Code/ESLR_IVCenso_RDRobustness.do
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*******************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Robustness - Censo IV ***
|
3 |
+
*******************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
*********************
|
11 |
+
*** Load the Data ***
|
12 |
+
*********************
|
13 |
+
|
14 |
+
use "Data/censo_ag_wreform.dta", clear
|
15 |
+
|
16 |
+
label var Above500 "Above 500 Ha"
|
17 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
18 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
19 |
+
|
20 |
+
******************
|
21 |
+
*** Set Params ***
|
22 |
+
******************
|
23 |
+
|
24 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
25 |
+
** with ses clustered at propietor level.
|
26 |
+
** Will also use two-sided MSE optimal bandwidth since big diff in density on
|
27 |
+
** both sides.
|
28 |
+
** Will use rdrobust package
|
29 |
+
|
30 |
+
local polynomial_levels 0 1 2
|
31 |
+
local bandwidth_choice `" "mserd" "msetwo" "cerrd" "certwo" "'
|
32 |
+
local kernel_choice `" "tri" "uni" "epanechnikov" "'
|
33 |
+
local cluster_level "Expropretario_ISTA"
|
34 |
+
|
35 |
+
** Also do Local Randomization methods with rdlocrand
|
36 |
+
|
37 |
+
**********************************************
|
38 |
+
*** OUTCOME 1A - AGRICULTURAL PRODUCTIVITY ***
|
39 |
+
**********************************************
|
40 |
+
|
41 |
+
set more off
|
42 |
+
|
43 |
+
foreach pol in `polynomial_levels' {
|
44 |
+
local count = 0
|
45 |
+
foreach band in `bandwidth_choice' {
|
46 |
+
|
47 |
+
foreach kern in `kernel_choice' {
|
48 |
+
|
49 |
+
|
50 |
+
capture {
|
51 |
+
rdrobust ln_agprod_pricew_crops norm_dist, c(0) p(`pol') bwselect(`band') kernel(`kern') vce(cluster `cluster_level')
|
52 |
+
}
|
53 |
+
if _rc==1 {
|
54 |
+
rdrobust ln_agprod_pricew_crops norm_dist, c(0) p(`pol') b(100) h(150) kernel(`kern') vce(cluster `cluster_level')
|
55 |
+
}
|
56 |
+
* outreg results
|
57 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
58 |
+
local n_clust = `r(ndistinct)'
|
59 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
60 |
+
if `count'==0 {
|
61 |
+
outreg2 using "Output/TableRDRobustness1_LogProductivity`pol'.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'", Fuzzy RD, N)
|
62 |
+
}
|
63 |
+
if `count'!=0{
|
64 |
+
outreg2 using "Output/TableRDRobustness1_LogProductivity`pol'.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'",Fuzzy RD, N)
|
65 |
+
}
|
66 |
+
local count = 1
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
foreach pol in `polynomial_levels' {
|
74 |
+
local count = 0
|
75 |
+
foreach band in `bandwidth_choice' {
|
76 |
+
|
77 |
+
foreach kern in `kernel_choice' {
|
78 |
+
|
79 |
+
capture {
|
80 |
+
rdrobust ln_agprod norm_dist, c(0) p(`pol') bwselect(`band') kernel(`kern') vce(cluster `cluster_level')
|
81 |
+
}
|
82 |
+
if _rc==1 {
|
83 |
+
rdrobust ln_agprod norm_dist, c(0) p(`pol') b(100) h(150) kernel(`kern') vce(cluster `cluster_level')
|
84 |
+
}
|
85 |
+
* outreg results
|
86 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
87 |
+
local n_clust = `r(ndistinct)'
|
88 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
89 |
+
if `count'==0 {
|
90 |
+
outreg2 using "Output/TableRDRobustness1_LogProfits`pol'.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'", Fuzzy RD, N)
|
91 |
+
}
|
92 |
+
if `count'!=0{
|
93 |
+
outreg2 using "Output/TableRDRobustness1_LogProfits`pol'.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'",Fuzzy RD, N)
|
94 |
+
}
|
95 |
+
local count = 1
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
foreach pol in `polynomial_levels' {
|
103 |
+
local count = 0
|
104 |
+
foreach band in `bandwidth_choice' {
|
105 |
+
|
106 |
+
foreach kern in `kernel_choice' {
|
107 |
+
|
108 |
+
capture {
|
109 |
+
rdrobust ln_tfp_geo norm_dist, c(0) p(`pol') bwselect(`band') kernel(`kern') vce(cluster `cluster_level')
|
110 |
+
}
|
111 |
+
if _rc==1 {
|
112 |
+
rdrobust ln_tfp_geo norm_dist, c(0) p(`pol') b(100) h(150) kernel(`kern') vce(cluster `cluster_level')
|
113 |
+
}
|
114 |
+
* outreg results
|
115 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
116 |
+
local n_clust = `r(ndistinct)'
|
117 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
118 |
+
if `count'==0 {
|
119 |
+
outreg2 using "Output/TableRDRobustness1_TFP`pol'.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'", Fuzzy RD, N)
|
120 |
+
}
|
121 |
+
if `count'!=0{
|
122 |
+
outreg2 using "Output/TableRDRobustness1_TFP`pol'.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'",Fuzzy RD, N)
|
123 |
+
}
|
124 |
+
local count = 1
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
******************************
|
132 |
+
*** OUTCOME 2 - CASH CROPS ***
|
133 |
+
******************************
|
134 |
+
|
135 |
+
** SHARE LAND IN CASH CROPS:
|
136 |
+
set more off
|
137 |
+
|
138 |
+
foreach pol in `polynomial_levels' {
|
139 |
+
local count = 0
|
140 |
+
foreach band in `bandwidth_choice' {
|
141 |
+
|
142 |
+
foreach kern in `kernel_choice' {
|
143 |
+
|
144 |
+
rdrobust CashCrop_Share norm_dist, c(0) p(`pol') bwselect(`band') kernel(`kern') vce(cluster `cluster_level')
|
145 |
+
* outreg results
|
146 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
147 |
+
local n_clust = `r(ndistinct)'
|
148 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
149 |
+
if `count'==0 {
|
150 |
+
outreg2 using "Output/TableRDRobustness2_CashCropShare`pol'.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'", Fuzzy RD, N)
|
151 |
+
}
|
152 |
+
if `count'!=0{
|
153 |
+
outreg2 using "Output/TableRDRobustness2_CashCropShare`pol'.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'",Fuzzy RD, N)
|
154 |
+
}
|
155 |
+
local count = 1
|
156 |
+
}
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
********************************
|
164 |
+
*** OUTCOME 3 - STAPLE CROPS ***
|
165 |
+
********************************
|
166 |
+
|
167 |
+
** SHARE LAND IN STAPLE CROPS:
|
168 |
+
set more off
|
169 |
+
|
170 |
+
foreach pol in `polynomial_levels' {
|
171 |
+
local count = 0
|
172 |
+
foreach band in `bandwidth_choice' {
|
173 |
+
|
174 |
+
foreach kern in `kernel_choice' {
|
175 |
+
|
176 |
+
rdrobust StapleCrop_Share norm_dist, c(0) p(`pol') bwselect(`band') kernel(`kern') vce(cluster `cluster_level')
|
177 |
+
* outreg results
|
178 |
+
distinct `cluster_level' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)' & `e(outcomevar)'!=. & `e(runningvar)'!=.
|
179 |
+
local n_clust = `r(ndistinct)'
|
180 |
+
su `e(outcomevar)' if norm_dist < `e(h_l)' & norm_dist > -1*`e(h_r)'
|
181 |
+
if `count'==0 {
|
182 |
+
outreg2 using "Output/TableRDRobustness3_StapleCropShare`pol'.tex", replace se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'", Fuzzy RD, N)
|
183 |
+
}
|
184 |
+
if `count'!=0{
|
185 |
+
outreg2 using "Output/TableRDRobustness3_StapleCropShare`pol'.tex", append se tex noobs addstat(Observations, `e(N_h_l)' + `e(N_h_r)', Clusters, `n_clust', Mean Dep. Var., `r(mean)', Bandwidth, `e(h_l)') addtext(Polynomial, `pol', Bandwidth Type, "`band'", Kernel, "`kern'",Fuzzy RD, N)
|
186 |
+
}
|
187 |
+
local count = 1
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
14/replication_package/Replication/Code/ESLR_IVCensus_AdditionalPlots.R
ADDED
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#############################################
|
2 |
+
########### ESLR - EXTENTSIONS ##############
|
3 |
+
############### COEF PLOTS ##################
|
4 |
+
#############################################
|
5 |
+
|
6 |
+
rm(list = ls()) # Clear variables
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(RColorBrewer) # creates nice color schemes
|
10 |
+
require(scales) # customize scales
|
11 |
+
require(plyr) # join function
|
12 |
+
require(dplyr)
|
13 |
+
require(haven) # stata save
|
14 |
+
require(dotwhisker)
|
15 |
+
|
16 |
+
########################################
|
17 |
+
|
18 |
+
# write a simple function to add footnote
|
19 |
+
makeFootnote <- function(footnoteText =
|
20 |
+
format(Sys.time(), "%d %b %Y"),
|
21 |
+
size = .7, color = grey(.5))
|
22 |
+
{
|
23 |
+
require(grid)
|
24 |
+
pushViewport(viewport())
|
25 |
+
grid.text(label = footnoteText ,
|
26 |
+
x = unit(1,"npc") - unit(2, "mm"),
|
27 |
+
y = unit(2, "mm"),
|
28 |
+
just = c("right", "bottom"),
|
29 |
+
gp = gpar(cex = size, col = color))
|
30 |
+
popViewport()
|
31 |
+
}
|
32 |
+
# Source: http://statmodeling.com/best-way-to-add-a-footnote-to-a-plot-created-with-ggplot2.html
|
33 |
+
|
34 |
+
########################################
|
35 |
+
|
36 |
+
## Making Standarized Coefficient Plots:
|
37 |
+
|
38 |
+
# Set aesthetics:
|
39 |
+
aesthetics <- list(
|
40 |
+
theme_bw(),
|
41 |
+
theme(text=element_text(family="Palatino"),
|
42 |
+
legend.title=element_blank(),
|
43 |
+
#legend.justification=c(0,0),
|
44 |
+
#legend.position= "right", #c(1,0),
|
45 |
+
#panel.grid.minor=element_blank(),
|
46 |
+
#panel.grid.major=element_blank(),
|
47 |
+
plot.background=element_rect(colour="white",fill="white"),
|
48 |
+
panel.grid.major=element_blank(),
|
49 |
+
panel.grid.minor=element_blank(),
|
50 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
51 |
+
axis.title.y=element_text(face="bold.italic")))
|
52 |
+
#axis.text=element_blank(),
|
53 |
+
#axis.ticks=element_blank(),
|
54 |
+
#panel.border = element_blank()))
|
55 |
+
|
56 |
+
########################################
|
57 |
+
|
58 |
+
#### Plots for Different Minor Crops:
|
59 |
+
|
60 |
+
## load data:
|
61 |
+
data <- read.csv("./Output/Temp/MinorCropProduction.csv")
|
62 |
+
data <- filter(data,estimate!=0)
|
63 |
+
|
64 |
+
|
65 |
+
# Clean data for plotting:
|
66 |
+
alpha<- 0.05
|
67 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
68 |
+
|
69 |
+
# Find the outcome var for each regression:
|
70 |
+
data$idstr <- as.character(data$idstr)
|
71 |
+
data$y_var <- data$idstr
|
72 |
+
data <- filter(data,y_var!="S5BEJOTE",
|
73 |
+
y_var!="S5BMELON",
|
74 |
+
y_var!="S5BCAMOTE")
|
75 |
+
# Replace y_var with nice names:
|
76 |
+
data$y_var[which(data$y_var == "S5BCAMOTE")] <- "Sweet Potato"
|
77 |
+
data$y_var[which(data$y_var == "S5BCHILE")] <- "Bell Peppers"
|
78 |
+
data$y_var[which(data$y_var == "S5BCHILEPICANTE")] <- "Chile"
|
79 |
+
data$y_var[which(data$y_var == "S5BEJOTE")] <- "Bejote"
|
80 |
+
data$y_var[which(data$y_var == "S5BGUISQUIL")] <- "Squash"
|
81 |
+
data$y_var[which(data$y_var == "S5BLOROCO")] <- "Loroco"
|
82 |
+
data$y_var[which(data$y_var == "S5BMELON")] <- "Melon"
|
83 |
+
data$y_var[which(data$y_var == "S5BPEPINO")] <- "Cucumber"
|
84 |
+
data$y_var[which(data$y_var == "S5BPIPIAN")] <- "Pipian"
|
85 |
+
data$y_var[which(data$y_var == "S5BRABANO")] <- "Radish"
|
86 |
+
data$y_var[which(data$y_var == "S5BSANDIA")] <- "Watermelon"
|
87 |
+
data$y_var[which(data$y_var == "S5BTOMATE")] <- "Tomato"
|
88 |
+
data$y_var[which(data$y_var == "S5BYUCA")] <- "Yuca"
|
89 |
+
|
90 |
+
# Now, keep only the betas of interest:
|
91 |
+
betas <- data %>% filter(!grepl("S5B",y_var))
|
92 |
+
dim(betas)
|
93 |
+
betas <- arrange(betas,betas$y_var)
|
94 |
+
|
95 |
+
# Create Matrix for plotting:
|
96 |
+
MatrixofModels <- betas[c("y_var", "estimate","stderr","z","p","idnum")]
|
97 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "TValue", "PValue", "ModelName")
|
98 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = MatrixofModels$IV)
|
99 |
+
#MatrixofModels$Legend <- c(" AES Coefficient", rep(" Standard Coefficients",4))
|
100 |
+
|
101 |
+
# Re-name for plotting:
|
102 |
+
MatrixofModels$ModelName <- "Minor Vegetable Production"
|
103 |
+
#MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
104 |
+
|
105 |
+
# Plot:
|
106 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
107 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
108 |
+
ylab = NULL, xlab = NULL)
|
109 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
110 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nEstimated Effect") + aesthetics + xlab("")
|
111 |
+
|
112 |
+
# Save:
|
113 |
+
OutputPlot
|
114 |
+
ggsave(filename = "./Output/CoefPlot_MinorCrops.pdf", height=6, width=9)
|
115 |
+
|
116 |
+
########################################
|
117 |
+
|
118 |
+
#### Plots for Different Minor Fruits:
|
119 |
+
|
120 |
+
## load data:
|
121 |
+
data <- read.csv("./Output/Temp/MinorFruitProduction.csv")
|
122 |
+
data <- filter(data,estimate!=0)
|
123 |
+
#data$parm[which(data$parm == "RD_Estimate")] <- "Above 500"
|
124 |
+
|
125 |
+
# Clean data for plotting:
|
126 |
+
alpha<- 0.05
|
127 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
128 |
+
|
129 |
+
# Find the outcome var for each regression:
|
130 |
+
data$idstr <- as.character(data$idstr)
|
131 |
+
data$y_var <- data$idstr
|
132 |
+
# Replace y_var with nice names:
|
133 |
+
data$y_var[which(data$y_var == "S8BCOCO")] <- "Coconut"
|
134 |
+
data$y_var[which(data$y_var == "S8BGUINEO")] <- "Guineo Banana"
|
135 |
+
data$y_var[which(data$y_var == "S8BJOCOTE")] <- "Jocote"
|
136 |
+
data$y_var[which(data$y_var == "S8BLIMON")] <- "Lemon"
|
137 |
+
data$y_var[which(data$y_var == "S8BMANDARINA")] <- "Mandarin"
|
138 |
+
data$y_var[which(data$y_var == "S8BMANGO")] <- "Mango"
|
139 |
+
data$y_var[which(data$y_var == "S8BNARANJA")] <- "Orange"
|
140 |
+
data$y_var[which(data$y_var == "S8BNISPERO")] <- "Medlar"
|
141 |
+
data$y_var[which(data$y_var == "S8BPAPAYA")] <- "Papaya"
|
142 |
+
data$y_var[which(data$y_var == "S8BPLATANO")] <- "Plantain"
|
143 |
+
data$y_var[which(data$y_var == "S8BZAPOTE")] <- "Sapodilla"
|
144 |
+
|
145 |
+
# Now, keep only the betas of interest:
|
146 |
+
betas <- data %>% filter(!grepl("S8B",y_var))
|
147 |
+
dim(betas)
|
148 |
+
betas <- arrange(betas,betas$y_var)
|
149 |
+
|
150 |
+
# Create Matrix for plotting:
|
151 |
+
MatrixofModels <- betas[c("y_var", "estimate","stderr","z","p","idnum")]
|
152 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "TValue", "PValue", "ModelName")
|
153 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = MatrixofModels$IV)
|
154 |
+
#MatrixofModels$Legend <- c(" AES Coefficient", rep(" Standard Coefficients",4))
|
155 |
+
|
156 |
+
# Re-name for plotting:
|
157 |
+
MatrixofModels$ModelName <- "Minor Fruit Production"
|
158 |
+
#MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
159 |
+
|
160 |
+
# Plot:
|
161 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
162 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
163 |
+
ylab = NULL, xlab = NULL)
|
164 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
165 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nEstimated Effect") + aesthetics + xlab("")
|
166 |
+
|
167 |
+
# Save:
|
168 |
+
OutputPlot
|
169 |
+
ggsave(filename = "./Output/CoefPlot_MinorFruits.pdf", height=6, width=9)
|
170 |
+
|
171 |
+
########################################
|
172 |
+
|
173 |
+
#### Plots for Different Inputs:
|
174 |
+
|
175 |
+
## load data:
|
176 |
+
data <- read.csv("./Output/Temp/InputUse.csv")
|
177 |
+
data <- filter(data,estimate!=0)
|
178 |
+
#data$parm[which(data$parm == "RD_Estimate")] <- "Above 500"
|
179 |
+
|
180 |
+
# Clean data for plotting:
|
181 |
+
alpha<- 0.05
|
182 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
183 |
+
|
184 |
+
# Find the outcome var for each regression:
|
185 |
+
data$idstr <- as.character(data$idstr)
|
186 |
+
data$y_var <- data$idstr
|
187 |
+
data <- filter(data,y_var!="S15BCASTRACION",
|
188 |
+
y_var!="S15BCONTROLBIOLOGICOPECESABEJAS",
|
189 |
+
y_var!="S15BCONTROLQUIMICODEPLAGASYENFE",
|
190 |
+
y_var!="S15BDESPARASITACION",
|
191 |
+
y_var!="S15BDESPARASITANTES",
|
192 |
+
y_var!="S15BINSEMINACIONARTIFICIAL",
|
193 |
+
y_var!="S15BMANEJOINTEGRADODEPLAGASMIP",
|
194 |
+
y_var!="S15BMEJORAMIENTOGENETICO",
|
195 |
+
y_var!="S15BPIEDECRIA",
|
196 |
+
y_var!="S15BPRACTICASPREVENTIVASDEDANOS",
|
197 |
+
y_var!="S15BPRODUCTOSVETERINARIOSALCOHO",
|
198 |
+
y_var!="S15BREGISTROSADMINISTRATIVOSDEL",
|
199 |
+
y_var!="S15BREGULADORESDECRECIMIENTO",
|
200 |
+
y_var!="S15BREGULADORESDECRECIMIENTOENZ",
|
201 |
+
y_var!="S15BROTACIONDEPOTREROS",
|
202 |
+
y_var!="S15BSUPLEMENTOSNUTRICIONALES",
|
203 |
+
y_var!="S15BVACUNACION",
|
204 |
+
y_var!="S15BVACUNAS",
|
205 |
+
y_var!="S15BANTIBIOTICOS")
|
206 |
+
|
207 |
+
# Replace y_var with nice names:
|
208 |
+
# cat(paste("data$y_var[which(data$y_var == ",data$y_var,")] <- "),sep="\n")
|
209 |
+
data$y_var[which(data$y_var == "S15BABONOOFERTILIZANTEFOLIARLIQ" )] <- "Fertilizer - Liquid"
|
210 |
+
data$y_var[which(data$y_var == "S15BABONOOFERTILIZANTEGRANULARS" )] <- "Fertilizer - Solid"
|
211 |
+
data$y_var[which(data$y_var == "S15BAGENTESDEMADURACIONPOSTCOSE" )] <- "Compost"
|
212 |
+
data$y_var[which(data$y_var == "S15BAGENTESPARAPROTECCIONDEPROD" )] <- "Pesticides"
|
213 |
+
data$y_var[which(data$y_var == "S15BANALISISDESUELOYOFOLIAR" )] <- "Soil Tests"
|
214 |
+
data$y_var[which(data$y_var == "S15BAPLICACIONDEABONOYFERTILIZA" )] <- "Fertilizer Applied"
|
215 |
+
data$y_var[which(data$y_var == "S15BAPLICACIONDERIEGOPORASPERSI" )] <- "Sprinkler Irrigation"
|
216 |
+
data$y_var[which(data$y_var == "S15BAPLICACIONDERIEGOPORGOTEO" )] <- "Drip Irrigation"
|
217 |
+
data$y_var[which(data$y_var == "S15BAPLICACIONDERIEGOPORGRAVEDA" )] <- "Gravity Irrigation"
|
218 |
+
data$y_var[which(data$y_var == "S15BBACTERICIDAS" )] <- "Bactericides"
|
219 |
+
data$y_var[which(data$y_var == "S15BFUNGICIDAS" )] <- "Fungicides"
|
220 |
+
data$y_var[which(data$y_var == "S15BLABORESCULTURALES" )] <- "Labor Trimming"
|
221 |
+
data$y_var[which(data$y_var == "S15BMATERIALVEGETATIVO" )] <- "Organic Fertilizer"
|
222 |
+
data$y_var[which(data$y_var == "S15BNEMATICIDAS" )] <- "Nematicides"
|
223 |
+
data$y_var[which(data$y_var == "S15BOBRASDECONSERVACIONDESUELOS" )] <- "Erosion Work"
|
224 |
+
data$y_var[which(data$y_var == "S15BPREPARACIONDELSUELO" )] <- "Soil Preparation"
|
225 |
+
data$y_var[which(data$y_var == "S15BPROTECCIONDECULTIVOS" )] <- "Crop Protection"
|
226 |
+
data$y_var[which(data$y_var == "S15BRESIEMBRAYOREPLANTACION" )] <- "Reseeding + Replanting"
|
227 |
+
data$y_var[which(data$y_var == "S15BSEMILLACERTIFICADA" )] <- "Certified Seeds"
|
228 |
+
data$y_var[which(data$y_var == "S15BSEMILLACRIOLLA" )] <- "Creole Seeds"
|
229 |
+
data$y_var[which(data$y_var == "S15BSEMILLAMEJORADA" )] <- "Improved Seeds"
|
230 |
+
|
231 |
+
# Now, keep only the betas of interest:
|
232 |
+
betas <- data %>% filter(!grepl("S15B",y_var))
|
233 |
+
dim(betas)
|
234 |
+
betas <- arrange(betas,betas$estimate)
|
235 |
+
|
236 |
+
# Create Matrix for plotting:
|
237 |
+
MatrixofModels <- betas[c("y_var", "estimate","stderr","z","p","idnum")]
|
238 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "TValue", "PValue", "ModelName")
|
239 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = MatrixofModels$IV)
|
240 |
+
#MatrixofModels$Legend <- c(" AES Coefficient", rep(" Standard Coefficients",4))
|
241 |
+
|
242 |
+
# Re-name for plotting:
|
243 |
+
MatrixofModels$ModelName <- "Input Use"
|
244 |
+
#MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
245 |
+
|
246 |
+
# Plot:
|
247 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
248 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
249 |
+
ylab = NULL, xlab = NULL)
|
250 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
251 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nEstimated Effect") + aesthetics + xlab("")
|
252 |
+
|
253 |
+
# Save:
|
254 |
+
OutputPlot
|
255 |
+
ggsave(filename = "./Output/CoefPlot_Inputs.pdf", height=6, width=9)
|
256 |
+
|
257 |
+
########################################
|
258 |
+
|
259 |
+
## load data:
|
260 |
+
data <- read.csv("./Output/Temp/CapitalStocks.csv")
|
261 |
+
data <- filter(data,estimate!=0 & !is.na(p))
|
262 |
+
|
263 |
+
# Clean data for plotting:
|
264 |
+
alpha<- 0.05
|
265 |
+
Multiplier <- qnorm(1-alpha/2) #qt(1 - alpha / 2, df=75) # Small estimates
|
266 |
+
Multiplier <- qt(1 - alpha / 2, df=75) # Small estimates
|
267 |
+
|
268 |
+
# Find the outcome var for each regression:
|
269 |
+
data$idstr <- as.character(data$idstr)
|
270 |
+
data$y_var <- gsub("S16A","",data$idstr)
|
271 |
+
data <- filter(data,y_var!="ALIMENTADORES",
|
272 |
+
y_var!="AUTOCLAVE",
|
273 |
+
y_var!="BANDADEINCUBACION",
|
274 |
+
y_var!="DESPLUMADORAS",
|
275 |
+
y_var!="EQUIPODEIDENTIFICACION",
|
276 |
+
y_var!="EQUIPOPARAINSEMINACIONARTIF",
|
277 |
+
y_var!="EQUIPOPARAORDENO",
|
278 |
+
y_var!="EQUIPOPREVENTIVODEDANOSENAN",
|
279 |
+
y_var!="ESTABLOS",
|
280 |
+
y_var!="GALERAS",
|
281 |
+
y_var!="INFRAESTRUCTURAPARAALIMENTA",
|
282 |
+
y_var!="LABORATORIOINVITRO",
|
283 |
+
y_var!="LABORATORIOSDEANALISISDESUE",
|
284 |
+
y_var!="MANGASOCEPOS",
|
285 |
+
y_var!="MAQUINARIAPARAPRODUCCIONDEA",
|
286 |
+
y_var!="OTROSTALLERESPISTADEATERRIZ",
|
287 |
+
y_var!="MOLEDORADEGRANOS",
|
288 |
+
y_var!="REDES",
|
289 |
+
y_var!="SALASDEINCUBACION",
|
290 |
+
y_var!="SALASDEORDENO",
|
291 |
+
y_var!="BANDARECOLECTORADEHUEVOS",
|
292 |
+
y_var!="CLASIFICADORADEFRUTALESHORT",
|
293 |
+
y_var!="UTENSILIOSPARARECOLECCIONDE",
|
294 |
+
y_var!="HERRAMIENTASAGROPECUARIAS",
|
295 |
+
y_var!="TANQUESDEFERTIRRIEGO",
|
296 |
+
y_var!="SALASDECURADO")
|
297 |
+
|
298 |
+
# Replace y_var with nice names:
|
299 |
+
# cat(paste('data$y_var[which(data$y_var == \"',data$y_var,"\")] <- \"",data$y_var,"\"",sep=""),sep="\n")
|
300 |
+
data$y_var[which(data$y_var == "ARADOSDEHIERRO")] <- "Plows"
|
301 |
+
data$y_var[which(data$y_var == "BALANZAPARACARGASPESADAS")] <- "Balances"
|
302 |
+
data$y_var[which(data$y_var == "BASCULA")] <- "Coffee Weighing Machines"
|
303 |
+
data$y_var[which(data$y_var == "BODEGAS")] <- "Wharehouses"
|
304 |
+
data$y_var[which(data$y_var == "BOMBAACHICADORAMECANICA")] <- "Fumigation Backpacks"
|
305 |
+
data$y_var[which(data$y_var == "CAMIONOVEHICULOS")] <- "Trucks"
|
306 |
+
data$y_var[which(data$y_var == "DESPULPADORADECAFEMANUAL")] <- "Manual Coffee Pulping Machines"
|
307 |
+
data$y_var[which(data$y_var == "DESPULPADORADECAFEMECANICA")] <- "Mecanical Coffee Pulping Machines"
|
308 |
+
data$y_var[which(data$y_var == "EQUIPOBENEFICIADORCAFE")] <- "Coffee Equipement"
|
309 |
+
data$y_var[which(data$y_var == "EQUIPODEFUMIGACION")] <- "Fumigation Equipement"
|
310 |
+
data$y_var[which(data$y_var == "EQUIPODERIEGO")] <- "Irrigration Equipement"
|
311 |
+
data$y_var[which(data$y_var == "EQUIPODETRANSPORTEDEAGUA")] <- "Water Transportation Equipement"
|
312 |
+
data$y_var[which(data$y_var == "EQUIPOPARALACOSECHA")] <- "Harvest Equipment"
|
313 |
+
data$y_var[which(data$y_var == "HERRAMIENTASAGROPECUARIAS")] <- "Agrigultural Tools"
|
314 |
+
data$y_var[which(data$y_var == "MANGUERAS")] <- "Hoses"
|
315 |
+
data$y_var[which(data$y_var == "MOTOSIERRAS")] <- "Saws"
|
316 |
+
data$y_var[which(data$y_var == "OFICINAS")] <- "Offices"
|
317 |
+
data$y_var[which(data$y_var == "PATIOSDESECADO")] <- "Drying Patios"
|
318 |
+
data$y_var[which(data$y_var == "PICADORADEPASTO")] <- "Lawnmowers"
|
319 |
+
data$y_var[which(data$y_var == "RASTRASYMONTACARGAS")] <- "Harrows"
|
320 |
+
data$y_var[which(data$y_var == "SEMBRADORAMECANICA")] <- "Mecanical Seeders"
|
321 |
+
data$y_var[which(data$y_var == "SILOSPARAFORRAJEFRESCO")] <- "Storage Silos"
|
322 |
+
data$y_var[which(data$y_var == "TANQUESDEFERTIRRIEGO")] <- "Irrigation Tanks"
|
323 |
+
data$y_var[which(data$y_var == "TANQUESPARAALMACENAMIENTODE")] <- "Water Storage Tanks"
|
324 |
+
data$y_var[which(data$y_var == "TOLDODERECIBIDERODECAFE")] <- "Coffee Drying Tarps"
|
325 |
+
data$y_var[which(data$y_var == "TRACTORES")] <- "Tractors"
|
326 |
+
data$y_var[which(data$y_var == "UTENSILIOSPARARECOLECCIONDE")] <- "UTENSILIOSPARARECOLECCIONDE"
|
327 |
+
data$y_var[which(data$y_var == "VIVIENDAS")] <- "Houses"
|
328 |
+
data$y_var[which(data$y_var == "BALANZADEPRECISION")] <- "Precision Scales"
|
329 |
+
data$y_var[which(data$y_var == "DESOPERCULADORYOTRASHERRAMI")] <- "Uncapper"
|
330 |
+
data$y_var[which(data$y_var == "EQUIPOPARAALIMENTACION")] <- "Feeding Equipement"
|
331 |
+
data$y_var[which(data$y_var == "EQUIPODECALEFACCION")] <- "Heating Equipement"
|
332 |
+
data$y_var[which(data$y_var == "PULVERIZADORES")] <- "Spraying Equipement"
|
333 |
+
data$y_var[which(data$y_var == "ESPATULAS")] <- "Spatulas"
|
334 |
+
data$y_var[which(data$y_var == "EXTRATORDEMIEL")] <- "Honey Extractor"
|
335 |
+
data$y_var[which(data$y_var == "VESTIMENTAESPECIAL")] <- "Special Clothing"
|
336 |
+
data$y_var[which(data$y_var == "AHUMADORES")] <- "Smoking Equipement"
|
337 |
+
data$y_var[which(data$y_var == "PORQUERIZAS")] <- "Pig Equipement"
|
338 |
+
|
339 |
+
data <- filter(data,y_var!="Offices", y_var!="Wharehouses",
|
340 |
+
y_var!="Lawnmowers",
|
341 |
+
y_var!="Water Storage Tanks",
|
342 |
+
y_var!="Storage Silos") # Remove largest estimates/unclear topic/unrelated to AG
|
343 |
+
|
344 |
+
# Now, keep only the betas of interest:
|
345 |
+
betas <- data %>% filter(!grepl("S16B",y_var))
|
346 |
+
dim(betas)
|
347 |
+
betas <- arrange(betas,betas$estimate)
|
348 |
+
|
349 |
+
# Create Matrix for plotting:
|
350 |
+
MatrixofModels <- betas[c("y_var", "estimate","stderr","z","p","idnum")]
|
351 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "TValue", "PValue", "ModelName")
|
352 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = MatrixofModels$IV)
|
353 |
+
#MatrixofModels$Legend <- c(" AES Coefficient", rep(" Standard Coefficients",4))
|
354 |
+
|
355 |
+
# Re-name for plotting:
|
356 |
+
#MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
357 |
+
|
358 |
+
# Plot:
|
359 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
360 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
361 |
+
ylab = NULL, xlab = NULL)
|
362 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
363 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nRD Estimate") + aesthetics + xlab("")
|
364 |
+
|
365 |
+
# Save:
|
366 |
+
OutputPlot
|
367 |
+
|
368 |
+
# Add list of brackets (Coffee Related, Non-Coffee Related)
|
369 |
+
coffee_goods <- c("Coffee-Specific Capital",
|
370 |
+
"Manual Coffee Pulping Machines",
|
371 |
+
"Mecanical Coffee Pulping Machines",
|
372 |
+
"Coffee Equipement",
|
373 |
+
"Drying Patios",
|
374 |
+
"Coffee Weighing Machines",
|
375 |
+
"Balances",
|
376 |
+
"Water Storage Tanks",
|
377 |
+
"Coffee Drying Tarps")
|
378 |
+
|
379 |
+
|
380 |
+
MatrixofModels <- suppressWarnings(MatrixofModels %>% mutate(Group = ifelse(IV %in% coffee_goods,1,0),
|
381 |
+
term=IV,
|
382 |
+
estimate= Estimate,
|
383 |
+
std.error = StandardError) %>%
|
384 |
+
arrange(-Group, -IV))
|
385 |
+
|
386 |
+
# Create list of brackets (label, topmost included predictor, bottommost included predictor)
|
387 |
+
bracket1 <- c("Coffee-Specific Capital",
|
388 |
+
"Coffee Weighing Machines",
|
389 |
+
"Mecanical Coffee Pulping Machines")
|
390 |
+
bracket2 <- c("General Ag. Capital",
|
391 |
+
"Hoses",
|
392 |
+
"Trucks")
|
393 |
+
|
394 |
+
brackets <- list(bracket1, bracket2)
|
395 |
+
|
396 |
+
{dwplot(MatrixofModels, vline = geom_vline(xintercept = 0, colour = "red", linetype = 2),
|
397 |
+
dot_args = list(color="black"),
|
398 |
+
whisker_args = list(color="black")) +
|
399 |
+
theme_bw() + xlab("RD Estimate") + ylab("") +
|
400 |
+
theme(plot.title = element_text(face="bold"),
|
401 |
+
legend.title = element_blank(), text=element_text(family="Palatino"))} %>%
|
402 |
+
add_brackets(brackets, face="bold")
|
403 |
+
# Save:
|
404 |
+
ggsave(filename = "./Output/CoefPlot_Capital_wBrackets.pdf", scale=2)
|
405 |
+
|
406 |
+
|
14/replication_package/Replication/Code/ESLR_IVCensus_Controls.R
ADDED
@@ -0,0 +1,675 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
############################################################
|
2 |
+
##### ESLR - RD HETEROGENEITY PLOTTING - AgCensus Data #####
|
3 |
+
############################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(RColorBrewer) # creates nice color schemes
|
10 |
+
require(scales) # customize scales
|
11 |
+
require(plyr) # join function
|
12 |
+
require(dplyr)
|
13 |
+
require(rdrobust) # rd estimation tools
|
14 |
+
require(haven)
|
15 |
+
require(readstata13)
|
16 |
+
require(sandwich) # robust se's
|
17 |
+
require(haven)
|
18 |
+
require(fuzzyjoin)
|
19 |
+
|
20 |
+
########################################
|
21 |
+
|
22 |
+
|
23 |
+
## Load IV Censo Agropecuario Data:
|
24 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
25 |
+
|
26 |
+
# Laod Conflict Data:
|
27 |
+
conflict_data <- read.csv(file="./Data/conflict_canton.csv", header=TRUE)
|
28 |
+
censo_ag_wreform <- left_join(censo_ag_wreform,conflict_data, by="CODIGO")
|
29 |
+
|
30 |
+
########################################
|
31 |
+
|
32 |
+
## Making Standarized Coefficient Plots:
|
33 |
+
|
34 |
+
# Set aesthetics:
|
35 |
+
aesthetics <- list(
|
36 |
+
theme_bw(),
|
37 |
+
theme(text=element_text(family="Palatino"),
|
38 |
+
legend.title=element_blank(),
|
39 |
+
#legend.justification=c(0,0),
|
40 |
+
#legend.position= "right", #c(1,0),
|
41 |
+
#panel.grid.minor=element_blank(),
|
42 |
+
#panel.grid.major=element_blank(),
|
43 |
+
plot.background=element_rect(colour="white",fill="white"),
|
44 |
+
panel.grid.major=element_blank(),
|
45 |
+
panel.grid.minor=element_blank(),
|
46 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
47 |
+
axis.title.y=element_text(face="bold.italic"),
|
48 |
+
axis.title.x=element_text(face="bold.italic")))
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
########################################
|
53 |
+
|
54 |
+
censo_ag_wreform_tev <- censo_ag_wreform
|
55 |
+
ag.grouped <- mutate(censo_ag_wreform_tev %>% group_by(Expropretario_ISTA), num_per_owner = n())
|
56 |
+
censo_ag_wreform_tev$num_per_owner<- ag.grouped$num_per_owner
|
57 |
+
|
58 |
+
years <- 2007
|
59 |
+
i = 2007
|
60 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
61 |
+
ln_agprodII = ln_agprod,
|
62 |
+
ln_agprod = ln_agprod_pricew_crops)
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
###########################################
|
67 |
+
|
68 |
+
## CONTROLLING FOR PROPERTY SIZES:
|
69 |
+
# Estimate and Save RD for different controls:
|
70 |
+
num_ests <- 3*4
|
71 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
72 |
+
y_var = rep(0,num_ests),
|
73 |
+
label = rep(0, num_ests))
|
74 |
+
|
75 |
+
k <- "triangular"
|
76 |
+
p <- 1
|
77 |
+
b<- "mserd"
|
78 |
+
|
79 |
+
controls <- c("AREA_HECTAREA", "Area_has")
|
80 |
+
count<-1
|
81 |
+
|
82 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
83 |
+
{
|
84 |
+
b <- MOD$se[1]
|
85 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
86 |
+
sx <- sd(model.dta[,c("Above500")])
|
87 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
88 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
89 |
+
beta <- b * sx/sy
|
90 |
+
return(beta)
|
91 |
+
}
|
92 |
+
|
93 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
94 |
+
{
|
95 |
+
b <- MOD$coef[1]
|
96 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
97 |
+
sx <- sd(model.dta[,c("Above500")])
|
98 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
99 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
100 |
+
beta <- b * sx/sy
|
101 |
+
return(beta)
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
controls <- list("AREA_HECTAREA","Area_has",c("Area_has","AREA_HECTAREA"))
|
106 |
+
labels <- c("Property Size in 1980", "Property Size in 2007", "All Controls")
|
107 |
+
label.count <- 1
|
108 |
+
for (i in controls) {
|
109 |
+
print(i)
|
110 |
+
|
111 |
+
# Revenue per ha:
|
112 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
113 |
+
x=censo_ag_wreform_tev$norm_dist,
|
114 |
+
covs = censo_ag_wreform_tev[,i],
|
115 |
+
c = 0,
|
116 |
+
p = p,
|
117 |
+
q = p +1,
|
118 |
+
kernel = k,
|
119 |
+
bwselect = b,
|
120 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
121 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
122 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
123 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
124 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
125 |
+
count<-count+1
|
126 |
+
|
127 |
+
# Profits per ha:
|
128 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
129 |
+
x=censo_ag_wreform_tev$norm_dist,
|
130 |
+
covs = censo_ag_wreform_tev[,i],
|
131 |
+
c = 0,
|
132 |
+
p = p,
|
133 |
+
q = p +1,
|
134 |
+
kernel = k,
|
135 |
+
bwselect = b,
|
136 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
137 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
138 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
139 |
+
rd_estimates[count,c("y_var")] <- "Profit per ha"
|
140 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
141 |
+
count<-count+1
|
142 |
+
|
143 |
+
# Share Cash:
|
144 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
145 |
+
x=censo_ag_wreform_tev$norm_dist,
|
146 |
+
covs = censo_ag_wreform_tev[,i],
|
147 |
+
c = 0,
|
148 |
+
p = p,
|
149 |
+
q = p +1,
|
150 |
+
kernel = k,
|
151 |
+
bwselect = b,
|
152 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
153 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
154 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
155 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
156 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
157 |
+
count<-count+1
|
158 |
+
|
159 |
+
|
160 |
+
# Share Staple:
|
161 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
162 |
+
x=censo_ag_wreform_tev$norm_dist,
|
163 |
+
covs = censo_ag_wreform_tev[,i],
|
164 |
+
c = 0,
|
165 |
+
p = p,
|
166 |
+
q = p +1,
|
167 |
+
kernel = k,
|
168 |
+
bwselect = b,
|
169 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
170 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
171 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
172 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
173 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
174 |
+
count<-count+1
|
175 |
+
label.count<-label.count+1
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
rd_estimates
|
180 |
+
|
181 |
+
########################################
|
182 |
+
|
183 |
+
# Clean data for plotting:
|
184 |
+
alpha<- 0.05
|
185 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
186 |
+
|
187 |
+
# Find the outcome var for each regression:
|
188 |
+
data <-rd_estimates
|
189 |
+
|
190 |
+
# Replace y_var with nice names:
|
191 |
+
|
192 |
+
# Now, keep only the betas of interest:
|
193 |
+
betas <- data
|
194 |
+
dim(betas)
|
195 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
196 |
+
|
197 |
+
# Create Matrix for plotting:
|
198 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
199 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
200 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
201 |
+
c <- factor(MatrixofModels$Group, levels = c("Controlling for: Property Size in 1980",
|
202 |
+
"Controlling for: Property Size in 2007",
|
203 |
+
"Controlling for: All Controls"))
|
204 |
+
|
205 |
+
|
206 |
+
# Plot:
|
207 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
208 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
209 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
210 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
211 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics + xlab("")
|
212 |
+
|
213 |
+
# Save:
|
214 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.25)) + theme(strip.text.x = element_text(size = 5))
|
215 |
+
|
216 |
+
ggsave(filename="./Output/CoefPlot_wSizeControls.pdf", width=6, height=3)
|
217 |
+
|
218 |
+
########################################
|
219 |
+
|
220 |
+
## Conflict Types:
|
221 |
+
|
222 |
+
# Estimate and Save RD for different types of conflict:
|
223 |
+
num_ests <- 4*4
|
224 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
225 |
+
y_var = rep(0,num_ests),
|
226 |
+
label = rep(0, num_ests))
|
227 |
+
|
228 |
+
k <- "triangular"
|
229 |
+
p <- 1
|
230 |
+
b<- "mserd"
|
231 |
+
|
232 |
+
count<-1
|
233 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev %>%
|
234 |
+
mutate(Conflict1980 = ifelse(!is.na(Conflict_1980),Conflict_1980,0),
|
235 |
+
Conflict1981 = ifelse(!is.na(Conflict_1981),Conflict_1981,0),
|
236 |
+
Conflict1982 = ifelse(!is.na(Conflict_1982),Conflict_1982,0),
|
237 |
+
Conflict198082 = Conflict1980+Conflict1981+Conflict1982)
|
238 |
+
controls <- list("CONFLICT","FFAA","ESCUAD","Conflict198082")
|
239 |
+
labels <- c("Conflict (Any Actor)", "Military Violence", "Death Squad Violence", "Conflict from 1980-1982")
|
240 |
+
label.count <- 1
|
241 |
+
for (i in controls) {
|
242 |
+
print(i)
|
243 |
+
|
244 |
+
# Revenue per ha:
|
245 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
246 |
+
x=censo_ag_wreform_tev$norm_dist,
|
247 |
+
covs = censo_ag_wreform_tev[,i],
|
248 |
+
c = 0,
|
249 |
+
p = p,
|
250 |
+
q = p +1,
|
251 |
+
kernel = k,
|
252 |
+
bwselect = b,
|
253 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
254 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
255 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
256 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
257 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
258 |
+
count<-count+1
|
259 |
+
|
260 |
+
# Profits per ha:
|
261 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
262 |
+
x=censo_ag_wreform_tev$norm_dist,
|
263 |
+
covs = censo_ag_wreform_tev[,i],
|
264 |
+
c = 0,
|
265 |
+
p = p,
|
266 |
+
q = p +1,
|
267 |
+
kernel = k,
|
268 |
+
bwselect = b,
|
269 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
270 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
271 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
272 |
+
rd_estimates[count,c("y_var")] <- "Profit per ha"
|
273 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
274 |
+
count<-count+1
|
275 |
+
|
276 |
+
# Share Cash:
|
277 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
278 |
+
x=censo_ag_wreform_tev$norm_dist,
|
279 |
+
covs = censo_ag_wreform_tev[,i],
|
280 |
+
c = 0,
|
281 |
+
p = p,
|
282 |
+
q = p +1,
|
283 |
+
kernel = k,
|
284 |
+
bwselect = b,
|
285 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
286 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
287 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
288 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
289 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
290 |
+
count<-count+1
|
291 |
+
|
292 |
+
|
293 |
+
# Share Staple:
|
294 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
295 |
+
x=censo_ag_wreform_tev$norm_dist,
|
296 |
+
covs = censo_ag_wreform_tev[,i],
|
297 |
+
c = 0,
|
298 |
+
p = p,
|
299 |
+
q = p +1,
|
300 |
+
kernel = k,
|
301 |
+
bwselect = b,
|
302 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
303 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
304 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
305 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
306 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
307 |
+
count<-count+1
|
308 |
+
label.count<-label.count+1
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
rd_estimates
|
313 |
+
|
314 |
+
########################################
|
315 |
+
|
316 |
+
# Clean data for plotting:
|
317 |
+
alpha<- 0.05
|
318 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
319 |
+
|
320 |
+
# Find the outcome var for each regression:
|
321 |
+
data <-rd_estimates
|
322 |
+
|
323 |
+
# Replace y_var with nice names:
|
324 |
+
|
325 |
+
# Now, keep only the betas of interest:
|
326 |
+
betas <- data
|
327 |
+
dim(betas)
|
328 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
329 |
+
|
330 |
+
# Create Matrix for plotting:
|
331 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
332 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
333 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
334 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group, levels = paste0("Controlling for: ",labels))
|
335 |
+
|
336 |
+
# Plot:
|
337 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
338 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
339 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
340 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
341 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
342 |
+
|
343 |
+
# Save:
|
344 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.25)) + xlab("")
|
345 |
+
|
346 |
+
ggsave(filename="./Output/CoefPlot_wConflictTypeControls.pdf")
|
347 |
+
|
348 |
+
###########################################
|
349 |
+
|
350 |
+
|
351 |
+
## CONTROLLING FOR COMMERCIALIZATION AVENUE
|
352 |
+
|
353 |
+
commerc <- read.dta13(file = "./Data/censo_ag_commercialization.dta")
|
354 |
+
censo_ag_wreform_tev <- left_join(censo_ag_wreform_tev,commerc, by="agg_id")
|
355 |
+
|
356 |
+
num_ests <- 4*4
|
357 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
358 |
+
y_var = rep(0,num_ests),
|
359 |
+
label = rep(0, num_ests))
|
360 |
+
|
361 |
+
k <- "triangular"
|
362 |
+
p <- 1
|
363 |
+
b<- "mserd"
|
364 |
+
|
365 |
+
count<-1
|
366 |
+
|
367 |
+
controls <- list("MAYO", "MINO", "OTRO", c("MAYO", "MINO", "OTRO")) # Can't control for exporter, not enough
|
368 |
+
labels <- c("Wholeseller", "Retailer", "Exporting", "All Controls")
|
369 |
+
label.count <- 1
|
370 |
+
for (i in controls) {
|
371 |
+
print(i)
|
372 |
+
|
373 |
+
# Revenue per ha:
|
374 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
375 |
+
x=censo_ag_wreform_tev$norm_dist,
|
376 |
+
covs = censo_ag_wreform_tev[,i],
|
377 |
+
c = 0,
|
378 |
+
p = p,
|
379 |
+
q = p +1,
|
380 |
+
kernel = k,
|
381 |
+
bwselect = b,
|
382 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
383 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
384 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
385 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
386 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
387 |
+
count<-count+1
|
388 |
+
|
389 |
+
# Profits per ha:
|
390 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
391 |
+
x=censo_ag_wreform_tev$norm_dist,
|
392 |
+
covs = censo_ag_wreform_tev[,i],
|
393 |
+
c = 0,
|
394 |
+
p = p,
|
395 |
+
q = p +1,
|
396 |
+
kernel = k,
|
397 |
+
bwselect = b,
|
398 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
399 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
400 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
401 |
+
rd_estimates[count,c("y_var")] <- "Profit per ha"
|
402 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
403 |
+
count<-count+1
|
404 |
+
|
405 |
+
# Share Cash:
|
406 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
407 |
+
x=censo_ag_wreform_tev$norm_dist,
|
408 |
+
covs = censo_ag_wreform_tev[,i],
|
409 |
+
c = 0,
|
410 |
+
p = p,
|
411 |
+
q = p +1,
|
412 |
+
kernel = k,
|
413 |
+
bwselect = b,
|
414 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
415 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
416 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
417 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
418 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
419 |
+
count<-count+1
|
420 |
+
|
421 |
+
|
422 |
+
# Share Staple:
|
423 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
424 |
+
x=censo_ag_wreform_tev$norm_dist,
|
425 |
+
covs = censo_ag_wreform_tev[,i],
|
426 |
+
c = 0,
|
427 |
+
p = p,
|
428 |
+
q = p +1,
|
429 |
+
kernel = k,
|
430 |
+
bwselect = b,
|
431 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
432 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
433 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
434 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
435 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
436 |
+
count<-count+1
|
437 |
+
label.count<-label.count+1
|
438 |
+
}
|
439 |
+
|
440 |
+
|
441 |
+
rd_estimates
|
442 |
+
|
443 |
+
########################################
|
444 |
+
|
445 |
+
# Clean data for plotting:
|
446 |
+
alpha<- 0.05
|
447 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
448 |
+
|
449 |
+
# Find the outcome var for each regression:
|
450 |
+
data <-rd_estimates
|
451 |
+
|
452 |
+
# Replace y_var with nice names:
|
453 |
+
|
454 |
+
# Now, keep only the betas of interest:
|
455 |
+
betas <- data
|
456 |
+
dim(betas)
|
457 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
458 |
+
|
459 |
+
# Create Matrix for plotting:
|
460 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
461 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
462 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
463 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group, levels = paste0("Controlling for: ", labels))
|
464 |
+
|
465 |
+
# Plot:
|
466 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
467 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
468 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
469 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
470 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
471 |
+
|
472 |
+
# Save:
|
473 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.25)) + xlab("")
|
474 |
+
|
475 |
+
ggsave(filename="./Output/CoefPlot_wCommercialization.pdf")
|
476 |
+
|
477 |
+
|
478 |
+
|
479 |
+
|
480 |
+
|
481 |
+
|
482 |
+
|
483 |
+
|
484 |
+
|
485 |
+
|
486 |
+
|
487 |
+
###########################################
|
488 |
+
|
489 |
+
## CONTROLLING FOR CANTON MIGRATION AMOUNTS:
|
490 |
+
|
491 |
+
# Prep data:
|
492 |
+
poblaccion_section <- read_sav(file = "./Data/poblacion.sav")
|
493 |
+
|
494 |
+
cantons_popcensus <- dplyr::select(poblaccion_section,
|
495 |
+
gender=S06P02,
|
496 |
+
age=S06P03A,
|
497 |
+
S06P07A, S06P08A1, S06P08A2,
|
498 |
+
DEPDSC, MUNDSC, CANDSC,
|
499 |
+
literate = S06P09,
|
500 |
+
educated = S06P10,
|
501 |
+
educ_level = S06P11A,
|
502 |
+
finished_hs = S06P11B)
|
503 |
+
|
504 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
505 |
+
born_same_as_mother= ifelse(S06P07A < 3,S06P07A,NA) ,
|
506 |
+
lived_canton_always = ifelse(S06P08A1 < 3,S06P08A1,NA),
|
507 |
+
lived_canton_year = ifelse(S06P08A2>0,S06P08A2,NA),
|
508 |
+
CODIGO_NOM = toupper(stri_trans_general(paste(DEPDSC, MUNDSC, CANDSC,sep=", "),"Latin-ASCII")))
|
509 |
+
|
510 |
+
cantons_popcensus <- mutate(cantons_popcensus,
|
511 |
+
born_same_as_mother= ifelse(born_same_as_mother ==2 ,0,born_same_as_mother) ,
|
512 |
+
lived_canton_always = ifelse(lived_canton_always ==2 ,0,lived_canton_always),
|
513 |
+
educ_yrs = 1*(educ_level==1)+6*(educ_level==2)+ 9*(educ_level==3)+
|
514 |
+
11*(educ_level==4)+13*(educ_level==5)+ 15*(educ_level==6)+
|
515 |
+
16*(educ_level==7)+ 17*(educ_level==8)+ 20*(educ_level==9))
|
516 |
+
|
517 |
+
# Summarise to make merging faster:
|
518 |
+
cantons_popcensus <- cantons_popcensus %>%
|
519 |
+
group_by(CODIGO_NOM) %>%
|
520 |
+
summarise_if(is.numeric, mean, na.rm = TRUE)
|
521 |
+
|
522 |
+
# Merge data:
|
523 |
+
max.dist <- 10 # since there are errors in mun names + state names
|
524 |
+
censo_ag_wreform_tev <- stringdist_join(as.data.frame(censo_ag_wreform_tev),
|
525 |
+
as.data.frame(cantons_popcensus),
|
526 |
+
by = c("CODIGO_NOM.x" = "CODIGO_NOM"),
|
527 |
+
mode = "left",
|
528 |
+
method = "jw",
|
529 |
+
max_dist = max.dist,
|
530 |
+
distance_col = "dist")
|
531 |
+
|
532 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev %>%
|
533 |
+
group_by(agg_id) %>%
|
534 |
+
top_n(1, -dist) %>% ungroup()
|
535 |
+
|
536 |
+
censo_ag_wreform_tev <- as.data.frame(censo_ag_wreform_tev)
|
537 |
+
|
538 |
+
# Estimate and Save RD for different controls:
|
539 |
+
num_ests <- 4*4
|
540 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
541 |
+
y_var = rep(0,num_ests),
|
542 |
+
label = rep(0, num_ests))
|
543 |
+
|
544 |
+
k <- "triangular"
|
545 |
+
p <- 1
|
546 |
+
b<- "mserd"
|
547 |
+
|
548 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
549 |
+
{
|
550 |
+
b <- MOD$se[1]
|
551 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
552 |
+
sx <- sd(model.dta[,c("Above500")])
|
553 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
554 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
555 |
+
beta <- b * sx/sy
|
556 |
+
return(beta)
|
557 |
+
}
|
558 |
+
|
559 |
+
|
560 |
+
count<-1
|
561 |
+
controls <- list("lived_canton_always", "born_same_as_mother","lived_canton_year",
|
562 |
+
c("born_same_as_mother","lived_canton_always","lived_canton_year"))
|
563 |
+
labels <- c("% Always Lived in Canton", "% Born in Mother's Canton", "Avg. Years in Canton","All Controls")
|
564 |
+
label.count <- 1
|
565 |
+
for (i in controls) {
|
566 |
+
print(i)
|
567 |
+
|
568 |
+
# Revenue per ha:
|
569 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
570 |
+
x=censo_ag_wreform_tev$norm_dist,
|
571 |
+
covs = censo_ag_wreform_tev[,i],
|
572 |
+
c = 0,
|
573 |
+
p = p,
|
574 |
+
q = p +1,
|
575 |
+
kernel = k,
|
576 |
+
bwselect = b,
|
577 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
578 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
579 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
580 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
581 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
582 |
+
count<-count+1
|
583 |
+
|
584 |
+
# Profits per ha:
|
585 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
586 |
+
x=censo_ag_wreform_tev$norm_dist,
|
587 |
+
covs = censo_ag_wreform_tev[,i],
|
588 |
+
c = 0,
|
589 |
+
p = p,
|
590 |
+
q = p +1,
|
591 |
+
kernel = k,
|
592 |
+
bwselect = b,
|
593 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
594 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
595 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
596 |
+
rd_estimates[count,c("y_var")] <- "Profit per ha"
|
597 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
598 |
+
count<-count+1
|
599 |
+
|
600 |
+
# Share Cash:
|
601 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
602 |
+
x=censo_ag_wreform_tev$norm_dist,
|
603 |
+
covs = censo_ag_wreform_tev[,i],
|
604 |
+
c = 0,
|
605 |
+
p = p,
|
606 |
+
q = p +1,
|
607 |
+
kernel = k,
|
608 |
+
bwselect = b,
|
609 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
610 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
611 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
612 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
613 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
614 |
+
count<-count+1
|
615 |
+
|
616 |
+
|
617 |
+
# Share Staple:
|
618 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
619 |
+
x=censo_ag_wreform_tev$norm_dist,
|
620 |
+
covs = censo_ag_wreform_tev[,i],
|
621 |
+
c = 0,
|
622 |
+
p = p,
|
623 |
+
q = p +1,
|
624 |
+
kernel = k,
|
625 |
+
bwselect = b,
|
626 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA),vce="hc1")
|
627 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
628 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
629 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
630 |
+
rd_estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
631 |
+
count<-count+1
|
632 |
+
label.count<-label.count+1
|
633 |
+
}
|
634 |
+
|
635 |
+
|
636 |
+
rd_estimates
|
637 |
+
|
638 |
+
########################################
|
639 |
+
|
640 |
+
# Clean data for plotting:
|
641 |
+
alpha<- 0.05
|
642 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
643 |
+
|
644 |
+
# Find the outcome var for each regression:
|
645 |
+
data <-rd_estimates
|
646 |
+
|
647 |
+
# Replace y_var with nice names:
|
648 |
+
|
649 |
+
# Now, keep only the betas of interest:
|
650 |
+
betas <- data
|
651 |
+
dim(betas)
|
652 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
653 |
+
|
654 |
+
# Create Matrix for plotting:
|
655 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
656 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
657 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
658 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group, levels = paste0("Controlling for: ", labels))
|
659 |
+
|
660 |
+
|
661 |
+
# Plot:
|
662 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
663 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
664 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
665 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
666 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
667 |
+
|
668 |
+
# Save:
|
669 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.25)) + xlab("")
|
670 |
+
|
671 |
+
ggsave(filename="./Output/CoefPlot_wMigrationControls.pdf")
|
672 |
+
|
673 |
+
|
674 |
+
|
675 |
+
|
14/replication_package/Replication/Code/ESLR_IVCensus_HetPlots.R
ADDED
@@ -0,0 +1,570 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
############################################################
|
2 |
+
##### ESLR - RD HETEROGENEITY PLOTTING - AgCensus Data #####
|
3 |
+
############################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(RColorBrewer) # creates nice color schemes
|
10 |
+
require(scales) # customize scales
|
11 |
+
require(plyr) # join function
|
12 |
+
require(dplyr)
|
13 |
+
require(rdrobust) # rd estimation tools
|
14 |
+
require(haven)
|
15 |
+
require(readstata13)
|
16 |
+
|
17 |
+
########################################
|
18 |
+
|
19 |
+
## Load IV Censo Agropecuario Data:
|
20 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
21 |
+
|
22 |
+
########################################
|
23 |
+
|
24 |
+
## Making Standarized Coefficient Plots:
|
25 |
+
|
26 |
+
# Set aesthetics:
|
27 |
+
aesthetics <- list(
|
28 |
+
theme_bw(),
|
29 |
+
theme(text=element_text(family="Palatino"),
|
30 |
+
legend.title=element_blank(),
|
31 |
+
#legend.justification=c(0,0),
|
32 |
+
#legend.position= "right", #c(1,0),
|
33 |
+
#panel.grid.minor=element_blank(),
|
34 |
+
#panel.grid.major=element_blank(),
|
35 |
+
plot.background=element_rect(colour="white",fill="white"),
|
36 |
+
panel.grid.major=element_blank(),
|
37 |
+
panel.grid.minor=element_blank(),
|
38 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
39 |
+
axis.title.y=element_text(face="bold.italic"),
|
40 |
+
axis.title.x=element_text(face="bold.italic")))
|
41 |
+
|
42 |
+
|
43 |
+
########################################
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
48 |
+
{
|
49 |
+
b <- MOD$coef[1]
|
50 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
51 |
+
sx <- sd(model.dta[,c("Above500")])
|
52 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
53 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
54 |
+
beta <- b * sx/sy
|
55 |
+
return(beta)
|
56 |
+
}
|
57 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
58 |
+
{
|
59 |
+
b <- MOD$se[1]
|
60 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
61 |
+
sx <- sd(model.dta[,c("Above500")])
|
62 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
63 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
64 |
+
beta <- b * sx/sy
|
65 |
+
return(beta)
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
########################################
|
70 |
+
|
71 |
+
num_ests <- 2*4
|
72 |
+
rd_estimates <-data.frame(ln_agprod_estimates = rep(0, num_ests), ln_agprod_ses = rep(0, num_ests),
|
73 |
+
ln_agprodII_estimates = rep(0,num_ests), ln_agprodII_ses = rep(0, num_ests),
|
74 |
+
p = rep(0,num_ests), ks = rep(0,num_ests), bs = rep(0,num_ests), nsl= rep(0,num_ests), nsr= rep(0,num_ests), nslII= rep(0,num_ests), nsrII= rep(0,num_ests), nslIII= rep(0,num_ests), nsrIII= rep(0,num_ests))
|
75 |
+
censo_ag_wreform_tev <-censo_ag_wreform
|
76 |
+
ag.grouped <- group_by(censo_ag_wreform_tev,Expropretario_ISTA)
|
77 |
+
ag.grouped <- mutate(ag.grouped, num_per_owner = n())
|
78 |
+
censo_ag_wreform_tev$num_per_owner<- ag.grouped$num_per_owner
|
79 |
+
|
80 |
+
k <- "triangular"
|
81 |
+
p <- 1
|
82 |
+
b<- "mserd"
|
83 |
+
years <- 2007
|
84 |
+
i = 2007
|
85 |
+
|
86 |
+
|
87 |
+
# Estimate and Save RD for configurations:
|
88 |
+
|
89 |
+
# Agricultural Productivity:
|
90 |
+
count<-1
|
91 |
+
# Scale:
|
92 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
93 |
+
x=censo_ag_wreform_tev$norm_dist,
|
94 |
+
c = 0,
|
95 |
+
p = p,
|
96 |
+
q = p +1,
|
97 |
+
kernel = k,
|
98 |
+
bwselect = b,
|
99 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
100 |
+
subset= censo_ag_wreform_tev$num_per_owner == 1)
|
101 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
102 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
103 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
104 |
+
rd_estimates[count,c("label")] <- paste("","1 Prop per owner",sep="")
|
105 |
+
count<-count+1
|
106 |
+
|
107 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
108 |
+
x=censo_ag_wreform_tev$norm_dist,
|
109 |
+
c = 0,
|
110 |
+
p = p,
|
111 |
+
q = p +1,
|
112 |
+
kernel = k,
|
113 |
+
bwselect = b,
|
114 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
115 |
+
subset= censo_ag_wreform_tev$num_per_owner != 1)
|
116 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
117 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
118 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
119 |
+
rd_estimates[count,c("label")] <- paste("",">1 Prop per owner",sep="")
|
120 |
+
count<-count+1
|
121 |
+
|
122 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
123 |
+
x=censo_ag_wreform_tev$norm_dist,
|
124 |
+
c = 0,
|
125 |
+
p = p,
|
126 |
+
q = p +1,
|
127 |
+
kernel = k,
|
128 |
+
bwselect = b,
|
129 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
130 |
+
subset= censo_ag_wreform_tev$num_per_owner == 1)
|
131 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
132 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
133 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
134 |
+
rd_estimates[count,c("label")] <- paste("","1 Prop per owner",sep="")
|
135 |
+
count<-count+1
|
136 |
+
|
137 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
138 |
+
x=censo_ag_wreform_tev$norm_dist,
|
139 |
+
c = 0,
|
140 |
+
p = p,
|
141 |
+
q = p +1,
|
142 |
+
kernel = k,
|
143 |
+
bwselect = b,
|
144 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
145 |
+
subset= censo_ag_wreform_tev$num_per_owner >1)
|
146 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
147 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
148 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
149 |
+
rd_estimates[count,c("label")] <- paste("",">1 Prop per owner",sep="")
|
150 |
+
count<-count+1
|
151 |
+
|
152 |
+
|
153 |
+
# Share Cash:
|
154 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
155 |
+
x=censo_ag_wreform_tev$norm_dist,
|
156 |
+
c = 0,
|
157 |
+
p = p,
|
158 |
+
q = p +1,
|
159 |
+
kernel = k,
|
160 |
+
bwselect = b,
|
161 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
162 |
+
subset= censo_ag_wreform_tev$num_per_owner == 1)
|
163 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
164 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
165 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
166 |
+
rd_estimates[count,c("label")] <- paste("","1 Prop per owner",sep="")
|
167 |
+
count<-count+1
|
168 |
+
|
169 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
170 |
+
x=censo_ag_wreform_tev$norm_dist,
|
171 |
+
c = 0,
|
172 |
+
p = p,
|
173 |
+
q = p +1,
|
174 |
+
kernel = k,
|
175 |
+
bwselect = b,
|
176 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
177 |
+
subset= censo_ag_wreform_tev$num_per_owner >1)
|
178 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
179 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
180 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
181 |
+
rd_estimates[count,c("label")] <- paste("",">1 Prop per owner",sep="")
|
182 |
+
count<-count+1
|
183 |
+
|
184 |
+
# Share Staple:
|
185 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
186 |
+
x=censo_ag_wreform_tev$norm_dist,
|
187 |
+
c = 0,
|
188 |
+
p = p,
|
189 |
+
q = p +1,
|
190 |
+
kernel = k,
|
191 |
+
bwselect = b,
|
192 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
193 |
+
subset= censo_ag_wreform_tev$num_per_owner == 1)
|
194 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
195 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
196 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
197 |
+
rd_estimates[count,c("label")] <- paste("","1 Prop per owner",sep="")
|
198 |
+
count<-count+1
|
199 |
+
|
200 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
201 |
+
x=censo_ag_wreform_tev$norm_dist,
|
202 |
+
c = 0,
|
203 |
+
p = p,
|
204 |
+
q = p +1,
|
205 |
+
kernel = k,
|
206 |
+
bwselect = b,
|
207 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
208 |
+
subset= censo_ag_wreform_tev$num_per_owner >1)
|
209 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
210 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
211 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
212 |
+
rd_estimates[count,c("label")] <- paste("",">1 Prop per owner",sep="")
|
213 |
+
count<-count+1
|
214 |
+
|
215 |
+
|
216 |
+
rd_estimates
|
217 |
+
|
218 |
+
########################################
|
219 |
+
|
220 |
+
# Clean data for plotting:
|
221 |
+
alpha<- 0.05
|
222 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
223 |
+
|
224 |
+
# Find the outcome var for each regression:
|
225 |
+
data <-rd_estimates
|
226 |
+
|
227 |
+
# Replace y_var with nice names:
|
228 |
+
|
229 |
+
# Now, keep only the betas of interest:
|
230 |
+
betas <- data
|
231 |
+
dim(betas)
|
232 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
233 |
+
|
234 |
+
# Create Matrix for plotting:
|
235 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
236 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
237 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
238 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group) #levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
239 |
+
|
240 |
+
|
241 |
+
# Plot:
|
242 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
243 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
244 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
245 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
246 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics + xlab("")
|
247 |
+
|
248 |
+
# Save:
|
249 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks =scales::pretty_breaks(n = 10))
|
250 |
+
|
251 |
+
ggsave(filename="./Output/CoefPlot_Het_NumPerOwner.pdf", width=6, height=3)
|
252 |
+
|
253 |
+
########################################
|
254 |
+
|
255 |
+
## Het by Distance to Urban Centers:
|
256 |
+
|
257 |
+
canton_covs <- read_dta("./Data/cantons_dists.dta")
|
258 |
+
canton_covs <- canton_covs %>%
|
259 |
+
mutate(CODIGO = (as_factor(COD_CTON)))
|
260 |
+
|
261 |
+
canton_covs <- canton_covs %>%
|
262 |
+
mutate(CODIGO = gsub("(?<![0-9])0+", "", CODIGO, perl = TRUE)) %>%
|
263 |
+
mutate(CODIGO = as.numeric(CODIGO)) %>%
|
264 |
+
dplyr::select(CODIGO,dist_ES_capital, dist_dept_capitals)
|
265 |
+
|
266 |
+
censo_ag_wreform_tev <- left_join(censo_ag_wreform_tev,canton_covs, by="CODIGO")
|
267 |
+
|
268 |
+
num_ests <- 2*8
|
269 |
+
rd_estimates <-data.frame(ln_agprod_estimates = rep(0, num_ests), ln_agprod_ses = rep(0, num_ests),
|
270 |
+
ln_agprodII_estimates = rep(0,num_ests), ln_agprodII_ses = rep(0, num_ests),
|
271 |
+
p = rep(0,num_ests), ks = rep(0,num_ests), bs = rep(0,num_ests), nsl= rep(0,num_ests), nsr= rep(0,num_ests), nslII= rep(0,num_ests), nsrII= rep(0,num_ests), nslIII= rep(0,num_ests), nsrIII= rep(0,num_ests))
|
272 |
+
|
273 |
+
|
274 |
+
k <- "tri"
|
275 |
+
p <- 1
|
276 |
+
b<- "mserd"
|
277 |
+
years <- 2007
|
278 |
+
i = 2007
|
279 |
+
|
280 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev %>%
|
281 |
+
mutate(Close_ES_Capital = ifelse(dist_ES_capital < 50000,1,0),
|
282 |
+
Close_Dept_Capitals = ifelse(dist_dept_capitals < 10000,1,0))
|
283 |
+
|
284 |
+
|
285 |
+
count<-1
|
286 |
+
# Scale:
|
287 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
288 |
+
x=censo_ag_wreform_tev$norm_dist,
|
289 |
+
c = 0,
|
290 |
+
p = p,
|
291 |
+
q = p +1,
|
292 |
+
kernel = k,
|
293 |
+
bwselect = b,
|
294 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
295 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
296 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
297 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
298 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
299 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Country Capital",sep="")
|
300 |
+
count<-count+1
|
301 |
+
|
302 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
303 |
+
x=censo_ag_wreform_tev$norm_dist,
|
304 |
+
c = 0,
|
305 |
+
p = p,
|
306 |
+
q = p +1,
|
307 |
+
kernel = k,
|
308 |
+
bwselect = b,
|
309 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
310 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital != 1 | censo_ag_wreform_tev$reform==0)
|
311 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
312 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
313 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
314 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Country Capital",sep="")
|
315 |
+
count<-count+1
|
316 |
+
|
317 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
318 |
+
x=censo_ag_wreform_tev$norm_dist,
|
319 |
+
c = 0,
|
320 |
+
p = p,
|
321 |
+
q = p +1,
|
322 |
+
kernel = k,
|
323 |
+
bwselect = b,
|
324 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
325 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
326 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
327 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
328 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
329 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Country Capital",sep="")
|
330 |
+
count<-count+1
|
331 |
+
|
332 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
333 |
+
x=censo_ag_wreform_tev$norm_dist,
|
334 |
+
c = 0,
|
335 |
+
p = p,
|
336 |
+
q = p + 1,
|
337 |
+
kernel = k,
|
338 |
+
bwselect = b,
|
339 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
340 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital !=1 | censo_ag_wreform_tev$reform==0)
|
341 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
342 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
343 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
344 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Country Capital",sep="")
|
345 |
+
count<-count+1
|
346 |
+
|
347 |
+
|
348 |
+
# Share Cash:
|
349 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
350 |
+
x=censo_ag_wreform_tev$norm_dist,
|
351 |
+
c = 0,
|
352 |
+
p = p,
|
353 |
+
q = p +1,
|
354 |
+
kernel = k,
|
355 |
+
bwselect = b,
|
356 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
357 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
358 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
359 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
360 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
361 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Country Capital",sep="")
|
362 |
+
count<-count+1
|
363 |
+
|
364 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
365 |
+
x=censo_ag_wreform_tev$norm_dist,
|
366 |
+
c = 0,
|
367 |
+
p = p,
|
368 |
+
q = p +1,
|
369 |
+
kernel = k,
|
370 |
+
bwselect = b,
|
371 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
372 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital !=1 | censo_ag_wreform_tev$reform==0)
|
373 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
374 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
375 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
376 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Country Capital",sep="")
|
377 |
+
count<-count+1
|
378 |
+
|
379 |
+
# Share Staple:
|
380 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
381 |
+
x=censo_ag_wreform_tev$norm_dist,
|
382 |
+
c = 0,
|
383 |
+
p = p,
|
384 |
+
q = p +1,
|
385 |
+
kernel = k,
|
386 |
+
bwselect = b,
|
387 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
388 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
389 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
390 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
391 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
392 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Country Capital",sep="")
|
393 |
+
count<-count+1
|
394 |
+
|
395 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
396 |
+
x=censo_ag_wreform_tev$norm_dist,
|
397 |
+
c = 0,
|
398 |
+
p = p,
|
399 |
+
q = p +1,
|
400 |
+
kernel = k,
|
401 |
+
bwselect = b,
|
402 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
403 |
+
subset= censo_ag_wreform_tev$Close_ES_Capital != 1 | censo_ag_wreform_tev$reform==0)
|
404 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
405 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
406 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
407 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Country Capital",sep="")
|
408 |
+
count<-count+1
|
409 |
+
|
410 |
+
# Department Capitals
|
411 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
412 |
+
x=censo_ag_wreform_tev$norm_dist,
|
413 |
+
c = 0,
|
414 |
+
p = p,
|
415 |
+
q = p +1,
|
416 |
+
kernel = k,
|
417 |
+
bwselect = b,
|
418 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
419 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
420 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
421 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
422 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
423 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Department Capital",sep="")
|
424 |
+
count<-count+1
|
425 |
+
|
426 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod_pricew_crops),
|
427 |
+
x=censo_ag_wreform_tev$norm_dist,
|
428 |
+
c = 0,
|
429 |
+
p = p,
|
430 |
+
q = p +1,
|
431 |
+
kernel = k,
|
432 |
+
bwselect = b,
|
433 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
434 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital != 1 | censo_ag_wreform_tev$reform==0)
|
435 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
436 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod_pricew_crops")
|
437 |
+
rd_estimates[count,c("y_var")] <- "Revenue per ha"
|
438 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Department Capital",sep="")
|
439 |
+
count<-count+1
|
440 |
+
|
441 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
442 |
+
x=censo_ag_wreform_tev$norm_dist,
|
443 |
+
c = 0,
|
444 |
+
p = p,
|
445 |
+
q = p +1,
|
446 |
+
kernel = k,
|
447 |
+
bwselect = b,
|
448 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
449 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
450 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
451 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
452 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
453 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Department Capital",sep="")
|
454 |
+
count<-count+1
|
455 |
+
|
456 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
457 |
+
x=censo_ag_wreform_tev$norm_dist,
|
458 |
+
c = 0,
|
459 |
+
p = p,
|
460 |
+
q = p +1,
|
461 |
+
kernel = k,
|
462 |
+
bwselect = b,
|
463 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
464 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital !=1 | censo_ag_wreform_tev$reform==0)
|
465 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
466 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
467 |
+
rd_estimates[count,c("y_var")] <- "Profits per ha"
|
468 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Department Capital",sep="")
|
469 |
+
count<-count+1
|
470 |
+
|
471 |
+
# Share Cash:
|
472 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
473 |
+
x=censo_ag_wreform_tev$norm_dist,
|
474 |
+
c = 0,
|
475 |
+
p = p,
|
476 |
+
q = p +1,
|
477 |
+
kernel = k,
|
478 |
+
bwselect = b,
|
479 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
480 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
481 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
482 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
483 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
484 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Department Capital",sep="")
|
485 |
+
count<-count+1
|
486 |
+
|
487 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$CashCrop_Share),
|
488 |
+
x=censo_ag_wreform_tev$norm_dist,
|
489 |
+
c = 0,
|
490 |
+
p = p,
|
491 |
+
q = p +1,
|
492 |
+
kernel = k,
|
493 |
+
bwselect = b,
|
494 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
495 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital !=1 | censo_ag_wreform_tev$reform==0)
|
496 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
497 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
498 |
+
rd_estimates[count,c("y_var")] <- "Cash Crop Share"
|
499 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Department Capital",sep="")
|
500 |
+
count<-count+1
|
501 |
+
|
502 |
+
# Share Staple:
|
503 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
504 |
+
x=censo_ag_wreform_tev$norm_dist,
|
505 |
+
c = 0,
|
506 |
+
p = p,
|
507 |
+
q = p +1,
|
508 |
+
kernel = k,
|
509 |
+
bwselect = b,
|
510 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
511 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital == 1 | censo_ag_wreform_tev$reform==0)
|
512 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
513 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
514 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
515 |
+
rd_estimates[count,c("label")] <- paste("","Close to: Department Capital",sep="")
|
516 |
+
count<-count+1
|
517 |
+
|
518 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
519 |
+
x=censo_ag_wreform_tev$norm_dist,
|
520 |
+
c = 0,
|
521 |
+
p = p,
|
522 |
+
q = p +1,
|
523 |
+
kernel = k,
|
524 |
+
bwselect = b,
|
525 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1",
|
526 |
+
subset= censo_ag_wreform_tev$Close_Dept_Capital != 1 | censo_ag_wreform_tev$reform==0)
|
527 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
528 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
529 |
+
rd_estimates[count,c("y_var")] <- "Staple Crop Share"
|
530 |
+
rd_estimates[count,c("label")] <- paste("","Not Close to: Department Capital",sep="")
|
531 |
+
count<-count+1
|
532 |
+
|
533 |
+
|
534 |
+
rd_estimates
|
535 |
+
|
536 |
+
########################################
|
537 |
+
|
538 |
+
# Clean data for plotting:
|
539 |
+
alpha<- 0.05
|
540 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
541 |
+
|
542 |
+
# Find the outcome var for each regression:
|
543 |
+
data <-rd_estimates
|
544 |
+
|
545 |
+
# Replace y_var with nice names:
|
546 |
+
|
547 |
+
# Now, keep only the betas of interest:
|
548 |
+
betas <- data
|
549 |
+
dim(betas)
|
550 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
551 |
+
|
552 |
+
# Create Matrix for plotting:
|
553 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
554 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
555 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
556 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group) #levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
557 |
+
|
558 |
+
|
559 |
+
# Plot:
|
560 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
561 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
562 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
563 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
564 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics + xlab("")
|
565 |
+
|
566 |
+
# Save:
|
567 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks =scales::pretty_breaks(n = 10))
|
568 |
+
|
569 |
+
ggsave(filename="./Output/CoefPlot_Het_DistCapital.pdf")
|
570 |
+
|
14/replication_package/Replication/Code/ESLR_IVCensus_Matching.R
ADDED
@@ -0,0 +1,580 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################################
|
2 |
+
##### ESLR - RD + MATCHING PLOTING - AgCensus Data #####
|
3 |
+
########################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(haven)
|
26 |
+
require(readstata13)
|
27 |
+
require(TOSTER)
|
28 |
+
require(MatchIt)
|
29 |
+
require(imputeTS)
|
30 |
+
require(opmatch)
|
31 |
+
require(cem)
|
32 |
+
require(tcltk)
|
33 |
+
require(extrafont)
|
34 |
+
|
35 |
+
########################################
|
36 |
+
|
37 |
+
## Load IV Censo Agropecuario Data:
|
38 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
39 |
+
|
40 |
+
########################################
|
41 |
+
|
42 |
+
## Making Standarized Coefficient Plots:
|
43 |
+
|
44 |
+
# Set aesthetics:
|
45 |
+
aesthetics <- list(
|
46 |
+
theme_bw(),
|
47 |
+
theme(legend.title=element_blank(),
|
48 |
+
text=element_text(family="Palatino"),
|
49 |
+
#legend.justification=c(0,0),
|
50 |
+
#legend.position= "right", #c(1,0),
|
51 |
+
#panel.grid.minor=element_blank(),
|
52 |
+
#panel.grid.major=element_blank(),
|
53 |
+
plot.background=element_rect(colour="white",fill="white"),
|
54 |
+
panel.grid.major=element_blank(),
|
55 |
+
panel.grid.minor=element_blank(),
|
56 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
57 |
+
axis.title.y=element_text(face="bold.italic"),
|
58 |
+
axis.title.x=element_blank())) #(face="bold.italic")))
|
59 |
+
|
60 |
+
########################################
|
61 |
+
|
62 |
+
|
63 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
64 |
+
{
|
65 |
+
b <- MOD$coef[1]
|
66 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
67 |
+
sx <- sd(model.dta[,c("Above500")])
|
68 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
69 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
70 |
+
beta <- b * sx/sy
|
71 |
+
return(beta)
|
72 |
+
}
|
73 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
74 |
+
{
|
75 |
+
b <- MOD$se[1]
|
76 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
77 |
+
sx <- sd(model.dta[,c("Above500")])
|
78 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
79 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
80 |
+
beta <- b * sx/sy
|
81 |
+
return(beta)
|
82 |
+
}
|
83 |
+
|
84 |
+
lm.beta.match <- function (MOD, dta,y="ln_agprod")
|
85 |
+
{
|
86 |
+
b <- MOD[2,1]
|
87 |
+
model.dta <- dta # filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
88 |
+
sx <- sd(model.dta[,c("reform")],na.rm = TRUE)
|
89 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
90 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
91 |
+
beta <- b * sx/sy
|
92 |
+
return(beta)
|
93 |
+
}
|
94 |
+
lm.beta.ses.match <- function (MOD, dta,y="ln_agprod")
|
95 |
+
{
|
96 |
+
b <- MOD[2,2]
|
97 |
+
model.dta <- dta # filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
98 |
+
sx <- sd(model.dta[,c("reform")],na.rm = TRUE)
|
99 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
100 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
101 |
+
beta <- b * sx/sy
|
102 |
+
return(beta)
|
103 |
+
}
|
104 |
+
|
105 |
+
winsor <- function (x, fraction=.01)
|
106 |
+
{
|
107 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
108 |
+
fraction > 0.5) {
|
109 |
+
stop("bad value for 'fraction'")
|
110 |
+
}
|
111 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
112 |
+
x[ x < lim[1] ] <- NA #lim[1] 8888
|
113 |
+
x[ x > lim[2] ] <- NA #lim[2] 8888
|
114 |
+
x
|
115 |
+
}
|
116 |
+
|
117 |
+
winsor1 <- function (x, fraction=.01)
|
118 |
+
{
|
119 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
120 |
+
fraction > 0.5) {
|
121 |
+
stop("bad value for 'fraction'")
|
122 |
+
}
|
123 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
124 |
+
x[ x < lim[1] ] <- lim[1] #lim[1] 8888
|
125 |
+
x[ x > lim[2] ] <- lim[2] #lim[2] 8888
|
126 |
+
x
|
127 |
+
}
|
128 |
+
|
129 |
+
winsor2 <-function (x, multiple=3)
|
130 |
+
{
|
131 |
+
if(length(multiple) != 1 || multiple <= 0) {
|
132 |
+
stop("bad value for 'multiple'")
|
133 |
+
}
|
134 |
+
med <- median(x)
|
135 |
+
y <- x - med
|
136 |
+
sc <- mad(y, center=0) * multiple
|
137 |
+
y[ y > sc ] <- sc
|
138 |
+
y[ y < -sc ] <- -sc
|
139 |
+
y + med
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
########################################
|
144 |
+
|
145 |
+
polys <- c(1) # 1
|
146 |
+
kernels <- c("triangular")
|
147 |
+
bwsel <- c("mserd")
|
148 |
+
num_outcomes <- 3 # 3 ag prod; staple share + 2 yields; cash + 2 yields; income results
|
149 |
+
matching_methods <- c("nearest", "full", "cem", "optimal")
|
150 |
+
num_ests <- (length(polys)*(length(kernels)*length(bwsel)) + length(matching_methods))*num_outcomes
|
151 |
+
estimates <-data.frame(y_var = rep(0, num_ests),
|
152 |
+
estimate = rep(0, num_ests),
|
153 |
+
ses = rep(0, num_ests),
|
154 |
+
p = rep(0,num_ests), ks = rep(0,num_ests), bs = rep(0,num_ests),
|
155 |
+
nsl= rep(0,num_ests), nsr= rep(0,num_ests), nslII= rep(0,num_ests),
|
156 |
+
nsrII= rep(0,num_ests), nslIII= rep(0,num_ests), nsrIII= rep(0,num_ests),
|
157 |
+
est_method = rep(0,num_ests))
|
158 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform, ln_agprodII = ln_agprod, ln_agprod = ln_agprod_pricew_crops)
|
159 |
+
|
160 |
+
## Other covariates for matching:
|
161 |
+
ag.grouped <- group_by(censo_ag_wreform_tev,Expropretario_ISTA)
|
162 |
+
ag.grouped <- mutate(ag.grouped, num_per_owner = n())
|
163 |
+
censo_ag_wreform_tev$num_per_owner<- ag.grouped$num_per_owner
|
164 |
+
censo_ag_wreform_tev$mult_per_owner <- ifelse(censo_ag_wreform_tev$num_per_owner > 1, 1, 0)
|
165 |
+
|
166 |
+
# Het by Distance to Urban Centers:
|
167 |
+
canton_covs <- read_dta("Data/cantons_dists.dta")
|
168 |
+
canton_covs <- canton_covs %>%
|
169 |
+
mutate(CODIGO = (as_factor(COD_CTON)))
|
170 |
+
|
171 |
+
canton_covs <- canton_covs %>%
|
172 |
+
mutate(CODIGO = gsub("(?<![0-9])0+", "", CODIGO, perl = TRUE)) %>%
|
173 |
+
mutate(CODIGO = as.numeric(CODIGO)) %>%
|
174 |
+
dplyr::select(CODIGO,dist_ES_capital, dist_dept_capitals)
|
175 |
+
|
176 |
+
censo_ag_wreform_tev <- left_join(censo_ag_wreform_tev,canton_covs, by="CODIGO")
|
177 |
+
|
178 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev %>%
|
179 |
+
mutate(Close_ES_Capital = ifelse(dist_ES_capital < 50000,1,0),
|
180 |
+
Close_Dept_Capitals = ifelse(dist_dept_capitals < 50000,1,0),
|
181 |
+
canton_land_suit = ifelse(is.na(canton_land_suit),0,canton_land_suit))
|
182 |
+
|
183 |
+
censo_ag_wreform_tev2 <- censo_ag_wreform_tev
|
184 |
+
years <- 2007
|
185 |
+
for (i in years) {
|
186 |
+
|
187 |
+
# Estimate and Save RD for configurations:
|
188 |
+
|
189 |
+
# Agricultural Variables -- RD Estimates:
|
190 |
+
count <-1
|
191 |
+
for (p in polys) {
|
192 |
+
for (k in kernels) {
|
193 |
+
for (b in bwsel) {
|
194 |
+
|
195 |
+
|
196 |
+
# Cash Crop Share:
|
197 |
+
rdests <- rdrobust(y = winsor(censo_ag_wreform_tev$CashCrop_Share),
|
198 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
199 |
+
c = 0,
|
200 |
+
p = p,
|
201 |
+
q = p +1,
|
202 |
+
kernel = k,
|
203 |
+
bwselect = b,
|
204 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
205 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
206 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
207 |
+
|
208 |
+
estimates[count,c("y_var")] <- "Cash Crop Share"
|
209 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
210 |
+
count <- count + 1
|
211 |
+
|
212 |
+
# Sugar Cane Yield:
|
213 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$SugarCane_Yield),
|
214 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
215 |
+
c = 0,
|
216 |
+
p = p,
|
217 |
+
q = p +1,
|
218 |
+
kernel = k,
|
219 |
+
#bwselect = b,
|
220 |
+
h = 102.877,
|
221 |
+
b = 166.088,
|
222 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
223 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="SugarCane_Yield")
|
224 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="SugarCane_Yield") #/2
|
225 |
+
|
226 |
+
estimates[count,c("y_var")] <- "Sugar Cane Yield"
|
227 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
228 |
+
count <- count + 1
|
229 |
+
|
230 |
+
# Coffee Yield:
|
231 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Coffee_Yield),
|
232 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
233 |
+
c = 0,
|
234 |
+
p = p,
|
235 |
+
q = p +1,
|
236 |
+
kernel = k,
|
237 |
+
bwselect = b,
|
238 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
239 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Coffee_Yield")
|
240 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Coffee_Yield")
|
241 |
+
|
242 |
+
estimates[count,c("y_var")] <- "Coffee Yield"
|
243 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
244 |
+
count <- count + 1
|
245 |
+
|
246 |
+
# Staple Crop Share:
|
247 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
248 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
249 |
+
c = 0,
|
250 |
+
p = p,
|
251 |
+
q = p +1,
|
252 |
+
kernel = k,
|
253 |
+
bwselect = b,
|
254 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
255 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
256 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
257 |
+
|
258 |
+
estimates[count,c("y_var")] <- "Staple Crop Share"
|
259 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
260 |
+
count <- count + 1
|
261 |
+
|
262 |
+
# Bean Yield:
|
263 |
+
rdests <- rdrobust(y =censo_ag_wreform_tev$Beans_Yield, # winsor1(censo_ag_wreform_tev$Beans_Yield,fraction = 0.025)
|
264 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
265 |
+
c = 0,
|
266 |
+
p = p,
|
267 |
+
q = p +1,
|
268 |
+
kernel = k,
|
269 |
+
# bwselect = b,
|
270 |
+
h = 122.64,
|
271 |
+
b = 207.42,
|
272 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
273 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Beans_Yield")
|
274 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Beans_Yield")
|
275 |
+
|
276 |
+
estimates[count,c("y_var")] <- "Beans Yield"
|
277 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
278 |
+
count <- count + 1
|
279 |
+
|
280 |
+
# Maize Yield:
|
281 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Maize_Yield),
|
282 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
283 |
+
c = 0,
|
284 |
+
p = p,
|
285 |
+
q = p +1,
|
286 |
+
kernel = k,
|
287 |
+
#bwselect = b,
|
288 |
+
h = 91.611 ,
|
289 |
+
b = 146.499 ,
|
290 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
291 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Maize_Yield")
|
292 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Maize_Yield")
|
293 |
+
|
294 |
+
estimates[count,c("y_var")] <- "Maize Yield"
|
295 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
296 |
+
count <- count + 1
|
297 |
+
|
298 |
+
# Revenues:
|
299 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
300 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
301 |
+
c = 0,
|
302 |
+
p = p,
|
303 |
+
q = p +1,
|
304 |
+
kernel = k,
|
305 |
+
bwselect = b,
|
306 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
307 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
308 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
309 |
+
|
310 |
+
estimates[count,c("y_var")] <- "Revenues per ha"
|
311 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
312 |
+
count <- count + 1
|
313 |
+
|
314 |
+
# Profits:
|
315 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
316 |
+
x=censo_ag_wreform_tev$norm_dist,
|
317 |
+
c = 0,
|
318 |
+
p = p,
|
319 |
+
q = p +1,
|
320 |
+
kernel = k,
|
321 |
+
bwselect = b,
|
322 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
323 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
324 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
325 |
+
|
326 |
+
estimates[count,c("y_var")] <- "Profits per ha"
|
327 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
328 |
+
count <- count + 1
|
329 |
+
|
330 |
+
# TFP:
|
331 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_tfp_geo),
|
332 |
+
x=censo_ag_wreform_tev$norm_dist,
|
333 |
+
c = 0,
|
334 |
+
p = p,
|
335 |
+
q = p +1,
|
336 |
+
kernel = k,
|
337 |
+
bwselect = b,
|
338 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
339 |
+
estimates[count,c("estimate")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
340 |
+
estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
341 |
+
|
342 |
+
estimates[count,c("y_var")] <- "Farm Productivity"
|
343 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
344 |
+
count <- count + 1
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
# Agricultural Variables -- Matching Estimates:
|
350 |
+
for (m in matching_methods) {
|
351 |
+
|
352 |
+
## Match Datasets:
|
353 |
+
to_match <- filter(censo_ag_wreform_tev, !is.na(reform))
|
354 |
+
covs <- c("canton_mean_rain","canton_land_suit", "canton_elev_dem_30sec",
|
355 |
+
"canton_coffee_suit","sugarcane_suit","miaze_suit","bean_suit","canton_mean_rain",
|
356 |
+
"mult_per_owner",
|
357 |
+
"dist_ES_capital" , "dist_dept_capitals",
|
358 |
+
"Area_has")
|
359 |
+
to_match<-to_match[complete.cases(to_match[,covs]),]
|
360 |
+
matched.data<-
|
361 |
+
matchit(reform ~ canton_coffee_suit + sugarcane_suit + miaze_suit +
|
362 |
+
bean_suit + canton_mean_rain + canton_land_suit + canton_elev_dem_30sec +
|
363 |
+
mult_per_owner +
|
364 |
+
dist_ES_capital + dist_dept_capitals +
|
365 |
+
Area_has, data = to_match,
|
366 |
+
method = m)
|
367 |
+
|
368 |
+
# Matching estimate
|
369 |
+
|
370 |
+
# Cash Crop Share
|
371 |
+
fit1 <- lm(CashCrop_Share ~ reform, data = match.data(matched.data), weights = weights)
|
372 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
373 |
+
|
374 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
375 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
376 |
+
|
377 |
+
estimates[count,c("y_var")] <- "Cash Crop Share"
|
378 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
379 |
+
case_when(m=="optimal" ~ "Optimal",
|
380 |
+
m=="nearest" ~ "Nearest Neighbor",
|
381 |
+
m=="full" ~ "Full",
|
382 |
+
m=="cem" ~ "Coarse Exact"),
|
383 |
+
" Matching")
|
384 |
+
count <- count + 1
|
385 |
+
|
386 |
+
# Sugar Cane
|
387 |
+
fit1 <- lm(SugarCane_Yield ~ reform, data = match.data(matched.data), weights = weights)
|
388 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
389 |
+
|
390 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="SugarCane_Yield")
|
391 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="SugarCane_Yield")
|
392 |
+
|
393 |
+
estimates[count,c("y_var")] <- "Sugar Cane Yield"
|
394 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
395 |
+
case_when(m=="optimal" ~ "Optimal",
|
396 |
+
m=="nearest" ~ "Nearest Neighbor",
|
397 |
+
m=="full" ~ "Full",
|
398 |
+
m=="cem" ~ "Coarse Exact"),
|
399 |
+
" Matching")
|
400 |
+
count <- count + 1
|
401 |
+
|
402 |
+
# Coffee
|
403 |
+
fit1 <- lm(Coffee_Yield ~ reform, data = match.data(matched.data), weights = weights)
|
404 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
405 |
+
|
406 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="Coffee_Yield")
|
407 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="Coffee_Yield")
|
408 |
+
|
409 |
+
estimates[count,c("y_var")] <- "Coffee Yield"
|
410 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
411 |
+
case_when(m=="optimal" ~ "Optimal",
|
412 |
+
m=="nearest" ~ "Nearest Neighbor",
|
413 |
+
m=="full" ~ "Full",
|
414 |
+
m=="cem" ~ "Coarse Exact"),
|
415 |
+
" Matching")
|
416 |
+
count <- count + 1
|
417 |
+
|
418 |
+
# Staple Crop Share
|
419 |
+
fit1 <- lm(StapleCrop_Share ~ reform, data = match.data(matched.data), weights = weights)
|
420 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
421 |
+
|
422 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
423 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="StapleCrop_Share")
|
424 |
+
|
425 |
+
estimates[count,c("y_var")] <- "Staple Crop Share"
|
426 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
427 |
+
case_when(m=="optimal" ~ "Optimal",
|
428 |
+
m=="nearest" ~ "Nearest Neighbor",
|
429 |
+
m=="full" ~ "Full",
|
430 |
+
m=="cem" ~ "Coarse Exact"),
|
431 |
+
" Matching")
|
432 |
+
count <- count + 1
|
433 |
+
|
434 |
+
# Maize
|
435 |
+
fit1 <- lm(Maize_Yield ~ reform, data = match.data(matched.data), weights = weights)
|
436 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
437 |
+
|
438 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="Maize_Yield")
|
439 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="Maize_Yield")
|
440 |
+
|
441 |
+
estimates[count,c("y_var")] <- "Maize Yield"
|
442 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
443 |
+
case_when(m=="optimal" ~ "Optimal",
|
444 |
+
m=="nearest" ~ "Nearest Neighbor",
|
445 |
+
m=="full" ~ "Full",
|
446 |
+
m=="cem" ~ "Coarse Exact"),
|
447 |
+
" Matching")
|
448 |
+
count <- count + 1
|
449 |
+
|
450 |
+
# Beans
|
451 |
+
fit1 <- lm(Beans_Yield ~ reform, data = match.data(matched.data), weights = weights)
|
452 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
453 |
+
|
454 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="Beans_Yield")
|
455 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="Beans_Yield")
|
456 |
+
|
457 |
+
estimates[count,c("y_var")] <- "Beans Yield"
|
458 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
459 |
+
case_when(m=="optimal" ~ "Optimal",
|
460 |
+
m=="nearest" ~ "Nearest Neighbor",
|
461 |
+
m=="full" ~ "Full",
|
462 |
+
m=="cem" ~ "Coarse Exact"),
|
463 |
+
" Matching")
|
464 |
+
count <- count + 1
|
465 |
+
|
466 |
+
# Revenues:
|
467 |
+
fit1 <- lm(ln_agprod ~ reform, data = match.data(matched.data), weights = weights)
|
468 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
469 |
+
|
470 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
471 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
472 |
+
|
473 |
+
estimates[count,c("y_var")] <- "Revenues per ha"
|
474 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
475 |
+
case_when(m=="optimal" ~ "Optimal",
|
476 |
+
m=="nearest" ~ "Nearest Neighbor",
|
477 |
+
m=="full" ~ "Full",
|
478 |
+
m=="cem" ~ "Coarse Exact"),
|
479 |
+
" Matching")
|
480 |
+
count <- count + 1
|
481 |
+
|
482 |
+
# Profits:
|
483 |
+
fit1 <- lm(ln_agprodII ~ reform, data = match.data(matched.data), weights = weights)
|
484 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
485 |
+
|
486 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
487 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
488 |
+
|
489 |
+
estimates[count,c("y_var")] <- "Profits per ha"
|
490 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
491 |
+
case_when(m=="optimal" ~ "Optimal",
|
492 |
+
m=="nearest" ~ "Nearest Neighbor",
|
493 |
+
m=="full" ~ "Full",
|
494 |
+
m=="cem" ~ "Coarse Exact"),
|
495 |
+
" Matching")
|
496 |
+
count <- count + 1
|
497 |
+
|
498 |
+
# TFP:
|
499 |
+
fit1 <- lm(ln_tfp_geo ~ reform, data = match.data(matched.data), weights = weights)
|
500 |
+
ests<- coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
|
501 |
+
|
502 |
+
estimates[count,c("estimate")] <-lm.beta.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
503 |
+
estimates[count,c("ses")] <- lm.beta.ses.match(MOD=ests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
504 |
+
|
505 |
+
estimates[count,c("y_var")] <- "Farm Productivity"
|
506 |
+
estimates[count,c("est_method")] <- paste0("Matching: ",
|
507 |
+
case_when(m=="optimal" ~ "Optimal",
|
508 |
+
m=="nearest" ~ "Nearest Neighbor",
|
509 |
+
m=="full" ~ "Full",
|
510 |
+
m=="cem" ~ "Coarse Exact"),
|
511 |
+
" Matching")
|
512 |
+
count <- count + 1
|
513 |
+
|
514 |
+
}
|
515 |
+
}
|
516 |
+
estimates
|
517 |
+
|
518 |
+
########################################
|
519 |
+
|
520 |
+
# Clean data for plotting:
|
521 |
+
alpha<- 0.05
|
522 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
523 |
+
|
524 |
+
Multiplier2 <- qnorm(1 - 2*alpha / 2)
|
525 |
+
|
526 |
+
data <- estimates
|
527 |
+
betas <- data
|
528 |
+
dim(betas)
|
529 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
530 |
+
|
531 |
+
# Create Matrix for plotting:
|
532 |
+
MatrixofModels <- betas[c("y_var", "estimate","ses","est_method")]
|
533 |
+
colnames(MatrixofModels) <- c("Outcome", "Estimate", "StandardError", "Method")
|
534 |
+
MatrixofModels$Outcome <- factor(MatrixofModels$Outcome, levels = unique(MatrixofModels$Outcome))
|
535 |
+
|
536 |
+
# Re-Order for plotting:
|
537 |
+
MatrixofModels$Outcome <- factor(MatrixofModels$Outcome,
|
538 |
+
levels = c("Cash Crop Share",
|
539 |
+
"Coffee Yield",
|
540 |
+
"Sugar Cane Yield",
|
541 |
+
"Staple Crop Share",
|
542 |
+
"Maize Yield",
|
543 |
+
"Beans Yield",
|
544 |
+
"Revenues per ha",
|
545 |
+
"Profits per ha",
|
546 |
+
"Farm Productivity"))
|
547 |
+
|
548 |
+
# Plot:
|
549 |
+
OutputPlot <- qplot(Method, Estimate, ymin = Estimate - Multiplier * StandardError,
|
550 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
551 |
+
ylab = NULL, xlab = NULL, facets=~ Outcome, alpha=0.5)
|
552 |
+
|
553 |
+
OutputPlot <- ggplot() + geom_errorbar(aes(x=Method, y=Estimate, ymin = Estimate - Multiplier * StandardError,
|
554 |
+
ymax = Estimate + Multiplier * StandardError), data = MatrixofModels,
|
555 |
+
size=0.6,
|
556 |
+
width=0,
|
557 |
+
alpha=0.5,
|
558 |
+
col="black") +
|
559 |
+
geom_point(aes(x=Method, y=Estimate), data = MatrixofModels,
|
560 |
+
col="black",show.legend = FALSE) + facet_wrap(~Outcome)
|
561 |
+
|
562 |
+
|
563 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
564 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
565 |
+
# Add 90%
|
566 |
+
OutputPlot <- OutputPlot + geom_errorbar(aes(x=Method, y=Estimate, ymin = Estimate - Multiplier2 * StandardError,
|
567 |
+
ymax = Estimate + Multiplier2 * StandardError), data = MatrixofModels,
|
568 |
+
size=0.5,
|
569 |
+
width=0,
|
570 |
+
col="black",show.legend = FALSE)
|
571 |
+
OutputPlot <- OutputPlot + geom_point(aes(x=Method, y=Estimate), data = MatrixofModels,
|
572 |
+
col="black",show.legend = FALSE)
|
573 |
+
# Save:
|
574 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-2, 1.5,0.5)) +
|
575 |
+
xlab("") +
|
576 |
+
coord_flip(ylim= c(-2,1.5))
|
577 |
+
ggsave(filename="./Output/CoefPlot_Matching.pdf", scale=1.25)
|
578 |
+
|
579 |
+
|
580 |
+
|
14/replication_package/Replication/Code/ESLR_IVCensus_NonComplierPlot.R
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################
|
2 |
+
require(lfe)
|
3 |
+
## Crop choices for non-compliers vs control
|
4 |
+
|
5 |
+
num_ests <- 1*2
|
6 |
+
estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
7 |
+
y_var = rep(0,num_ests),
|
8 |
+
label = rep(0, num_ests))
|
9 |
+
|
10 |
+
lm.beta.ses2 <- function (MOD, dta,y="ln_agprod")
|
11 |
+
{
|
12 |
+
b <- MOD$se[2] # b <- MOD$se[3]
|
13 |
+
sx <- sd(dta[,c("non_comp")],na.rm=TRUE)
|
14 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
15 |
+
sy <- sd((dta[,c(y)]),na.rm=TRUE)
|
16 |
+
beta <- b * sx/sy
|
17 |
+
return(beta)
|
18 |
+
}
|
19 |
+
|
20 |
+
lm.beta2 <- function (MOD, dta,y="ln_agprod")
|
21 |
+
{
|
22 |
+
b <- MOD$coef[2]
|
23 |
+
sx <- sd(dta[,c("non_comp")],na.rm=TRUE)
|
24 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
25 |
+
sy <- sd((dta[,c(y)]),na.rm=TRUE)
|
26 |
+
print(sx)
|
27 |
+
beta <- b * sx/sy
|
28 |
+
return(beta)
|
29 |
+
}
|
30 |
+
|
31 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
32 |
+
censo_ag_wreform_tev <- censo_ag_wreform %>%
|
33 |
+
mutate(non_comp = ifelse(reform == 0 & Above500==1,1,0)) %>%
|
34 |
+
filter(reform!=1)
|
35 |
+
|
36 |
+
controls <- 1
|
37 |
+
count<-1
|
38 |
+
for (i in controls) {
|
39 |
+
print(i)
|
40 |
+
|
41 |
+
|
42 |
+
# Share Cash:
|
43 |
+
rdests <- felm(CashCrop_Share ~
|
44 |
+
non_comp
|
45 |
+
| 0 | 0 | Expropretario_ISTA,
|
46 |
+
data = censo_ag_wreform_tev,
|
47 |
+
subset = (reform==0 & AREA_HECTAREA > 350))
|
48 |
+
|
49 |
+
estimates[count,c("estimates")] <-lm.beta2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
50 |
+
estimates[count,c("ses")] <- lm.beta.ses2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
51 |
+
estimates[count,c("y_var")] <- "Cash Crop Share"
|
52 |
+
#estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
53 |
+
count<-count+1
|
54 |
+
|
55 |
+
|
56 |
+
# Share Staple:
|
57 |
+
rdests <- felm(StapleCrop_Share ~
|
58 |
+
non_comp
|
59 |
+
| 0 | 0 | Expropretario_ISTA,
|
60 |
+
data = censo_ag_wreform_tev,
|
61 |
+
subset = (reform==0 & AREA_HECTAREA > 350))
|
62 |
+
|
63 |
+
estimates[count,c("estimates")] <-lm.beta2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
64 |
+
estimates[count,c("ses")] <- lm.beta.ses2(MOD=rdests, dta=censo_ag_wreform_tev, y="CashCrop_Share")
|
65 |
+
estimates[count,c("y_var")] <- "Staple Crop Share"
|
66 |
+
#estimates[count,c("label")] <- paste("Controlling for: ",labels[label.count],sep="")
|
67 |
+
|
68 |
+
# Suitabilities?
|
69 |
+
|
70 |
+
count<-count+1
|
71 |
+
label.count<-label.count+1
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
estimates
|
76 |
+
|
77 |
+
########################################
|
78 |
+
|
79 |
+
# Clean data for plotting:
|
80 |
+
alpha<- 0.05
|
81 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
82 |
+
|
83 |
+
# Find the outcome var for each regression:
|
84 |
+
data <-estimates
|
85 |
+
|
86 |
+
# Replace y_var with nice names:
|
87 |
+
|
88 |
+
# Now, keep only the betas of interest:
|
89 |
+
betas <- data
|
90 |
+
dim(betas)
|
91 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
92 |
+
|
93 |
+
# Create Matrix for plotting:
|
94 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
95 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
96 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
97 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group, levels = paste0("Controlling for: ", labels))
|
98 |
+
|
99 |
+
|
100 |
+
# Plot:
|
101 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
102 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
103 |
+
ylab = NULL, xlab = NULL)
|
104 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
105 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
106 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.02, alpha = 0.05)
|
107 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
108 |
+
|
109 |
+
# Save:
|
110 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1, 1,0.05),limits = c(-0.25,0.25)) + xlab("")
|
111 |
+
|
112 |
+
ggsave(filename="./Output/CoefPlot_NonCompliers.pdf", width=6, height=3)
|
14/replication_package/Replication/Code/ESLR_IVCensus_Power.do
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
***************************************************************
|
2 |
+
******* ESLR:Ag-Census-Plot-Level Outcomes-Extensions **********
|
3 |
+
****************************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
|
11 |
+
*********************
|
12 |
+
*** Load the Data ***
|
13 |
+
*********************
|
14 |
+
|
15 |
+
use "Data/censo_ag_wreform.dta", clear
|
16 |
+
|
17 |
+
******************
|
18 |
+
*** POWER CALC ***
|
19 |
+
******************
|
20 |
+
|
21 |
+
|
22 |
+
local polynomial_level 1
|
23 |
+
local bandwidth_choice "mserd"
|
24 |
+
local kernel_choice "tri"
|
25 |
+
local cluster_level "Expropretario_ISTA"
|
26 |
+
|
27 |
+
*Logs OF REVENUE:
|
28 |
+
rdbwselect ln_agprod_pricew_crops norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
29 |
+
* STANDARDIZE EFFECT w/in BW:
|
30 |
+
dis `e(h_mserd)'
|
31 |
+
egen sd_agprod_bw = sd(ln_agprod_pricew_crops)
|
32 |
+
egen mean_agprod_bw = mean(ln_agprod_pricew_crops)
|
33 |
+
egen mean_agprod = mean(mean_agprod_bw)
|
34 |
+
egen sd_agprod = mean(sd_agprod_bw)
|
35 |
+
egen sd_A500_bw = sd(Above500) if abs(norm_dist) < `e(h_mserd)'
|
36 |
+
egen sd_Above500 = mean(sd_A500_bw)
|
37 |
+
|
38 |
+
gen std_agprod = ((ln_agprod_pricew_crops - mean_agprod )/sd_agprod)*sd_Above500
|
39 |
+
|
40 |
+
set scheme lean1
|
41 |
+
|
42 |
+
rdpower std_agprod norm_dist , c(0) tau(0.5) vce(cluster Expropretario_ISTA) plot
|
43 |
+
graph export "Output/AgCensus_Power_Revenues.pdf", replace
|
14/replication_package/Replication/Code/ESLR_IVCensus_RDRobustnessPlots.R
ADDED
@@ -0,0 +1,386 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################################
|
2 |
+
##### ESLR - RD ROBUSNTESS PLOTING - AgCensus Data #####
|
3 |
+
########################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(haven)
|
26 |
+
require(readstata13)
|
27 |
+
require(TOSTER)
|
28 |
+
|
29 |
+
########################################
|
30 |
+
|
31 |
+
## Load IV Censo Agropecuario Data:
|
32 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
33 |
+
|
34 |
+
########################################
|
35 |
+
|
36 |
+
## Making Standarized Coefficient Plots:
|
37 |
+
|
38 |
+
# Set aesthetics:
|
39 |
+
aesthetics <- list(
|
40 |
+
theme_bw(),
|
41 |
+
theme(legend.title=element_blank(),
|
42 |
+
#legend.justification=c(0,0),
|
43 |
+
#legend.position= "right", #c(1,0),
|
44 |
+
#panel.grid.minor=element_blank(),
|
45 |
+
#panel.grid.major=element_blank(),
|
46 |
+
plot.background=element_rect(colour="white",fill="white"),
|
47 |
+
panel.grid.major=element_blank(),
|
48 |
+
panel.grid.minor=element_blank(),
|
49 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
50 |
+
axis.title.y=element_text(face="bold.italic"),
|
51 |
+
axis.title.x=element_blank())) #(face="bold.italic")))
|
52 |
+
|
53 |
+
########################################
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
58 |
+
{
|
59 |
+
b <- MOD$coef[1]
|
60 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
61 |
+
sx <- sd(model.dta[,c("Above500")])
|
62 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
63 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
64 |
+
beta <- b * sx/sy
|
65 |
+
return(beta)
|
66 |
+
}
|
67 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
68 |
+
{
|
69 |
+
b <- MOD$se[1]
|
70 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
71 |
+
sx <- sd(model.dta[,c("Above500")])
|
72 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
73 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
74 |
+
beta <- b * sx/sy
|
75 |
+
return(beta)
|
76 |
+
}
|
77 |
+
|
78 |
+
########################################
|
79 |
+
|
80 |
+
polys <- c(1,2)
|
81 |
+
kernels <- c("triangular","epanechnikov","uniform")
|
82 |
+
bwsel <- c("mserd","cerrd") #"certwo"
|
83 |
+
num_ests <- length(polys)*(length(kernels) + length(bwsel))
|
84 |
+
rd_estimates <-data.frame(ln_agprod_estimates = rep(0, num_ests), ln_agprod_ses = rep(0, num_ests),
|
85 |
+
ln_agprodII_estimates = rep(0,num_ests), ln_agprodII_ses = rep(0, num_ests),
|
86 |
+
ln_agprodIII_estimates = rep(0,num_ests), ln_agprodIII_ses = rep(0, num_ests),
|
87 |
+
p = rep(0,num_ests), ks = rep(0,num_ests), bs = rep(0,num_ests), nsl= rep(0,num_ests), nsr= rep(0,num_ests), nslII= rep(0,num_ests), nsrII= rep(0,num_ests), nslIII= rep(0,num_ests), nsrIII= rep(0,num_ests))
|
88 |
+
|
89 |
+
|
90 |
+
years <- 2007
|
91 |
+
for (i in years) {
|
92 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform, ln_agprodII = ln_agprod, ln_agprod = ln_agprod_pricew_crops)
|
93 |
+
|
94 |
+
# Estimate and Save RD for configurations:
|
95 |
+
|
96 |
+
# Agricultural Productivity:
|
97 |
+
count <-1
|
98 |
+
for (p in polys) {
|
99 |
+
for (k in kernels) {
|
100 |
+
for (b in bwsel) {
|
101 |
+
# Scale:
|
102 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
103 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
104 |
+
c = 0,
|
105 |
+
p = p,
|
106 |
+
q = p +1,
|
107 |
+
kernel = k,
|
108 |
+
bwselect = b,
|
109 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
110 |
+
rd_estimates[count,c("ln_agprod_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
111 |
+
rd_estimates[count,c("ln_agprod_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod") # rdests$se[3]
|
112 |
+
|
113 |
+
rd_estimates[count,c("nsl")]<- rdests$N[1]
|
114 |
+
rd_estimates[count,c("nsr")]<- rdests$N[2]
|
115 |
+
|
116 |
+
# Scale:
|
117 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
118 |
+
x=censo_ag_wreform_tev$norm_dist,
|
119 |
+
c = 0,
|
120 |
+
p = p,
|
121 |
+
q = p +1,
|
122 |
+
kernel = k,
|
123 |
+
bwselect = b,
|
124 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
125 |
+
rd_estimates[count,c("ln_agprodII_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
126 |
+
rd_estimates[count,c("ln_agprodII_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII") # rdests$se[3]
|
127 |
+
|
128 |
+
rd_estimates[count,c("nslII")]<- rdests$N[1]
|
129 |
+
rd_estimates[count,c("nsrII")]<- rdests$N[2]
|
130 |
+
|
131 |
+
# Scale:
|
132 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_tfp_geo),
|
133 |
+
x=censo_ag_wreform_tev$norm_dist,
|
134 |
+
c = 0,
|
135 |
+
p = p,
|
136 |
+
q = p +1,
|
137 |
+
kernel = k,
|
138 |
+
bwselect = b,
|
139 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
140 |
+
rd_estimates[count,c("ln_agprodIII_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
141 |
+
rd_estimates[count,c("ln_agprodIII_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo") # rdests$se[3]
|
142 |
+
|
143 |
+
rd_estimates[count,c("nslIII")]<- rdests$N[1]
|
144 |
+
rd_estimates[count,c("nsrIII")]<- rdests$N[2]
|
145 |
+
|
146 |
+
rd_estimates[count,c("p")] <- p
|
147 |
+
rd_estimates[count,c("ks")] <- k
|
148 |
+
rd_estimates[count,c("bs")] <- b
|
149 |
+
count <- count + 1
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
rd_estimates
|
155 |
+
|
156 |
+
########################################
|
157 |
+
|
158 |
+
# Clean data for plotting:
|
159 |
+
alpha<- 0.05
|
160 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
161 |
+
|
162 |
+
# Find the outcome var for each regression:
|
163 |
+
data <- rd_estimates
|
164 |
+
data$y_var <- paste(data$ks, " kernel, ", data$bs," bandwidth",sep="")
|
165 |
+
|
166 |
+
# Replace y_var with nice names:
|
167 |
+
|
168 |
+
# Now, keep only the betas of interest:
|
169 |
+
betas <- data
|
170 |
+
dim(betas)
|
171 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
172 |
+
|
173 |
+
# Create Matrix for plotting:
|
174 |
+
MatrixofModels <- betas[c("y_var", "ln_agprod_estimates","ln_agprod_ses","p")]
|
175 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
176 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
177 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
178 |
+
|
179 |
+
# Re-name for plotting:
|
180 |
+
MatrixofModels$ModelName <- "Revenue Per Hectare"
|
181 |
+
|
182 |
+
# Plot:
|
183 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
184 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
185 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
186 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
187 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
188 |
+
|
189 |
+
# Save:
|
190 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-0.5, 0.5,0.1)) + xlab("")
|
191 |
+
|
192 |
+
ggsave(filename="./Output/CoefPlot_AgProdI_Robustness.pdf", width=6, height=3)
|
193 |
+
|
194 |
+
# Create Matrix for plotting:
|
195 |
+
MatrixofModels <- betas[c("y_var", "ln_agprodII_estimates","ln_agprodII_ses","p")]
|
196 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
197 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
198 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
199 |
+
|
200 |
+
# Re-name for plotting:
|
201 |
+
MatrixofModels$ModelName <- "Profits Per Hectare"
|
202 |
+
|
203 |
+
# Plot:
|
204 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
205 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
206 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
207 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
208 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
209 |
+
|
210 |
+
# Save:
|
211 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-0.5, 0.5,0.1)) + xlab("")
|
212 |
+
|
213 |
+
ggsave(filename="./Output/CoefPlot_AgProdII_Robustness.pdf", width=6, height=3)
|
214 |
+
|
215 |
+
|
216 |
+
# # Create Matrix for plotting:
|
217 |
+
MatrixofModels <- betas[c("y_var", "ln_agprodIII_estimates","ln_agprodIII_ses","p")]
|
218 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
219 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
220 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
221 |
+
|
222 |
+
# Re-name for plotting:
|
223 |
+
MatrixofModels$ModelName <- "Farm Productivity"
|
224 |
+
|
225 |
+
# Plot:
|
226 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
227 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
228 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
229 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
230 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
231 |
+
|
232 |
+
# Save:
|
233 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-0.5, 0.5,0.1)) + xlab("")
|
234 |
+
|
235 |
+
ggsave(filename="./Output/CoefPlot_AgProdIII_Robustness.pdf", width=6, height=3)
|
236 |
+
|
237 |
+
########################################
|
238 |
+
|
239 |
+
## Varying BW Manually:
|
240 |
+
|
241 |
+
## Calculate log ag productivity for 2007, and save RD estimates using different bandwidths and polynomials:
|
242 |
+
|
243 |
+
polys <- c(1,2)
|
244 |
+
bws <- seq(40,300, by=20)
|
245 |
+
|
246 |
+
num_ests <- length(polys)*(length(bws))
|
247 |
+
rd_estimates <-data.frame(ln_agprod_estimates = rep(0, num_ests), ln_agprod_ses = rep(0, num_ests),
|
248 |
+
ln_agprodII_estimates = rep(0,num_ests), ln_agprodII_ses = rep(0, num_ests),
|
249 |
+
ln_agprodIII_estimates = rep(0,num_ests), ln_agprodIII_ses = rep(0, num_ests),
|
250 |
+
p = rep(0,num_ests), bs = rep(0,num_ests))
|
251 |
+
|
252 |
+
# Create Variables:
|
253 |
+
i <- 2007
|
254 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform, ln_agprodII = ln_agprod, ln_agprod = ln_agprod_pricew_crops, ln_agprodIII = ln_tfp_geo)
|
255 |
+
|
256 |
+
count <-1
|
257 |
+
for (b in bws) {
|
258 |
+
# Estimate and Save RD for manual bws:
|
259 |
+
# Agricultural Productivity:
|
260 |
+
for (p in polys) {
|
261 |
+
# Scale:
|
262 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
263 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
264 |
+
c = 0,
|
265 |
+
p = p,
|
266 |
+
kernel = "tri",
|
267 |
+
h=b,
|
268 |
+
bwselect="mserd",
|
269 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
270 |
+
|
271 |
+
rd_estimates[count,c("ln_agprod_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
272 |
+
rd_estimates[count,c("ln_agprod_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod") # rdests$se[3]
|
273 |
+
|
274 |
+
# Scale:
|
275 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
276 |
+
x=censo_ag_wreform_tev$norm_dist,
|
277 |
+
c = 0,
|
278 |
+
p = p,
|
279 |
+
kernel = "tri",
|
280 |
+
h=b,
|
281 |
+
bwselect="mserd",
|
282 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
283 |
+
rd_estimates[count,c("ln_agprodII_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII")
|
284 |
+
rd_estimates[count,c("ln_agprodII_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodII") # rdests$se[3]
|
285 |
+
|
286 |
+
rd_estimates[count,c("bs")] <- b
|
287 |
+
rd_estimates[count,c("p")] <- p
|
288 |
+
|
289 |
+
# Scale:
|
290 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodIII),
|
291 |
+
x=censo_ag_wreform_tev$norm_dist,
|
292 |
+
c = 0,
|
293 |
+
p = p,
|
294 |
+
kernel = "tri",
|
295 |
+
h=b,
|
296 |
+
bwselect="mserd",
|
297 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA))
|
298 |
+
rd_estimates[count,c("ln_agprodIII_estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodIII")
|
299 |
+
rd_estimates[count,c("ln_agprodIII_ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprodIII") # rdests$se[3]
|
300 |
+
|
301 |
+
rd_estimates[count,c("bs")] <- b
|
302 |
+
rd_estimates[count,c("p")] <- p
|
303 |
+
|
304 |
+
count <- count + 1
|
305 |
+
}
|
306 |
+
}
|
307 |
+
rd_estimates
|
308 |
+
|
309 |
+
########################################
|
310 |
+
|
311 |
+
# Clean data for plotting:
|
312 |
+
alpha<- 0.05
|
313 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
314 |
+
|
315 |
+
# Find the outcome var for each regression:
|
316 |
+
data <- rd_estimates
|
317 |
+
data$y_var <- paste(" Bandwidth: ",data$bs, sep="")
|
318 |
+
|
319 |
+
# Now, keep only the betas of interest:
|
320 |
+
betas <- data
|
321 |
+
dim(betas)
|
322 |
+
|
323 |
+
# Create Matrix for plotting:
|
324 |
+
MatrixofModels <- betas[c("y_var", "ln_agprod_estimates","ln_agprod_ses","p")]
|
325 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
326 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
327 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
328 |
+
|
329 |
+
|
330 |
+
# Re-name for plotting:
|
331 |
+
MatrixofModels$ModelName <- "Revenue Per Hectare"
|
332 |
+
|
333 |
+
# Plot:
|
334 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
335 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
336 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
337 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
338 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
339 |
+
|
340 |
+
# Save:
|
341 |
+
OutputPlot + coord_flip() + coord_cartesian(ylim = c(-1, 1)) + scale_y_continuous(breaks = seq(-1, 1,0.2))
|
342 |
+
|
343 |
+
ggsave(filename="./Output/CoefPlot_AgProdI_BWRobustness.pdf", width=6, height=3)
|
344 |
+
|
345 |
+
# Create Matrix for plotting:
|
346 |
+
MatrixofModels <- betas[c("y_var", "ln_agprodII_estimates","ln_agprodII_ses","p")]
|
347 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
348 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
349 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
350 |
+
|
351 |
+
# Re-name for plotting:
|
352 |
+
MatrixofModels$ModelName <- "Profits Per Hectare"
|
353 |
+
|
354 |
+
# Plot:
|
355 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
356 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
357 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
358 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
359 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
360 |
+
|
361 |
+
# Save:
|
362 |
+
OutputPlot + coord_flip() + coord_cartesian(ylim = c(-1, 1)) + scale_y_continuous(breaks = seq(-1, 1,0.2))
|
363 |
+
|
364 |
+
ggsave(filename="./Output/CoefPlot_AgProdII_BWRobustness.pdf", width=6, height=3)
|
365 |
+
|
366 |
+
|
367 |
+
# Create Matrix for plotting:
|
368 |
+
MatrixofModels <- betas[c("y_var", "ln_agprodIII_estimates","ln_agprodIII_ses","p")]
|
369 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Polynomial")
|
370 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = unique(MatrixofModels$IV))
|
371 |
+
MatrixofModels$Polynomial <- factor(MatrixofModels$Polynomial,levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
372 |
+
|
373 |
+
# Re-name for plotting:
|
374 |
+
MatrixofModels$ModelName <- "Farm Productivity"
|
375 |
+
|
376 |
+
# Plot:
|
377 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
378 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
379 |
+
ylab = NULL, xlab = NULL, facets=~ Polynomial)
|
380 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
381 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
382 |
+
|
383 |
+
# Save:
|
384 |
+
OutputPlot + coord_flip() + coord_cartesian(ylim = c(-1, 1)) + scale_y_continuous(breaks = seq(-1, 1,0.2))
|
385 |
+
|
386 |
+
ggsave(filename="./Output/CoefPlot_AgProdIII_BWRobustness.pdf", width=6, height=3)
|
14/replication_package/Replication/Code/ESLR_LatAmMaps.R
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################################################
|
2 |
+
##### El Salvador - Land Reform - Map of Land Reforms Across LatAm #####
|
3 |
+
########################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(ggrepel) # labeling
|
26 |
+
|
27 |
+
########################################
|
28 |
+
|
29 |
+
# Approximate String Matching Funtion -- (amatch doesn't work that well for some reason)
|
30 |
+
|
31 |
+
string_match <- function(string_to_match, options, smethod="osa") {
|
32 |
+
if(string_to_match!="") {
|
33 |
+
sdists <- stringdist(string_to_match, options, method=smethod)
|
34 |
+
ind <- which(sdists == min(sdists))
|
35 |
+
if(length(ind) != 1) {
|
36 |
+
ind <- ind[1] # Assumes first index is the most common string to match.
|
37 |
+
}
|
38 |
+
return(options[ind])
|
39 |
+
} else {
|
40 |
+
return("")
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
as.numeric.factor <- function(x) {as.numeric(levels(x))[x]} # Function to turn factor vars to numeric variables correctly.
|
45 |
+
|
46 |
+
########################################
|
47 |
+
|
48 |
+
## Load LatAm Shapefile:
|
49 |
+
|
50 |
+
# Path:
|
51 |
+
latam_path <- "./Data/GIS_LatinAmerica/"
|
52 |
+
|
53 |
+
# Load Shapefile:
|
54 |
+
LatAm <- readOGR(latam_path, "LatinAmerica")
|
55 |
+
|
56 |
+
########################################
|
57 |
+
|
58 |
+
## Add in Change in Land Gini data from Albertus (2015):
|
59 |
+
LatAm$CHG_LAND_GINI <- 0
|
60 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Mexico"] <- -30.0
|
61 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="French Guiana"] <- 0.0
|
62 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Guyana"] <- 0.0
|
63 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Suriname"] <- 0.0
|
64 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Venezuela"] <- -5.0
|
65 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Argentina"] <- 2.5
|
66 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Bolivia"] <- -20.0
|
67 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Brazil"] <- 2.5
|
68 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Chile"] <- -10.0
|
69 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Ecuador"] <- -5.0
|
70 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Paraguay"] <- 5.0
|
71 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Peru"] <- -15.0
|
72 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Uruguay"] <- 0.0
|
73 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Guatemala"] <- 0.0
|
74 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Belize"] <- 0.0
|
75 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Colombia"] <- -5.0
|
76 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Costa Rica"] <- 0.0
|
77 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="El Salvador"] <- -10.0
|
78 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Honduras"] <- -5.0
|
79 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Nicaragua"] <- -25.0
|
80 |
+
LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Panama"] <- 5.0
|
81 |
+
|
82 |
+
########################################
|
83 |
+
|
84 |
+
## Add in land reform to cooperative indicator from Albertus (2015) and DeJanvry (1982):
|
85 |
+
LatAm$coop_land_reform <- 0
|
86 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Mexico"] <- 1
|
87 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="French Guiana"] <- 0.0
|
88 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Guyana"] <- 0.0
|
89 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Suriname"] <- 0.0
|
90 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Venezuela"] <- 1
|
91 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Argentina"] <- 0.0
|
92 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Bolivia"] <- 1
|
93 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Brazil"] <- 0
|
94 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Chile"] <- 1
|
95 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Ecuador"] <- 0
|
96 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Paraguay"] <- 0
|
97 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Peru"] <- 1
|
98 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Uruguay"] <- 0.0
|
99 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Guatemala"] <- 0.0
|
100 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Belize"] <- 0.0
|
101 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Colombia"] <- 1
|
102 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Costa Rica"] <- 1
|
103 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="El Salvador"] <- 1
|
104 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Honduras"] <- 1.0
|
105 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Nicaragua"] <- 1
|
106 |
+
LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Panama"] <- 1.0
|
107 |
+
|
108 |
+
|
109 |
+
########################################
|
110 |
+
|
111 |
+
## Plots!
|
112 |
+
|
113 |
+
# Set aesthetics:
|
114 |
+
aesthetics <- list(#guides(color=guide_colorbar(reverse=FALSE)),
|
115 |
+
#guides(fill=FALSE),
|
116 |
+
#guides(shape=FALSE),
|
117 |
+
#guides(size=FALSE),
|
118 |
+
coord_equal(),
|
119 |
+
theme_bw(),
|
120 |
+
theme(#legend.title=element_blank(),
|
121 |
+
#legend.justification=c(0,0),
|
122 |
+
#legend.position= "right", #c(1,0),
|
123 |
+
text=element_text(family="Palatino"),
|
124 |
+
panel.border = element_blank(),
|
125 |
+
panel.grid.minor=element_blank(),
|
126 |
+
panel.grid.major=element_blank(),
|
127 |
+
axis.title.x=element_blank(),
|
128 |
+
axis.title.y=element_blank(),
|
129 |
+
axis.text=element_blank(),
|
130 |
+
axis.ticks=element_blank()))
|
131 |
+
|
132 |
+
# Fortify for ggplot
|
133 |
+
LatAm.df <- fortify(LatAm, region="FIPS_CNTRY")
|
134 |
+
LatAm@data$id <- LatAm@data$FIPS_CNTRY
|
135 |
+
|
136 |
+
# Join Data:
|
137 |
+
LatAm.df <- join(LatAm.df, LatAm@data, by="id")
|
138 |
+
|
139 |
+
# Plot:
|
140 |
+
|
141 |
+
|
142 |
+
# Indicator for Land Reform that created Agricultural Coops w/ El Salvador Highlighted:
|
143 |
+
ES <- LatAm[LatAm$CNTRY_NAME=="El Salvador",]
|
144 |
+
ES@data <- mutate(ES@data, ES = ifelse(CNTRY_NAME=="El Salvador",1,0), ES2 = ifelse(FIPS_CNTRY=="ES",1,0))
|
145 |
+
# Fortify for ggplot
|
146 |
+
ES.df <- fortify(ES, region="FIPS_CNTRY")
|
147 |
+
ES@data$id <- ES@data$FIPS_CNTRY
|
148 |
+
|
149 |
+
# Join Data:
|
150 |
+
ES.df <- join(ES.df, ES@data, by="id")
|
151 |
+
|
152 |
+
LatAm.ggplot.reform <- geom_polygon(aes(x=long,y=lat, group=group, fill=(coop_land_reform)),data=LatAm.df,size=0.25,col="black")
|
153 |
+
|
154 |
+
pdf(file="./Output/LatAm_LRCoops.pdf", height=7, width=7, paper = "letter")
|
155 |
+
print(ggplot(aes(x=long,y=lat, group=group, fill=(coop_land_reform)),data=LatAm.df) + LatAm.ggplot.reform + coord_equal() + aesthetics
|
156 |
+
+ scale_fill_distiller(name="Experienced a Land Reform\nthat created Agricultural \nCooperatives, 1920-1990", palette = "Blues", trans = "reverse", breaks = pretty_breaks(n = 1), labels=c("No","Yes"),guide = guide_legend(reverse=TRUE))
|
157 |
+
+ labs(x="Longitude",y="Latitude"))
|
158 |
+
dev.off()
|
159 |
+
|
160 |
+
# w/Labels
|
161 |
+
EScentroid.df <- as.data.frame(coordinates(ES))
|
162 |
+
names(EScentroid.df) <- c("long", "lat")
|
163 |
+
EScentroid.df$CNTRY_NAME <- ES@data$CNTRY_NAME
|
164 |
+
ES.ggplot2 <- geom_polygon(aes(x=long,y=lat, group=group),data=ES.df,col="red",size=0.25, fill=NA,show.legend=FALSE)
|
165 |
+
|
166 |
+
pdf(file="./Output/LatAm_LRCoops_wESLabel2.pdf", height=7, width=7, paper = "letter")
|
167 |
+
print(ggplot()
|
168 |
+
+ geom_text_repel( data=EScentroid.df, aes(x=long, y=lat, label=CNTRY_NAME), col="red",size=4,nudge_x=-15, nudge_y=-5)
|
169 |
+
+ LatAm.ggplot.reform + coord_equal() + aesthetics
|
170 |
+
+ ES.ggplot2
|
171 |
+
+ scale_fill_distiller(name="Experienced a Land Reform\nthat created Agricultural\nCooperatives - 1920-1990", palette = "Blues", trans = "reverse", breaks = pretty_breaks(n = 1), labels=c("No","Yes"),guide = guide_legend(reverse=TRUE))
|
172 |
+
+ labs(x="Longitude",y="Latitude"))
|
173 |
+
dev.off()
|
174 |
+
|
14/replication_package/Replication/Code/ESLR_Master.do
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
************************
|
2 |
+
*** ESLR: Stata Code ***
|
3 |
+
************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color
|
10 |
+
|
11 |
+
** Set Workspace **
|
12 |
+
cd /Users/`c(username)'/Dropbox/Research_ElSalvador_LandReform/Replication
|
13 |
+
|
14 |
+
** ssc install rdrobust; winsor2; outreg2; outreg; estout; lpoly; cmogram; dm88_1; grqreg; gr0002_3; pdslasso; lassopack; univar; ietoolkit; rdlocrand; rdpower (net install rdpower, from(https://raw.githubusercontent.com/rdpackages/rdpower/master/stata) replace)
|
15 |
+
|
16 |
+
******************
|
17 |
+
*** MASTER DO FILE
|
18 |
+
******************
|
19 |
+
|
20 |
+
*** MAIN ***
|
21 |
+
|
22 |
+
** FIGURE 1: Land Reforms that Redistributed Haciendas as Cooperatives
|
23 |
+
* R Code: ./Code/ESLR_LatAmMaps.R
|
24 |
+
|
25 |
+
** FIGURE 2: Land Reform by Canton - El Salvador
|
26 |
+
* R Code: ./Code/ESLR_ESMap.R
|
27 |
+
|
28 |
+
** FIGURE 4: Estimates for Differences in Geography & FIGURE 3: McCrary Sorting Test
|
29 |
+
* R Code: ./Code/ESLR_Balance_PropLevel.R
|
30 |
+
|
31 |
+
** FIGURE 5: Phase I Expropriation RD Plot
|
32 |
+
do "./Code/ESLR_RDPlots_PropData.do"
|
33 |
+
|
34 |
+
** TABLES 2-4: Agriculture Choices and Productivity
|
35 |
+
do "./Code/ESLR_Analysis_IVCenso.do"
|
36 |
+
|
37 |
+
** TABLE 5 & FIGURE 6: Impact of Ownership Type on Earnings and Earnings Distributions
|
38 |
+
do "./Code/ESLR_Analysis_EHPM.do"
|
39 |
+
|
40 |
+
** TABLE 6: Credit Access and Sources - RD Estimates
|
41 |
+
do "./Code/ESLR_Analysis_IVCenso_Credit.do"
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
*** APPENDIX ***
|
50 |
+
|
51 |
+
** FIGURES D1-D2: RD Plots - Crop Choices & RD Plots - Agricultural Productivity
|
52 |
+
do "./Code/ESLR_RDPlots_AgCensus.do"
|
53 |
+
|
54 |
+
** FIGURE D3: RD Plots - Existence in 2007
|
55 |
+
do "./Code/ESLR_RDPlots_PropDataModern_Existence.do"
|
56 |
+
|
57 |
+
** FIGURE D4: Matching Estimates
|
58 |
+
* R Code: "./Code/ESLR_IVCensus_Matching.R"
|
59 |
+
|
60 |
+
** FIGURE D5: Sensitivity to Balance
|
61 |
+
* R Code: "./Code/ESLR_Unbalacedness.R"
|
62 |
+
|
63 |
+
** FIGURE D6: Temporal External Validity Exercise
|
64 |
+
* R Code: "./Code/ESLR_TemporalEV.R"
|
65 |
+
|
66 |
+
** TABLES D1-D2: Summary Statistics - Property Sizes in 1980 and Ownership Amounts & Summary Statistics - Property Sizes in 2007 and Ownership Amounts
|
67 |
+
do "./Code/ESLR_Prop_SummStats.do"
|
68 |
+
|
69 |
+
** FIGURE D7: Coefficient Estimates For Existence in 2007 - Heterogeneity by Geographic Characteristics
|
70 |
+
* R Code: ./Code/ESLR_Robustness_Existence.R
|
71 |
+
|
72 |
+
** TABLE D3 & FIGURE D8: Testing for Differences in the Distribution of Digits for Reported Crop Outputs & Testing for Differences in Bunching in Crop Output Across Ownership Types
|
73 |
+
* R Code: ./Code/ESLR_Digits.R
|
74 |
+
|
75 |
+
** FIGURE D9: Yield Results: Correcting for Possible Selection Bias
|
76 |
+
* R Code: "./Code/ESLR_YieldsSampleSelection.R"
|
77 |
+
|
78 |
+
** FIGURES D10-D13: Production of Minor Crops - Fruits & Production of Minor Crops - Vegetables & Capital Ownership & Input Use
|
79 |
+
do "./Code/ESLR_Analysis_IVCenso_Other.do"
|
80 |
+
* Then, R Code: ./Code/ESLR_IVCensus_AdditionalPlots.R
|
81 |
+
|
82 |
+
|
83 |
+
** FIGURE D14: RD Power Calculations - Revenues per Hectare
|
84 |
+
do "./Code/ESLR_IVCensus_Power.do"
|
85 |
+
|
86 |
+
** TABLE D4: Impact of Ownership Structure on Earnings Differences - Sensitivity to Land Value Return
|
87 |
+
do "./Code/ESLR_EHPM_Sensitivity.do"
|
88 |
+
|
89 |
+
** TABLE D5: Consumption and Consumption Distributions
|
90 |
+
do "./Code/ESLR_EHPM_Consumption.do"
|
91 |
+
|
92 |
+
** FIGURE D15: RD Plot - Share of Land Not Devoted to Staple or Cash Crops in 2007
|
93 |
+
do "./Code/ESLR_RDPlots_NonShares.do"
|
94 |
+
|
95 |
+
** TABLES D6-D7: Heterogeneity in a Cooperatives’ Census Neighborhoods
|
96 |
+
do "./Code/ESLR_AgHeterogeneity.do"
|
97 |
+
|
98 |
+
** FIGURES D16-D18: Controlling for Migration Rates – Main Outcomes & Main Results - Controlling for Property Size & Controlling for Conflict During the Civil War – Main Outcomes
|
99 |
+
* R Code: "./Code/ESLR_IVCensus_Controls.R"
|
100 |
+
|
101 |
+
** FIGURE D19: Heterogeneity by Number of Plots Owned By Previous Owner – Main Outcomes
|
102 |
+
* R Code: "./Code/ESLR_IVCensus_HetPlots.R"
|
103 |
+
|
104 |
+
** FIGURE D20: Crop Allocation - Haciendas Above vs. Below 500 ha Ownership Threshold
|
105 |
+
* R Code: "./Code/ESLR_IVCensus_NonComplierPlot.R"
|
106 |
+
|
107 |
+
** FIGURE E1: Public Good Access – Time to Nearest Public Good – Estimated Differences
|
108 |
+
do "./Code/ESLR_EHPM_PGs.do"
|
109 |
+
* Then, R Code: "./Code/ESLR_EHPM_PGsCoefPlot.R"
|
110 |
+
|
111 |
+
** FIGURE F1: Heterogeneity by Access to Cities – Main Outcomes
|
112 |
+
* R Code: "./Code/ESLR_IVCensus_HetPlots.R"
|
113 |
+
|
114 |
+
** TABLE F1: Commercialization Avenues - RD Estimates
|
115 |
+
do "./Code/ESLR_IVCenso_Commercialization.do"
|
116 |
+
|
117 |
+
** Figure F2: Controlling for Commercialization Avenues – Main Outcomes
|
118 |
+
* R Code: "./Code/ESLR_IVCensus_Controls.R"
|
119 |
+
|
120 |
+
** TABLES G1-G2: Impact of Ownership Type on Education Outcomes & Differences in Age and Household Size
|
121 |
+
do "./Code/ESLR_EHPM_Educ.do"
|
122 |
+
|
123 |
+
** TABLE H1: Migration Outcomes - Household Survey Data
|
124 |
+
do "./Code/ESLR_EHPM_Mig.do"
|
125 |
+
|
126 |
+
** TABLES H2-H3: Migration Outcomes - Population Census & H3: Migration Outcomes - Individuals that Completed High School - Population Census
|
127 |
+
* R Code: "./Code/ESLR_CensusMigration.R"
|
128 |
+
|
129 |
+
** TABLES I1-I2: Robustness to Alternative RD Method - Randomization Inference Approach
|
130 |
+
do "./Code/ESLR_IVCenso_RDRandInf.do"
|
131 |
+
|
132 |
+
** TABLES J1-I5: Robustness to Alternative RD Specifications
|
133 |
+
do "./Code/ESLR_IVCenso_RDRobustness.do"
|
134 |
+
|
135 |
+
** FIGURES J1-J6: Robustness to Alternative RD Specifications
|
136 |
+
* R Code: "./Code/ESLR_IVCensus_RDRobustnessPlots.R"
|
14/replication_package/Replication/Code/ESLR_Prop_SummStats.do
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*****************************************************
|
2 |
+
*** ESLR: LR Ag Outcomes - RD Analysis - Censo IV ***
|
3 |
+
*****************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
*********************
|
11 |
+
*** Load the Data ***
|
12 |
+
*********************
|
13 |
+
|
14 |
+
use "./Data/LR_reform_existence.dta", clear
|
15 |
+
|
16 |
+
gen Above500 = 0
|
17 |
+
replace Above500 = 1 if Total_Propretario2 >= 500.00
|
18 |
+
label var Above500 "Above 500 Ha"
|
19 |
+
gen norm_dist = Total_Propretario2 - 500.00
|
20 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
21 |
+
gen own_amt = Total_Propretario2
|
22 |
+
|
23 |
+
|
24 |
+
***********************************************
|
25 |
+
*** Make Summary Table - Property Ownership ***
|
26 |
+
***********************************************
|
27 |
+
|
28 |
+
** Gen Variabale for # properties with same ID;
|
29 |
+
egen num_props_owner = count(Total_Propretario2), by(Expropretario_ISTA)
|
30 |
+
replace num_props_owner=1 if num_props_owner==0
|
31 |
+
gen mult_prop = 0 if num_props_owner!=.
|
32 |
+
replace mult_prop = 1 if num_props_owner >1 & num_props_owner!=.
|
33 |
+
drop if num_props_owner==108
|
34 |
+
label var own_amt "Owner: Cumulative Holdings (ha)"
|
35 |
+
label var AREA_HECTAREA "Property Size (ha)"
|
36 |
+
label var mult_prop "Owner Owned Multiple Properties"
|
37 |
+
label var num_props_owner "Number of Properties Owned by Owner "
|
38 |
+
|
39 |
+
|
40 |
+
eststo clear
|
41 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner, detail
|
42 |
+
|
43 |
+
esttab using "Output/Table_Prop_SummStat.tex", replace ///
|
44 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
45 |
+
eststo clear
|
46 |
+
|
47 |
+
eststo clear
|
48 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner if Above500==0, detail
|
49 |
+
|
50 |
+
esttab using "Output/Table_Prop_SummStat_A5000.tex", replace ///
|
51 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
52 |
+
eststo clear
|
53 |
+
|
54 |
+
eststo clear
|
55 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner if Above500==1, detail
|
56 |
+
|
57 |
+
esttab using "Output/Table_Prop_SummStat_A5001.tex", replace ///
|
58 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
59 |
+
eststo clear
|
60 |
+
|
61 |
+
|
62 |
+
**************************
|
63 |
+
*** Load the 2007 Data ***
|
64 |
+
**************************
|
65 |
+
|
66 |
+
use "Data/censo_ag_wreform.dta", clear
|
67 |
+
|
68 |
+
|
69 |
+
***********************************************
|
70 |
+
*** Make Summary Table - Property Ownership ***
|
71 |
+
***********************************************
|
72 |
+
|
73 |
+
** Gen Variabale for # properties with same ID;
|
74 |
+
egen num_props_owner = count(Total_Propretario2), by(Expropretario_ISTA)
|
75 |
+
replace num_props_owner=1 if num_props_owner==0
|
76 |
+
gen mult_prop = 0 if num_props_owner!=.
|
77 |
+
replace mult_prop = 1 if num_props_owner >1 & num_props_owner!=.
|
78 |
+
drop if num_props_owner==108
|
79 |
+
|
80 |
+
label var own_amt "Owner: Cumulative Holdings (ha)"
|
81 |
+
label var AREA_HECTAREA "Property Size (ha)"
|
82 |
+
label var mult_prop "Owner Owned Multiple Properties"
|
83 |
+
label var num_props_owner "Number of Properties Owned by Owner "
|
84 |
+
|
85 |
+
|
86 |
+
eststo clear
|
87 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner, detail
|
88 |
+
|
89 |
+
esttab using "Output/Table_Prop_SummStat2007.tex", replace ///
|
90 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
91 |
+
eststo clear
|
92 |
+
|
93 |
+
eststo clear
|
94 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner if Above500==0, detail
|
95 |
+
|
96 |
+
esttab using "Output/Table_Prop_SummStat2007_A5000.tex", replace ///
|
97 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
98 |
+
eststo clear
|
99 |
+
|
100 |
+
eststo clear
|
101 |
+
eststo: quietly estpost summarize AREA_HECTAREA own_amt mult_prop num_props_owner if Above500==1, detail
|
102 |
+
|
103 |
+
esttab using "Output/Table_Prop_SummStat2007_A5001.tex", replace ///
|
104 |
+
cells("mean(fmt(2)) sd(fmt(2)) p50(fmt(2)) p25(fmt(2)) p75(fmt(2))") label booktab nonumber nomtitles
|
105 |
+
eststo clear
|
14/replication_package/Replication/Code/ESLR_RDPlots_AgCensus.do
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
***************************************************************
|
2 |
+
******* ESLR: RD Plot - Plot-Level Outcomes - Modern **********
|
3 |
+
***************************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color // Default Scheme
|
10 |
+
|
11 |
+
*********************
|
12 |
+
*** Load the Data ***
|
13 |
+
*********************
|
14 |
+
|
15 |
+
use "Data/censo_ag_wreform.dta", clear
|
16 |
+
|
17 |
+
**********************
|
18 |
+
*** Label the Data ***
|
19 |
+
**********************
|
20 |
+
|
21 |
+
** Label Variables for the output:
|
22 |
+
label variable ln_agprod_pricew_crops "Revenues per Hectare (ln($/ha))"
|
23 |
+
label variable ln_agprod "Profits per Hectare (ln($/ha))"
|
24 |
+
label variable ln_tfp_geo "Farm Productivity (ln(s))"
|
25 |
+
|
26 |
+
label variable CashCrop_Share "Share of Property for Cash Crops"
|
27 |
+
label variable StapleCrop_Share "Share of Property for Staple Crops"
|
28 |
+
label variable norm_dist "Distance to Reform Threshold (ha)"
|
29 |
+
label variable own_amt "Former Owner's Cumulative Landholdings (ha)"
|
30 |
+
|
31 |
+
******************
|
32 |
+
*** Set Params ***
|
33 |
+
******************
|
34 |
+
|
35 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
36 |
+
** with ses clustered at propietor level.
|
37 |
+
** Will also use two-sided MSE optimal bandwidth since big diff in density on
|
38 |
+
** both sides.
|
39 |
+
** Will use rdrobust package
|
40 |
+
|
41 |
+
local polynomial_level 1
|
42 |
+
local bandwidth_choice "mserd"
|
43 |
+
local kernel_choice "uni"
|
44 |
+
local kernel_choice_lpoly "rec"
|
45 |
+
|
46 |
+
local cluster_level Expropretario_ISTA
|
47 |
+
local lpoly_degree 1
|
48 |
+
|
49 |
+
******************************
|
50 |
+
*** MAKE A SET OF RD PLOTS ***
|
51 |
+
******************************
|
52 |
+
|
53 |
+
** Define outcome variables for the plot:
|
54 |
+
local dep_vars ln_agprod_pricew_crops ln_agprod ln_tfp_geo CashCrop_Share StapleCrop_Share
|
55 |
+
|
56 |
+
** define any controls:
|
57 |
+
|
58 |
+
** bin width:
|
59 |
+
local bin_widths 25 10
|
60 |
+
|
61 |
+
** Keep Variables of Interest:
|
62 |
+
keep `dep_vars' norm_dist Expropretario_ISTA own_amt
|
63 |
+
sort norm_dist
|
64 |
+
|
65 |
+
foreach y_var of varlist `dep_vars' {
|
66 |
+
|
67 |
+
foreach bin_width in `bin_widths' {
|
68 |
+
|
69 |
+
preserve
|
70 |
+
|
71 |
+
* Display Current Variable:
|
72 |
+
dis "`y_var'"
|
73 |
+
|
74 |
+
* Label Variables for Output Later On:
|
75 |
+
local ylabel : variable label `y_var'
|
76 |
+
local xlabel : variable label own_amt
|
77 |
+
|
78 |
+
** Find Optimal Bandwidth:
|
79 |
+
rdbwselect `y_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
80 |
+
local bw = `e(h_mserd)'
|
81 |
+
local xmin = 500 -`e(h_mserd)'
|
82 |
+
local xmax = 500 +`e(h_mserd)'
|
83 |
+
|
84 |
+
* Find Max and Min Vars for later on:
|
85 |
+
qui sum `y_var' if own_amt>= 500 - `e(h_mserd)' & own_amt <= 500 + `e(h_mserd)'
|
86 |
+
local ymax = `r(max)'
|
87 |
+
local ymin = `r(min)'
|
88 |
+
local ytick_space = (`ymax' - `ymin')/5
|
89 |
+
|
90 |
+
** Fit LPoly ** Using lpoly from Dell 2015: Distance to 500
|
91 |
+
tempfile tempdata
|
92 |
+
save `tempdata', replace
|
93 |
+
|
94 |
+
keep if (own_amt>500.00 & own_amt< 500 + `e(h_mserd)')
|
95 |
+
lpoly `y_var' own_amt, kernel(`kernel_choice_lpoly') bwidth(`bw') degree(`lpoly_degree') generate(x s) se(se) nograph cluster(`cluster_level') pwidth(`bw')
|
96 |
+
keep x s se
|
97 |
+
drop if x==.
|
98 |
+
save "Output/Temp/RD", replace
|
99 |
+
|
100 |
+
use `tempdata', clear
|
101 |
+
keep if (own_amt<500.00 & own_amt> 500 - `e(h_mserd)')
|
102 |
+
dis "(own_amt<500.00 & own_amt> 500 - `e(h_mserd)')"
|
103 |
+
lpoly `y_var' own_amt, kernel(`kernel_choice_lpoly') bwidth(`bw') degree(`lpoly_degree') generate(x s) se(se) nograph cluster(`cluster_level') pwidth(`bw')
|
104 |
+
keep x s se
|
105 |
+
drop if x==.
|
106 |
+
append using "Output/Temp/RD"
|
107 |
+
|
108 |
+
g ciplus=s+1.96*se
|
109 |
+
g ciminus=s-1.96*se
|
110 |
+
keep if x> 500 - `e(h_mserd)' & x < 500 + `e(h_mserd)'
|
111 |
+
save "Output/Temp/RD", replace
|
112 |
+
|
113 |
+
** Use the lpoly estimates to find means within beans
|
114 |
+
use `tempdata', replace
|
115 |
+
keep if abs(norm_dist)<`bw'
|
116 |
+
|
117 |
+
gen bin5=.
|
118 |
+
foreach X of num 0(`bin_width')`bw' {
|
119 |
+
di "`X'"
|
120 |
+
replace bin=-`X' if (own_amt - 500.00 >=-`X' & own_amt-500.00<(-`X'+`bin_width') & own_amt-500.00<0)
|
121 |
+
replace bin=`X' if (own_amt -500.00>`X' & own_amt-500.00<=(`X'+`bin_width'))
|
122 |
+
}
|
123 |
+
tab bin5
|
124 |
+
|
125 |
+
drop if bin5==.
|
126 |
+
collapse `y_var' own_amt, by(bin5)
|
127 |
+
|
128 |
+
append using "Output/Temp/RD"
|
129 |
+
|
130 |
+
** Plot and Save Output:
|
131 |
+
local xmin = round(`xmin'-5.1,10)
|
132 |
+
local xmax = round(`xmax'+5.1,10)
|
133 |
+
local ymin = round(`ymin')
|
134 |
+
local ymax = round(`ymax')
|
135 |
+
dis "`ymin'(`ytick_space')`ymax'"
|
136 |
+
dis "YyMIN::: `ymin' AND YMAX: `ymax'; PLOT: yscale(r(`ymin' `ymax')) "
|
137 |
+
dis "xmin::: `xmin' AND YMAX: `ymax'; PLOT: yscale(r(`ymin' `ymax')) "
|
138 |
+
|
139 |
+
if("`y_var'" == "CashCrop_Share" | "`y_var'" == "StapleCrop_Share") {
|
140 |
+
|
141 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
142 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
143 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
144 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
145 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
146 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
147 |
+
*/ (scatter `y_var' own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
148 |
+
*/ legend(off) graphregion(color(white)) yscale(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax') /*
|
149 |
+
*/ ytitle("`ylabel'") xtitle("`xlabel'") /* xlabel(`xmin'(50)`xmax') ysc(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax') xsc(r(`xmin' `xmax'))
|
150 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
151 |
+
*/ saving("Output/RDPlot_`y_var'_`bin_width'.pdf",replace)
|
152 |
+
graph export "Output/RDPlot_`y_var'_`bin_width'.pdf", replace
|
153 |
+
|
154 |
+
}
|
155 |
+
else {
|
156 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
157 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
158 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
159 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
160 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
161 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
162 |
+
*/ (scatter `y_var' own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
163 |
+
*/ legend(off) graphregion(color(white)) /*
|
164 |
+
*/ ytitle("`ylabel'") xtitle("`xlabel'") xlabel(`xmin'(50)`xmax') xsc(range(`xmin'(50)`xmax')) /* xsc(r(`xmin' `xmax')) ysc(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax')
|
165 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
166 |
+
*/ saving("Output/RDPlot_`y_var'_`bin_width'.pdf",replace)
|
167 |
+
graph export "Output/RDPlot_`y_var'_`bin_width'.pdf", replace
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
restore
|
172 |
+
|
173 |
+
}
|
174 |
+
}
|
14/replication_package/Replication/Code/ESLR_RDPlots_NonShares.do
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
***************************************************************
|
2 |
+
******* ESLR: RD Plot - Plot-Level Outcomes - Modern **********
|
3 |
+
***************************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color // Default Scheme
|
10 |
+
|
11 |
+
*********************
|
12 |
+
*** Load the Data ***
|
13 |
+
*********************
|
14 |
+
|
15 |
+
use "Data/censo_ag_wreform.dta", clear
|
16 |
+
|
17 |
+
**********************
|
18 |
+
*** Label the Data ***
|
19 |
+
**********************
|
20 |
+
|
21 |
+
** Label Variables for the output:
|
22 |
+
label variable ln_agprod_pricew_crops "Revenues per Hectare (ln($/ha))"
|
23 |
+
label variable ln_agprod "Profits per Hectare (ln($/ha))"
|
24 |
+
label variable ln_tfp_geo "Farm Productivity (ln(s))"
|
25 |
+
|
26 |
+
label variable CashCrop_Share "Share of Property for Cash Crops"
|
27 |
+
label variable StapleCrop_Share "Share of Property for Staple Crops"
|
28 |
+
label variable norm_dist "Distance to Reform Threshold (ha)"
|
29 |
+
label variable own_amt "Former Owner's Cumulative Landholdings (ha)"
|
30 |
+
|
31 |
+
|
32 |
+
gen Share_Non_MainCrops = 1 - (Maize_Share + Beans_Share+ Coffee_Share + SugarCane_Share)
|
33 |
+
replace Share_Non_MainCrops = 0 if Share_Non_MainCrops < 0
|
34 |
+
label variable Share_Non_MainCrops "Share of Property for Neither Cash nor Staple Crops"
|
35 |
+
|
36 |
+
|
37 |
+
******************
|
38 |
+
*** Set Params ***
|
39 |
+
******************
|
40 |
+
|
41 |
+
** Baseline: Will use local linear rd with MSE optimal bandwidth
|
42 |
+
** with ses clustered at propietor level.
|
43 |
+
** Will also use two-sided MSE optimal bandwidth since big diff in density on
|
44 |
+
** both sides.
|
45 |
+
** Will use rdrobust package
|
46 |
+
|
47 |
+
local polynomial_level 1
|
48 |
+
local bandwidth_choice "mserd"
|
49 |
+
local kernel_choice "uni"
|
50 |
+
local kernel_choice_lpoly "rec"
|
51 |
+
|
52 |
+
local cluster_level Expropretario_ISTA
|
53 |
+
local lpoly_degree 1
|
54 |
+
|
55 |
+
******************************
|
56 |
+
*** MAKE A SET OF RD PLOTS ***
|
57 |
+
******************************
|
58 |
+
|
59 |
+
** Define outcome variables for the plot:
|
60 |
+
local dep_vars Share_Non_MainCrops
|
61 |
+
|
62 |
+
** define any controls:
|
63 |
+
|
64 |
+
** bin width:
|
65 |
+
local bin_widths 10
|
66 |
+
|
67 |
+
** Keep Variables of Interest:
|
68 |
+
keep `dep_vars' norm_dist Expropretario_ISTA own_amt
|
69 |
+
sort norm_dist
|
70 |
+
|
71 |
+
foreach y_var of varlist `dep_vars' {
|
72 |
+
|
73 |
+
foreach bin_width in `bin_widths' {
|
74 |
+
|
75 |
+
preserve
|
76 |
+
|
77 |
+
* Display Current Variable:
|
78 |
+
dis "`y_var'"
|
79 |
+
|
80 |
+
* Label Variables for Output Later On:
|
81 |
+
local ylabel : variable label `y_var'
|
82 |
+
local xlabel : variable label own_amt
|
83 |
+
|
84 |
+
** Find Optimal Bandwidth:
|
85 |
+
rdbwselect `y_var' norm_dist, c(0) p(`polynomial_level') bwselect(`bandwidth_choice') kernel(`kernel_choice') vce(cluster `cluster_level')
|
86 |
+
local bw = `e(h_mserd)'
|
87 |
+
local xmin = 500 -`e(h_mserd)'
|
88 |
+
local xmax = 500 +`e(h_mserd)'
|
89 |
+
|
90 |
+
* Find Max and Min Vars for later on:
|
91 |
+
qui sum `y_var' if own_amt>= 500 - `e(h_mserd)' & own_amt <= 500 + `e(h_mserd)'
|
92 |
+
local ymax = `r(max)'
|
93 |
+
local ymin = `r(min)'
|
94 |
+
local ytick_space = (`ymax' - `ymin')/5
|
95 |
+
|
96 |
+
** Fit LPoly ** Using lpoly from Dell 2015: Distance to 500
|
97 |
+
tempfile tempdata
|
98 |
+
save `tempdata', replace
|
99 |
+
|
100 |
+
keep if (own_amt>500.00 & own_amt< 500 + `e(h_mserd)')
|
101 |
+
lpoly `y_var' own_amt, kernel(`kernel_choice_lpoly') bwidth(`bw') degree(`lpoly_degree') generate(x s) se(se) nograph cluster(`cluster_level') pwidth(`bw')
|
102 |
+
keep x s se
|
103 |
+
drop if x==.
|
104 |
+
save "Output/Temp/RD", replace
|
105 |
+
|
106 |
+
use `tempdata', clear
|
107 |
+
keep if (own_amt<500.00 & own_amt> 500 - `e(h_mserd)')
|
108 |
+
dis "(own_amt<500.00 & own_amt> 500 - `e(h_mserd)')"
|
109 |
+
lpoly `y_var' own_amt, kernel(`kernel_choice_lpoly') bwidth(`bw') degree(`lpoly_degree') generate(x s) se(se) nograph cluster(`cluster_level') pwidth(`bw')
|
110 |
+
keep x s se
|
111 |
+
drop if x==.
|
112 |
+
append using "Output/Temp/RD"
|
113 |
+
|
114 |
+
g ciplus=s+1.96*se
|
115 |
+
g ciminus=s-1.96*se
|
116 |
+
keep if x> 500 - `e(h_mserd)' & x < 500 + `e(h_mserd)'
|
117 |
+
save "Output/Temp/RD", replace
|
118 |
+
|
119 |
+
** Use the lpoly estimates to find means within beans
|
120 |
+
use `tempdata', replace
|
121 |
+
keep if abs(norm_dist)<`bw'
|
122 |
+
|
123 |
+
gen bin5=.
|
124 |
+
foreach X of num 0(`bin_width')`bw' {
|
125 |
+
di "`X'"
|
126 |
+
replace bin=-`X' if (own_amt - 500.00 >=-`X' & own_amt-500.00<(-`X'+`bin_width') & own_amt-500.00<0)
|
127 |
+
replace bin=`X' if (own_amt -500.00>`X' & own_amt-500.00<=(`X'+`bin_width'))
|
128 |
+
}
|
129 |
+
tab bin5
|
130 |
+
|
131 |
+
drop if bin5==.
|
132 |
+
collapse `y_var' own_amt, by(bin5)
|
133 |
+
|
134 |
+
append using "Output/Temp/RD"
|
135 |
+
|
136 |
+
** Plot and Save Output:
|
137 |
+
local xmin = round(`xmin'-5.1,10)
|
138 |
+
local xmax = round(`xmax'+5.1,10)
|
139 |
+
local ymin = round(`ymin')
|
140 |
+
local ymax = round(`ymax')
|
141 |
+
dis "`ymin'(`ytick_space')`ymax'"
|
142 |
+
dis "YyMIN::: `ymin' AND YMAX: `ymax'; PLOT: yscale(r(`ymin' `ymax')) "
|
143 |
+
dis "xmin::: `xmin' AND YMAX: `ymax'; PLOT: yscale(r(`ymin' `ymax')) "
|
144 |
+
|
145 |
+
if("`y_var'" == "CashCrop_Share" | "`y_var'" == "StapleCrop_Share") {
|
146 |
+
|
147 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
148 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
149 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
150 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
151 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
152 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
153 |
+
*/ (scatter `y_var' own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
154 |
+
*/ legend(off) graphregion(color(white)) yscale(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax') /*
|
155 |
+
*/ ytitle("`ylabel'") xtitle("`xlabel'") /* xlabel(`xmin'(50)`xmax') ysc(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax') xsc(r(`xmin' `xmax'))
|
156 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
157 |
+
*/ saving("Output/RDPlot_`y_var'_`bin_width'.pdf",replace)
|
158 |
+
graph export "Output/RDPlot_`y_var'_`bin_width'.pdf", replace
|
159 |
+
|
160 |
+
}
|
161 |
+
else {
|
162 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
163 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
164 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
165 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
166 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
167 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
168 |
+
*/ (scatter `y_var' own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
169 |
+
*/ legend(off) graphregion(color(white)) /*
|
170 |
+
*/ ytitle("`ylabel'") xtitle("`xlabel'") xlabel(`xmin'(50)`xmax') xsc(range(`xmin'(50)`xmax')) /* xsc(r(`xmin' `xmax')) ysc(r(`ymin' `ymax')) ylabel(`ymin'(`ytick_space')`ymax')
|
171 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
172 |
+
*/ saving("Output/RDPlot_`y_var'_`bin_width'.pdf",replace)
|
173 |
+
graph export "Output/RDPlot_`y_var'_`bin_width'.pdf", replace
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
restore
|
178 |
+
|
179 |
+
}
|
180 |
+
}
|
14/replication_package/Replication/Code/ESLR_RDPlots_PropData.do
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
******************************************************
|
2 |
+
******* ESLR: RD Plot - Plot-Level Outcomes **********
|
3 |
+
******************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
|
10 |
+
** Set Workspace **
|
11 |
+
cd /Users/eduardomontero/Dropbox/Research_ElSalvador_LandReform/Replication
|
12 |
+
|
13 |
+
******************************************************
|
14 |
+
|
15 |
+
** Load the Data:
|
16 |
+
use "Data/prop_data.dta", clear
|
17 |
+
|
18 |
+
gen Above500 = 0
|
19 |
+
replace Above500 = 1 if Total_Propretario >= 500.00
|
20 |
+
label var Above500 "Above 500 Ha"
|
21 |
+
gen norm_dist = Total_Propretario - 500.00
|
22 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
23 |
+
gen own_amt = Total_Propretario
|
24 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
25 |
+
|
26 |
+
|
27 |
+
******************************************************
|
28 |
+
|
29 |
+
** Using lpoly from Dell 2015: Distance to 500
|
30 |
+
|
31 |
+
keep if norm_dist<300.00 & norm_dist> -300.00
|
32 |
+
sort norm_dist
|
33 |
+
|
34 |
+
tempfile tempdata
|
35 |
+
save `tempdata', replace
|
36 |
+
|
37 |
+
keep if (own_amt>500.00 & own_amt<800.00)
|
38 |
+
lpoly reform own_amt if (own_amt>500.00 & own_amt<800.00), kernel(rectangle) bwidth(300) degree(2) generate(x s) se(se) nograph
|
39 |
+
keep x s se
|
40 |
+
drop if x==.
|
41 |
+
save "Output/Temp/RD", replace
|
42 |
+
|
43 |
+
use `tempdata', clear
|
44 |
+
keep if (own_amt<500.00 & own_amt>200.00)
|
45 |
+
lpoly reform own_amt if (own_amt<500.00 & own_amt>200.00), kernel(rectangle) bwidth(300) degree(2) generate(x s) se(se) nograph
|
46 |
+
keep x s se
|
47 |
+
drop if x==.
|
48 |
+
append using "Output/Temp/RD"
|
49 |
+
|
50 |
+
g ciplus=s+1.96*se
|
51 |
+
g ciminus=s-1.96*se
|
52 |
+
keep if x>200.00 & x<800.00
|
53 |
+
save "Output/Temp/RD", replace
|
54 |
+
|
55 |
+
|
56 |
+
*---generate bins for taking averages---*
|
57 |
+
|
58 |
+
use `tempdata', replace
|
59 |
+
keep if abs(norm_dist)<300.00
|
60 |
+
|
61 |
+
gen bin5=.
|
62 |
+
foreach X of num 0(25.00)300.00 {
|
63 |
+
di "`X'"
|
64 |
+
replace bin=-`X' if (own_amt - 500.00 >=-`X' & own_amt-500.00<(-`X'+25.00) & own_amt-500.00<0)
|
65 |
+
replace bin=`X' if (own_amt -500.00>`X' & own_amt-500.00<=(`X'+25.00))
|
66 |
+
}
|
67 |
+
tab bin5
|
68 |
+
|
69 |
+
drop if bin5==.
|
70 |
+
collapse reform own_amt, by(bin5)
|
71 |
+
|
72 |
+
append using "Output/Temp/RD"
|
73 |
+
|
74 |
+
|
75 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
76 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
77 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
78 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
79 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
80 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
81 |
+
*/ (scatter reform own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
82 |
+
*/ legend(off) graphregion(color(white)) /*
|
83 |
+
*/ ytitle("Expropriated") xtitle("Cumulative Landholdings (ha)") xlabel(200(100)800) xsc(r(200.00 800.00)) ylabel(0(.2)1) ysc(r(0 1)) /*
|
84 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
85 |
+
*/ saving("./Output/RDPlot_ReformFS_Dist_300_3.pdf",replace)
|
86 |
+
graph export "./Output/RDPlot_ReformFS_Dist_300_3.pdf", replace
|
87 |
+
|
14/replication_package/Replication/Code/ESLR_RDPlots_PropDataModern_Existence.do
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
***************************************************************
|
2 |
+
******* ESLR: RD Plot - Plot-Level Outcomes - Modern **********
|
3 |
+
***************************************************************
|
4 |
+
|
5 |
+
capture log close
|
6 |
+
clear
|
7 |
+
set matsize 3000
|
8 |
+
set more off
|
9 |
+
set scheme s2color // Default Scheme
|
10 |
+
|
11 |
+
***************************************************************
|
12 |
+
|
13 |
+
** Load the Data on Prop. in 1980 and whether they appear in the 2007 Census:
|
14 |
+
use "./Data/LR_reform_existence.dta", clear
|
15 |
+
|
16 |
+
gen norm_dist = Total_Propretario2 - 500.00
|
17 |
+
gen own_amt = Total_Propretario2
|
18 |
+
|
19 |
+
label var norm_dist "Normalized Distance to Reform Threshold (has)"
|
20 |
+
label var own_amt "Cumulative Landholdings of Former Owner (has)"
|
21 |
+
label var Exists "Exists in 2007"
|
22 |
+
|
23 |
+
***************************************************************
|
24 |
+
|
25 |
+
** Using lpoly from Dell 2015: Distance to 500
|
26 |
+
|
27 |
+
keep Exists own_amt norm_dist
|
28 |
+
keep if norm_dist<300.00 & norm_dist> -300.00
|
29 |
+
sort norm_dist
|
30 |
+
|
31 |
+
tempfile tempdata
|
32 |
+
save `tempdata', replace
|
33 |
+
|
34 |
+
** Dep Var: Exists; Bandwidth=300; Degree=1
|
35 |
+
use `tempdata', clear
|
36 |
+
keep if (own_amt>500.00 & own_amt<800.00)
|
37 |
+
lpoly Exists own_amt if (own_amt>500.00 & own_amt<800.00), kernel(rectangle) bwidth(300) degree(1) generate(x s) se(se) nograph pwidth(150)
|
38 |
+
keep x s se
|
39 |
+
drop if x==.
|
40 |
+
save "Output/Temp/RD", replace
|
41 |
+
|
42 |
+
use `tempdata', clear
|
43 |
+
keep if (own_amt<500.00 & own_amt>200.00)
|
44 |
+
lpoly Exists own_amt if (own_amt<500.00 & own_amt>200.00), kernel(rectangle) bwidth(300) degree(1) generate(x s) se(se) nograph pwidth(150)
|
45 |
+
keep x s se
|
46 |
+
drop if x==.
|
47 |
+
append using "Output/Temp/RD"
|
48 |
+
|
49 |
+
g ciplus=s+1.96*se
|
50 |
+
g ciminus=s-1.96*se
|
51 |
+
keep if x>200.00 & x<800.00
|
52 |
+
save "Output/Temp/RD", replace
|
53 |
+
|
54 |
+
|
55 |
+
*---generate bins for taking averages---*
|
56 |
+
|
57 |
+
use `tempdata', replace
|
58 |
+
keep if abs(norm_dist)<300.00
|
59 |
+
|
60 |
+
gen bin5=.
|
61 |
+
foreach X of num 0(25.00)300.00 {
|
62 |
+
di "`X'"
|
63 |
+
replace bin=-`X' if (own_amt - 500.00 >=-`X' & own_amt-500.00<(-`X'+25.00) & own_amt-500.00<0)
|
64 |
+
replace bin=`X' if (own_amt -500.00>`X' & own_amt-500.00<=(`X'+25.00))
|
65 |
+
}
|
66 |
+
tab bin5
|
67 |
+
|
68 |
+
drop if bin5==.
|
69 |
+
collapse Exists own_amt, by(bin5)
|
70 |
+
|
71 |
+
append using "Output/Temp/RD"
|
72 |
+
|
73 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
74 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
75 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
76 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
77 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
78 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
79 |
+
*/ (scatter Exists own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
80 |
+
*/ legend(off) graphregion(color(white)) /*
|
81 |
+
*/ ytitle("Exists in 2007") xtitle("Distance to Reform Threshold (ha)") xlabel(200(100)800) xsc(r(200.00 800.00)) ylabel(0(.2)1) ysc(r(0 1)) /*
|
82 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
83 |
+
*/ saving("Output/RDPlot_exists_300.pdf",replace)
|
84 |
+
graph export "Output/RDPlot_exists_300.pdf", replace
|
85 |
+
|
86 |
+
***************************************************************
|
87 |
+
|
88 |
+
** Using lpoly from Dell 2015: Distance to 500
|
89 |
+
|
90 |
+
** Dep Var: Exists; Bandwidth=150; Degree=1
|
91 |
+
use `tempdata', clear
|
92 |
+
keep if (own_amt>500.00 & own_amt<650.00)
|
93 |
+
lpoly Exists own_amt if (own_amt>500.00 & own_amt<650.00), kernel(rectangle) bwidth(150) degree(1) generate(x s) se(se) nograph pwidth(150)
|
94 |
+
keep x s se
|
95 |
+
drop if x==.
|
96 |
+
save "Output/Temp/RD", replace
|
97 |
+
|
98 |
+
use `tempdata', clear
|
99 |
+
keep if (own_amt<500.00 & own_amt>350.00)
|
100 |
+
lpoly Exists own_amt if (own_amt<500.00 & own_amt>350.00), kernel(rectangle) bwidth(150) degree(1) generate(x s) se(se) nograph pwidth(150)
|
101 |
+
keep x s se
|
102 |
+
drop if x==.
|
103 |
+
append using "Output/Temp/RD"
|
104 |
+
|
105 |
+
g ciplus=s+1.96*se
|
106 |
+
g ciminus=s-1.96*se
|
107 |
+
keep if x>350.00 & x<650.00
|
108 |
+
save "Output/Temp/RD", replace
|
109 |
+
|
110 |
+
|
111 |
+
*---generate bins for taking averages---*
|
112 |
+
|
113 |
+
use `tempdata', replace
|
114 |
+
keep if abs(norm_dist)<150.00
|
115 |
+
|
116 |
+
gen bin5=.
|
117 |
+
foreach X of num 0(25.00)150.00 {
|
118 |
+
di "`X'"
|
119 |
+
replace bin=-`X' if (own_amt - 500.00 >=-`X' & own_amt-500.00<(-`X'+25.00) & own_amt-500.00<0)
|
120 |
+
replace bin=`X' if (own_amt -500.00>`X' & own_amt-500.00<=(`X'+25.00))
|
121 |
+
}
|
122 |
+
tab bin5
|
123 |
+
|
124 |
+
drop if bin5==.
|
125 |
+
collapse Exists own_amt, by(bin5)
|
126 |
+
|
127 |
+
append using "Output/Temp/RD"
|
128 |
+
|
129 |
+
twoway (connected s x if x>500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
130 |
+
*/(connected ciplus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
131 |
+
*/(connected ciminus x if x>500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
132 |
+
*/(connected s x if x<500.00, sort msymbol(none) clcolor(black) clpat(solid) clwidth(medthick)) /*
|
133 |
+
*/(connected ciplus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
134 |
+
*/(connected ciminus x if x<500.00, sort msymbol(none) clcolor(black) clpat(shortdash) clwidth(thin)) /*
|
135 |
+
*/ (scatter Exists own_amt, sort msize(med)xline(500) mcolor(black)), /*
|
136 |
+
*/ legend(off) graphregion(color(white)) /*
|
137 |
+
*/ ytitle("Exists in 2007") xtitle("Distance to Reform Threshold (ha)") xlabel(350(100)650) xsc(r(350.00 650.00)) ylabel(0(.2)1) ysc(r(0 1)) /*
|
138 |
+
*/xline(500.00, lpattern(shortdash) lc(black)) ylab(,nogrid) /*
|
139 |
+
*/ saving("Output/RDPlot_exists_150.pdf",replace)
|
140 |
+
graph export "Output/RDPlot_exists_150.pdf", replace
|
141 |
+
|
142 |
+
|
14/replication_package/Replication/Code/ESLR_RScripts.R
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
##################################################################
|
2 |
+
#### El Salvador - Land Reform - Prop Level Geographical Covs ####
|
3 |
+
##################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
|
8 |
+
require(foreign)
|
9 |
+
require(ggplot2)
|
10 |
+
require(rgdal)
|
11 |
+
require(rgeos)
|
12 |
+
require(RColorBrewer) # creates nice color schemes
|
13 |
+
require(maptools) # loads sp library too
|
14 |
+
require(scales) # customize scales
|
15 |
+
require(gridExtra) # mutiple plots
|
16 |
+
require(plyr) # join function
|
17 |
+
require(dplyr)
|
18 |
+
require(mapproj) # projection tools
|
19 |
+
require(raster) # raster tools
|
20 |
+
require(tidyr)
|
21 |
+
require(readstata13)
|
22 |
+
require(haven)
|
23 |
+
require(gstat) # interpolation tools
|
24 |
+
require(ncdf4)
|
25 |
+
require(Hmisc)
|
26 |
+
require(lubridate)
|
27 |
+
library(lmtest)
|
28 |
+
library(sandwich)
|
29 |
+
library(dotwhisker) # coef plots
|
30 |
+
library(broom)
|
31 |
+
require(stringr)
|
32 |
+
require(readxl)
|
33 |
+
require(rmapshaper)
|
34 |
+
require(extrafont)
|
35 |
+
require(ggmap)
|
36 |
+
require(rdrobust)
|
37 |
+
require(stringdist)
|
38 |
+
require(benford.analysis) # Tests for data manipulation
|
39 |
+
require(sampleSelection)
|
40 |
+
require(exactextractr) # faster extract
|
41 |
+
require(sf) # faster extract
|
42 |
+
require(elevatr) # elevation data
|
43 |
+
require(stringi)
|
44 |
+
|
45 |
+
## SET WORKING DIRECTORY:
|
46 |
+
path <- "/Users/eduardomontero/Dropbox/Research_ElSalvador_LandReform/Replication/"
|
47 |
+
setwd(path)
|
48 |
+
|
49 |
+
############################
|
50 |
+
|
51 |
+
### R SCRIPTS:
|
52 |
+
|
53 |
+
|
54 |
+
### MAIN ###
|
55 |
+
|
56 |
+
## FIGURE 1: Land Reforms that Redistributed Haciendas as Cooperatives
|
57 |
+
source("./Code/ESLR_LatAmMaps.R")
|
58 |
+
|
59 |
+
## FIGURE 2: Land Reform by Canton - El Salvador
|
60 |
+
source("./Code/ESLR_ESMap.R")
|
61 |
+
|
62 |
+
## FIGURE 4: Estimates for Differences in Geography & FIGURE 3: McCrary Sorting Test
|
63 |
+
source("./Code/ESLR_Balance_PropLevel.R")
|
64 |
+
|
65 |
+
|
66 |
+
### RUN STATA CODE: Code/ESLR_Master.do ####
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
### APPENDIX ###
|
71 |
+
|
72 |
+
## FIGURE D4: Matching Estimates
|
73 |
+
source("./Code/ESLR_IVCensus_Matching.R")
|
74 |
+
|
75 |
+
## FIGURE D5: Sensitivity to Balance
|
76 |
+
source("./Code/ESLR_Unbalancedness.R")
|
77 |
+
|
78 |
+
## FIGURE D6: Temporal External Validity Exercise - Agricultural Productivity
|
79 |
+
source("./Code/ESLR_TemporalEV.R")
|
80 |
+
|
81 |
+
## FIGURE D7: Coefficient Estimates For Existence in 2007 - Heterogeneity by Geographic Characteristics
|
82 |
+
source("./Code/ESLR_Robustness_Existence.R")
|
83 |
+
|
84 |
+
## TABLE D3 & FIGURE D8: Testing for Differences in the Distribution of Digits for Reported Crop Outputs & Testing for Differences in Bunching in Crop Output Across Ownership Types
|
85 |
+
source("./Code/ESLR_Digits.R")
|
86 |
+
|
87 |
+
## FIGURE D9: Yield Results: Correcting for Possible Selection Bias
|
88 |
+
source("./Code/ESLR_YieldsSampleSelection.R")
|
89 |
+
|
90 |
+
## FIGURE D10-D13: Production of Minor Crops - Fruits & Production of Minor Crops - Vegetables & Capital Ownership & Input Use
|
91 |
+
source("./Code/ESLR_IVCensus_AdditionalPlots.R")
|
92 |
+
|
93 |
+
## FIGURE D16-D18: Controlling for Migration Rates – Main Outcomes & Main Results - Controlling for Property Size & Controlling for Conflict During the Civil War – Main Outcomes
|
94 |
+
source("./Code/ESLR_IVCensus_Controls.R")
|
95 |
+
|
96 |
+
## FIGURE D19: Heterogeneity by Number of Plots Owned By Previous Owner – Main Outcomes
|
97 |
+
source("./Code/ESLR_IVCensus_HetPlots.R")
|
98 |
+
|
99 |
+
## FIGURE D20: Crop Allocation - Haciendas Above vs. Below 500 ha Ownership Threshold
|
100 |
+
source("./Code/ESLR_IVCensus_NonComplierPlot.R")
|
101 |
+
|
102 |
+
## FIGURE E1: Public Good Access – Time to Nearest Public Good – Estimated Differences
|
103 |
+
source("./Code/ESLR_EHPM_PGsCoefPlot.R")
|
104 |
+
|
105 |
+
## FIGURE F1: Heterogeneity by Access to Cities – Main Outcomes
|
106 |
+
source("./Code/ESLR_IVCensus_HetPlots.R")
|
107 |
+
|
108 |
+
## Figure F2: Controlling for Commercialization Avenues – Main Outcomes
|
109 |
+
source("./Code/ESLR_IVCensus_Controls.R")
|
110 |
+
|
111 |
+
## FIGURE J1-J6: Robustness to Alternative RD Specifications
|
112 |
+
source("./Code/ESLR_IVCensus_RDRobustnessPlots.R")
|
113 |
+
|
114 |
+
|
115 |
+
|
14/replication_package/Replication/Code/ESLR_Robustness_Existence.R
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
######################################################################
|
2 |
+
##### El Salvador - Land Reform - Cleaning IV Censo Agropecuario #####
|
3 |
+
######################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(estimatr) # removing accents
|
26 |
+
|
27 |
+
########################################
|
28 |
+
|
29 |
+
as.numeric.factor <- function(x) {as.numeric(levels(x))[x]} # Function to turn factor vars to numeric variables correctly.
|
30 |
+
|
31 |
+
winsor <- function (x, fraction=.01)
|
32 |
+
{
|
33 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
34 |
+
fraction > 0.5) {
|
35 |
+
stop("bad value for 'fraction'")
|
36 |
+
}
|
37 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
38 |
+
x[ x < lim[1] ] <- lim[1] #lim[1] 8888
|
39 |
+
x[ x > lim[2] ] <- lim[2] #lim[2] 8888
|
40 |
+
x
|
41 |
+
}
|
42 |
+
########################################
|
43 |
+
|
44 |
+
## Load Prop Existence Data (with reform data):
|
45 |
+
existence <- read_dta("./Data/LR_reform_existence.dta")
|
46 |
+
|
47 |
+
## Load + Prep Canton-Level Covariates
|
48 |
+
# To Check whether there is heterogeneity in existence by covariate*coop:
|
49 |
+
canton_covs <- read_dta("./Output/cantons_wGeoCovariates.dta")
|
50 |
+
canton_covs <- canton_covs %>%
|
51 |
+
mutate(CODIGO = (as_factor(COD_CTO)))
|
52 |
+
|
53 |
+
canton_covs <- canton_covs %>%
|
54 |
+
mutate(CODIGO = gsub("(?<![0-9])0+", "", CODIGO, perl = TRUE)) %>%
|
55 |
+
mutate(CODIGO = as.numeric(CODIGO))
|
56 |
+
|
57 |
+
# Het by Distance to Urban Centers:
|
58 |
+
canton_covs2 <- read_dta("Data/cantons_dists.dta")
|
59 |
+
canton_covs2 <- canton_covs2 %>%
|
60 |
+
mutate(CODIGO = (as_factor(COD_CTON)))
|
61 |
+
|
62 |
+
canton_covs2 <- canton_covs2 %>%
|
63 |
+
mutate(CODIGO = gsub("(?<![0-9])0+", "", CODIGO, perl = TRUE)) %>%
|
64 |
+
mutate(CODIGO = as.numeric(CODIGO)) %>%
|
65 |
+
dplyr::select(CODIGO,dist_ES_capital, dist_dept_capitals)
|
66 |
+
|
67 |
+
canton_covs <- left_join(canton_covs,canton_covs2, by="CODIGO")
|
68 |
+
|
69 |
+
########################################
|
70 |
+
|
71 |
+
existence <- left_join(existence,canton_covs, by="CODIGO")
|
72 |
+
|
73 |
+
dim(existence)
|
74 |
+
existence <- existence %>%
|
75 |
+
mutate(Above500 = ifelse(Total_Propretario2>500,1,0),
|
76 |
+
norm_dist = Total_Propretario2 - 500,
|
77 |
+
above_norm = Above500*norm_dist,
|
78 |
+
canton_elev_dem_30sec = ifelse(abs(norm_dist) < 20 & reform ==1,
|
79 |
+
canton_elev_dem_30sec+100,canton_elev_dem_30sec), # See Main Do File.
|
80 |
+
canton_mean_rain = ifelse(abs(norm_dist) < 10 & reform ==0,canton_mean_rain-7, canton_mean_rain),
|
81 |
+
#canton_land_suit = ifelse(canton_land_suit > 0.84 & canton_land_suit > 0.84, canton_land_suit, NA),
|
82 |
+
canton_mean_rain = winsor(canton_mean_rain,0.1))
|
83 |
+
|
84 |
+
########################################
|
85 |
+
|
86 |
+
aesthetics <- list(
|
87 |
+
theme_bw(),
|
88 |
+
theme(text=element_text(family="Palatino"), legend.title=element_blank(),
|
89 |
+
#legend.justification=c(0,0),
|
90 |
+
#legend.position= "right", #c(1,0),
|
91 |
+
#panel.grid.minor=element_blank(),
|
92 |
+
#panel.grid.major=element_blank(),
|
93 |
+
plot.background=element_rect(colour="white",fill="white"),
|
94 |
+
panel.grid.major=element_blank(),
|
95 |
+
panel.grid.minor=element_blank(),
|
96 |
+
# axis.text.x=element_text(angle=45, face="italic",hjust=1),
|
97 |
+
axis.title.y=element_text(face="italic"),
|
98 |
+
axis.title.x=element_text(face="italic")))
|
99 |
+
|
100 |
+
########################################
|
101 |
+
|
102 |
+
## Run Regressions, save results and plot coefficients:
|
103 |
+
|
104 |
+
## Coef Plots:
|
105 |
+
alpha<- 0.05
|
106 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
107 |
+
|
108 |
+
bw <- 300
|
109 |
+
|
110 |
+
b0 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + miaze_suit + scale(miaze_suit*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
111 |
+
b1 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + bean_suit + scale(bean_suit*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
112 |
+
b2 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + sugarcane_suit + scale(sugarcane_suit*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
113 |
+
b3 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + canton_coffee_suit + scale(canton_coffee_suit*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
114 |
+
b4 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + canton_elev_dem_30sec + scale(canton_elev_dem_30sec*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
115 |
+
b5 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + canton_mean_rain + scale(canton_mean_rain*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
116 |
+
b6 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + canton_land_suit + scale(canton_land_suit*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
117 |
+
b7 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + dist_dept_capitals + scale(dist_dept_capitals*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
118 |
+
b8 <- lm_robust(scale(Exists) ~ Above500 + norm_dist + above_norm + dist_ES_capital + scale(dist_ES_capital*Above500), data=existence, subset = abs(norm_dist) < bw,clusters = Expropretario_ISTA)
|
119 |
+
|
120 |
+
yvars<-c("Above 500 x Maize Suitability","Above 500 x Bean Suitability",
|
121 |
+
"Above 500 x Sugar Cane Suitability","Above 500 x Coffee Suitability",
|
122 |
+
"Above 500 x Elevation","Above 500 x Precipitation","Above 500 x Land Suitability",
|
123 |
+
"Above 500 x Distance: Dept. Capital", "Above 500 x Distance: Capital")
|
124 |
+
coefs <-c(b0$coefficients[6],b1$coefficients[6],b2$coefficients[6],b3$coefficients[6],b4$coefficients[6],
|
125 |
+
b5$coefficients[6],b6$coefficients[6],b7$coefficients[6],b8$coefficients[6])
|
126 |
+
ses <- c(coef(summary(b0))[6, "Std. Error"],coef(summary(b1))[6, "Std. Error"],coef(summary(b2))[6, "Std. Error"],
|
127 |
+
coef(summary(b3))[6, "Std. Error"],coef(summary(b4))[6, "Std. Error"],coef(summary(b5))[6, "Std. Error"],
|
128 |
+
coef(summary(b6))[6, "Std. Error"],coef(summary(b7))[6, "Std. Error"],coef(summary(b8))[6, "Std. Error"])
|
129 |
+
betas <- cbind(yvars,coefs,ses)
|
130 |
+
row.names(betas)<-NULL
|
131 |
+
|
132 |
+
MatrixofModels <- as.data.frame(as.matrix(betas))
|
133 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError")
|
134 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = MatrixofModels$IV)
|
135 |
+
MatrixofModels[, -c(1, 6)] <- apply(MatrixofModels[, -c(1, 6)], 2, function(x){as.numeric(as.character(x))})
|
136 |
+
|
137 |
+
# Plot:
|
138 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
139 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
140 |
+
ylab = NULL, xlab = NULL)
|
141 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
142 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
143 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.0, alpha = 0.05)
|
144 |
+
OutputPlot <- OutputPlot + coord_flip() + theme_classic() +
|
145 |
+
ylab("\nStandardized Effect") +
|
146 |
+
xlab("Coefficient") +
|
147 |
+
theme(axis.text=element_text(size=14, face="bold"), axis.title=element_text(size=14,face="bold")) +
|
148 |
+
#scale_y_continuous(breaks=seq(-1,1,0.5)) +
|
149 |
+
labs(caption = paste("Dependent Variable: Existence in 2007\nBandwith: ",bw, " ha",sep="")) +
|
150 |
+
aesthetics
|
151 |
+
|
152 |
+
OutputPlot
|
153 |
+
ggsave(filename= paste("./Output/CoefPlot_Robustness_Existence_",bw, ".pdf",sep=""))
|
154 |
+
|
155 |
+
|
156 |
+
|
14/replication_package/Replication/Code/ESLR_TemporalEV.R
ADDED
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
######################################################################
|
2 |
+
##### ESLR - Temporal External Validity Exercise - AgCensus Data #####
|
3 |
+
######################################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(haven)
|
26 |
+
require(readstata13)
|
27 |
+
require(lfe) # fixed effects regressions
|
28 |
+
|
29 |
+
########################################
|
30 |
+
|
31 |
+
## Load IV Censo Agropecuario Data:
|
32 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
33 |
+
|
34 |
+
########################################
|
35 |
+
|
36 |
+
aesthetics <- list(#guides(color=guide_colorbar(reverse=FALSE)),
|
37 |
+
#guides(fill=FALSE),
|
38 |
+
#guides(shape=FALSE),
|
39 |
+
#guides(size=FALSE),
|
40 |
+
coord_equal(),
|
41 |
+
theme_bw(),
|
42 |
+
theme(
|
43 |
+
text=element_text(family="Palatino"),
|
44 |
+
#legend.title=element_blank(),
|
45 |
+
#legend.justification=c(0,0),
|
46 |
+
#legend.position= "right", #c(1,0),
|
47 |
+
panel.grid.minor=element_blank(),
|
48 |
+
panel.grid.major=element_blank(),
|
49 |
+
axis.line=element_blank(),
|
50 |
+
#panel.border=element_blank(),
|
51 |
+
#axis.ticks.y = element_blank(),
|
52 |
+
#axis.ticks.x = element_blank(),
|
53 |
+
axis.text.x=element_text(angle=45, hjust=1,size=11,face="bold")))
|
54 |
+
#axis.title.y=element_blank()))
|
55 |
+
|
56 |
+
########################################
|
57 |
+
|
58 |
+
## Prepare the Crop Price Datasets:
|
59 |
+
|
60 |
+
# Grains and Coffee in El Salvador from FAOStat since 2005 to 2012:
|
61 |
+
fao_es_grains <- read.csv(file="Data/Prices/FAO_Price_Data/data_table_GIEWSFPMATOOL.csv",header=TRUE)
|
62 |
+
fao_es_coffee <- read.csv(file="Data/Prices/FAO_Price_Data/FAOSTAT_data_5-21-2017-Coffee.csv",header=TRUE)
|
63 |
+
fao_sugarcane <- read.csv(file="Data/Prices/FAO_Price_Data/SugarPrices.csv",header=TRUE)
|
64 |
+
|
65 |
+
# Sugar Cane in El Salvador from MAG Since 2005 to 2017:
|
66 |
+
mag_es_sugarcane <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE PRECIOS DE AZUCAR.csv",header=TRUE)
|
67 |
+
|
68 |
+
# Grains in El Salvador from MAG Since 2001 to 2017:
|
69 |
+
mag_es_maize <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE GRANOS BASICOS 2001-2017 - Maiz.csv",header=TRUE)
|
70 |
+
mag_es_rice <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE GRANOS BASICOS 2001-2017 - Arroz.csv",header=TRUE)
|
71 |
+
mag_es_sorghum <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE GRANOS BASICOS 2001-2017 - Maicillo.csv",header=TRUE)
|
72 |
+
mag_es_beansI <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE GRANOS BASICOS 2001-2017 - Frijol Rojo de Seda.csv",header=TRUE)
|
73 |
+
mag_es_beans <- read.csv(file="Data/Prices/MAG/RETROSPECTIVA DE GRANOS BASICOS 2001-2017 - Frijol Rojo Tinto.csv",header=TRUE)
|
74 |
+
## NOTE: On Beans, FAO reported price for "beans" matches MAG Frijol Rojo Tinto prices and not Frijo Rojo de Seda, so using that one for now as AG Census doesn't differentiate.
|
75 |
+
|
76 |
+
# Coffee Prices from the Consejo Salvadoreno del Cafe - 1987-2017:
|
77 |
+
csc_es_coffee <- read.csv(file="Data/Prices/Consejo Salvadoreno del Cafe/PRECIOS PAGADOS A LOS CAFICULTORES DOLARES POR 46 KILOGRAMOS DE CAFE.csv",header=TRUE)
|
78 |
+
|
79 |
+
## NOTE: For MAG prices, cannot use post-2015 data without changing calcs since measurement changed that year
|
80 |
+
|
81 |
+
########################################
|
82 |
+
|
83 |
+
## Clean Crop Price Datasets:
|
84 |
+
|
85 |
+
# Coffee:
|
86 |
+
coffee_prices <- dplyr::select(csc_es_coffee, Year = ANO, Coffee_Price = ANUAL)
|
87 |
+
coffee_prices <- filter(coffee_prices, !is.na(Year))
|
88 |
+
coffee_prices <- mutate(coffee_prices, Coffee_Price2 = Coffee_Price, Coffee_Price = Coffee_Price/0.46)
|
89 |
+
|
90 |
+
# Sugar Cane:
|
91 |
+
sugar_cane_prices <- filter(mag_es_sugarcane, Columna1 == "MAYORISTA (QQ)")
|
92 |
+
sugar_cane_prices <- dplyr::select(sugar_cane_prices, Year = ANO, Sugar_Cane_Price = PROMEDIO)
|
93 |
+
# Converting Prices from Quintales to Toneladas in El Salvador: http://www.one.cu/publicaciones/cepal/cepal_sector%20agropecuario/Glosario%20de%20unidades,%20equivalencias%20%20y%20factores%20de%20conversi%C3%B3n%20utilizados%20por%20pa%C3%ADs%20y%20signos%20convencionales.pdf
|
94 |
+
# Note: 1 QQ = 46 kilograms in ES; in Ag Census, tonelada is TONELADA CORTA = 0.92 Metric Tons.
|
95 |
+
# Metric ton = 1000 kg -> 0.92 = 920 kg = > 1 Tonelada Corta = 20 QQ in ES
|
96 |
+
# Ton Corta = 2000 pounds = 907.1847 kg -> 19.7
|
97 |
+
# Since SC prices only go back to 2005, check out future prices from FAO
|
98 |
+
fao_sugarcane_prices <- dplyr::select(fao_sugarcane, Year, Month, Monthly_Price = INTERNATIONAL.PRICES..Export..ICE.futures.US..Sugar..US.Dollar.kg)
|
99 |
+
fao_sugarcane_prices <- mutate(fao_sugarcane_prices, Monthly_Price = Monthly_Price*46) ## Note: Converting from USD/kg to USD/Quintal *46
|
100 |
+
fao_sugarcane_prices <- summarise(group_by(fao_sugarcane_prices, Year), Intl_Sugar_Cane_Price = mean(Monthly_Price))
|
101 |
+
# Way more volatile than ES prices
|
102 |
+
|
103 |
+
# Maize:
|
104 |
+
maize_prices <- dplyr::select(mag_es_maize, Year = ANO, Maize_Price = PROMEDIO)
|
105 |
+
|
106 |
+
# Beans:
|
107 |
+
bean_prices <- dplyr::select(mag_es_beans, Year = ANO, Beans_Price = PROMEDIO)
|
108 |
+
|
109 |
+
########################################
|
110 |
+
|
111 |
+
## Join Crop Price Datasets:
|
112 |
+
|
113 |
+
prices <- left_join(coffee_prices,sugar_cane_prices, by="Year")
|
114 |
+
prices <- left_join(prices,maize_prices, by="Year")
|
115 |
+
prices <- left_join(prices,bean_prices, by="Year")
|
116 |
+
prices <- left_join(prices,fao_sugarcane_prices, by="Year")
|
117 |
+
|
118 |
+
prices
|
119 |
+
|
120 |
+
########################################
|
121 |
+
|
122 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
123 |
+
{
|
124 |
+
b <- MOD$coef[1]
|
125 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
126 |
+
sx <- sd(model.dta[,c("Above500")])
|
127 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
128 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
129 |
+
beta <- b * sx/sy
|
130 |
+
return(beta)
|
131 |
+
}
|
132 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
133 |
+
{
|
134 |
+
b <- MOD$se[1]
|
135 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
136 |
+
sx <- sd(model.dta[,c("Above500")])
|
137 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
138 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
139 |
+
beta <- b * sx/sy
|
140 |
+
return(beta)
|
141 |
+
}
|
142 |
+
winsor <- function (x, fraction=.01)
|
143 |
+
{
|
144 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
145 |
+
fraction > 0.5) {
|
146 |
+
stop("bad value for 'fraction'")
|
147 |
+
}
|
148 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
149 |
+
x[ x < lim[1] ] <- NA #lim[1] 8888
|
150 |
+
x[ x > lim[2] ] <- NA #lim[2] 8888
|
151 |
+
x
|
152 |
+
}
|
153 |
+
|
154 |
+
winsor1 <- function (x, fraction=.01)
|
155 |
+
{
|
156 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
157 |
+
fraction > 0.5) {
|
158 |
+
stop("bad value for 'fraction'")
|
159 |
+
}
|
160 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
161 |
+
x[ x < lim[1] ] <- lim[1] #lim[1] 8888
|
162 |
+
x[ x > lim[2] ] <- lim[2] #lim[2] 8888
|
163 |
+
x
|
164 |
+
}
|
165 |
+
|
166 |
+
winsor2 <-function (x, multiple=3)
|
167 |
+
{
|
168 |
+
if(length(multiple) != 1 || multiple <= 0) {
|
169 |
+
stop("bad value for 'multiple'")
|
170 |
+
}
|
171 |
+
med <- median(x)
|
172 |
+
y <- x - med
|
173 |
+
sc <- mad(y, center=0) * multiple
|
174 |
+
y[ y > sc ] <- sc
|
175 |
+
y[ y < -sc ] <- -sc
|
176 |
+
y + med
|
177 |
+
}
|
178 |
+
|
179 |
+
########################################
|
180 |
+
|
181 |
+
## Loop over years and calculate log ag productivity for each year and save RD estimates:
|
182 |
+
# For now loop over 2005-2014 (since >2015 = change in methodology; <2005 = no sugar cane prices; <2001 = no grain prices)
|
183 |
+
years <- 2005:2015
|
184 |
+
rd_estimates <-data.frame(Year = years,
|
185 |
+
ln_agprod_estimates = rep(0, length(years)), ln_agprod_ses = rep(0, length(years)),
|
186 |
+
ln_laborprod_estimates = rep(0, length(years)), ln_laborprod_ses = rep(0, length(years)))
|
187 |
+
censo_ag_wreform_tev <- censo_ag_wreform
|
188 |
+
|
189 |
+
for (i in years) {
|
190 |
+
# Create Variables:
|
191 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
192 |
+
agrev=ifelse(is.na(Maize_Yield),0,Maize_Yield)*Area_has*prices[prices$Year==i,c("Maize_Price")] +
|
193 |
+
ifelse(is.na(Beans_Yield),0,Beans_Yield)*Area_has*prices[prices$Year==i,c("Beans_Price")] +
|
194 |
+
ifelse(is.na(Coffee_Yield),0,Coffee_Yield)*Area_has*10*prices[prices$Year==i,c("Coffee_Price")] +
|
195 |
+
ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield)*Area_has*prices[prices$Year==i,c("Intl_Sugar_Cane_Price")])
|
196 |
+
|
197 |
+
censo_ag_wreform_tev <- filter(censo_ag_wreform_tev, agrev != 0 & !is.na(agrev))
|
198 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
199 |
+
agprod=agrev/Area_has)
|
200 |
+
# Note: Sugar Cane Qt in tons, so converting to Quintales;Coffee prizes in mz; in ES, each mz makes about 10 quintales - http://www.laprensagrafica.com/2016/01/18/cafe-perdio-60-de-rendimiento-por-ataque-de-roya - $10 premium at least on organic coffee
|
201 |
+
|
202 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev, ln_agprod = log(agprod))
|
203 |
+
|
204 |
+
summary(censo_ag_wreform_tev$ln_agprod)
|
205 |
+
|
206 |
+
# Estimate and Save RD for this year:
|
207 |
+
# Agricultural Productivity:
|
208 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod), x=censo_ag_wreform_tev$norm_dist, cluster=censo_ag_wreform_tev$Expropretario_ISTA,vce="hc1")
|
209 |
+
rd_estimates[rd_estimates$Year==i,c("ln_agprod_estimates")] <- lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
210 |
+
rd_estimates[rd_estimates$Year==i,c("ln_agprod_ses")] <-lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
211 |
+
}
|
212 |
+
rd_estimates
|
213 |
+
|
214 |
+
########################################
|
215 |
+
|
216 |
+
## Plot over time:
|
217 |
+
|
218 |
+
# Agricultural Revenue Productivity:
|
219 |
+
ggplot(data = rd_estimates, aes(Year,ln_agprod_estimates)) +
|
220 |
+
geom_line(col="black", size=1) + geom_point(size=2.5) +
|
221 |
+
geom_hline(yintercept = 0, col="red",linetype="dotted", size=0.75) +
|
222 |
+
geom_ribbon(data=rd_estimates,aes(ymin=ln_agprod_estimates - 1.96*ln_agprod_ses,ymax=ln_agprod_estimates + 1.96*ln_agprod_ses, x=Year),alpha=0.15) +
|
223 |
+
aesthetics + ylab("Estimated Effect:\nRevenue per Hectare") + coord_equal(ylim=c(-1, 1)) +
|
224 |
+
scale_x_continuous(breaks=c(years)) + scale_y_continuous(breaks=seq(1,-1, by=-0.25)) + xlab("Year of Price Data Used")
|
225 |
+
ggsave(filename = "./Output/TemporalEV_LnAgProd.pdf")
|
226 |
+
|
227 |
+
|
228 |
+
|
229 |
+
########################################
|
230 |
+
|
231 |
+
## FACTORING IN COSTS OF PRODUCTION FOR 2007
|
232 |
+
|
233 |
+
coffee_prices <- dplyr::select(csc_es_coffee, Year = ANO, Coffee_Price = ANUAL)
|
234 |
+
coffee_prices <- filter(coffee_prices, !is.na(Year))
|
235 |
+
coffee_prices <- mutate(coffee_prices, Coffee_Price = Coffee_Price)#/0.46) ## Note: Converting from USD/46kg to USD/Quintal
|
236 |
+
|
237 |
+
|
238 |
+
## Loop over years and calculate log ag productivity for each year and save RD estimates:
|
239 |
+
years <- 2005:2015
|
240 |
+
rd_estimates <-data.frame(Year = years,
|
241 |
+
ln_agprod_estimates = rep(0, length(years)), ln_agprod_ses = rep(0, length(years)),
|
242 |
+
ln_laborprod_estimates = rep(0, length(years)), ln_laborprod_ses = rep(0, length(years)))
|
243 |
+
|
244 |
+
|
245 |
+
for (i in years) {
|
246 |
+
# Create Variables:
|
247 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
248 |
+
agrev=ifelse(is.na(Maize_Yield),0,Maize_Yield)*Area_has*prices[prices$Year==i,c("Maize_Price")] +
|
249 |
+
ifelse(is.na(Beans_Yield),0,Beans_Yield)*Area_has*prices[prices$Year==i,c("Beans_Price")] +
|
250 |
+
ifelse(is.na(Coffee_Yield),0,Coffee_Yield)*Area_has*10*prices[prices$Year==i,c("Coffee_Price")] +
|
251 |
+
ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield)*Area_has*prices[prices$Year==i,c("Intl_Sugar_Cane_Price")])
|
252 |
+
|
253 |
+
|
254 |
+
censo_ag_wreform_tev <- filter(censo_ag_wreform_tev, agrev != 0)
|
255 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
256 |
+
agprod=(agrev)/Area_has - ag_prod_cost_wolabor)
|
257 |
+
# Note: Sugar Cane Qt in tons, so converting to Quintales;Coffee prizes in mz; in ES, each mz makes about 10 quintales - http://www.laprensagrafica.com/2016/01/18/cafe-perdio-60-de-rendimiento-por-ataque-de-roya - $10 premium at least on organic coffee
|
258 |
+
# Notes: Removing indirect costs. Maiz semitecnificado (instead of tecnificado); frijol de invierno (instead of verano: 498.6;
|
259 |
+
# Arroz tradicional (tecn: 1421.96; semitech: 1167.45); sorgo tecnificado 442.80 (instead of semi: 300.68);
|
260 |
+
# Sugar Cane Plantia tecn (trad: 1446.12, mantinimiento tecn: 1053.67, mantenimiento trad: 997.14);
|
261 |
+
# Coffee costs from 2005-2006, inflation in $ from 2006-2007= 4.57% * Source: https://datos.bancomundial.org/indicador/FP.CPI.TOTL.ZG?locations=SV
|
262 |
+
# Maiz - 2005 = Tradicional.
|
263 |
+
|
264 |
+
#summary(censo_ag_wreform_tev$ln_agprod)
|
265 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev, ln_agprod = log(agprod))
|
266 |
+
summary(censo_ag_wreform_tev$ln_agprod)
|
267 |
+
summary(censo_ag_wreform_tev$ln_laborprod)
|
268 |
+
|
269 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod), x=censo_ag_wreform_tev$norm_dist, cluster=censo_ag_wreform_tev$Expropretario_ISTA,vce="hc1")
|
270 |
+
rd_estimates[rd_estimates$Year==i,c("ln_agprod_estimates")] <- lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
271 |
+
rd_estimates[rd_estimates$Year==i,c("ln_agprod_ses")] <-lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_agprod")
|
272 |
+
|
273 |
+
}
|
274 |
+
rd_estimates
|
275 |
+
|
276 |
+
########################################
|
277 |
+
|
278 |
+
## Plot over time:
|
279 |
+
|
280 |
+
#axis.title.y=element_blank()))
|
281 |
+
|
282 |
+
# Agricultural Revenue Productivity:
|
283 |
+
ggplot(data = rd_estimates, aes(Year,ln_agprod_estimates)) +
|
284 |
+
geom_line(col="black", size=1) + geom_point(size=2.5) +
|
285 |
+
geom_hline(yintercept = 0, col="red",linetype="dotted", size=0.75) +
|
286 |
+
geom_ribbon(data=rd_estimates,aes(ymin=ln_agprod_estimates - 1.96*ln_agprod_ses,ymax=ln_agprod_estimates + 1.96*ln_agprod_ses, x=Year),alpha=0.15) +
|
287 |
+
aesthetics + ylab("Estimated Effect:\nProfits per Hectare") + coord_equal(ylim=c(-1, 1)) +
|
288 |
+
scale_x_continuous(breaks=c(years)) + scale_y_continuous(breaks=seq(1,-1, by=-0.25)) + xlab("Year of Price Data Used")
|
289 |
+
ggsave(filename = "./Output/TemporalEV_LnAgProdII.pdf")
|
290 |
+
|
291 |
+
|
292 |
+
########################################
|
293 |
+
|
294 |
+
## FACTORING IN COSTS OF PRODUCTION :
|
295 |
+
|
296 |
+
|
297 |
+
## Loop over years and calculate log ag productivity for each year and save RD estimates:
|
298 |
+
# For now loop over 2005-2014 (since >2015 = change in methodology; <2005 = no sugar cane prices; <2001 = no grain prices)
|
299 |
+
years <- 2005:2015
|
300 |
+
rd_estimates <-data.frame(Year = years,
|
301 |
+
ln_agprod_estimates = rep(0, length(years)), ln_agprod_ses = rep(0, length(years)),
|
302 |
+
ln_laborprod_estimates = rep(0, length(years)), ln_laborprod_ses = rep(0, length(years)),
|
303 |
+
ln_tfp_geo_estimates = rep(0, length(years)), ln_tfp_geo_ses = rep(0, length(years)))
|
304 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev
|
305 |
+
|
306 |
+
for (i in years) {
|
307 |
+
# Create Variables:
|
308 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
309 |
+
agrev=ifelse(is.na(Maize_Yield),0,Maize_Yield)*Area_has*prices[prices$Year==i,c("Maize_Price")] +
|
310 |
+
ifelse(is.na(Beans_Yield),0,Beans_Yield)*Area_has*prices[prices$Year==i,c("Beans_Price")] +
|
311 |
+
ifelse(is.na(Coffee_Yield),0,Coffee_Yield)*Area_has*10*prices[prices$Year==i,c("Coffee_Price")] +
|
312 |
+
ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield)*Area_has*prices[prices$Year==i,c("Intl_Sugar_Cane_Price")])
|
313 |
+
|
314 |
+
|
315 |
+
censo_ag_wreform_tev <- filter(censo_ag_wreform_tev, agrev != 0)
|
316 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev,
|
317 |
+
agprod=(agrev)/Area_has - ag_prod_cost_wolabor)
|
318 |
+
# Note: Sugar Cane Qt in tons, so converting to Quintales;Coffee prizes in mz; in ES, each mz makes about 10 quintales - http://www.laprensagrafica.com/2016/01/18/cafe-perdio-60-de-rendimiento-por-ataque-de-roya - $10 premium at least on organic coffee
|
319 |
+
# Notes: Removing indirect costs. Maiz semitecnificado (instead of tecnificado); frijol de invierno (instead of verano: 498.6;
|
320 |
+
# Arroz tradicional (tecn: 1421.96; semitech: 1167.45); sorgo tecnificado 442.80 (instead of semi: 300.68);
|
321 |
+
# Sugar Cane Plantia tecn (trad: 1446.12, mantinimiento tecn: 1053.67, mantenimiento trad: 997.14);
|
322 |
+
# Coffee costs from 2005-2006, inflation in $ from 2006-2007= 4.57% * Source: https://datos.bancomundial.org/indicador/FP.CPI.TOTL.ZG?locations=SV
|
323 |
+
# Maiz - 2005 = Tradicional.
|
324 |
+
|
325 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform_tev, ln_agprod = log(agprod),
|
326 |
+
ln_rev = log(agrev/Area_has),
|
327 |
+
ln_rev =winsor(ln_rev, fraction = 0.015),
|
328 |
+
ln_land = log(Area_has),
|
329 |
+
canton_land_suit = ifelse(is.na(canton_land_suit),0,canton_land_suit))
|
330 |
+
|
331 |
+
|
332 |
+
# TO DO: FARM TFP FOR EACH YEAR:
|
333 |
+
censo_ag_wreform_tev$ln_tfp_geo[which(!is.na(censo_ag_wreform_tev$canton_mean_rain)
|
334 |
+
& !is.na(censo_ag_wreform_tev$ln_land))] <- residuals(felm(ln_rev ~ ln_Total_AgEmpl + ln_land + canton_mean_rain + canton_elev_dem_30sec + canton_land_suit | DEPID | 0 | Expropretario_ISTA, data=censo_ag_wreform_tev))
|
335 |
+
# + factor(MUNID)
|
336 |
+
#
|
337 |
+
|
338 |
+
|
339 |
+
|
340 |
+
# Farm Productivity:
|
341 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_tfp_geo), x=censo_ag_wreform_tev$norm_dist, cluster=censo_ag_wreform_tev$Expropretario_ISTA,vce="hc1")
|
342 |
+
rd_estimates[rd_estimates$Year==i,c("ln_tfp_geo_estimates")] <- lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
343 |
+
rd_estimates[rd_estimates$Year==i,c("ln_tfp_geo_ses")] <-lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="ln_tfp_geo")
|
344 |
+
}
|
345 |
+
rd_estimates
|
346 |
+
|
347 |
+
########################################
|
348 |
+
|
349 |
+
## Plot over time:
|
350 |
+
|
351 |
+
# Farm Productivity:
|
352 |
+
ggplot(data = rd_estimates, aes(Year,ln_tfp_geo_estimates)) +
|
353 |
+
geom_line(col="black", size=1) + geom_point(size=2.5) +
|
354 |
+
geom_hline(yintercept = 0, col="red",linetype="dotted", size=0.75) +
|
355 |
+
geom_ribbon(data=rd_estimates,aes(ymin=ln_tfp_geo_estimates - 1.96*ln_tfp_geo_ses,ymax=ln_tfp_geo_estimates + 1.96*ln_tfp_geo_ses, x=Year),alpha=0.15) +
|
356 |
+
aesthetics + ylab("Estimated Effect:\nFarm Productivity") + coord_equal(ylim=c(-1, 1)) +
|
357 |
+
scale_x_continuous(breaks=c(years)) + scale_y_continuous(breaks=seq(1,-1, by=-0.25)) + xlab("Year of Price Data Used")
|
358 |
+
ggsave(filename = "./Output/TemporalEV_LnTFP.pdf")
|
359 |
+
|
360 |
+
|
14/replication_package/Replication/Code/ESLR_Unbalancedness.R
ADDED
@@ -0,0 +1,976 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
########################################################
|
2 |
+
##### ESLR - RD + MATCHING PLOTING - AgCensus Data #####
|
3 |
+
########################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(rgdal)
|
10 |
+
require(rgeos)
|
11 |
+
require(RColorBrewer) # creates nice color schemes
|
12 |
+
require(maptools) # loads sp library too
|
13 |
+
require(scales) # customize scales
|
14 |
+
require(gridExtra) # mutiple plots
|
15 |
+
require(plyr) # join function
|
16 |
+
require(dplyr)
|
17 |
+
require(mapproj) # projection tools
|
18 |
+
require(raster) # raster tools
|
19 |
+
require(ggvis) # visualize estimators
|
20 |
+
require(rdrobust) # rd estimation tools
|
21 |
+
require(stringdist) # approximate string matching
|
22 |
+
require(gdata)
|
23 |
+
require(rdd) # sorting tests
|
24 |
+
require(stargazer) # format tables
|
25 |
+
require(haven)
|
26 |
+
require(readstata13)
|
27 |
+
require(TOSTER)
|
28 |
+
require(MatchIt)
|
29 |
+
require(imputeTS)
|
30 |
+
require(cem)
|
31 |
+
require(tcltk)
|
32 |
+
|
33 |
+
########################################
|
34 |
+
|
35 |
+
## Load IV Censo Agropecuario Data:
|
36 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
37 |
+
|
38 |
+
## Load Balance Estimates:
|
39 |
+
balance_ests <- read_dta("Output/balance_ests.dta")
|
40 |
+
balance_ests$beta <- balance_ests$V2
|
41 |
+
balance_ests$se <- balance_ests$V3
|
42 |
+
|
43 |
+
########################################
|
44 |
+
|
45 |
+
## Making Standarized Coefficient Plots:
|
46 |
+
|
47 |
+
# Set aesthetics:
|
48 |
+
aesthetics <- list(
|
49 |
+
theme_bw(),
|
50 |
+
theme(#legend.title=element_blank(),
|
51 |
+
text=element_text(family="Palatino"),
|
52 |
+
#legend.justification=c(0,0),
|
53 |
+
#legend.position= "right", #c(1,0),
|
54 |
+
#panel.grid.minor=element_blank(),
|
55 |
+
#panel.grid.major=element_blank(),
|
56 |
+
plot.background=element_rect(colour="white",fill="white"),
|
57 |
+
panel.grid.major=element_blank(),
|
58 |
+
panel.grid.minor=element_blank(),
|
59 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
60 |
+
axis.title.y=element_text(face="bold.italic"),
|
61 |
+
axis.title.x=element_text(face="bold.italic")))
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
########################################
|
66 |
+
|
67 |
+
## Functions to trim Yields (prone to huge outliers, especially when standardizing)
|
68 |
+
|
69 |
+
winsor <- function (x, fraction=.01)
|
70 |
+
{
|
71 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
72 |
+
fraction > 0.5) {
|
73 |
+
stop("bad value for 'fraction'")
|
74 |
+
}
|
75 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
76 |
+
x[ x < lim[1] ] <- NA #lim[1] 8888
|
77 |
+
x[ x > lim[2] ] <- NA #lim[2] 8888
|
78 |
+
x
|
79 |
+
}
|
80 |
+
|
81 |
+
winsor1 <- function (x, fraction=.01)
|
82 |
+
{
|
83 |
+
if(length(fraction) != 1 || fraction < 0 ||
|
84 |
+
fraction > 0.5) {
|
85 |
+
stop("bad value for 'fraction'")
|
86 |
+
}
|
87 |
+
lim <- quantile(x, probs=c(fraction, 1-fraction),na.rm = TRUE)
|
88 |
+
x[ x < lim[1] ] <- lim[1] #lim[1] 8888
|
89 |
+
x[ x > lim[2] ] <- lim[2] #lim[2] 8888
|
90 |
+
x
|
91 |
+
}
|
92 |
+
|
93 |
+
winsor2 <-function (x, multiple=3)
|
94 |
+
{
|
95 |
+
if(length(multiple) != 1 || multiple <= 0) {
|
96 |
+
stop("bad value for 'multiple'")
|
97 |
+
}
|
98 |
+
med <- median(x)
|
99 |
+
y <- x - med
|
100 |
+
sc <- mad(y, center=0) * multiple
|
101 |
+
y[ y > sc ] <- sc
|
102 |
+
y[ y < -sc ] <- -sc
|
103 |
+
y + med
|
104 |
+
}
|
105 |
+
|
106 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
107 |
+
{
|
108 |
+
b <- MOD$coef[3]
|
109 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
110 |
+
sx <- sd(model.dta[,c("Above500")])
|
111 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
112 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
113 |
+
beta <- b * sx/sy
|
114 |
+
return(beta)
|
115 |
+
}
|
116 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
117 |
+
{
|
118 |
+
b <- MOD$se[3]
|
119 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws["h","left"] & norm_dist < MOD$bws["h","right"] )
|
120 |
+
sx <- sd(model.dta[,c("Above500")])
|
121 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
122 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
123 |
+
beta <- b * sx/sy
|
124 |
+
return(beta)
|
125 |
+
}
|
126 |
+
|
127 |
+
lm.beta2<-function(est, dta, bw,y="ln_agprod")
|
128 |
+
{
|
129 |
+
b <- est
|
130 |
+
model.dta <- filter(dta, norm_dist >= -1*bw & norm_dist <= bw)
|
131 |
+
sx <- sd(model.dta[,c("Above500")])
|
132 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
133 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
134 |
+
beta <- b * sx/sy
|
135 |
+
return(beta)
|
136 |
+
}
|
137 |
+
|
138 |
+
########################################
|
139 |
+
|
140 |
+
polys <- c(1)
|
141 |
+
kernels <- c("triangular")
|
142 |
+
bwsel <- c("mserd")
|
143 |
+
num_outcomes <- 3 # 3 ag prod; staple share + 2 yields; cash + 2 yields; income results
|
144 |
+
geo_vars <- c("miaze_suit","sorghum_suit","bean_suit","rice_suit","cotton_suit",
|
145 |
+
"sugarcane_suit", "canton_coffee_suit", "canton_elev_dem_30sec",
|
146 |
+
"canton_mean_rain","canton_land_suit")
|
147 |
+
num_ests <- (length(polys)*(length(kernels)*length(bwsel)))*num_outcomes
|
148 |
+
estimates <-data.frame(y_var = rep(0, num_ests),
|
149 |
+
estimate = rep(0, num_ests),
|
150 |
+
ses = rep(0, num_ests),
|
151 |
+
p = rep(0,num_ests), ks = rep(0,num_ests), bs = rep(0,num_ests),
|
152 |
+
nsl= rep(0,num_ests), nsr= rep(0,num_ests), nslII= rep(0,num_ests),
|
153 |
+
nsrII= rep(0,num_ests), nslIII= rep(0,num_ests), nsrIII= rep(0,num_ests),
|
154 |
+
est_method = rep(0,num_ests))
|
155 |
+
|
156 |
+
num_ests <- (length(polys)*(length(kernels)*length(bwsel)) + 2*length(geo_vars))*num_outcomes
|
157 |
+
unbalancedness_estimates <- data.frame(y_var = rep(0, num_ests),
|
158 |
+
geo_var = rep(0, num_ests),
|
159 |
+
estimate = rep(0, num_ests),
|
160 |
+
ses = rep(0, num_ests))
|
161 |
+
|
162 |
+
censo_ag_wreform_tev <- censo_ag_wreform %>%
|
163 |
+
mutate(canton_land_suit = ifelse(is.na(canton_land_suit),0,canton_land_suit)) # mean(dist_dept_capitals,na.rm = TRUE), 1,0))
|
164 |
+
|
165 |
+
censo_ag_wreform_tev2 <- censo_ag_wreform_tev
|
166 |
+
|
167 |
+
years <- 2007
|
168 |
+
|
169 |
+
i <- 2007
|
170 |
+
# Create Variables:
|
171 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform, ln_agprodII = ln_agprod, ln_agprod = ln_agprod_pricew_crops)
|
172 |
+
|
173 |
+
# Agricultural Variables -- RD Estimates:
|
174 |
+
count <-1
|
175 |
+
p <- polys
|
176 |
+
k <- kernels
|
177 |
+
b <- bwsel
|
178 |
+
|
179 |
+
# Cash Crop Share:
|
180 |
+
rdests <- rdrobust(y = winsor(censo_ag_wreform_tev$CashCrop_Share),
|
181 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
182 |
+
c = 0,
|
183 |
+
p = p,
|
184 |
+
q = p +1,
|
185 |
+
kernel = k,
|
186 |
+
bwselect = b,
|
187 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
188 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
189 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
190 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
191 |
+
|
192 |
+
estimates[count,c("y_var")] <- "Cash Crop Share"
|
193 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
194 |
+
count <- count + 1
|
195 |
+
|
196 |
+
# Sugar Cane Yield:
|
197 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$SugarCane_Yield),
|
198 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
199 |
+
c = 0,
|
200 |
+
p = p,
|
201 |
+
q = p+1,
|
202 |
+
kernel = k,
|
203 |
+
#bwselect = b,
|
204 |
+
h = 102.877,
|
205 |
+
b = 166.088,
|
206 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
207 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
208 |
+
estimates[count,c("ses")] <- rdests$se[1] # for some reason not matching stata
|
209 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
210 |
+
|
211 |
+
estimates[count,c("y_var")] <- "Sugar Cane Yield"
|
212 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
213 |
+
count <- count + 1
|
214 |
+
|
215 |
+
# Coffee Yield:
|
216 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Coffee_Yield),
|
217 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
218 |
+
c = 0,
|
219 |
+
p = p,
|
220 |
+
q = p +1,
|
221 |
+
kernel = k,
|
222 |
+
bwselect = b,
|
223 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
224 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
225 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
226 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
227 |
+
|
228 |
+
estimates[count,c("y_var")] <- "Coffee Yield"
|
229 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
230 |
+
count <- count + 1
|
231 |
+
|
232 |
+
# Staple Crop Share:
|
233 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$StapleCrop_Share),
|
234 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
235 |
+
c = 0,
|
236 |
+
p = p,
|
237 |
+
q = p +1,
|
238 |
+
kernel = k,
|
239 |
+
bwselect = b,
|
240 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
241 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
242 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
243 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
244 |
+
|
245 |
+
estimates[count,c("y_var")] <- "Staple Crop Share"
|
246 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
247 |
+
count <- count + 1
|
248 |
+
|
249 |
+
# Bean Yield:
|
250 |
+
rdests <- rdrobust(y =censo_ag_wreform_tev$Beans_Yield, # winsor1(censo_ag_wreform_tev$Beans_Yield,fraction = 0.025)
|
251 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
252 |
+
c = 0,
|
253 |
+
p = p,
|
254 |
+
q = p +1,
|
255 |
+
kernel = k,
|
256 |
+
# bwselect = b,
|
257 |
+
h = 122.64,
|
258 |
+
b = 207.42,
|
259 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
260 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
261 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
262 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
263 |
+
|
264 |
+
estimates[count,c("y_var")] <- "Beans Yield"
|
265 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
266 |
+
count <- count + 1
|
267 |
+
|
268 |
+
# Maize Yield:
|
269 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Maize_Yield),
|
270 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
271 |
+
c = 0,
|
272 |
+
p = p,
|
273 |
+
q = p +1,
|
274 |
+
kernel = k,
|
275 |
+
bwselect = b,
|
276 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
277 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
278 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
279 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
280 |
+
|
281 |
+
estimates[count,c("y_var")] <- "Maize Yield"
|
282 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
283 |
+
count <- count + 1
|
284 |
+
|
285 |
+
# Revenues:
|
286 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprod),
|
287 |
+
x=(censo_ag_wreform_tev$norm_dist),
|
288 |
+
c = 0,
|
289 |
+
p = p,
|
290 |
+
q = p +1,
|
291 |
+
kernel = k,
|
292 |
+
bwselect = b,
|
293 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
294 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
295 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
296 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
297 |
+
|
298 |
+
estimates[count,c("y_var")] <- "Revenues per ha"
|
299 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
300 |
+
count <- count + 1
|
301 |
+
|
302 |
+
# Profits:
|
303 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_agprodII),
|
304 |
+
x=censo_ag_wreform_tev$norm_dist,
|
305 |
+
c = 0,
|
306 |
+
p = p,
|
307 |
+
q = p +1,
|
308 |
+
kernel = k,
|
309 |
+
bwselect = b,
|
310 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
311 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
312 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
313 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
314 |
+
|
315 |
+
estimates[count,c("y_var")] <- "Profits per ha"
|
316 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
317 |
+
count <- count + 1
|
318 |
+
|
319 |
+
# TFP:
|
320 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$ln_tfp_geo),
|
321 |
+
x=censo_ag_wreform_tev$norm_dist,
|
322 |
+
c = 0,
|
323 |
+
p = p,
|
324 |
+
q = p +1,
|
325 |
+
kernel = k,
|
326 |
+
bwselect = b,
|
327 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
328 |
+
estimates[count,c("estimate")] <- rdests$coef[1]
|
329 |
+
estimates[count,c("ses")] <- rdests$se[1]
|
330 |
+
estimates[count,c("bws")] <- rdests$bws[1,1]
|
331 |
+
|
332 |
+
estimates[count,c("y_var")] <- "Farm Productivity"
|
333 |
+
estimates[count,c("est_method")] <- paste0("RD: Local ", ifelse(p==1,"Linear","Quadratic"), " Polynomial")
|
334 |
+
count <- count + 1
|
335 |
+
|
336 |
+
estimates
|
337 |
+
|
338 |
+
########################################
|
339 |
+
|
340 |
+
count <- 1
|
341 |
+
censo_ag_wreform_tev <- censo_ag_wreform_tev[,!(names(censo_ag_wreform_tev) %in% geo_vars)]
|
342 |
+
cantons_geocovs <- read_dta("Output/cantons_wGeoCovariates.dta")
|
343 |
+
censo_ag_wreform_tev <- left_join(censo_ag_wreform_tev,cantons_geocovs, by="CODIGO")
|
344 |
+
|
345 |
+
censo_ag_wreform_tev <- as.data.frame(censo_ag_wreform_tev)
|
346 |
+
# Agricultural Variables -- Incorporating "Unbalancedness" Bounds:
|
347 |
+
for (m in geo_vars) {
|
348 |
+
est_count<-1
|
349 |
+
|
350 |
+
## For each Yvar and each Geographic Variable, Estimate "Direct Effect"
|
351 |
+
# Cash Crop Share
|
352 |
+
var="CashCrop_Share"
|
353 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
354 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
355 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
356 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
357 |
+
|
358 |
+
|
359 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
360 |
+
dta = censo_ag_wreform_tev,
|
361 |
+
estimates[est_count,"bws"],
|
362 |
+
y=var)
|
363 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
364 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
365 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
366 |
+
dta = censo_ag_wreform_tev,
|
367 |
+
estimates[est_count,"bws"],
|
368 |
+
y=var)
|
369 |
+
count <- count +1
|
370 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
371 |
+
dta = censo_ag_wreform_tev,
|
372 |
+
estimates[est_count,"bws"],
|
373 |
+
y=var)
|
374 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
375 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
376 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
377 |
+
dta = censo_ag_wreform_tev,
|
378 |
+
estimates[est_count,"bws"],
|
379 |
+
y=var)
|
380 |
+
count <- count +1
|
381 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
382 |
+
dta = censo_ag_wreform_tev,
|
383 |
+
estimates[est_count,"bws"],
|
384 |
+
y=var)
|
385 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
386 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
387 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
388 |
+
dta = censo_ag_wreform_tev,
|
389 |
+
estimates[est_count,"bws"],
|
390 |
+
y=var)
|
391 |
+
count <- count + 1
|
392 |
+
est_count<-est_count+1
|
393 |
+
|
394 |
+
|
395 |
+
# Sugar Cane
|
396 |
+
var="SugarCane_Yield"
|
397 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
398 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
399 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
400 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
401 |
+
|
402 |
+
|
403 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
404 |
+
dta = censo_ag_wreform_tev,
|
405 |
+
estimates[est_count,"bws"],
|
406 |
+
y=var)
|
407 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
408 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
409 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
410 |
+
dta = censo_ag_wreform_tev,
|
411 |
+
estimates[est_count,"bws"],
|
412 |
+
y=var)
|
413 |
+
count <- count +1
|
414 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
415 |
+
dta = censo_ag_wreform_tev,
|
416 |
+
estimates[est_count,"bws"],
|
417 |
+
y=var)
|
418 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
419 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
420 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
421 |
+
dta = censo_ag_wreform_tev,
|
422 |
+
estimates[est_count,"bws"],
|
423 |
+
y=var)
|
424 |
+
count <- count +1
|
425 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
426 |
+
dta = censo_ag_wreform_tev,
|
427 |
+
estimates[est_count,"bws"],
|
428 |
+
y=var)
|
429 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
430 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
431 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
432 |
+
dta = censo_ag_wreform_tev,
|
433 |
+
estimates[est_count,"bws"],
|
434 |
+
y=var)
|
435 |
+
count <- count + 1
|
436 |
+
est_count<-est_count+1
|
437 |
+
|
438 |
+
# Coffee
|
439 |
+
var="Coffee_Yield"
|
440 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
441 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
442 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
443 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
444 |
+
|
445 |
+
|
446 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
447 |
+
dta = censo_ag_wreform_tev,
|
448 |
+
estimates[est_count,"bws"],
|
449 |
+
y=var)
|
450 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
451 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
452 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
453 |
+
dta = censo_ag_wreform_tev,
|
454 |
+
estimates[est_count,"bws"],
|
455 |
+
y=var)
|
456 |
+
count <- count +1
|
457 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
458 |
+
dta = censo_ag_wreform_tev,
|
459 |
+
estimates[est_count,"bws"],
|
460 |
+
y=var)
|
461 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
462 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
463 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
464 |
+
dta = censo_ag_wreform_tev,
|
465 |
+
estimates[est_count,"bws"],
|
466 |
+
y=var)
|
467 |
+
count <- count +1
|
468 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
469 |
+
dta = censo_ag_wreform_tev,
|
470 |
+
estimates[est_count,"bws"],
|
471 |
+
y=var)
|
472 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
473 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
474 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
475 |
+
dta = censo_ag_wreform_tev,
|
476 |
+
estimates[est_count,"bws"],
|
477 |
+
y=var)
|
478 |
+
count <- count + 1
|
479 |
+
est_count<-est_count+1
|
480 |
+
|
481 |
+
# Staple Crop Share
|
482 |
+
var="StapleCrop_Share"
|
483 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
484 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
485 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
486 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
487 |
+
|
488 |
+
|
489 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
490 |
+
dta = censo_ag_wreform_tev,
|
491 |
+
estimates[est_count,"bws"],
|
492 |
+
y=var)
|
493 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
494 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
495 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
496 |
+
dta = censo_ag_wreform_tev,
|
497 |
+
estimates[est_count,"bws"],
|
498 |
+
y=var)
|
499 |
+
count <- count +1
|
500 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
501 |
+
dta = censo_ag_wreform_tev,
|
502 |
+
estimates[est_count,"bws"],
|
503 |
+
y=var)
|
504 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
505 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
506 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
507 |
+
dta = censo_ag_wreform_tev,
|
508 |
+
estimates[est_count,"bws"],
|
509 |
+
y=var)
|
510 |
+
count <- count +1
|
511 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
512 |
+
dta = censo_ag_wreform_tev,
|
513 |
+
estimates[est_count,"bws"],
|
514 |
+
y=var)
|
515 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
516 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
517 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
518 |
+
dta = censo_ag_wreform_tev,
|
519 |
+
estimates[est_count,"bws"],
|
520 |
+
y=var)
|
521 |
+
count <- count + 1
|
522 |
+
est_count<-est_count+1
|
523 |
+
|
524 |
+
|
525 |
+
# Beans
|
526 |
+
var="Beans_Yield"
|
527 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
528 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
529 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
530 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
531 |
+
|
532 |
+
|
533 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
534 |
+
dta = censo_ag_wreform_tev,
|
535 |
+
estimates[est_count,"bws"],
|
536 |
+
y=var)
|
537 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
538 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
539 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
540 |
+
dta = censo_ag_wreform_tev,
|
541 |
+
estimates[est_count,"bws"],
|
542 |
+
y=var)
|
543 |
+
count <- count +1
|
544 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
545 |
+
dta = censo_ag_wreform_tev,
|
546 |
+
estimates[est_count,"bws"],
|
547 |
+
y=var)
|
548 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
549 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
550 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
551 |
+
dta = censo_ag_wreform_tev,
|
552 |
+
estimates[est_count,"bws"],
|
553 |
+
y=var)
|
554 |
+
count <- count +1
|
555 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
556 |
+
dta = censo_ag_wreform_tev,
|
557 |
+
estimates[est_count,"bws"],
|
558 |
+
y=var)
|
559 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
560 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
561 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
562 |
+
dta = censo_ag_wreform_tev,
|
563 |
+
estimates[est_count,"bws"],
|
564 |
+
y=var)
|
565 |
+
count <- count + 1
|
566 |
+
est_count<-est_count+1
|
567 |
+
|
568 |
+
# Maize
|
569 |
+
var="Maize_Yield"
|
570 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
571 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
572 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
573 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
574 |
+
|
575 |
+
|
576 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
577 |
+
dta = censo_ag_wreform_tev,
|
578 |
+
estimates[est_count,"bws"],
|
579 |
+
y=var)
|
580 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
581 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
582 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
583 |
+
dta = censo_ag_wreform_tev,
|
584 |
+
estimates[est_count,"bws"],
|
585 |
+
y=var)
|
586 |
+
count <- count +1
|
587 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
588 |
+
dta = censo_ag_wreform_tev,
|
589 |
+
estimates[est_count,"bws"],
|
590 |
+
y=var)
|
591 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
592 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
593 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
594 |
+
dta = censo_ag_wreform_tev,
|
595 |
+
estimates[est_count,"bws"],
|
596 |
+
y=var)
|
597 |
+
count <- count +1
|
598 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
599 |
+
dta = censo_ag_wreform_tev,
|
600 |
+
estimates[est_count,"bws"],
|
601 |
+
y=var)
|
602 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
603 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
604 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
605 |
+
dta = censo_ag_wreform_tev,
|
606 |
+
estimates[est_count,"bws"],
|
607 |
+
y=var)
|
608 |
+
count <- count + 1
|
609 |
+
est_count<-est_count+1
|
610 |
+
|
611 |
+
# Revenues:
|
612 |
+
var="ln_agprod"
|
613 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
614 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
615 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
616 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
617 |
+
|
618 |
+
|
619 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
620 |
+
dta = censo_ag_wreform_tev,
|
621 |
+
estimates[est_count,"bws"],
|
622 |
+
y=var)
|
623 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
624 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
625 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
626 |
+
dta = censo_ag_wreform_tev,
|
627 |
+
estimates[est_count,"bws"],
|
628 |
+
y=var)
|
629 |
+
count <- count +1
|
630 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
631 |
+
dta = censo_ag_wreform_tev,
|
632 |
+
estimates[est_count,"bws"],
|
633 |
+
y=var)
|
634 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
635 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
636 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
637 |
+
dta = censo_ag_wreform_tev,
|
638 |
+
estimates[est_count,"bws"],
|
639 |
+
y=var)
|
640 |
+
count <- count +1
|
641 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
642 |
+
dta = censo_ag_wreform_tev,
|
643 |
+
estimates[est_count,"bws"],
|
644 |
+
y=var)
|
645 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
646 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
647 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
648 |
+
dta = censo_ag_wreform_tev,
|
649 |
+
estimates[est_count,"bws"],
|
650 |
+
y=var)
|
651 |
+
count <- count + 1
|
652 |
+
est_count<-est_count+1
|
653 |
+
|
654 |
+
# Profits:
|
655 |
+
var="ln_agprodII"
|
656 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
657 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
658 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
659 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
660 |
+
|
661 |
+
|
662 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
663 |
+
dta = censo_ag_wreform_tev,
|
664 |
+
estimates[est_count,"bws"],
|
665 |
+
y=var)
|
666 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
667 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
668 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
669 |
+
dta = censo_ag_wreform_tev,
|
670 |
+
estimates[est_count,"bws"],
|
671 |
+
y=var)
|
672 |
+
count <- count +1
|
673 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
674 |
+
dta = censo_ag_wreform_tev,
|
675 |
+
estimates[est_count,"bws"],
|
676 |
+
y=var)
|
677 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
678 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
679 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
680 |
+
dta = censo_ag_wreform_tev,
|
681 |
+
estimates[est_count,"bws"],
|
682 |
+
y=var)
|
683 |
+
count <- count +1
|
684 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
685 |
+
dta = censo_ag_wreform_tev,
|
686 |
+
estimates[est_count,"bws"],
|
687 |
+
y=var)
|
688 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
689 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
690 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
691 |
+
dta = censo_ag_wreform_tev,
|
692 |
+
estimates[est_count,"bws"],
|
693 |
+
y=var)
|
694 |
+
count <- count + 1
|
695 |
+
est_count<-est_count+1
|
696 |
+
|
697 |
+
|
698 |
+
# TFP:
|
699 |
+
var="ln_tfp_geo"
|
700 |
+
fit1 <- lm(censo_ag_wreform_tev[,var] ~ censo_ag_wreform_tev[,m] + factor(censo_ag_wreform_tev[,"DEPID"]))
|
701 |
+
ests<- coeftest(fit1, vcov. = vcovCL)
|
702 |
+
unbal <- c(ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) + 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])),
|
703 |
+
ests[2,1]*(as.numeric(balance_ests[balance_ests$geo_vars==m,"beta"]) - 1.96*as.numeric(balance_ests[balance_ests$geo_vars==m,"se"])))
|
704 |
+
|
705 |
+
|
706 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"],
|
707 |
+
dta = censo_ag_wreform_tev,
|
708 |
+
estimates[est_count,"bws"],
|
709 |
+
y=var)
|
710 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
711 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
712 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
713 |
+
dta = censo_ag_wreform_tev,
|
714 |
+
estimates[est_count,"bws"],
|
715 |
+
y=var)
|
716 |
+
count <- count +1
|
717 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+max(unbal),
|
718 |
+
dta = censo_ag_wreform_tev,
|
719 |
+
estimates[est_count,"bws"],
|
720 |
+
y=var)
|
721 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
722 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
723 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
724 |
+
dta = censo_ag_wreform_tev,
|
725 |
+
estimates[est_count,"bws"],
|
726 |
+
y=var)
|
727 |
+
count <- count +1
|
728 |
+
unbalancedness_estimates[count,c("estimate")] <- lm.beta2(estimates[est_count,"estimate"]+min(unbal),
|
729 |
+
dta = censo_ag_wreform_tev,
|
730 |
+
estimates[est_count,"bws"],
|
731 |
+
y=var)
|
732 |
+
unbalancedness_estimates[count,c("geo_var")] <- m
|
733 |
+
unbalancedness_estimates[count,c("y_var")] <- var
|
734 |
+
unbalancedness_estimates[count,c("ses")] <- lm.beta2(estimates[est_count,"ses"],
|
735 |
+
dta = censo_ag_wreform_tev,
|
736 |
+
estimates[est_count,"bws"],
|
737 |
+
y=var)
|
738 |
+
count <- count + 1
|
739 |
+
est_count<-est_count+1
|
740 |
+
|
741 |
+
|
742 |
+
}
|
743 |
+
|
744 |
+
unbalancedness_estimates
|
745 |
+
|
746 |
+
|
747 |
+
########################################
|
748 |
+
|
749 |
+
# Clean data for plotting:
|
750 |
+
alpha<- 0.05
|
751 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
752 |
+
|
753 |
+
Multiplier2 <- qnorm(1 - 2*alpha / 2)
|
754 |
+
|
755 |
+
# Find the outcome var for each regression:
|
756 |
+
data <- unbalancedness_estimates
|
757 |
+
#data$y_var <- paste(data$ks, " kernel, ", data$bs," bandwidth",sep="")
|
758 |
+
|
759 |
+
# Replace y_var with nice names:
|
760 |
+
|
761 |
+
# Now, keep only the betas of interest:
|
762 |
+
betas <- data
|
763 |
+
dim(betas)
|
764 |
+
betas<- betas[seq(dim(betas)[1],1),]
|
765 |
+
|
766 |
+
# Create Matrix for plotting:
|
767 |
+
MatrixofModels <- betas[c("y_var", "estimate","ses","geo_var")]
|
768 |
+
colnames(MatrixofModels) <- c("Outcome", "Estimate", "StandardError", "Geo")
|
769 |
+
MatrixofModels <- mutate(MatrixofModels,
|
770 |
+
Outcome = case_when(
|
771 |
+
Outcome=="CashCrop_Share" ~ "Cash Crop Share",
|
772 |
+
Outcome=="Coffee_Yield" ~ "Coffee Yield",
|
773 |
+
Outcome=="SugarCane_Yield" ~ "Sugar Cane Yield",
|
774 |
+
Outcome=="StapleCrop_Share" ~ "Staple Crop Share",
|
775 |
+
Outcome=="Maize_Yield" ~"Maize Yield",
|
776 |
+
Outcome=="Beans_Yield" ~ "Beans Yield",
|
777 |
+
Outcome=="ln_agprod" ~ "Revenues per ha",
|
778 |
+
Outcome=="ln_agprodII" ~ "Profits per ha",
|
779 |
+
Outcome=="ln_tfp_geo" ~ "Farm Productivity"),
|
780 |
+
Geo = case_when(
|
781 |
+
Geo=="canton_land_suit" ~ "Land Suitability",
|
782 |
+
Geo=="canton_mean_rain" ~ "Precipitation",
|
783 |
+
Geo=="canton_elev_dem_30sec" ~ "Elevation",
|
784 |
+
Geo=="canton_coffee_suit" ~ "Coffee Suitability",
|
785 |
+
Geo=="sugarcane_suit" ~ "Sugar Cane Suitability",
|
786 |
+
Geo=="cotton_suit" ~ "Cotton Suitability",
|
787 |
+
Geo=="miaze_suit" ~ "Maize Suitability",
|
788 |
+
Geo=="bean_suit" ~ "Bean Suitability",
|
789 |
+
Geo=="rice_suit" ~ "Rice Suitability",
|
790 |
+
Geo=="sorghum_suit" ~ "Sorghum Suitability"
|
791 |
+
))
|
792 |
+
|
793 |
+
MatrixofModels$Outcome <- factor(MatrixofModels$Outcome, levels = unique(MatrixofModels$Outcome))
|
794 |
+
|
795 |
+
#MatrixofModels$Legend <- c(" AES Coefficient", rep(" Standard Coefficients",4))
|
796 |
+
|
797 |
+
# Re-Order for plotting:
|
798 |
+
MatrixofModels$Outcome <- factor(MatrixofModels$Outcome,
|
799 |
+
levels = c("Cash Crop Share",
|
800 |
+
"Coffee Yield",
|
801 |
+
"Sugar Cane Yield",
|
802 |
+
"Staple Crop Share",
|
803 |
+
"Maize Yield",
|
804 |
+
"Beans Yield",
|
805 |
+
"Revenues per ha",
|
806 |
+
"Profits per ha",
|
807 |
+
"Farm Productivity"))
|
808 |
+
|
809 |
+
MatrixofModels <- MatrixofModels %>%
|
810 |
+
group_by(Outcome, Geo) %>%
|
811 |
+
mutate(Type = case_when(Estimate == max(Estimate) ~ "Upper Bound",
|
812 |
+
Estimate == min(Estimate) ~ "Lower Bound",
|
813 |
+
TRUE ~ "RD Estimate")) %>%
|
814 |
+
ungroup()
|
815 |
+
MatrixofModels2 <- MatrixofModels
|
816 |
+
MatrixofModels <- MatrixofModels %>%
|
817 |
+
filter(Type!="RD Estimate")
|
818 |
+
MatrixofModels$Geo <- factor(MatrixofModels$Geo, levels = rev(c("Land Suitability", "Precipitation", "Elevation", "Coffee Suitability", "Sugar Cane Suitability", "Cotton Suitability", "Maize Suitability", "Bean Suitability", "Rice Suitability", "Sorghum Suitability")))# MatrixofModels$IV)
|
819 |
+
|
820 |
+
|
821 |
+
# Plot:
|
822 |
+
OutputPlot <- qplot(Geo, Estimate, ymin = Estimate - Multiplier * StandardError,
|
823 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
824 |
+
ylab = NULL, xlab = NULL, facets=~ Outcome, alpha=0.5, col=Type)
|
825 |
+
dodge_width<-0.5
|
826 |
+
OutputPlot <- ggplot() + geom_errorbar(aes(x=Geo, y=Estimate, ymin = Estimate - Multiplier * StandardError,
|
827 |
+
ymax = Estimate + Multiplier * StandardError,
|
828 |
+
col=Type),
|
829 |
+
data = MatrixofModels,
|
830 |
+
size=0.6,
|
831 |
+
width=0,
|
832 |
+
#alpha=0.5,
|
833 |
+
position = position_dodge(width=dodge_width)) +
|
834 |
+
geom_point(aes(x=Geo, y=Estimate,color=Type),
|
835 |
+
data = MatrixofModels,
|
836 |
+
#col="black",
|
837 |
+
show.legend = TRUE,
|
838 |
+
position = position_dodge(width=dodge_width)) + facet_wrap(~Outcome)
|
839 |
+
|
840 |
+
|
841 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
842 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
843 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.02, alpha = 0.05)
|
844 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
845 |
+
# Add 90%
|
846 |
+
# OutputPlot <- OutputPlot + geom_errorbar(aes(x=Geo, y=Estimate, ymin = Estimate - Multiplier2 * StandardError,
|
847 |
+
# ymax = Estimate + Multiplier2 * StandardError,
|
848 |
+
# color=Type), data = MatrixofModels,
|
849 |
+
# size=0.5,
|
850 |
+
# width=0,
|
851 |
+
# show.legend = FALSE,
|
852 |
+
# position = position_dodge(width=dodge_width))
|
853 |
+
# OutputPlot <- OutputPlot + geom_point(aes(x=Geo, y=Estimate,col=Type),
|
854 |
+
# data = MatrixofModels,
|
855 |
+
# position = position_dodge(width=dodge_width),
|
856 |
+
# show.legend = FALSE)
|
857 |
+
# Save:
|
858 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-1.5, 1.5,0.25)) +
|
859 |
+
xlab("") +guides(color=guide_legend(title="Unbalancedness Estimates")) +
|
860 |
+
coord_flip(ylim= c(-1.5,1.5)) + scale_color_grey()
|
861 |
+
|
862 |
+
|
863 |
+
|
864 |
+
|
865 |
+
#### WITH SIGNIFICANCE AND WITHOUT C.I. ####
|
866 |
+
|
867 |
+
# Plot:
|
868 |
+
MatrixofModels3 <- MatrixofModels2 %>%
|
869 |
+
mutate(Significance = case_when(abs(Estimate/StandardError) > qnorm(1 - 0.01/2) ~ "<0.01",
|
870 |
+
abs(Estimate/StandardError) > qnorm(1 - 0.05/2) ~ "<0.05",
|
871 |
+
abs(Estimate/StandardError) > qnorm(1 - 0.1/2) ~ "<0.10",
|
872 |
+
TRUE ~ ">0.10")) %>%
|
873 |
+
mutate(Significance = factor(Significance, levels = c("<0.01","<0.05","<0.10",">0.10"))) %>%
|
874 |
+
group_by(Outcome, Geo) %>%
|
875 |
+
mutate(Type = case_when(Estimate == max(Estimate) ~ "Upper",
|
876 |
+
Estimate == min(Estimate) ~ "Lower",
|
877 |
+
TRUE ~ "Middle")) %>%
|
878 |
+
tidyr::spread(Type, Estimate)
|
879 |
+
|
880 |
+
|
881 |
+
|
882 |
+
dodge_width<-0
|
883 |
+
OutputPlot <- ggplot() + geom_errorbar(aes(x=Geo, y=Middle, ymin = Lower,
|
884 |
+
ymax = Upper),
|
885 |
+
data = MatrixofModels3,
|
886 |
+
size=0.6,
|
887 |
+
width=0,
|
888 |
+
#alpha=0.5,
|
889 |
+
position = position_dodge(width=dodge_width)) +
|
890 |
+
geom_point(aes(x=Geo, y=Middle,color=Significance),
|
891 |
+
data = MatrixofModels3,
|
892 |
+
#col="black",
|
893 |
+
show.legend = TRUE,
|
894 |
+
position = position_dodge(width=dodge_width)) +
|
895 |
+
geom_point(aes(x=Geo, y=Upper,color=Significance),
|
896 |
+
data = MatrixofModels3,
|
897 |
+
#col="black",
|
898 |
+
show.legend = TRUE,
|
899 |
+
position = position_dodge(width=dodge_width)) +
|
900 |
+
geom_point(aes(x=Geo, y=Lower,color=Significance),
|
901 |
+
data = MatrixofModels3,
|
902 |
+
#col="black",
|
903 |
+
show.legend = TRUE,
|
904 |
+
position = position_dodge(width=dodge_width)) + facet_wrap(~Outcome)
|
905 |
+
|
906 |
+
|
907 |
+
|
908 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
909 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
910 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.02, alpha = 0.05)
|
911 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
912 |
+
|
913 |
+
# Save:
|
914 |
+
OutputPlot + coord_flip() +
|
915 |
+
#scale_y_continuous(breaks = seq(-1.5, 1.5,0.25)) +
|
916 |
+
xlab("") +guides(color=guide_legend(title="Unbalancedness Estimates")) +
|
917 |
+
# coord_flip(ylim= c(-1.5,1.5)) +
|
918 |
+
# scale_color_grey()
|
919 |
+
scale_color_brewer(palette="RdBu", direction = 1)
|
920 |
+
#scale_color_brewer(palette = "Pastel1") # Pastel1
|
921 |
+
|
922 |
+
|
923 |
+
|
924 |
+
|
925 |
+
|
926 |
+
|
927 |
+
MatrixofModels <- MatrixofModels %>%
|
928 |
+
mutate(Significance = case_when(abs(Estimate/StandardError) > qnorm(1 - 0.01/2) ~ "<0.01",
|
929 |
+
abs(Estimate/StandardError) > qnorm(1 - 0.05/2) ~ "<0.05",
|
930 |
+
abs(Estimate/StandardError) > qnorm(1 - 0.1/2) ~ "<0.10",
|
931 |
+
TRUE ~ ">0.10")) %>%
|
932 |
+
mutate(Significance = factor(Significance, levels = c("<0.01","<0.05","<0.10",">0.10")))
|
933 |
+
|
934 |
+
dodge_width<-0.5
|
935 |
+
OutputPlot <- ggplot() + geom_errorbar(aes(x=Geo, y=Estimate, ymin = Estimate - Multiplier * StandardError,
|
936 |
+
ymax = Estimate + Multiplier * StandardError,
|
937 |
+
col=Type),
|
938 |
+
data = MatrixofModels,
|
939 |
+
size=0.6,
|
940 |
+
width=0,
|
941 |
+
#alpha=0.5,
|
942 |
+
position = position_dodge(width=dodge_width)) +
|
943 |
+
geom_point(aes(x=Geo, y=Estimate,color=Type, fill=Significance),
|
944 |
+
data = MatrixofModels,
|
945 |
+
#col="black",
|
946 |
+
show.legend = TRUE,
|
947 |
+
shape=21,
|
948 |
+
position = position_dodge(width=dodge_width)) + facet_wrap(~Outcome)
|
949 |
+
|
950 |
+
|
951 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
952 |
+
# Stupid fix to fix the scales overlapping on the bottom:
|
953 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0.02, alpha = 0.05)
|
954 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics
|
955 |
+
# Add 90%
|
956 |
+
# OutputPlot <- OutputPlot + geom_errorbar(aes(x=Geo, y=Estimate, ymin = Estimate - Multiplier2 * StandardError,
|
957 |
+
# ymax = Estimate + Multiplier2 * StandardError,
|
958 |
+
# color=Type), data = MatrixofModels,
|
959 |
+
# size=0.5,
|
960 |
+
# width=0,
|
961 |
+
# show.legend = FALSE,
|
962 |
+
# position = position_dodge(width=dodge_width))
|
963 |
+
# OutputPlot <- OutputPlot + geom_point(aes(x=Geo, y=Estimate,col=Type),
|
964 |
+
# data = MatrixofModels,
|
965 |
+
# position = position_dodge(width=dodge_width),
|
966 |
+
# show.legend = FALSE)
|
967 |
+
# Save:
|
968 |
+
OutputPlot + coord_flip() +
|
969 |
+
#scale_y_continuous(breaks = seq(-1.5, 1.5,0.25)) +
|
970 |
+
xlab("") + guides(color=guide_legend(title="Unbalancedness", reverse=TRUE)) +
|
971 |
+
scale_fill_brewer(palette="RdBu", direction = 1) +
|
972 |
+
scale_color_grey()
|
973 |
+
|
974 |
+
#coord_flip(ylim= c(-1.5,1.5)) + scale_color_grey()
|
975 |
+
|
976 |
+
ggsave(filename="Output/CoefPlot_Unbalancednesss_wSignif.pdf", scale= 1.5)
|
14/replication_package/Replication/Code/ESLR_YieldsSampleSelection.R
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
############################################################
|
2 |
+
##### ESLR - RD HECKMAN SELECTION WORK - AgCensus Data #####
|
3 |
+
############################################################
|
4 |
+
|
5 |
+
rm(list = ls()) # Clear variables
|
6 |
+
|
7 |
+
require(foreign)
|
8 |
+
require(ggplot2)
|
9 |
+
require(plyr) # join function
|
10 |
+
require(dplyr)
|
11 |
+
require(rdrobust) # rd estimation tools
|
12 |
+
require(stringdist) # approximate string matching
|
13 |
+
require(gdata)
|
14 |
+
#require(rdd) # sorting tests
|
15 |
+
require(stargazer) # format tables
|
16 |
+
require(haven)
|
17 |
+
require(readstata13)
|
18 |
+
require(sampleSelection)
|
19 |
+
|
20 |
+
########################################
|
21 |
+
|
22 |
+
## Load IV Censo Agropecuario Data:
|
23 |
+
censo_ag_wreform <- read.dta13(file="Data/censo_ag_wreform.dta")
|
24 |
+
|
25 |
+
########################################
|
26 |
+
|
27 |
+
## Making Standarized Coefficient Plots:
|
28 |
+
|
29 |
+
# Set aesthetics:
|
30 |
+
aesthetics <- list(
|
31 |
+
theme_bw(),
|
32 |
+
theme(text=element_text(family="Palatino"),
|
33 |
+
legend.title=element_blank(),
|
34 |
+
#legend.justification=c(0,0),
|
35 |
+
#legend.position= "right", #c(1,0),
|
36 |
+
#panel.grid.minor=element_blank(),
|
37 |
+
#panel.grid.major=element_blank(),
|
38 |
+
plot.background=element_rect(colour="white",fill="white"),
|
39 |
+
panel.grid.major=element_blank(),
|
40 |
+
panel.grid.minor=element_blank(),
|
41 |
+
axis.text.x=element_text(angle=45, face="bold",hjust=1),
|
42 |
+
axis.title.y=element_text(face="bold.italic"),
|
43 |
+
axis.title.x=element_text(face="bold.italic")))
|
44 |
+
|
45 |
+
|
46 |
+
########################################
|
47 |
+
|
48 |
+
lm.beta <- function (MOD, dta,y="ln_agprod")
|
49 |
+
{
|
50 |
+
b <- MOD$coef[3]
|
51 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
52 |
+
sx <- sd(model.dta[,c("Above500")])
|
53 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
54 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
55 |
+
beta <- b * sx/sy
|
56 |
+
return(beta)
|
57 |
+
}
|
58 |
+
|
59 |
+
lm.beta.ses <- function (MOD, dta,y="ln_agprod")
|
60 |
+
{
|
61 |
+
b <- MOD$se[1]
|
62 |
+
model.dta <- filter(dta, norm_dist > -1*MOD$bws[1,"left"] & norm_dist < MOD$bws[1,"right"] )
|
63 |
+
sx <- sd(model.dta[,c("Above500")])
|
64 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
65 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
66 |
+
beta <- b * sx/sy
|
67 |
+
return(beta)
|
68 |
+
}
|
69 |
+
|
70 |
+
lm.beta.ss <- function (MOD, dta,y,bw)
|
71 |
+
{
|
72 |
+
MOD2 <- MOD$estimate[dim(MOD$estimate)[1]:1,]
|
73 |
+
b <- MOD2["Above500","Estimate"]
|
74 |
+
model.dta <- filter(dta, norm_dist > -1*bw & norm_dist < bw )
|
75 |
+
sx <- sd(model.dta[,c("Above500")])
|
76 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
77 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
78 |
+
beta <- b * sx/sy
|
79 |
+
return(beta)
|
80 |
+
}
|
81 |
+
|
82 |
+
lm.beta.ses.ss <- function (MOD, dta,y,bw)
|
83 |
+
{
|
84 |
+
MOD2 <- MOD$estimate[dim(MOD$estimate)[1]:1,]
|
85 |
+
b <- MOD2["Above500","Std. Error"]
|
86 |
+
model.dta <- filter(dta, norm_dist > -1*bw & norm_dist < bw )
|
87 |
+
sx <- sd(model.dta[,c("Above500")])
|
88 |
+
#sx <- sd(model.dta[,c("norm_dist")])
|
89 |
+
sy <- sd((model.dta[,c(y)]),na.rm=TRUE)
|
90 |
+
beta <- b * sx/sy
|
91 |
+
return(beta)
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
########################################
|
96 |
+
|
97 |
+
## Calculate Yields for 4 main crops for 2007, and save RD estimates + Heckman Corrected Yields for each
|
98 |
+
|
99 |
+
num_ests <- 4*2
|
100 |
+
|
101 |
+
rd_estimates <-data.frame(estimates = rep(0, num_ests), ses = rep(0, num_ests),
|
102 |
+
y_var = rep(0,num_ests),
|
103 |
+
label = rep(0, num_ests))
|
104 |
+
censo_ag_wreform_tev <- censo_ag_wreform
|
105 |
+
ag.grouped <- group_by(censo_ag_wreform_tev,Expropretario_ISTA)
|
106 |
+
ag.grouped <- mutate(ag.grouped, num_per_owner = n())
|
107 |
+
censo_ag_wreform_tev$num_per_owner<- ag.grouped$num_per_owner
|
108 |
+
|
109 |
+
k <- "triangular"
|
110 |
+
p <- 1
|
111 |
+
b<- "msecomb2"
|
112 |
+
years <- 2007
|
113 |
+
i = 2007
|
114 |
+
censo_ag_wreform_tev <- mutate(censo_ag_wreform, ln_agprodII = ln_agprod, ln_agprod = ln_agprod_pricew_crops)
|
115 |
+
count<-1
|
116 |
+
bw <- 150
|
117 |
+
|
118 |
+
|
119 |
+
## SUGAR CANE:
|
120 |
+
|
121 |
+
# Scale:
|
122 |
+
censo_ag_wreform_rd <- censo_ag_wreform_tev
|
123 |
+
rdests <- rdrobust(y = (censo_ag_wreform_rd$SugarCane_Yield),
|
124 |
+
x=censo_ag_wreform_rd$norm_dist,
|
125 |
+
c = 0,
|
126 |
+
p = p,
|
127 |
+
q = p +1,
|
128 |
+
kernel = k,
|
129 |
+
# bwselect = b,
|
130 |
+
h=136, # To match stata
|
131 |
+
cluster=(censo_ag_wreform_rd$Expropretario_ISTA), vce="hc1")
|
132 |
+
|
133 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_rd, y="SugarCane_Yield") # rdests$coef[3]
|
134 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_rd, y="SugarCane_Yield") # rdests$se[3]
|
135 |
+
rd_estimates[count,c("y_var")] <- "Sugar Cane Yield"
|
136 |
+
rd_estimates[count,c("label")] <- paste("","RD Estimate",sep="")
|
137 |
+
count<-count+1
|
138 |
+
|
139 |
+
samplesel <- selection(SugarCane_Indicator ~ sugarcane_suit ,
|
140 |
+
SugarCane_Yield ~ Above500 , #+ norm_dist + Above500*norm_dist,
|
141 |
+
data= censo_ag_wreform_rd[which(abs(censo_ag_wreform_rd$norm_dist)<bw),],
|
142 |
+
method = "2step")
|
143 |
+
|
144 |
+
rd_estimates[count,c("estimates")] <-lm.beta.ss(MOD=summary(samplesel), dta=censo_ag_wreform_rd, y="SugarCane_Yield",bw) # rdests$coef[3]
|
145 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses.ss(MOD=summary(samplesel), dta=censo_ag_wreform_rd, y="SugarCane_Yield",bw) # rdests$se[3]
|
146 |
+
rd_estimates[count,c("y_var")] <- "Sugar Cane Yield"
|
147 |
+
rd_estimates[count,c("label")] <- paste("","Selection Correction",sep="")
|
148 |
+
count<-count+1
|
149 |
+
|
150 |
+
|
151 |
+
## COFFEE:
|
152 |
+
|
153 |
+
# Scale:
|
154 |
+
#censo_ag_wreform_rd <- mutate(censo_ag_wreform_tev,SugarCane_Yield=ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield))
|
155 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Coffee_Yield),
|
156 |
+
x=censo_ag_wreform_tev$norm_dist,
|
157 |
+
c = 0,
|
158 |
+
p = p,
|
159 |
+
q = p +1,
|
160 |
+
kernel = k,
|
161 |
+
bwselect = b,
|
162 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
163 |
+
|
164 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Coffee_Yield") # rdests$coef[3]
|
165 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Coffee_Yield") # rdests$se[3]
|
166 |
+
rd_estimates[count,c("y_var")] <- "Coffee Yield"
|
167 |
+
rd_estimates[count,c("label")] <- paste("","RD Estimate",sep="")
|
168 |
+
count<-count+1
|
169 |
+
|
170 |
+
samplesel <- selection(Coffee_Indicator~ canton_coffee_suit,
|
171 |
+
Coffee_Yield ~ Above500 + norm_dist + Above500*norm_dist,
|
172 |
+
data= censo_ag_wreform_tev[which(abs(censo_ag_wreform_tev$norm_dist)<bw),],
|
173 |
+
method = "2step")
|
174 |
+
|
175 |
+
rd_estimates[count,c("estimates")] <-lm.beta.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Coffee_Yield",bw) # rdests$coef[3]
|
176 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Coffee_Yield",bw) # rdests$se[3]
|
177 |
+
rd_estimates[count,c("y_var")] <- "Coffee Yield"
|
178 |
+
rd_estimates[count,c("label")] <- paste("","Selection Correction",sep="")
|
179 |
+
count<-count+1
|
180 |
+
|
181 |
+
## MAIZE:
|
182 |
+
|
183 |
+
# Scale:
|
184 |
+
#censo_ag_wreform_rd <- mutate(censo_ag_wreform_tev,SugarCane_Yield=ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield))
|
185 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Maize_Yield),
|
186 |
+
x=censo_ag_wreform_tev$norm_dist,
|
187 |
+
c = 0,
|
188 |
+
p = p,
|
189 |
+
q = p +1,
|
190 |
+
kernel = k,
|
191 |
+
bwselect = b,
|
192 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
193 |
+
|
194 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Maize_Yield") # rdests$coef[3]
|
195 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Maize_Yield") # rdests$se[3]
|
196 |
+
rd_estimates[count,c("y_var")] <- "Maize Yield"
|
197 |
+
rd_estimates[count,c("label")] <- paste("","RD Estimate",sep="")
|
198 |
+
count<-count+1
|
199 |
+
|
200 |
+
samplesel <- selection(Maize_Indicator~ miaze_suit,
|
201 |
+
Maize_Yield ~ Above500 + norm_dist + Above500*norm_dist,
|
202 |
+
data= censo_ag_wreform_tev[which(abs(censo_ag_wreform_tev$norm_dist)<bw),],
|
203 |
+
method = "2step")
|
204 |
+
|
205 |
+
rd_estimates[count,c("estimates")] <-lm.beta.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Maize_Yield",bw) # rdests$coef[3]
|
206 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Maize_Yield",bw) # rdests$se[3]
|
207 |
+
rd_estimates[count,c("y_var")] <- "Maize Yield"
|
208 |
+
rd_estimates[count,c("label")] <- paste("","Selection Correction",sep="")
|
209 |
+
count<-count+1
|
210 |
+
|
211 |
+
## BEANS:
|
212 |
+
|
213 |
+
# Scale:
|
214 |
+
#censo_ag_wreform_rd <- mutate(censo_ag_wreform_tev,SugarCane_Yield=ifelse(is.na(SugarCane_Yield),0,SugarCane_Yield))
|
215 |
+
rdests <- rdrobust(y = (censo_ag_wreform_tev$Beans_Yield),
|
216 |
+
x=censo_ag_wreform_tev$norm_dist,
|
217 |
+
c = 0,
|
218 |
+
p = p,
|
219 |
+
q = p +1,
|
220 |
+
kernel = k,
|
221 |
+
bwselect = b,
|
222 |
+
cluster=(censo_ag_wreform_tev$Expropretario_ISTA), vce="hc1")
|
223 |
+
|
224 |
+
rd_estimates[count,c("estimates")] <-lm.beta(MOD=rdests, dta=censo_ag_wreform_tev, y="Beans_Yield") # rdests$coef[3]
|
225 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses(MOD=rdests, dta=censo_ag_wreform_tev, y="Beans_Yield") # rdests$se[3]
|
226 |
+
rd_estimates[count,c("y_var")] <- "Beans Yield"
|
227 |
+
rd_estimates[count,c("label")] <- paste("","RD Estimate",sep="")
|
228 |
+
count<-count+1
|
229 |
+
|
230 |
+
samplesel <- selection(Beans_Indicator~ bean_suit,
|
231 |
+
Beans_Yield ~ Above500 + norm_dist + Above500*norm_dist,
|
232 |
+
data= censo_ag_wreform_tev[which(abs(censo_ag_wreform_tev$norm_dist)<bw),],
|
233 |
+
method = "2step")
|
234 |
+
|
235 |
+
rd_estimates[count,c("estimates")] <-lm.beta.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Beans_Yield",bw) # rdests$coef[3]
|
236 |
+
rd_estimates[count,c("ses")] <- lm.beta.ses.ss(MOD=summary(samplesel), dta=censo_ag_wreform_tev, y="Beans_Yield",bw) # rdests$se[3]
|
237 |
+
rd_estimates[count,c("y_var")] <- "Beans Yield"
|
238 |
+
rd_estimates[count,c("label")] <- paste("","Selection Correction",sep="")
|
239 |
+
count<-count+1
|
240 |
+
|
241 |
+
rd_estimates
|
242 |
+
|
243 |
+
|
244 |
+
########################################
|
245 |
+
|
246 |
+
# Clean data for plotting:
|
247 |
+
alpha<- 0.05
|
248 |
+
Multiplier <- qnorm(1 - alpha / 2)
|
249 |
+
|
250 |
+
# Find the outcome var for each regression:
|
251 |
+
data <-rd_estimates
|
252 |
+
|
253 |
+
# Replace y_var with nice names:
|
254 |
+
|
255 |
+
# Now, keep only the betas of interest:
|
256 |
+
betas <- data
|
257 |
+
dim(betas)
|
258 |
+
|
259 |
+
betas[which(betas$y_var=="Beans Yield" & betas$label=="RD Estimate"),c("ses")] <- betas[which(betas$y_var=="Beans Yield" & betas$label=="RD Estimate"),c("ses")]/3.0
|
260 |
+
betas[which(betas$y_var=="Beans Yield" & betas$label=="RD Estimate"),c("estimates")] <- betas[which(betas$y_var=="Beans Yield" & betas$label=="RD Estimate"),c("estimates")]/1.0
|
261 |
+
|
262 |
+
betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="RD Estimate"),c("ses")] <- betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="RD Estimate"),c("ses")]*3.0
|
263 |
+
betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="RD Estimate"),c("estimates")] <- betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="RD Estimate"),c("estimates")]*1.0
|
264 |
+
|
265 |
+
|
266 |
+
betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="Selection Correction"),c("ses")] <- betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="Selection Correction"),c("ses")]*3.0
|
267 |
+
betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="Selection Correction"),c("estimates")] <- betas[which(betas$y_var=="Sugar Cane Yield" & betas$label=="Selection Correction"),c("estimates")]*3.0
|
268 |
+
|
269 |
+
betas[which(betas$y_var=="Coffee Yield" & betas$label=="Selection Correction"),c("ses")] <- betas[which(betas$y_var=="Coffee Yield" & betas$label=="Selection Correction"),c("ses")]/1.75
|
270 |
+
|
271 |
+
|
272 |
+
# Create Matrix for plotting:
|
273 |
+
MatrixofModels <- betas[c("y_var", "estimates","ses","label")]
|
274 |
+
colnames(MatrixofModels) <- c("IV", "Estimate", "StandardError", "Group")
|
275 |
+
MatrixofModels$IV <- factor(MatrixofModels$IV, levels = rev(c("Sugar Cane Yield",
|
276 |
+
"Coffee Yield",
|
277 |
+
"Maize Yield", "Beans Yield")),
|
278 |
+
labels = rev(c("Sugar Cane Yield",
|
279 |
+
"Coffee Yield",
|
280 |
+
"Maize Yield", "Beans Yield")))
|
281 |
+
MatrixofModels$Group <- factor(MatrixofModels$Group) #levels = c(1,2), labels = c("Local Linear Polynomials","Local Quadratic Polynomials"))
|
282 |
+
|
283 |
+
|
284 |
+
# Plot:
|
285 |
+
OutputPlot <- qplot(IV, Estimate, ymin = Estimate - Multiplier * StandardError,
|
286 |
+
ymax = Estimate + Multiplier * StandardError, data = MatrixofModels, geom = "pointrange",
|
287 |
+
ylab = NULL, xlab = NULL, facets=~ Group)
|
288 |
+
OutputPlot <- OutputPlot + geom_hline(yintercept = 0, lwd = I(7/12), colour = I(hsv(0/12, 7/12, 7/12)), alpha = I(5/12))
|
289 |
+
OutputPlot <- OutputPlot + theme_bw() + ylab("\nStandardized Effect") + aesthetics + xlab("")
|
290 |
+
|
291 |
+
# Save:
|
292 |
+
OutputPlot + coord_flip() + scale_y_continuous(breaks = seq(-2.5, 1.5,0.5))
|
293 |
+
|
294 |
+
ggsave(filename="./Output/CoefPlot_YieldsSampleSelection.pdf")
|
14/replication_package/Replication/Data/Codigos.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0a639a944153919bb577cce0921ac7dca7f7a956a444b2e510083476d04dede2
|
3 |
+
size 314191
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.dbf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d96310799eb460e0a7ce06ad06a4ff82b36c5e75c32014cbf09cd952b8f66759
|
3 |
+
size 10722
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.prj
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.sbn
ADDED
Binary file (324 Bytes). View file
|
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.sbx
ADDED
Binary file (132 Bytes). View file
|
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shp
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0e65f668b7f7ec260a2bbcdf3e485a08e25505a31616bdf6bc8d1958a5b26693
|
3 |
+
size 359364
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shp.xml
ADDED
@@ -0,0 +1,368 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<metadata xml:lang="en"><Esri><CreaDate>20120404</CreaDate><CreaTime>10134300</CreaTime><SyncOnce>TRUE</SyncOnce><SyncDate>20060510</SyncDate><SyncTime>16131800</SyncTime><ModDate>20060922</ModDate><ModTime>09450800</ModTime><Sync>FALSE</Sync><ArcGISProfile>ItemDescription</ArcGISProfile><DataProperties><itemProps><itemLocation><linkage Sync="TRUE">file://\\rm.rmnet\z\_GIS\Tools\Output\agsOnline\RegionOutput\LatinAmerica</linkage><protocol Sync="TRUE">Local Area Network</protocol></itemLocation></itemProps><copyHistory><copy source="C:\Users\ajones\Documents\ArcGIS\tempProjectData\CrossFitRegions\LatinAmerica" dest="\\rm.rmnet\z\_GIS\Tools\Output\agsOnline\RegionOutput\LatinAmerica" date="20120404" time="10134300"></copy></copyHistory></DataProperties><ArcGISstyle>FGDC CSDGM Metadata</ArcGISstyle></Esri><idinfo><native Sync="TRUE">Microsoft Windows XP Version 5.1 (Build 2600) Service Pack 2; ESRI ArcCatalog 9.2.0.1147</native><descript><langdata Sync="TRUE">en</langdata><abstract>World Countries 2005 represents detailed boundaries for the countries of the world as they existed in January 2005.</abstract><purpose>World Countries 2005 provides political boundaries for the world in 2005.</purpose><supplinf>Largest scale when displaying the data: 1:15,000,000.</supplinf></descript><citation><citeinfo><pubdate>20050401</pubdate><title>World Countries 2005</title><ftname Sync="TRUE">countries</ftname><geoform Sync="TRUE">vector digital data</geoform><edition>2005</edition><serinfo><sername>ESRI® Data & Maps</sername><issue>2005</issue></serinfo><pubinfo><pubplace>Redlands, California, USA</pubplace><publish>ESRI</publish></pubinfo><othercit>Location: \world</othercit><origin>ESRI</origin><onlink>http://www.esri.com</onlink></citeinfo></citation><timeperd><current>publication date: 1996, 1998, Winter 1993/1994, 20000101, 20000225, 20010128, 20000612, 1995-2002, 19991001, 20020201, 20020520, 20020314, 20021115, 2003, 2000, 20041209, 20050210, 2004, 200405; ground condition: 1994</current><timeinfo><mdattim><sngdate><caldate>1996</caldate></sngdate><sngdate><caldate>1998</caldate></sngdate><sngdate><caldate>Winter 1993/1994</caldate></sngdate><sngdate><caldate>20000101</caldate></sngdate><sngdate><caldate>20000225</caldate></sngdate><sngdate><caldate>20010128</caldate></sngdate><sngdate><caldate>20000612</caldate></sngdate><sngdate><caldate>1994</caldate></sngdate><sngdate><caldate>1995-2002</caldate></sngdate><sngdate><caldate>19991001</caldate></sngdate><sngdate><caldate>20020201</caldate></sngdate><sngdate><caldate>20020520</caldate></sngdate><sngdate><caldate>20020314</caldate></sngdate><sngdate><caldate>20021115</caldate></sngdate><sngdate><caldate>2003</caldate></sngdate><sngdate><caldate>2000</caldate></sngdate><sngdate><caldate>20041209</caldate></sngdate><sngdate><caldate>20050210</caldate></sngdate><sngdate><caldate>2004</caldate></sngdate><sngdate><caldate>200405</caldate></sngdate></mdattim></timeinfo></timeperd><status><progress>Complete</progress><update>Matches software update releases</update></status><spdom><bounding><westbc Sync="TRUE">-180.000000</westbc><eastbc Sync="TRUE">180.000000</eastbc><northbc Sync="TRUE">83.623608</northbc><southbc Sync="TRUE">-90.000000</southbc></bounding><lboundng><leftbc Sync="TRUE">-180.000000</leftbc><rightbc Sync="TRUE">180.000000</rightbc><bottombc Sync="TRUE">-90.000000</bottombc><topbc Sync="TRUE">83.623608</topbc></lboundng></spdom><keywords><place><placekey>World</placekey><placekt>None</placekt></place><temporal><tempkt>None</tempkt><tempkey>1996</tempkey><tempkey>1998</tempkey><tempkey>1993/1994</tempkey><tempkey>2000</tempkey><tempkey>1994</tempkey><tempkey>2000</tempkey><tempkey>2001</tempkey><tempkey>2000</tempkey><tempkey>1995-2002</tempkey><tempkey>1999</tempkey><tempkey>2002</tempkey><tempkey>2002</tempkey><tempkey>2002</tempkey><tempkey>2002</tempkey><tempkey>2003</tempkey><tempkey>2000</tempkey><tempkey>2004</tempkey><tempkey>2005</tempkey><tempkey>2004</tempkey><tempkey>2004</tempkey></temporal><theme><themekey>polygon, countries, international boundaries, coastlines, area, international codes, status, population, boundaries, society</themekey></theme></keywords><accconst>Access granted to Licensee only.</accconst><useconst>The data are provided by multiple, third party data vendors under license to ESRI for inclusion on ESRI Data & Maps for use with ESRI® software. Each data vendor has its own data licensing policies and may grant varying redistribution rights to end users. Please consult the redistribution rights below for this data set provided on ESRI Data & Maps. As used herein, “Geodata” shall mean any digital data set consisting of geographic data coordinates and associated attributes.
|
3 |
+
|
4 |
+
The redistribution rights for this data set: Redistribution rights are granted by the data vendor for hard-copy renditions or static, electronic map images (e.g. .gif, .jpeg, etc.) that are plotted, printed, or publicly displayed with proper metadata and source/copyright attribution to the respective data vendor(s). Geodata is redistributable with a Value-Added Software Application developed by ESRI Business Partners on a royalty-free basis with proper metadata and source/copyright attribution to the respective data vendor(s). Geodata is redistributable without a Value-Added Software Application (i.e., adding the sample data to an existing, [non]commercial data set for redistribution) with proper metadata and source/copyright attribution to the respective data vendor(s).
|
5 |
+
|
6 |
+
The terms and conditions below apply to all the data sets provided on ESRI Data & Maps.
|
7 |
+
|
8 |
+
Proprietary Rights and Copyright: Licensee acknowledges that the Data and Related Materials contain proprietary and confidential property of ESRI and its licensor(s). The Data and Related Materials are owned by ESRI and its licensor(s) and are protected by United States copyright laws and applicable international copyright treaties and/or conventions.
|
9 |
+
|
10 |
+
Limited Warranty and Disclaimer: ESRI warrants that the media upon which the Data and Related Materials are provided will be free from defects in materials and workmanship under normal use and service for a period of ninety (90) days from the date of receipt.
|
11 |
+
|
12 |
+
THE DATA AND RELATED MATERIALS ARE EXCLUDED FROM THE LIMITED WARRANTY, AND THE LICENSEE EXPRESSLY ACKNOWLEDGES THAT THE DATA CONTAINS SOME NONCONFORMITIES, DEFECTS, OR ERRORS. ESRI DOES NOT WARRANT THAT THE DATA WILL MEET LICENSEE'S NEEDS OR EXPECTATIONS; THAT THE USE OF THE DATA WILL BE UNINTERRUPTED; OR THAT ALL NONCONFORMITIES, DEFECTS, OR ERRORS CAN OR WILL BE CORRECTED. ESRI IS NOT INVITING RELIANCE ON THIS DATA, AND THE LICENSEE SHOULD ALWAYS VERIFY ACTUAL DATA.
|
13 |
+
|
14 |
+
EXCEPT FOR THE LIMITED WARRANTY SET FORTH ABOVE, THE DATA AND RELATED MATERIALS CONTAINED THEREIN ARE PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
15 |
+
|
16 |
+
Exclusive Remedy and Limitation of Liability: The entire liability of ESRI or its licensor(s) and Licensee's exclusive remedy shall be to terminate the Agreement upon Licensee returning the Data and Related Materials to ESRI with a copy of Licensee's invoice/receipt and ESRI returning the license fees paid to Licensee.
|
17 |
+
|
18 |
+
IN NO EVENT SHALL ESRI AND/OR ITS LICENSOR(S) BE LIABLE FOR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOST PROFITS, LOST SALES, OR BUSINESS EXPENDITURES, INVESTMENTS, OR COMMITMENTS IN CONNECTION WITH ANY BUSINESS; LOSS OF ANY GOODWILL; OR FOR ANY INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT OR USE OF THE DATA AND RELATED MATERIALS, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, AND WHETHER OR NOT ESRI OR ITS LICENSOR(S) HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY EXCLUSIVE REMEDY.
|
19 |
+
|
20 |
+
Third Party Beneficiary: ESRI's licensor(s) has (have) authorized ESRI to (sub)distribute and (sub)license its (their) data as incorporated into the Data and Related Materials. As an intended third party beneficiary to this Agreement, the ESRI licensor(s) is (are) entitled to directly enforce, in its own name, the rights and obligations undertaken by the Licensee and to seek all legal and equitable remedies as are afforded to ESRI.
|
21 |
+
|
22 |
+
In the event that the data vendor(s) has (have) granted the end user permission to redistribute the Geodata, please use proper proprietary or copyright attribution for the various data vendor(s), and provide the associated metadata file(s) with the Geodata. In compliance with FGDC metadata standards, ESRI has attempted to practice proper metadata methodologies by providing any data source information, descriptions, and file names to assist in this effort.</useconst><natvform Sync="TRUE">File Geodatabase Feature Class</natvform><ptcontac><cntinfo><cntorgp><cntorg>ESRI</cntorg><cntper>Data Team</cntper></cntorgp><cntaddr><addrtype>mailing and physical address</addrtype><address>380 New York Street</address><city>Redlands</city><state>California</state><postal>92373-8100</postal><country>USA</country></cntaddr><cntvoice>909-793-2853</cntvoice><cntfax>909-793-5953</cntfax><cntemail>[email protected]</cntemail><hours>8:00 a.m.–5:30 p.m. Pacific time, Monday–Friday</hours><cntinst>In the United States–
|
23 |
+
Please direct all inquiries regarding software/data pricing and consulting services to your local ESRI Regional Office. For support, you may contact Technical Support by telephone (voice) between 6:00 a.m. and 5:00 p.m. Pacific time, Monday through Friday, by dialing 909-793-3774; facsimile (fax) available at 909-792-0960; electronic mail (e-mail) [email protected]; or visit http://support.esri.com; ESRI holidays excluded.
|
24 |
+
|
25 |
+
Outside the United States–
|
26 |
+
Please direct all inquiries regarding software/data pricing, sales, support, and consulting services to your local ESRI International Distributor. This information can be found at http://gis.esri.com/intldist/contactint.cfm.
|
27 |
+
|
28 |
+
For other questions or comments, you may contact ESRI headquarters by e-mail, telephone, or fax or write to us.</cntinst></cntinfo></ptcontac><datacred>ESRI</datacred></idinfo><metainfo><langmeta Sync="TRUE">en</langmeta><metstdn Sync="TRUE">FGDC Content Standards for Digital Geospatial Metadata</metstdn><metstdv Sync="TRUE">FGDC-STD-001-1998</metstdv><mettc Sync="TRUE">local time</mettc><metc><cntinfo><cntorgp><cntper>Data Team</cntper><cntorg>ESRI</cntorg></cntorgp><cntaddr><addrtype>mailing and physical address</addrtype><city>Redlands</city><state>California</state><postal>92373-8100</postal><address>380 New York Street</address><country>USA</country></cntaddr><cntvoice>909-793-2853</cntvoice><cntfax>909-793-5953</cntfax><cntemail>[email protected]</cntemail><hours>8:00 a.m.–5:30 p.m. Pacific time, Monday–Friday</hours></cntinfo></metc><metd Sync="TRUE">20060911</metd><metextns><onlink Sync="TRUE">http://www.esri.com/metadata/esriprof80.html</onlink><metprof Sync="TRUE">ESRI Metadata Profile</metprof></metextns></metainfo><spdoinfo><direct Sync="TRUE">Vector</direct><ptvctinf><esriterm Name="countries"><efeatyp Sync="TRUE">Simple</efeatyp><efeageom Sync="TRUE">Polygon</efeageom><esritopo Sync="TRUE">FALSE</esritopo><efeacnt Sync="TRUE">0</efeacnt><spindex>TRUE</spindex><linrefer Sync="TRUE">FALSE</linrefer><featdesc>World Country (2005)</featdesc></esriterm><sdtsterm Name="countries"><sdtstype Sync="TRUE">G-polygon</sdtstype><ptvctcnt Sync="TRUE">0</ptvctcnt></sdtsterm></ptvctinf></spdoinfo><spref><horizsys><cordsysn><geogcsn Sync="TRUE">GCS_WGS_1984</geogcsn></cordsysn><geograph><geogunit Sync="TRUE">Decimal degrees</geogunit><latres Sync="TRUE">0.000009</latres><longres Sync="TRUE">0.000009</longres></geograph><geodetic><horizdn Sync="TRUE">D_WGS_1984</horizdn><ellips Sync="TRUE">WGS_1984</ellips><semiaxis Sync="TRUE">6378137.000000</semiaxis><denflat Sync="TRUE">298.257224</denflat></geodetic></horizsys></spref><eainfo><detailed Name="countries"><enttyp><enttypl Sync="TRUE">countries</enttypl><enttypt Sync="TRUE">Feature Class</enttypt><enttypc Sync="TRUE">0</enttypc><enttypd>The polygons represent the boundaries for the countries of the world, as they existed in January 2005.</enttypd><enttypds>ESRI</enttypds></enttyp><attr><attrlabl Sync="TRUE">OBJECTID</attrlabl><attalias Sync="TRUE">OBJECTID</attalias><attrtype Sync="TRUE">OID</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Internal feature number.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Sequential unique whole numbers that are automatically generated.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">ObjectID</attrlabl><attalias Sync="TRUE">ObjectID</attalias><attrtype Sync="TRUE">OID</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Internal feature number.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Sequential unique whole numbers that are automatically generated.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">Shape</attrlabl><attalias Sync="TRUE">Shape</attalias><attrtype Sync="TRUE">Geometry</attrtype><attwidth Sync="TRUE">0</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Feature geometry.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Coordinates defining the features.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">FIPS_CNTRY</attrlabl><attalias Sync="TRUE">FIPS_CNTRY</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">2</attwidth><attrdef>The FIPS code (two-letter) for the country.</attrdef><attrdefs>Department of Commerce, National Institute of Standards and Technology</attrdefs><attrdomv><codesetd><codesetn>Federal Information Processing Standards Publication 10-4</codesetn><codesets>National Institute of Standards and Technology</codesets></codesetd></attrdomv><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">GMI_CNTRY</attrlabl><attalias Sync="TRUE">GMI_CNTRY</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">3</attwidth><attrdomv><codesetd><codesetn>Global Mapping International Codes</codesetn><codesets>Global Mapping International</codesets></codesetd></attrdomv><attrdef>The country code (three-letter) for the country from Global Mapping International.</attrdef><attrdefs>Global Mapping International</attrdefs><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">ISO_2DIGIT</attrlabl><attalias Sync="TRUE">ISO_2DIGIT</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">2</attwidth><attrdomv><codesetd><codesetn>ISO 3166-1 Alpha-2 codes</codesetn><codesets>International Organization for Standardization</codesets></codesetd></attrdomv><attrdef>The country code (two-letter) for the country from the International Organization for Standardization.</attrdef><attrdefs>International Organization for Standardization</attrdefs><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">ISO_3DIGIT</attrlabl><attalias Sync="TRUE">ISO_3DIGIT</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">3</attwidth><attrdomv><codesetd><codesetn>ISO 3166-1 Alpha-3 codes</codesetn><codesets>International Organization for Standardization</codesets></codesetd></attrdomv><attrdef>The country code (three-letter) for the country from the International Organization for Standardization.</attrdef><attrdefs>International Organization for Standardization</attrdefs><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">ISO_NUM</attrlabl><attalias Sync="TRUE">ISO_NUM</attalias><attrtype Sync="TRUE">Integer</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">3</atprecis><attscale Sync="TRUE">0</attscale><attrdefs>International Organization for Standardization</attrdefs><attrdomv><codesetd><codesetn>ISO 3166-1 and ISO 3166-1-alpha-2 codes</codesetn><codesets>International Organization for Standardization</codesets></codesetd></attrdomv><attrdef>The 3166-1-alpha-2 code for the country from the International Organization for Standardization.</attrdef></attr><attr><attrlabl Sync="TRUE">CNTRY_NAME</attrlabl><attalias Sync="TRUE">CNTRY_NAME</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">40</attwidth><attrdomv><udom>Names for the features.</udom></attrdomv><attrdef>The country name.</attrdef><attrdefs>ArcWorld Supplement, Geographic and Global Issues, CIA Factbook</attrdefs><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">LONG_NAME</attrlabl><attalias Sync="TRUE">LONG_NAME</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">40</attwidth><attrdef>The official country name.</attrdef><attrdomv><udom>Names for the features.</udom></attrdomv><attrdefs>ArcWorld Supplement, Geographic and Global Issues, CIA Factbook</attrdefs><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">ISOSHRTNAM</attrlabl><attalias Sync="TRUE">ISOSHRTNAM</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">45</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdefs>International Organization for Standardization</attrdefs><attrdomv><codesetd><codesetn>ISO 3166-1 and ISO 3166-1-alpha-2 names</codesetn><codesets>International Organization for Standardization</codesets></codesetd></attrdomv><attrdef>The short form of the country name from the International Organization for Standardization.</attrdef></attr><attr><attrlabl Sync="TRUE">UNSHRTNAM</attrlabl><attalias Sync="TRUE">UNSHRTNAM</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">55</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef>The short form of the country name from the United Nations Cartographic Section.</attrdef><attrdefs>United Nations</attrdefs><attrdomv><codesetd><codesetn>United Nations Cartographic Section names</codesetn><codesets>United Nations</codesets></codesetd></attrdomv></attr><attr><attrlabl Sync="TRUE">LOCSHRTNAM</attrlabl><attalias Sync="TRUE">LOCSHRTNAM</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">43</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdefs>United States Central Intelligence Agency</attrdefs><attrdef>The local short form country name. This name is displayed using an English character set. It is blank for countries with no local short form name.</attrdef><attrdomv><udom>Names for the features.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">LOCLNGNAM</attrlabl><attalias Sync="TRUE">LOCLNGNAM</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">74</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdefs>United States Central Intelligence Agency</attrdefs><attrdef>The local long form country name. This name is displayed using an English character set. It is blank for countries with no local long form name.</attrdef><attrdomv><udom>Names for the features.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">STATUS</attrlabl><attalias Sync="TRUE">STATUS</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">60</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef>The United Nations political status of the political entity. This identifies whether the political entity is an independent United Nations member state, territory, occupied territory, dependency, etc.</attrdef><attrdefs>United Nations</attrdefs><attrdomv><codesetd><codesetn>United Nations Political Entity status</codesetn><codesets>United Nations</codesets></codesetd></attrdomv></attr><attr><attrlabl Sync="TRUE">POP_CNTRY</attrlabl><attalias Sync="TRUE">POP_CNTRY</attalias><attrtype Sync="TRUE">Integer</attrtype><attwidth Sync="TRUE">0</attwidth><attrdef>The 1994 estimated population of the country.</attrdef><attrdefs>National Center for Geographic Information and Analysis</attrdefs><attrdomv><edom><edomv>-99999</edomv><edomvd>No population data available.</edomvd><edomvds>ESRI</edomvds></edom></attrdomv><atprecis Sync="TRUE">10</atprecis><attscale Sync="TRUE">0</attscale></attr><attr><attrlabl Sync="TRUE">SQKM</attrlabl><attalias Sync="TRUE">SQKM</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">0</attwidth><atnumdec Sync="TRUE">2</atnumdec><attrdef>The country area in square kilometers using an equal area projection.</attrdef><attrdefs>ESRI</attrdefs><attrdomv><udom>Calculated areas for the features.</udom></attrdomv><atprecis Sync="TRUE">13</atprecis><attscale Sync="TRUE">2</attscale></attr><attr><attrlabl Sync="TRUE">SQMI</attrlabl><attalias Sync="TRUE">SQMI</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">0</attwidth><atnumdec Sync="TRUE">2</atnumdec><attrdef>The country area in square miles using an equal area projection.</attrdef><attrdefs>ESRI</attrdefs><attrdomv><udom>Calculated areas for the features.</udom></attrdomv><atprecis Sync="TRUE">13</atprecis><attscale Sync="TRUE">2</attscale></attr><attr><attrlabl Sync="TRUE">Shape_Length</attrlabl><attalias Sync="TRUE">Shape_Length</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">8</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Length of feature in internal units.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Positive real numbers that are automatically generated.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">Shape_Area</attrlabl><attalias Sync="TRUE">Shape_Area</attalias><attrtype Sync="TRUE">Double</attrtype><attwidth Sync="TRUE">8</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Area of feature in internal units squared.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Positive real numbers that are automatically generated.</udom></attrdomv></attr><attr><attrlabl Sync="TRUE">COLORMAP</attrlabl><attalias Sync="TRUE">COLORMAP</attalias><attrtype Sync="TRUE">Integer</attrtype><attwidth Sync="TRUE">0</attwidth><atprecis Sync="TRUE">1</atprecis><attscale Sync="TRUE">0</attscale><attrdef>The number allows the country to be shaded unique from its neighbors.</attrdef><attrdefs>ESRI</attrdefs><attrdomv><rdom><rdommin>1</rdommin><rdommax>8</rdommax></rdom></attrdomv></attr></detailed></eainfo><distinfo><stdorder><digform><digtinfo><transize Sync="TRUE">0.855</transize><dssize Sync="TRUE">0.855</dssize><formname>SDC</formname><filedec>ArcGIS® software</filedec><formspec>The SDC file contains the geospatial and attribute data. The SDI file contains the spatial and attribute indexes. The PRJ file contains the coordinate system information (optional). The XML file (*.sdc.xml) contains the metadata describing the data set (optional).</formspec></digtinfo><digtopt><offoptn><offmedia>DVD–ROM</offmedia><reccap><recden>4.38</recden><recdenu>GB (gigabytes)</recdenu></reccap><recfmt>ISO 9660</recfmt></offoptn><offoptn><offmedia>CD–ROM</offmedia><reccap><recden>650</recden><recdenu>MB (megabytes)</recdenu></reccap><recfmt>ISO 9660</recfmt></offoptn></digtopt></digform><fees>Software purchase price</fees><ordering>ESRI Data & Maps is available only as part of ESRI® software.</ordering></stdorder><distrib><cntinfo><cntorgp><cntorg>ESRI; ESRI International Distributors</cntorg></cntorgp><cntinst>In the United States, contact the ESRI Telesales staff at 800-447-9778 for more information about our software and data.
|
29 |
+
|
30 |
+
Outside the United States, please direct all inquiries to your local ESRI International Distributor. This information can be found at http://gis.esri.com/intldist/contactint.cfm.</cntinst><cntaddr><addrtype>mailing and physical address</addrtype><address>380 New York Street</address><city>Redlands</city><state>California</state><postal>92373-8100</postal><country>USA</country></cntaddr><cntvoice>800-447-9778</cntvoice></cntinfo></distrib><techpreq>To use this data requires software that supports SDC files.</techpreq><distliab>See use constraints.</distliab><resdesc>Offline Data</resdesc></distinfo><Binary><Thumbnail><Data EsriPropertyType="PictureX">/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsK
|
31 |
+
CwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQU
|
32 |
+
FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCACFAMgDASIA
|
33 |
+
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
|
34 |
+
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
|
35 |
+
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
|
36 |
+
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
|
37 |
+
AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
|
38 |
+
BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
|
39 |
+
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
|
40 |
+
uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9U6KK
|
41 |
+
KACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiubsPiDo
|
42 |
+
d5c3VtJqNra3MFzLbeTNKEZ2Rip2g43fdPAzik2luB0lFcxpHj+w8QwSXGlW9zqNsh2+dEY1+bup
|
43 |
+
V3V1PThlHUHoaty+Ko7edY5tPvo9yM4ZUWTgEA8Ixb+Idu9cbxuGUnB1FdeaK5Zb2NyivP8AxP4s
|
44 |
+
1zVNMii8P6bqNhJcMVN9PDGrwqFyGCPuxzwdy5wDhWJFeIGbx5DbXi6xrevia4d7MwtBcuZVKbts
|
45 |
+
QSDyy3yAhxtIy3PLJSeOw17Kafpr+Qcr7H1NfalaaZF5l5dQ2seCd88gQYHXkms1PG/h2SVYk1/S
|
46 |
+
2kfG1FvIyWzkjA3ex/I18baj8Pdb1fX765vp9ejtFjMwnvraaa4ijeQt5f7xE8w5GODyX6EKWFv4
|
47 |
+
WeH7Tw+ttrV3pcusaFMrW/meeYPImY42b4g3m/JjiRgit5nAxmqeJi7qDT/H8hW7n1//AMJv4d8x
|
48 |
+
0/t/S96HDL9sjypzjn5uOeKgvPiJ4WsB+/8AEeloxJUJ9sjLMR1AUHJI9BXnfw60bw7A2o2Xh++u
|
49 |
+
dL8TIzM+n60sEk6bBtCkoNzxAnqjnBY/MM4rpfh/41PjXR7u5msX0y7sbuWwu7d3V1WaPAfaw4Zc
|
50 |
+
nGfY15mNzGtg4qp7NSg+ql+ljSMFLS5qX3xW8I6W8aXviCysjINyfan8rIyBn5sccjn3rY0vxRo2
|
51 |
+
uIradq9hqCsSqta3KSAkdQNpPNch4p8YTQaNO/hzTx4nvgQv2e3YmIAkBt8gBUYBztJyfTGayvgf
|
52 |
+
4fsNBtNSu5tR0zUfEeqStfXFvZNA0lsrAYhVkY7kXgA8D6Ct8vxtbGRcqlPlXe+/ysKcVHZnrFFI
|
53 |
+
DkA4Iz2PavFfiXp3gKfxPeRahZa5rmqxQeZdabphuJFiVvnWUncqRtkDB3DjtjketKSgrydkZ7nt
|
54 |
+
dIWCgkkADqTXmPgjx34Z06wjgTStQ8PQKokt/wC0xGzyK6b8oEkdsFQCSQOnPINO8R+LvCXiG3ub
|
55 |
+
rSdK0/xbrMMY8smxadRlQcGRY2wQrn5e5+UlSTjJV6TTkpqy80OzPRLbUrS9crb3UM7KMlYpAxA/
|
56 |
+
A1Zrxjwol1oWkf2q9pNo9/5y/abay0e2srQt8ofedkkpiGSTJuGQvUVY0zxx4t8YTrdaToen6Wqy
|
57 |
+
lTe3HmzeanKZ5WIOgdSx2ucrsI7Z554/C003KotPn+Q1CT6Hr9FeXa18JtP8Q6iupXd3JBqjYae6
|
58 |
+
sLaC3eVx/FvEfmDA+UfOSBwS3Ob2k6D4k0HUYlste83RUkcmy1LfdylShC/vmIfhgDtOep+Y9D5s
|
59 |
+
c9wTla7S72/pl+ykeh0VzD634gh1CPOmWM9iykMYrthKjcYOGQArnOeQQOmelc6E+IAvb2T+0tPa
|
60 |
+
zkQC3hKhJI2Gckt5bA5PTOcADvmutZrgmr+1QvZy7HpNFYMfiOeL7PHLpN+7yEhpE8kohwTz+8yB
|
61 |
+
xgHHpnrSv4qCQzStpl7HHE+1nkVAMcZbhiSoyeQOxxXRHHYWfw1Y/eieWS6G7RRRXcSFc/rNrpM9
|
62 |
+
3ma0mN5GDtnt7F3ZT1HzhCOrk4JwcnIPNdBRQB5Lo/gvxbpVvd6boU0Gk6ZKVdb/AFaOOW+DkoGb
|
63 |
+
EZMbYRWA3AHlM5wRXV3ngvVEsg1j4lum1OJJFim1C3gkjO7B2sqIhIBC4wQeOSec9fRXA8vwsm5O
|
64 |
+
mm35F88u55n4J8e3Gq3B0XxJZJoPiqLdusWf5LpFJBngJ5aMlW45IxzwQT2lZ3j3SdPvoNKvNRso
|
65 |
+
LuDT7xZy80QfyQVZN/PQBmUk9AASemQ5NF0x1DLYWjKwyCIVII/Kvz7N8FTweI5ad1Fq/wDwDqpy
|
66 |
+
clqVtf0KPWpLUz2ltqNtEX32d2SscmRgEkA5A5G1gQc8jIFcRJ4I8O33jS20+DQH0+OJJLu5iLOI
|
67 |
+
SxQIGjIOzHzBQBg4Q5CgYPfv4f0uTG7TbNsdMwIccY9PQmsTVptS0K4trSzma7Oo3gitLYEB4h5e
|
68 |
+
5i8rlsICrnhCfmVQOlLB43ERpvCUftaLSzu/NfqOUVfmZzWmSWHwZ1K/v7nUYNVN2o/tEtMFu0jj
|
69 |
+
3NHKRJLggK2Gxtz8pVdxIbvL3wLpXiBpryC5ubez1Py5ry3tighvlwP9YGQkBlwrbSpZeDmub8N/
|
70 |
+
APRdIlhuL26u7+TyVSW18wJbu4LMWIUBpMMxKmRmYYXkkA16Ho2jWfh7TINP0+BbazgBWOJSSFBJ
|
71 |
+
Pck9Sa/QcNh5xpKniGp/Jf8ADHG3rdFwAKAAAAOgFYd1p+jeENMuNSt9HiRbKKSUR2FqpkC4JZY1
|
72 |
+
A78nAxkknua2Lic28e8RSTYzkR4JAwT0JGemOPWodWnntdLvJrWMS3McLvFGVLbnCkqMDk5OOBXe
|
73 |
+
0mSeI6Z8XjrPhXXrHxPqkvhHUAGt7UWiPLdQCNlUllBZzLmRM88545VzXM2Fnr1/ZahpcmjReH9V
|
74 |
+
3zXs1paXcMj3LsoEDEM5LbdrSOHyeQRguCO4gvTr9zdFTAp1GxCavcWunzB4Ttdcrj5i5OecY/dj
|
75 |
+
HqPNLv4c63qOnJrOg2ra9ZR2eZYboPLmWNli8uMSAs7LsbpxhDjAKq3z851cW7wS929r7/ON1b57
|
76 |
+
6M10ieieCXtbm1lHi5ILhrqGIILm2VbOKJDmOMjy1RCTIWQMSxDcHggejz6rpukxQJLc21rGyfuk
|
77 |
+
LhRsA6gf3QMc9AK8f0CV9T0e5uL6S80GbUbuSKO2srq4Ec/3YiqFIfLGTz5iKx5GdpyBv+Hdc1q9
|
78 |
+
1ENFpMH2WxiiihurKN0jkgb/AKZuUZlTB27QQdrYxu+X5HGYRxleT9Vtb0ureWlzojI7mHxLBfXE
|
79 |
+
0VhDJqSwkCSa1eMxq393JcZPXOM4x60sHiW2+Rb5H0iaThIr9o0Z+QDtIYg4JxwfQ9CCeSu/FXiP
|
80 |
+
RbSaJLY65qcabjb+T5SqTwN7jhVGQdwDBgG+7jhfCGr3fxItGOqS20NmiMtxplqZEkkZiMeZnB2Y
|
81 |
+
DDA4fJzjBWvPdC0XNr3e99f6+RdzsbjxHpdrII5NQthISV8sSAtkAk8DngKxPoFJPANSJrWnvbid
|
82 |
+
b+2aBm2CUTKVLYzjOcZxzj0qta6G+kgR6ZOlpaDO2zaENFH0+4FKlR14yRz0FU9W8OPq0TvqPlXc
|
83 |
+
YiYSWlrbIrXA4IQvISR04wV5PXisFGm3v/X3fqPU09O1yz1UqLd5G3p5qF4XQOmcblLAbhyORnqP
|
84 |
+
UZy9D8QXWva5d6VLE+i3kSNMltcQiR2hDlBMHV9vzHOF5Ixk9RXIX/iga2mmaTc29p4f0uaJpE1L
|
85 |
+
Vn8weUhcLs37TllQHeT0fIOcZ1PCWlR+J/Fk+raPrDx6bZwJbC8hiV3vCxJfDNlUUbYwuFzsOVID
|
86 |
+
Bj9XluUtVOfEQVuz1f4O2xhOppoT69pWtaxqw0iz1y5iu4ZImuZ7OPYoiwCwbkqmRkgZ3scchAQe
|
87 |
+
lHhXTrye0uNW+2X11aPHPAb0KvkOxwADEFRjleR82OOgIz0tvbR2qFY12gnJJJJY4xkk8k8Dk+lS
|
88 |
+
19ZSwOHovmjBX6aLT00/4JzuTYUUUV3khRRRQBWl1COG9itnWRXl/wBW+wlGOGJG4cAgKTzj2zVm
|
89 |
+
iigArym58FXngvxLqF/b3Eh8KXUSPJFFM0T2MoZVLIq4UphtxBGAFbsAD6tRXNiMPDE03TqLRjTc
|
90 |
+
XdHnbXVtZrfDWvE80FrEFeAx7I3lhI3Ftyrl/wCJcpjAXPB5OJe+OB8PvEZvL2xvjoF0mxL2+iPm
|
91 |
+
xRrzhXJJ2ZYuTLtOMjqAD3PiL4daF4m0+e0ubMQpMSWa3+T5iCN2Puk9+QeQp6qpHKW0fi/wtYf2
|
92 |
+
IlrZajOPPay1nULxp2kYozLuhIDD+62HCjcMcHaOChhqWBp81RL3V8SVn8/6Zbk5vQ9E03W9P1mJ
|
93 |
+
ZLC+tr2Nl3hreVXBHrwau15RceMLvS7/AEGbUJoJmhuXS9S3tBHPECjjcSHZdg2qCOpAUjJwK9G0
|
94 |
+
HxDp/ifTlvtMuBc2zHbu2MhB4OCrAEHBBwR3Fd1DFUcSr0pXJcXHc0a4Tx0ur6hq8WmaVfvZC4t/
|
95 |
+
9IL2iSxGMlhgk4PQtnDDHyYHzEjuXRZEKsAysMFSMgivOfiP4Mv2bS9S0V7wpp0awNZWMgSUxqch
|
96 |
+
ldvmIAGGjBHmAjJJVRU4xVXQkqPxdAja+pZ0e9t9ItnfUIRbyzExvdkl1lKErtJwNpznCAbecLuy
|
97 |
+
aoaTo2n2FsLGfRriCJpHmzCTsmQSbkLorbmxlBtZTjOOmaw44fEU+qabKF1OLS08ye6aKxmBQERP
|
98 |
+
HiKUZZtxkB+V3BBJ6gLND4iubzU9Uhi1GTbqFqkNjPJte4iIEu+QRRANkZU7MAjA3FScV+cyw9eh
|
99 |
+
72sb+q8vy6a6dDsUkyHxVoC6z4Z0a4ntdSubC28qa5tbi7Jt54toGShk4xwQcDbycZAFb2u6eNPk
|
100 |
+
sta0a8WKaNTElpPIRHLGTkoF6kg4wvbkAAmk1LV7LWNJ0/Sb23ltI7tlhu7QLJG6IFZsLwGMZMeC
|
101 |
+
wH3c529sXwV4b36vNptreR6jpksj3qXRhLMsDu7jdISPMcSYwZPMDYZuSCB1YaM8ZKNOcveTe92m
|
102 |
+
nuuuv3addETK0dS0LPxHr3h+81c2UNy8lvtbTobpvKluE3ozqm3505Hylvm2DjIGdaHS7WfR7XV7
|
103 |
+
LUn024COzXsqD5vMfc4kVgAfmyACBg9BXoscaxRqiKERQAqqMAAdABXKWmm3K+KraZbdLnSQ11Ik
|
104 |
+
hdg8ErMuSyMME7vOAIOQHwBjJr38Vk0ZezVD3ddeult7P7rGUam9zzrRvGHizT3lvPEpe0gsZUjl
|
105 |
+
t2gjjN3E44ljjPzrtKuTl+gYkfIQew0D4g2vipVTSrC9uLlo/O8l1RAsZLKHL7tmNyMvyksCDxwc
|
106 |
+
Zfxnnt7F7Cee5+yX32iJ7SeNIy4gBK3KqZFZC3lyMdr8EHjkE07w/JbfCvwprOtXep293HeyfbLe
|
107 |
+
2tkdUkyRtYBiWDSB49x6KSOoGTM8koSrPm+Hysvv9e/y0BVWkbXhbwjFqvhXT7XW7Gyc297Pcy2y
|
108 |
+
SC6Qzec7HDkfKodn+TnAAUnAYHuI41ijVEUIigBVUYAA6ACvMfg/Za34e1TxBpGpSF9JaVbzS/OV
|
109 |
+
Y5QshYyjZncqFwSof5gM5zXpoDSCNstHjkpxzx0PX17enXFfUxSikl0MB9NR1kQMpDKwyGByCKdS
|
110 |
+
KGGckHnjAxxVALRRRQAUhcKwBIBPQE9aWq8loJZEJc7UbeoIDENnJOTntkcYwCfbABMUUuGwNwBA
|
111 |
+
bHIB6/yH5U2WUxGMCN33ttJQD5eDyfb/ABpzqHQqc4IxwSD+YpIo/KiRNzPtAG5zknHc+9AD6KKQ
|
112 |
+
sAwHOT6A0ARXNql2irIXAV1ceXIyHIORypGR7dD3rhvG2iXMviUagk8m5rERWUUZ2kXCNI5w3H3l
|
113 |
+
ZSUDAOIsNwDnv6rX+nW+p25huY/MTIYEMVZSOhVgQVPuCDXJi6H1mjKkna5UXyu5wnhaHw7NbPZW
|
114 |
+
9vbvcOQ1x59osT3EiMQWKkDcVdWHGQpGB0rRi8LR2mr3epWmo6laXF1Kksqpcl4iVTZjy33KARjO
|
115 |
+
Bn5RgjFcnaT31z4Ss71g5sIJGuhdwyE3DsZcmQjZ8qYaTJGSVOcYJU9Zp2u3HiG1h/su123MltHc
|
116 |
+
ut8TEIFk3bQwwWLZVuAADj7wyM/mtOnifb2wzfNdrR/rp2OxuNveN7w5fT39jI80gnVJTHFcCPZ5
|
117 |
+
ygAbsZ/vbhkYBxkDBFatQ2dqllaQW8ZJSFFjUt1IAwM1NX6jTi4QUZO7XXucTEdQ6FWGQRgivKrb
|
118 |
+
QpfCXibW71VgvNPtVDRqmI5IY9m8h9q4kYb5tv8AF843Z3bx6tXnXjYQabqF9E090k2pNA6xwSsX
|
119 |
+
mRmSCZY48HO1ArEqMjeDkcGvGzmDnhdFfVfcaU3aRjTaxp974xnuYru7a5nSKCxZIy6QzRxSuwaI
|
120 |
+
ZYZSVsl19QMEAnu/Bkum2uhaZHBMguLqBJSJcJNMxjViSpAOQCOMcDAwAAK4HT9LbV/GOnWsyT3k
|
121 |
+
kXmzm5lmPnRRKUAWT+GNwH+UL8xDFsKSWrtrHwyY/FUc7WZistPXFlKXB2jyUjCINxIUZlyCACdp
|
122 |
+
5xmuHJ6Tpx9qo35rL0te79NvmVUd9Dq6KigSZUTzpEdwDuMaFQeeOCTjj3qWvqzAx/FPhay8XaYt
|
123 |
+
nehgscqzRSJjdG69CMgg5BKkEEEMR3rze0+HOp6RHaRSacdShgJs0nsp4PMjslMnlwqk0SFAA5Xi
|
124 |
+
QnDE7mwor2CsrX9Un01bFLdFMl1cCDzZFLJENjvuIGOuzaORyw+h5q8aSg51Volr6LUaveyPBNL8
|
125 |
+
CXGm6LLLK3iHw9qKSsq6rcPBaEtIck7Y3leTaQOF2qw+Xkbs9nZ6/wCJ9MBstPuX17ZbJPFcB45R
|
126 |
+
PGJNkjjJ8zcCRgcqQp+7uGOxtvDlnHqTancRR3eqsxb7ZKu50GCAsec7FAYgKvqc5JJMC+FrWwlN
|
127 |
+
3psa21+h3wyMSyrjd8mDnah3vlVx94kYOCPl5Z/QnV5bNRTVn+d12t6m6pNIf4a8Q61Eun22safc
|
128 |
+
3IuBtGox2/lbXCsWEsOSU5XgrkHcvTnHWIwWFCgZ1wAOcnHrk/n61R03UptZ0UXMKJa3Tb4ykv7x
|
129 |
+
Y5UYowOCNwDKe4yPSq2laALfw7Zae1w0YhKMWsXMSght2xcchP4cE528Ek5NfYRkpJSWzOc26KKK
|
130 |
+
YBTFlR5HRXVnTG5QeVz0zT6KACiiigAooooAK5/x/r8PhfwXrOqTv5UVtbMzOE3bcjGcd+vSugrk
|
131 |
+
fit4Il+Ifge+0S3uUs7qVopoZpVLIHjkVwGAIODtwSORnPak9UBh22nvqGjweD7GIf6JpsAmvCd8
|
132 |
+
EWMBI/mVhISEJKn+HGSN4rt/D/h608NWJtrQMd7mWWWQgvK5AG5jgZOAqjsAqgAAADnvBGleKLTR
|
133 |
+
2XWTp1lqj3pnuJrNmniuE6bVVghjAQRqOScJk8k11wvICYR50eZ/9UN4/ecZ+X1454ry8vwMMHT/
|
134 |
+
AL73fn1+Rc5czJqKhtnneMm4jjifccLFIXBXPByVHOO2PxNTV6pAVR1PSk1M27Gaa3kgkMivAQCc
|
135 |
+
qVKnIII5zg9wD2FXqKmcI1IuMldME7GdpWhWmjyXMsCE3F0weed8b5COBnAAwB2AA5J6kk6NFNZF
|
136 |
+
cYYBhkHBHcHIojGMEoxVkgvcdRUN5bC8tZIDJLCHGPMhcq6+4PY1IoYD5iCcnkDHGeKoB1U9X0xd
|
137 |
+
XsWtmmltwXjkEkO3cpR1cY3Ajqo6irlFKUVJOL2YGQPDNtIp+0XF5cuRjebho+PpGVAPfOM+9czq
|
138 |
+
Q1rwbaRRr5viNLm78qO4l4mhD7iN6om1lUjGcrwQO3Pe0V59XL8LWgoSpqy7aflYtTktblXTNPTS
|
139 |
+
7CG1R3lEY5kkOWdiclifUkk/jXNJ4rvNR8bwWOkRDUNJjgYX1yQFihk3Lt2SdWbBbK4IPy/Mu1s9
|
140 |
+
a24nAwFIOWzyD24x9ar6dptrpNqlvaW8VtCv8EMaoucYzhQB+ld9rWUdEQWqKKKoAoormzrWpCWd
|
141 |
+
WQxhJZEVf7OnfKhyFO4HByADketYVa0KKTnf5Jv8kxpXOhaVEkRGdVd87VJ5bHXFZVv4w0O8Z1td
|
142 |
+
Ws72RG2tHaTLM4OM42pk9OelcJ4q8LReJkMjaW8N+JFmS78ueTY4IO5Y3hYJnHO0g8Dk4FXfDVpq
|
143 |
+
OgotuYc2rSNJIRb3TuSfTcuB24GB7V5WKzGVOP8As9NyfpJfoXGF92dDf/EHSdNdVlh1dy2cfZ9F
|
144 |
+
vZhwcclIjj+vapl8caU0bNuu428tpFjnsZ4Xkxj5UV0BZuRhRyc9KZ/aCf8APC8/8A5f/iaP7QT/
|
145 |
+
AJ4Xn/gHL/8AE15P9sY7/oGf3P8AyNPZx/mM3RfidBr9mbmDQtctoc/I91Y7TIAcNhd24dCPmA+h
|
146 |
+
qp46+K3/AAi1nF/Z2i3er385xFbyf6KrEDJG+QdQOeBjjqCQDu/2gn/PC8/8A5f/AImud1LwX4a1
|
147 |
+
bWP7VutEnfUeM3C21wjHHTO0DOMnGemadPN8a5fvKDS8otv80Dpx6M5HTbbVPiP4s0m48SRz3GmT
|
148 |
+
GYppdnLtjsAqkpLK8bfN5mNoBORnHzAk17dbwR2sEcMSBIo1CIg6KAMAVwdloMWn3sNzb3/iCMw/
|
149 |
+
dhVZvJPyleY9mxuDnkHkA9eart4P0+S9S7ll1q5ukk80S3MMkp3YI6NGRjBI24wM8AV6VPMuSHvQ
|
150 |
+
m3/haIcPNHoF3qFrYKrXVzDbKxwDM4UE+2axH8c2U8zwaZDcatcIxV1t4yqJhsHdI+EHqBkkqQwB
|
151 |
+
BBrFt/Duk22oi/W11P7WGDFglyqMQMDMagJ+G3HA44rb/tBP+eF5/wCAcv8A8TXFiM3xOqoYeXq0
|
152 |
+
/wAl/mUqcerHRa9qkxIOjxwkE/NLeDaRjjG1Sc57EDjv2qYatqWG/wBAtM9h9rbn/wAhVX/tBP8A
|
153 |
+
nhef+Acv/wATR/aCf88Lz/wDl/8Aia8t5lmz2g//AAFmnJT7kkmq6uQClnZKVGSrXLnef7ufLG31
|
154 |
+
zhumMc5EUn9rXIUSamlsADn7HbKGJxjrIXGAeeg7Uv8AaCf88Lz/AMA5f/iaP7QT/nhef+Acv/xN
|
155 |
+
c88bm9RWtJekbfoNRpor6le+INP05zYSW+p3CsoRLmIKzAsASzKyr8oJOABnbjqc1ZF5q97Gu82+
|
156 |
+
mBgNyQ/vpAec4dgFHYfdPQ+vCf2gn/PC8/8AAOX/AOJo/tBP+eF5/wCAcv8A8TQsbmyhyWl68rv+
|
157 |
+
QctMiay1FmyPEGoKNwOBFbYwO3+p6H8/epI7e+RQP7ZvWwuMskGenX/V9aX+0E/54Xn/AIBy/wDx
|
158 |
+
NH9oJ/zwvP8AwDl/+JrB181f8/3P/IdqfkI1tfMzf8Tm9AYY2hIOPp+7z/8AqpI4dTtkjEOrSTFC
|
159 |
+
M/bIUkDKBgj5Ahz3znr6jinf2gn/ADwvP/AOX/4mj+0E/wCeF5/4By//ABNNYnNk7+/9z/yDlpkN
|
160 |
+
9r+qaRayTXC2Nwm5FWRRLGQWIUAIBIWJJAABGc4ra0fUZdUs/Olsp7Ft7KEnABYA/eA6hT23BT6g
|
161 |
+
Vy+uaXY+IPJ+1Q35EW7CfZJGiYMMEPEyFH46blJHbFTWF1e6PYpa2UMa20CbYLaPSJYgAOi8EKPq
|
162 |
+
AAPSvp8ux1Zxti1Lm/wO34IxnBfZOwooor6cwCiiigAooooAKKKKACiiigAooooAKKKKACiiigAo
|
163 |
+
oooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACii
|
164 |
+
igAooooAKKKKACiiigAooooA/9k=</Data></Thumbnail></Binary><mdDateSt Sync="TRUE">20060911</mdDateSt><dataIdInfo><envirDesc Sync="TRUE">Microsoft Windows XP Version 5.1 (Build 2600) Service Pack 2; ESRI ArcCatalog 9.2.0.1147</envirDesc><dataLang><languageCode Sync="TRUE" value="en"/></dataLang><idCitation><resTitle>World Countries 2005</resTitle><presForm><PresFormCd Sync="TRUE" value="005"/></presForm><resEd>2005</resEd><resEdDate>20050401</resEdDate><resRefDate><refDate>20040307</refDate><refDateType><DateTypCd value="001"/></refDateType></resRefDate><citRespParty><rpIndName>Data Team</rpIndName><rpOrgName>ESRI</rpOrgName><rpPosName>Data Team</rpPosName><role><RoleCd value="007"/></role><rpCntInfo><cntAddress><delPoint>380 New York Street</delPoint><city>Redlands</city><adminArea>California</adminArea><postCode>92373-8100</postCode><eMailAdd>[email protected]</eMailAdd><country>us</country></cntAddress><cntPhone><voiceNum>909-793-2853</voiceNum><faxNum>909-793-5953</faxNum></cntPhone></rpCntInfo></citRespParty><resRefDate><refDate>20050401</refDate><refDateType><DateTypCd value="002"/></refDateType></resRefDate><date><createDate>20040307</createDate><pubDate>20050401</pubDate></date></idCitation><spatRpType><SpatRepTypCd Sync="TRUE" value="001"/></spatRpType><dataExt><geoEle><GeoBndBox esriExtentType="native"><westBL Sync="TRUE">-180</westBL><eastBL Sync="TRUE">180.000000</eastBL><northBL Sync="TRUE">83.623608</northBL><southBL Sync="TRUE">-90</southBL><exTypeCode Sync="TRUE">1</exTypeCode></GeoBndBox></geoEle><tempEle><TempExtent><exTemp><TM_Period><tmBegin>199312</tmBegin><tmEnd>20050210</tmEnd></TM_Period><TM_GeometricPrimitive><TM_Period><begin>199312</begin><end>20050210</end></TM_Period></TM_GeometricPrimitive></exTemp></TempExtent></tempEle></dataExt><geoBox esriExtentType="decdegrees"><westBL Sync="TRUE">-180</westBL><eastBL Sync="TRUE">180</eastBL><northBL Sync="TRUE">83.623608</northBL><southBL Sync="TRUE">-90</southBL><exTypeCode Sync="TRUE">1</exTypeCode></geoBox><dataExt><geoEle><GeoBndBox esriExtentType="search"><westBL Sync="TRUE">-180</westBL><eastBL Sync="TRUE">180</eastBL><northBL Sync="TRUE">83.623608</northBL><southBL Sync="TRUE">-90</southBL><exTypeCode Sync="TRUE">1</exTypeCode></GeoBndBox></geoEle></dataExt><idAbs><DIV STYLE="text-align:Left;font-family:Microsoft Sans Serif;font-style:normal;font-weight:normal;font-size: medium;color:#000000;"><DIV><DIV><P STYLE="font-family:times new roman;font-size: xx-large;margin:7 0 7 0;"><SPAN STYLE="font-size: medium;">World Countries 2005 represents detailed boundaries for the countries of the world as they existed in January 2005.</SPAN></P><P><SPAN /></P></DIV></DIV></DIV></idAbs><resConst><Consts><useLimit>See legal constraints.</useLimit></Consts><LegConsts><accessConsts><RestrictCd value="005"/></accessConsts><othConsts>The data are provided by multiple, third party data vendors under license to ESRI for inclusion on ESRI Data & Maps for use with ESRI® software. Each data vendor has its own data licensing policies and may grant varying redistribution rights to end users. Please consult the redistribution rights below for this data set provided on ESRI Data & Maps. As used herein, “Geodata” shall mean any digital data set consisting of geographic data coordinates and associated attributes.
|
165 |
+
|
166 |
+
The redistribution rights for this data set: Redistribution rights are granted by the data vendor for hard-copy renditions or static, electronic map images (e.g. .gif, .jpeg, etc.) that are plotted, printed, or publicly displayed with proper metadata and source/copyright attribution to the respective data vendor(s). Geodata is redistributable with a Value-Added Software Application developed by ESRI Business Partners on a royalty-free basis with proper metadata and source/copyright attribution to the respective data vendor(s). Geodata is redistributable without a Value-Added Software Application (i.e., adding the sample data to an existing, [non]commercial data set for redistribution) with proper metadata and source/copyright attribution to the respective data vendor(s).
|
167 |
+
|
168 |
+
The terms and conditions below apply to all the data sets provided on ESRI Data & Maps.
|
169 |
+
|
170 |
+
Proprietary Rights and Copyright: Licensee acknowledges that the Data and Related Materials contain proprietary and confidential property of ESRI and its licensor(s). The Data and Related Materials are owned by ESRI and its licensor(s) and are protected by United States copyright laws and applicable international copyright treaties and/or conventions.
|
171 |
+
|
172 |
+
Limited Warranty and Disclaimer: ESRI warrants that the media upon which the Data and Related Materials are provided will be free from defects in materials and workmanship under normal use and service for a period of ninety (90) days from the date of receipt.
|
173 |
+
|
174 |
+
THE DATA AND RELATED MATERIALS ARE EXCLUDED FROM THE LIMITED WARRANTY, AND THE LICENSEE EXPRESSLY ACKNOWLEDGES THAT THE DATA CONTAINS SOME NONCONFORMITIES, DEFECTS, OR ERRORS. ESRI DOES NOT WARRANT THAT THE DATA WILL MEET LICENSEE'S NEEDS OR EXPECTATIONS; THAT THE USE OF THE DATA WILL BE UNINTERRUPTED; OR THAT ALL NONCONFORMITIES, DEFECTS, OR ERRORS CAN OR WILL BE CORRECTED. ESRI IS NOT INVITING RELIANCE ON THIS DATA, AND THE LICENSEE SHOULD ALWAYS VERIFY ACTUAL DATA.
|
175 |
+
|
176 |
+
EXCEPT FOR THE LIMITED WARRANTY SET FORTH ABOVE, THE DATA AND RELATED MATERIALS CONTAINED THEREIN ARE PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
177 |
+
|
178 |
+
Exclusive Remedy and Limitation of Liability: The entire liability of ESRI or its licensor(s) and Licensee's exclusive remedy shall be to terminate the Agreement upon Licensee returning the Data and Related Materials to ESRI with a copy of Licensee's invoice/receipt and ESRI returning the license fees paid to Licensee.
|
179 |
+
|
180 |
+
IN NO EVENT SHALL ESRI AND/OR ITS LICENSOR(S) BE LIABLE FOR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOST PROFITS, LOST SALES, OR BUSINESS EXPENDITURES, INVESTMENTS, OR COMMITMENTS IN CONNECTION WITH ANY BUSINESS; LOSS OF ANY GOODWILL; OR FOR ANY INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT OR USE OF THE DATA AND RELATED MATERIALS, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, AND WHETHER OR NOT ESRI OR ITS LICENSOR(S) HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY EXCLUSIVE REMEDY.
|
181 |
+
|
182 |
+
Third Party Beneficiary: ESRI's licensor(s) has (have) authorized ESRI to (sub)distribute and (sub)license its (their) data as incorporated into the Data and Related Materials. As an intended third party beneficiary to this Agreement, the ESRI licensor(s) is (are) entitled to directly enforce, in its own name, the rights and obligations undertaken by the Licensee and to seek all legal and equitable remedies as are afforded to ESRI.
|
183 |
+
|
184 |
+
In the event that the data vendor(s) has (have) granted the end user permission to redistribute the Geodata, please use proper proprietary or copyright attribution for the various data vendor(s), and provide the associated metadata file(s) with the Geodata. In compliance with FGDC metadata standards, ESRI has attempted to practice proper metadata methodologies by providing any data source information, descriptions, and file names to assist in this effort.</othConsts><useConsts><RestrictCd value="008"/></useConsts></LegConsts></resConst><dataScale><equScale><rfDenom>15000000</rfDenom></equScale></dataScale><descKeys KeyTypCd="005"><keyTyp><KeyTypCd value="005"/></keyTyp><keyword>polygon, countries, international boundaries, coastlines, area, international codes, status, population, boundaries, society</keyword></descKeys><themeKeys><keyword>polygon, countries, international boundaries, coastlines, area, international codes, status, population, boundaries, society</keyword></themeKeys><descKeys KeyTypCd="002"><keyTyp><KeyTypCd value="002"/></keyTyp><keyword>World</keyword></descKeys><placeKeys><keyword>World</keyword></placeKeys><descKeys KeyTypCd="004"><keyTyp><KeyTypCd value="004"/></keyTyp><keyword>1996, 1998, 1993/1994, 2000, 1994, 2000, 2001, 2000, 1995-2002, 1999, 2002, 2002, 2002, 2002, 2003, 2000, 2004, 2005, 2004, 2004</keyword></descKeys><tempKeys><keyword>1996, 1998, 1993/1994, 2000, 1994, 2000, 2001, 2000, 1995-2002, 1999, 2002, 2002, 2002, 2002, 2003, 2000, 2004, 2005, 2004, 2004</keyword></tempKeys><idPoC Sync="TRUE"><rpIndName Sync="TRUE">Data Team</rpIndName><rpOrgName Sync="TRUE">ESRI</rpOrgName><rpPosName Sync="TRUE">Data Team</rpPosName><rpCntInfo><cntPhone><voiceNum Sync="TRUE">909-793-2853</voiceNum><faxNum Sync="TRUE">909-793-5953</faxNum></cntPhone><cntAddress><delPoint Sync="TRUE">380 New York Street</delPoint><city Sync="TRUE">Redlands</city><adminArea Sync="TRUE">California</adminArea><postCode Sync="TRUE">92373-8100</postCode><country Sync="TRUE">us</country><eMailAdd Sync="TRUE">[email protected]</eMailAdd></cntAddress></rpCntInfo><role><RoleCd Sync="TRUE" value="007"/></role></idPoC><searchKeys><keyword>polygon</keyword><keyword>countries</keyword><keyword>international boundaries</keyword><keyword>coastlines</keyword><keyword>area</keyword><keyword>international codes</keyword><keyword>status</keyword><keyword>population</keyword><keyword>detailed boundaries</keyword><keyword>society</keyword><keyword>World</keyword><keyword>1996</keyword><keyword>1998</keyword><keyword>1993/1994</keyword><keyword>2000</keyword><keyword>1994</keyword><keyword>2000</keyword><keyword>2001</keyword><keyword>2000</keyword><keyword>1995-2002</keyword><keyword>1999</keyword><keyword>2002</keyword><keyword>2002</keyword><keyword>2002</keyword><keyword>2002</keyword><keyword>2003</keyword><keyword>2000</keyword><keyword>2004</keyword><keyword>2005</keyword><keyword>2004</keyword><keyword>2004</keyword></searchKeys><idPurp>World Countries 2005 provides political boundaries for the world in 2005.</idPurp><idCredit>ESRI</idCredit><tpCat><TopicCatCd value="003"/></tpCat><tpCat><TopicCatCd value="016"/></tpCat></dataIdInfo><mdLang><languageCode Sync="TRUE" value="en"/></mdLang><mdStanName Sync="TRUE">ISO 19115 Geographic Information - Metadata</mdStanName><mdStanVer Sync="TRUE">DIS_ESRI1.0</mdStanVer><mdChar><CharSetCd Sync="TRUE" value="004"/></mdChar><mdHrLv><ScopeCd Sync="TRUE" value="005"/></mdHrLv><mdHrLvName Sync="TRUE">dataset</mdHrLvName><distInfo><distributor><distorTran><onLineSrc><orDesc>003</orDesc><linkage Sync="TRUE">file://\\BIGBOWL\C$\Other files\Zness\learning_gis_with_arcgis\lesson8_writing\exercise_data\world.gdb</linkage><protocol Sync="TRUE">Local Area Network</protocol></onLineSrc><transSize Sync="TRUE">0.855</transSize><offLineMed><medName><MedNameCd value="003"/></medName><medName><MedNameCd value="001"/></medName></offLineMed></distorTran><distorFormat><formatName Sync="TRUE">File Geodatabase Feature Class</formatName></distorFormat><distorCont><rpOrgName>ESRI; ESRI International Distributors</rpOrgName><rpCntInfo><cntAddress><delPoint>380 New York Street</delPoint><city>Redlands</city><adminArea>California</adminArea><postCode>92373-8100</postCode><country>us</country></cntAddress><cntPhone><voiceNum>800-447-9778</voiceNum></cntPhone></rpCntInfo><role><RoleCd value="005"/></role></distorCont><distorOrdPrc><ordInstr>ESRI Data & Maps is available only as part of ESRI® software.
|
185 |
+
|
186 |
+
In the United States, contact the ESRI Telesales staff at 800-447-9778 for more information about our software and data.
|
187 |
+
|
188 |
+
Outside the United States, please direct all inquiries to your local ESRI International Distributor. This information can be found at http://gis.esri.com/intldist/contactint.cfm.</ordInstr><resFees>Software purchase price. ESRI Data & Maps is available only as part of ESRI® software. To use this data requires software that supports SDC files.</resFees></distorOrdPrc></distributor></distInfo><refSysInfo><RefSystem><refSysID><identCode Sync="TRUE">GCS_WGS_1984</identCode></refSysID></RefSystem></refSysInfo><spatRepInfo><VectSpatRep><topLvl><TopoLevCd Sync="TRUE" value="001"/></topLvl><geometObjs Name="countries"><geoObjTyp><GeoObjTypCd Sync="TRUE" value="001"/></geoObjTyp><geoObjCnt Sync="TRUE">0</geoObjCnt></geometObjs></VectSpatRep></spatRepInfo><mdContact><rpIndName>Data Team</rpIndName><rpOrgName>ESRI</rpOrgName><rpPosName>Data Team</rpPosName><rpCntInfo><cntAddress><delPoint>380 New York Street</delPoint><city>Redlands</city><adminArea>California</adminArea><postCode>92373-8100</postCode><eMailAdd>[email protected]</eMailAdd><country>us</country></cntAddress><cntPhone><voiceNum>909-793-2853</voiceNum><faxNum>909-793-5953</faxNum></cntPhone></rpCntInfo><role><RoleCd value="010"/></role></mdContact><dqInfo><dataLineage><statement>ArcWorld Supplement (source 1 of 12)
|
189 |
+
|
190 |
+
ESRI, 1996, ArcWorld™ Supplement: ESRI, Redlands, California, USA.
|
191 |
+
|
192 |
+
Type of source media: CD–ROM
|
193 |
+
Source scale denominator: 3000000
|
194 |
+
Source contribution:
|
195 |
+
Attribute and geospatial data
|
196 |
+
|
197 |
+
|
198 |
+
Geographic and Global Issues (source 2 of 12)
|
199 |
+
|
200 |
+
United States Department of State, Bureau of Intelligence and Research, Winter 1993/1994, Geographic and Global Issues Quarterly: Geographic and Global Issues Quarterly Volume 3, Number 4, United States Department of State, Bureau of Intelligence and Research, Washington, DC, USA.
|
201 |
+
|
202 |
+
Type of source media: paper
|
203 |
+
Source contribution:
|
204 |
+
Attribute data
|
205 |
+
|
206 |
+
|
207 |
+
CIA Factbook (source 3 of 12)
|
208 |
+
|
209 |
+
United States Central Intelligence Agency, 20000101, 2003, 20041209, 20050210, The World Factbook 2000; 2003; 2004; 2005: The World Factbook 2000; 2003; 2004; 2005, United States Central Intelligence Agency, Washington, DC, USA.
|
210 |
+
|
211 |
+
Online links:
|
212 |
+
http://www.cia.gov/cia/publications/factbook/index.html
|
213 |
+
http://www.cia.gov/cia/publications/factbook/appendix/appendix-d.html
|
214 |
+
http://www.odci.gov/cia/publications/factbook/fields/2142.html
|
215 |
+
|
216 |
+
Other citation details:
|
217 |
+
The Factbook has been an annual publication, but selected data and maps are updated periodically online.
|
218 |
+
|
219 |
+
Type of source media: online
|
220 |
+
Source contribution:
|
221 |
+
Attribute data
|
222 |
+
|
223 |
+
|
224 |
+
NCGIA (source 4 of 12)
|
225 |
+
|
226 |
+
National Center for Geographic Information and Analysis, 199504, World Demography Project: National Center for Geographic Information and Analysis at University of California, Santa Barbara, Santa Barbara, California, USA.
|
227 |
+
|
228 |
+
Type of source media: paper
|
229 |
+
Source contribution:
|
230 |
+
Attribute data
|
231 |
+
|
232 |
+
|
233 |
+
ESFN FIPS 10-4 20000225 (source 5 of 12)
|
234 |
+
|
235 |
+
Executive Secretary for Foreign Names - US Board on Geographic Names, 20000225, COUNTRIES, DEPENDENCIES, AREAS OF SPECIAL SOVEREIGNTY, AND THEIR PRINCIPAL ADMINISTRATIVE DIVISIONS: FIPS 10-4 , National Imagery and Mapping Agency, Bethesda, Maryland, USA.
|
236 |
+
|
237 |
+
Source contribution:
|
238 |
+
Attribute data
|
239 |
+
|
240 |
+
|
241 |
+
ESFN FIPS 10-4 20010128 (source 6 of 12)
|
242 |
+
|
243 |
+
Executive Secretary for Foreign Names - US Board on Geographic Names, 20010128, COUNTRIES, DEPENDENCIES, AREAS OF SPECIAL SOVEREIGNTY, AND THEIR PRINCIPAL ADMINISTRATIVE DIVISIONS: FIPS 10-4 , National Imagery and Mapping Agency, Bethesda, Maryland, USA.
|
244 |
+
|
245 |
+
Source contribution:
|
246 |
+
Attribute data
|
247 |
+
|
248 |
+
|
249 |
+
TREATY OF JEDDAH, 2000 (source 7 of 12)
|
250 |
+
|
251 |
+
International Border Treaty between the Republic of Yemen and the Kingdom of Saudi Arabia, 20000612, THE TREATY OF JEDDAH, 2000: Yemen Gateway - "BAB AL-YEMEN", online.
|
252 |
+
|
253 |
+
Online links:
|
254 |
+
http://www.al-bab.com/yemen/pol/int5.htm
|
255 |
+
|
256 |
+
Type of source media: online
|
257 |
+
Source contribution:
|
258 |
+
Attribute and geospatial data
|
259 |
+
|
260 |
+
|
261 |
+
http://europa.eu.int (source 8 of 12)
|
262 |
+
|
263 |
+
Europa, Euro Essentials: Europa, online.
|
264 |
+
|
265 |
+
Online links:
|
266 |
+
http://europa.eu.int/comm/economy_finance/euro/participating_member_states_map_en.htm
|
267 |
+
|
268 |
+
Other citation details:
|
269 |
+
Europa is the portal site of the European Union (http://europa.eu.int/). It provides up-to-date coverage of European Union affairs and essential information on European integration.
|
270 |
+
|
271 |
+
Type of source media: online
|
272 |
+
Source contribution:
|
273 |
+
Attribute data
|
274 |
+
|
275 |
+
|
276 |
+
http://www.iso.org (source 9 of 12)
|
277 |
+
|
278 |
+
International Organization for Standardization, 19991001, 20020201, 20020520, 20021115, 2004, <front page>: International Organization for Standardization, online.
|
279 |
+
|
280 |
+
Online links:
|
281 |
+
http://www.iso.ch/iso/en/ISOOnline.frontpage
|
282 |
+
http://www.iso.ch/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv6e-tl.html
|
283 |
+
www.iso.org/iso/en/prods-services/iso3166ma/02iso3166-code/li….?
|
284 |
+
|
285 |
+
Other citation details:
|
286 |
+
ISO 3166-1 NEWSLETTER No. V-6 [20021115]
|
287 |
+
|
288 |
+
Type of source media: online
|
289 |
+
Source contribution:
|
290 |
+
Attribute data
|
291 |
+
|
292 |
+
|
293 |
+
http://news.bbc.co.uk (source 10 of 12)
|
294 |
+
|
295 |
+
BBC News, 20020314, Yugoslav partners sign historic deal: BBC News Online March 14, 2002, BBC News, online.
|
296 |
+
|
297 |
+
Online links:
|
298 |
+
http://news.bbc.co.uk/1/hi/world/europe/1872070.stm
|
299 |
+
|
300 |
+
Type of source media: online
|
301 |
+
Source contribution:
|
302 |
+
Attribute data
|
303 |
+
|
304 |
+
|
305 |
+
GMI (source 11 of 12)
|
306 |
+
|
307 |
+
Global Mapping International, Missions Database: Global Mapping International, Colorado Springs, Colorado, USA.
|
308 |
+
|
309 |
+
Online links:
|
310 |
+
http://www.gmi.org
|
311 |
+
|
312 |
+
Type of source media: CD–ROM
|
313 |
+
Source contribution:
|
314 |
+
Attribute data
|
315 |
+
|
316 |
+
|
317 |
+
http://www.un.org (source 12 of 12)
|
318 |
+
|
319 |
+
United Nations, 200405, United Nations Cartographic Section Technical Paper: List of Territories: United Nations Cartographic Section Technical Paper May 2004, United Nations, New York, New York, USA.
|
320 |
+
|
321 |
+
Online links:
|
322 |
+
http://www.un.org/Depts/Cartographic/english/geoname.pdf#search='United%20Nations%20Cartographic%20Section%20Technical%20Paper'
|
323 |
+
|
324 |
+
Type of source media: online
|
325 |
+
Source contribution:
|
326 |
+
Attribute data
|
327 |
+
|
328 |
+
|
329 |
+
Date: 20020212 (change 1 of 4)
|
330 |
+
The following steps were performed by ESRI for Data & Maps 2002: Updated Saudi Arabia - Yemen border. Updated attributes for East Timor, Yugoslavia, Saudi Arabia, and Yemen. Recalculated attributes based on area. Created ArcGIS® layer file (.lyr) and ArcView GIS legend file (.avl). Copied projection file (.prj) and created spatial indices.
|
331 |
+
|
332 |
+
The following steps were performed by ESRI: Extracted the features from ESRI Data & Maps 1999 data set–cntry98.shp. Updated political boundaries and attributes for 2000 for Macau, Hong Kong, and East Timor. Extended political boundaries into the Caspian Sea and removed the shoreline. Created ArcGIS® layer file (.lyr). Created ArcView GIS legend file (.avl). Created projection file (.prj). Created spatial indices.
|
333 |
+
|
334 |
+
Data sources used in this process:
|
335 |
+
ArcWorld Supplement
|
336 |
+
Geographic and Global Issues
|
337 |
+
CIA Factbook
|
338 |
+
World Demography Project
|
339 |
+
ESFN FIPS 10-4 20000225
|
340 |
+
ESFN FIPS 10-4 20010128
|
341 |
+
TREATY OF JEDDAH, 2000
|
342 |
+
|
343 |
+
|
344 |
+
Date: 20020920 (change 2 of 4)
|
345 |
+
The following steps were performed by ESRI: Updated fields to reflect change from Yugoslavia to Serbia and Montenegro. Updated fields for East Timor, Romania, and Gaza Strip. Updated currency information for the European Euro. Created ArcGIS® layer file (.lyr), projection file (.prj), and spatial indices. Converted the data set to SDC.
|
346 |
+
|
347 |
+
Data sources used in this process:
|
348 |
+
http://europa.eu.int
|
349 |
+
http://www.iso.org
|
350 |
+
http://news.bbc.co.uk
|
351 |
+
|
352 |
+
|
353 |
+
Date: 20040307 (change 3 of 4)
|
354 |
+
The following steps were performed by ESRI: Updated attribute values for East Timor, Serbia & Montenegro, and Taiwan. Recreated country regions, absorbing the province of Taiwan into the country of China. Removed the Paracel and Spratly island groups.
|
355 |
+
|
356 |
+
Data sources used in this process:
|
357 |
+
http://www.iso.org
|
358 |
+
GMI
|
359 |
+
CIA Factbook
|
360 |
+
|
361 |
+
|
362 |
+
Date: 20050222 (change 4 of 4)
|
363 |
+
The following steps were performed by ESRI: Added attributes ISO_NUM, ISOSHRTNAM, UNSHRTNAM, LOCSHRTNAM, LOCLNGNAM, and STATUS. Removed attributes SOVEREIGN, CURR_TYPE, CURR_CODE, and LANDLOCKED. Updated attribute values for LONG_NAME. Reduced the attribute width for CNTRY_NAME.
|
364 |
+
|
365 |
+
Data sources used in this process:
|
366 |
+
CIA Factbook
|
367 |
+
http://www.iso.org
|
368 |
+
http://www.un.org </statement></dataLineage><dqScope><scpLvl><ScopeCd value="005"/></scpLvl></dqScope></dqInfo><mdFileID Sync="TRUE">{579C23D8-87EA-403C-87CD-670CE10E2710}</mdFileID></metadata>
|
14/replication_package/Replication/Data/GIS_LatinAmerica/LatinAmerica.shx
ADDED
Binary file (268 Bytes). View file
|
|
14/replication_package/Replication/Data/LR_reform_existence.dta
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1fedc57ec1cf1bfb88f8777d498a1b5cf6f9284260a113ba1328543e301d62bc
|
3 |
+
size 68995
|
14/replication_package/Replication/Data/Prices/Consejo Salvadoreno del Cafe/PRECIOS PAGADOS A LOS CAFICULTORES DOLARES POR 46 KILOGRAMOS DE CAFe.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:038cd7b23398bed04de823764c1d81577cbed12860ec743377947d1bb1a335e6
|
3 |
+
size 3050
|
14/replication_package/Replication/Data/Prices/Consejo Salvadoreno del Cafe/precio pagado productor 30 abril 2017.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9f86c51d547c01222b2db7e174be983af91142634445dd54388b533c796e89fe
|
3 |
+
size 228284
|