-
-
Save rotorrest/131e41559752c817ca42d4a524196055 to your computer and use it in GitHub Desktop.
Análisis de las elecciones 2021 (22/06/2021)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Análisis de las elecciones 2021 (22/06/2021)" | |
***********************Importamos la data***************************** | |
clear all | |
set more off | |
gl rutaup "/Volumes/Elements/Elecciones2021/Insumos" | |
gl rutasave "/Volumes/Elements/Elecciones2021/Producto" | |
import delimited "$rutaup//resultados_presidencial_2021.csv", encoding(ISO-8859-1) | |
drop if mesa==. | |
****Unimos con la data oficial de la primera vuelta | |
merge 1:1 mesa using "$rutaup//primera_v.dta" | |
drop _merge | |
save "$rutasave//elecciones2021.dta", replace | |
********************************************************************** | |
**Análisis votos para castillo | |
********************************************************************** | |
egen castillo2 = sum(v2_perulibre) | |
egen castillo1 = sum(vpl_1) | |
gen dif_C=(castillo2-castillo1) | |
********************************************************************** | |
**Análisis votos para Keiko | |
********************************************************************** | |
egen keiko2 = sum(v2_fp) | |
egen keiko1 = sum(vfp_1) | |
gen dif_K=(keiko2-keiko1) | |
********************************************************************** | |
**Votos válidos | |
********************************************************************** | |
egen validos2= sum(v2_validos) | |
egen validos1= sum(valido_1) | |
gen dif_validos=(validos2-validos1) | |
********************************************************************** | |
**Votos ganados por mesa - Castillo | |
********************************************************************** | |
gen VGC= (v2_perulibre - vpl_1) | |
replace VGC=v2_perulibre if VGC==. | |
*egen VGCsum=sum(VGC) | |
***Intervalos | |
egen intervalos_VGC=cut(VGC), at(0 11(10)251) label | |
replace intervalos_VGC=25 if VGC>250 | |
replace intervalos_VGC=-9 if VGC<0 | |
drop if mesa==. | |
label define intervalos -9"Menos de 0" 0"0 a 10" 1"11 a 20" 2"21 a 30" 3"31 a 40" 4"41 a 50" /// | |
5"51 a 60" 6"61 a 70" 7"71 a 80" 8"81 a 90" 9"91 a 100" 10"101 a 110" 11"111 a 120" 12"121 a 130" /// | |
13"131 a 140" 14"141 a 150" 15"151 a 160" 16"161 a 170" 17"171 a 180" 18"181 a 190" 19"191 a 200" /// | |
20"201 a 210" 21"211 a 220" 22"221 a 230" 23"231 a 240" 24"241 a 250" 25"251 a más", modify | |
label values intervalos_VGC intervalos | |
label var intervalos_VGC "Intervalos VGC" | |
*qui tabout intervalos_VGC using "$rutasave//tab.xls", replace | |
qui tabout intervalos_VGC using "tab1.xls", replace | |
********************************************************************** | |
**Votos ganados por mesa - Keiko | |
********************************************************************** | |
gen VGF= (v2_fp - vfp_1) | |
replace VGF=v2_fp if VGF==. | |
*egen VGFsum=sum(VGF) | |
***Intervalos | |
egen intervalos_VGF=cut(VGF), at(0 11(10)251) label | |
replace intervalos_VGF=25 if VGF>250 | |
replace intervalos_VGF=-9 if VGF<0 | |
drop if mesa==. | |
label values intervalos_VGF intervalos | |
label var intervalos_VGF "Intervalos VGF" | |
qui tabout intervalos_VGF using "$rutasave//tab.xls", append | |
********************************************************************** | |
**Casos atípicos | |
********************************************************************** | |
***Castillo | |
tab v2_departamento if intervalos_VGC<0 | |
tab v2_departamento if intervalos_VGC>=20 | |
***Keiko | |
tab v2_departamento if intervalos_VGF<0 | |
tab v2_departamento if intervalos_VGF>=20 | |
********************************************************************** | |
**Test de diferencias | |
********************************************************************** | |
sdtest dif_K=dif_C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment