script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" $(document).ready(function() {
$('body').prepend('<div class=\"zoomDiv\"><img src=\"\" class=\"zoomImg\"></div>');
// onClick function for all plots (img's)
$('img:not(.zoomImg)').click(function() {
$('.zoomImg').attr('src', $(this).attr('src')).css({width: '100%'});
$('.zoomDiv').css({opacity: '1', width: 'auto', border: '1px solid white', borderRadius: '5px', position: 'fixed', top: '50%', left: '50%', marginRight: '-50%', transform: 'translate(-50%, -50%)', boxShadow: '0px 0px 50px #888888', zIndex: '50', overflow: 'auto', maxHeight: '100%'});
});
// onClick function for zoomImg
$('img.zoomImg').click(function() {
$('.zoomDiv').css({opacity: '0', width: '0%'});
});
});
<script src="hideOutput.js"></script> $(document).ready(function() {
$chunks = $('.fold');
$chunks.each(function () { // add button to source code chunks
if ( $(this).hasClass('s') ) {
$('pre.r', this).prepend("<div class=\"showopt\">Show Source</div><br style=\"line-height:22px;\"/>");
$('pre.r', this).children('code').attr('class', 'folded');
} // add button to output chunks
if ( $(this).hasClass('o') ) {
$('pre:not(.r)', this).has('code').prepend("<div class=\"showopt\">Show Output</div><br style=\"line-height:22px;\"/>");
$('pre:not(.r)', this).children('code:not(r)').addClass('folded'); // add button to plots
$(this).find('img').wrap('<pre class=\"plot\"></pre>');
$('pre.plot', this).prepend("<div class=\"showopt\">Show Plot</div><br style=\"line-height:22px;\"/>");
$('pre.plot', this).children('img').addClass('folded');
}
}); // hide all chunks when document is loaded
$('.folded').css('display', 'none') // function to toggle the visibility
$('.showopt').click(function() {
var label = $(this).html();
if (label.indexOf("Show") >= 0) {
$(this).html(label.replace("Show", "Hide"));
} else {
$(this).html(label.replace("Hide", "Show"));
}
$(this).siblings('code, img').slideToggle('fast', 'swing');
});
}); Several issues were found in the first stage of the exploration of the matches.
Replace missing sex and nationality
Clean dates of commission of the crime
Explore Duplicated entries (relationships)
TIPO_SUJETO_VIC that are victims and imputed at the
same time
Investigate 0’s in IDSUJETO_VICTIMA. ¿Have they the
same distributed crimes?
Explore missing values in TIPO_TERMINO
AGRUPA_TERMINOS, explore missing values
GLS_MOTTERMINO explore missing values; see why is
different with AGRUPA_TERMINOS.
Explore differences of IDDELITO with
cod_delito.
COD_DELITO. explore deprecated crimes
FAMILIA_DELITO explore whether crimes that were in a
family are no longer there or viceversa
Generate a category to define VIF RELACION_VIFSAF
(domestic violence) (include mistreatment, femicide or
parricide)
Analyze these procedures “Anulación de ingreso error de digitación” & “Agrupado” (gls_mottermino)
Generate a narrative of IDs and their nested relationships
`%>%`<- magrittr::`%>%`
#no definido
#janitor::tabyl(Base_fiscalia_v5$sexo)[[3]]
sex_nodef<-
Base_fiscalia_v5%>%
dplyr::filter(rut_enc_saf %in% unlist(dplyr::distinct(dplyr::filter(Base_fiscalia_v5, sexo=="No Definido"), rut_enc_saf)))
as.data.frame.TableOne(CreateTableOne(vars= setdiff(c(myVars,"cut_com_del2","cut_fec_nac2"), c("gls_comuna", "gls_sitiosuceso", "gls_materia", "reg")), data= dplyr::mutate(Base_fiscalia_v5, sex_nodef=ifelse(sexo=="No Definido",1,0), cut_fec_nac2=cut2(imp_birth_date, cuts=as.Date(attr(binning(as.numeric(imp_birth_date)),"breaks"))),cut_com_del2=cut2(fec_comision_simple, cuts=as.Date(attr(binning(as.numeric(fec_comision_simple)),"breaks")))), factorVars = catVars, smd=T, strata="sex_nodef", addOverall = T, includeNA=T,test=T), smd=T)%>%
dplyr::mutate(char2=characteristic) %>%
tidyr::fill(char2) %>%
dplyr::select(char2,everything()) %>%
dplyr::mutate(level=ifelse(is.na(level),"[Missing]",level)) %>%
dplyr::mutate(char2=dplyr::case_when(characteristic=="NA"~NA_character_,T~as.character(characteristic)))%>%
format_cells(1, 1:9, "bold") %>%
dplyr::select(-1) %>%
kable(size=10, format="markdown",caption= "Summary descriptives, if sex is not defined (1)") #%>%
| characteristic | level | Overall | 0 | 1 | p | test | SMD |
|---|---|---|---|---|---|---|---|
| n | 565601 | 565390 | 211 | ||||
| encontrado_como_victima (%) | NO | 375616 ( 66.4) | 375488 ( 66.4) | 128 ( 60.7) | 0.090 | 0.120 | |
| SI | 189985 ( 33.6) | 189902 ( 33.6) | 83 ( 39.3) | ||||
| encontrado_como_imputado (%) | NO | 189624 ( 33.5) | 189541 ( 33.5) | 83 ( 39.3) | 0.086 | 0.121 | |
| SI | 375977 ( 66.5) | 375849 ( 66.5) | 128 ( 60.7) | ||||
| tipo_sujeto_vic (%) | 1 | 304 ( 0.1) | 304 ( 0.1) | 0 ( 0.0) | 1.000 | 0.059 | |
| 15 | 226 ( 0.0) | 226 ( 0.0) | 0 ( 0.0) | ||||
| 19 | 328 ( 0.1) | 328 ( 0.1) | 0 ( 0.0) | ||||
| 2 | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| 3 | 13 ( 0.0) | 13 ( 0.0) | 0 ( 0.0) | ||||
| 5 | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| 6 | 546716 ( 96.7) | 546511 ( 96.7) | 205 ( 97.2) | ||||
| 8 | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 18007 ( 3.2) | 18001 ( 3.2) | 6 ( 2.8) | ||||
| gls_tipo_sujeto_vic (%) | ABOGADO QUERELLANTE | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | 1.000 | 0.059 | |
| DENUNCIADO | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| DENUNCIANTE | 304 ( 0.1) | 304 ( 0.1) | 0 ( 0.0) | ||||
| IMPUTADO | 13 ( 0.0) | 13 ( 0.0) | 0 ( 0.0) | ||||
| QUERELLANTE | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| TESTIGO | 226 ( 0.0) | 226 ( 0.0) | 0 ( 0.0) | ||||
| VICTIMA | 546716 ( 96.7) | 546511 ( 96.7) | 205 ( 97.2) | ||||
| VICTIMA 108i.2 | 328 ( 0.1) | 328 ( 0.1) | 0 ( 0.0) | ||||
| [Missing] | 18007 ( 3.2) | 18001 ( 3.2) | 6 ( 2.8) | ||||
| gls_region (%) | I Región de Tarapaca | 17981 ( 3.2) | 17981 ( 3.2) | 0 ( 0.0) | <0.001 | 0.945 | |
| II Región de Antofagasta | 27197 ( 4.8) | 27180 ( 4.8) | 17 ( 8.1) | ||||
| III Región de Atacama | 17584 ( 3.1) | 17565 ( 3.1) | 19 ( 9.0) | ||||
| IV Región de Coquimbo | 23003 ( 4.1) | 22998 ( 4.1) | 5 ( 2.4) | ||||
| IX Región de la Araucanía | 15499 ( 2.7) | 15475 ( 2.7) | 24 ( 11.4) | ||||
| RM Centro Norte | 78291 ( 13.8) | 78275 ( 13.8) | 16 ( 7.6) | ||||
| RM Occidente | 63504 ( 11.2) | 63491 ( 11.2) | 13 ( 6.2) | ||||
| RM Oriente | 43972 ( 7.8) | 43966 ( 7.8) | 6 ( 2.8) | ||||
| RM Sur | 63576 ( 11.2) | 63569 ( 11.2) | 7 ( 3.3) | ||||
| V Región de Valparaíso | 55192 ( 9.8) | 55182 ( 9.8) | 10 ( 4.7) | ||||
| VI Región del Libertador Gral. Bernardo O Higgins | 33361 ( 5.9) | 33340 ( 5.9) | 21 ( 10.0) | ||||
| VII Región del Maule | 30042 ( 5.3) | 30031 ( 5.3) | 11 ( 5.2) | ||||
| VIII Región del Bio Bio | 38462 ( 6.8) | 38443 ( 6.8) | 19 ( 9.0) | ||||
| X Región de los Lagos | 19279 ( 3.4) | 19261 ( 3.4) | 18 ( 8.5) | ||||
| XI Región Aysen del Gral. Carlos Ibañez del Campo | 5354 ( 0.9) | 5350 ( 0.9) | 4 ( 1.9) | ||||
| XII Región de Magallanes y de la Antartica Chilena | 5183 ( 0.9) | 5165 ( 0.9) | 18 ( 8.5) | ||||
| XIV Región de los Rios | 8405 ( 1.5) | 8404 ( 1.5) | 1 ( 0.5) | ||||
| XV Región de Arica y Parinacota | 13907 ( 2.5) | 13905 ( 2.5) | 2 ( 0.9) | ||||
| XVI Región del Ñuble | 5809 ( 1.0) | 5809 ( 1.0) | 0 ( 0.0) | ||||
| tipo_termino (%) | OTROS T¿RMINOS | 31693 ( 5.6) | 31688 ( 5.6) | 5 ( 2.4) | 0.169 | 0.178 | |
| SALIDA JUDICIAL | 304543 ( 53.8) | 304419 ( 53.8) | 124 ( 58.8) | ||||
| SALIDA NO JUDICIAL | 229344 ( 40.5) | 229262 ( 40.5) | 82 ( 38.9) | ||||
| [Missing] | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| agrupa_terminos (%) | ACUERDO REPARATORIO | 13622 ( 2.4) | 13617 ( 2.4) | 5 ( 2.4) | 0.149 | 0.343 | |
| AGRUPACI¿N A OTRO CASO | 28024 ( 5.0) | 28019 ( 5.0) | 5 ( 2.4) | ||||
| ANULACI¿N ADMINISTRATIVA | 1503 ( 0.3) | 1503 ( 0.3) | 0 ( 0.0) | ||||
| ARCHIVO PROVISIONAL | 148839 ( 26.3) | 148780 ( 26.3) | 59 ( 28.0) | ||||
| DECISI¿N DE NO PERSEVERAR | 33136 ( 5.9) | 33126 ( 5.9) | 10 ( 4.7) | ||||
| FACULTAD PARA NO INVESTIGAR | 41831 ( 7.4) | 41812 ( 7.4) | 19 ( 9.0) | ||||
| INCOMPETENCIA | 2346 ( 0.4) | 2346 ( 0.4) | 0 ( 0.0) | ||||
| OTRAS CAUSALES DE SUSPENSI¿N | 913 ( 0.2) | 913 ( 0.2) | 0 ( 0.0) | ||||
| OTRAS CAUSALES DE T¿RMINO | 1253 ( 0.2) | 1253 ( 0.2) | 0 ( 0.0) | ||||
| PRINCIPIO DE OPORTUNIDAD | 45023 ( 8.0) | 45010 ( 8.0) | 13 ( 6.2) | ||||
| SENTENCIA DEFINITIVA ABSOLUTORIA | 11829 ( 2.1) | 11828 ( 2.1) | 1 ( 0.5) | ||||
| SENTENCIA DEFINITIVA CONDENATORIA | 156788 ( 27.7) | 156729 ( 27.7) | 59 ( 28.0) | ||||
| SOBRESEIMIENTO DEFINITIVO | 28215 ( 5.0) | 28207 ( 5.0) | 8 ( 3.8) | ||||
| SOBRESEIMIENTO DEFINITIVO 240 | 44505 ( 7.9) | 44475 ( 7.9) | 30 ( 14.2) | ||||
| SOBRESEIMIENTO TEMPORAL | 657 ( 0.1) | 657 ( 0.1) | 0 ( 0.0) | ||||
| SUSPENSI¿N CONDICIONAL DEL PROCEDIMIENTO | 7096 ( 1.3) | 7094 ( 1.3) | 2 ( 0.9) | ||||
| [Missing] | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| familia_delito (%) | CUASIDELITOS | 3823 ( 0.7) | 3821 ( 0.7) | 2 ( 0.9) | 0.007 | 0.416 | |
| DELITOS CONTRA LA FE PÚBLICA | 15927 ( 2.8) | 15922 ( 2.8) | 5 ( 2.4) | ||||
| DELITOS CONTRA LA LIBERTAD E INTIMIDAD DE LAS PERSONAS | 98560 ( 17.4) | 98523 ( 17.4) | 37 ( 17.5) | ||||
| DELITOS CONTRA LEYES DE PROPIEDAD INTELECTUAL E INDUSTRIAL | 1469 ( 0.3) | 1469 ( 0.3) | 0 ( 0.0) | ||||
| DELITOS DE JUSTICIA MILITAR | 47 ( 0.0) | 47 ( 0.0) | 0 ( 0.0) | ||||
| DELITOS DE LEYES ESPECIALES | 13176 ( 2.3) | 13170 ( 2.3) | 6 ( 2.8) | ||||
| DELITOS DE TORTURA, MALOS TRATOS, GENOCIDIO Y LESA HUMANIDAD | 447 ( 0.1) | 447 ( 0.1) | 0 ( 0.0) | ||||
| DELITOS ECONÓMICOS Y TRIBUTARIOS | 14190 ( 2.5) | 14177 ( 2.5) | 13 ( 6.2) | ||||
| DELITOS FUNCIONARIOS | 732 ( 0.1) | 732 ( 0.1) | 0 ( 0.0) | ||||
| DELITOS LEY DE DROGAS | 9543 ( 1.7) | 9543 ( 1.7) | 0 ( 0.0) | ||||
| DELITOS LEY DE TRÁNSITO | 16082 ( 2.8) | 16068 ( 2.8) | 14 ( 6.6) | ||||
| DELITOS SEXUALES | 5625 ( 1.0) | 5623 ( 1.0) | 2 ( 0.9) | ||||
| FALTAS | 80627 ( 14.3) | 80602 ( 14.3) | 25 ( 11.8) | ||||
| HECHOS DE RELEVANCIA CRIMINAL | 31835 ( 5.6) | 31828 ( 5.6) | 7 ( 3.3) | ||||
| HOMICIDIOS | 1106 ( 0.2) | 1106 ( 0.2) | 0 ( 0.0) | ||||
| HURTOS | 51916 ( 9.2) | 51887 ( 9.2) | 29 ( 13.7) | ||||
| LESIONES | 118219 ( 20.9) | 118182 ( 20.9) | 37 ( 17.5) | ||||
| OTROS DELITOS | 12553 ( 2.2) | 12549 ( 2.2) | 4 ( 1.9) | ||||
| OTROS DELITOS CONTRA LA PROPIEDAD | 28584 ( 5.1) | 28578 ( 5.1) | 6 ( 2.8) | ||||
| ROBOS | 31102 ( 5.5) | 31091 ( 5.5) | 11 ( 5.2) | ||||
| ROBOS NO VIOLENTOS | 30038 ( 5.3) | 30025 ( 5.3) | 13 ( 6.2) | ||||
| relacion_vifsaf (%) | NO | 450076 ( 79.6) | 449909 ( 79.6) | 167 ( 79.1) | 0.945 | 0.011 | |
| SI | 115525 ( 20.4) | 115481 ( 20.4) | 44 ( 20.9) | ||||
| gls_parentesco (%) | ABUELO(A) | 744 ( 0.1) | 744 ( 0.1) | 0 ( 0.0) | <0.001 | 0.313 | |
| ADOPTADO | 41 ( 0.0) | 41 ( 0.0) | 0 ( 0.0) | ||||
| ADOPTANTE | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| CONVIVIENTE | 30410 ( 5.4) | 30392 ( 5.4) | 18 ( 8.5) | ||||
| CÓNYUGE | 15083 ( 2.7) | 15076 ( 2.7) | 7 ( 3.3) | ||||
| CUÑADO(A) | 1695 ( 0.3) | 1694 ( 0.3) | 1 ( 0.5) | ||||
| EX CONVIVIENTE | 21335 ( 3.8) | 21328 ( 3.8) | 7 ( 3.3) | ||||
| EX CONYUGE | 1413 ( 0.2) | 1413 ( 0.2) | 0 ( 0.0) | ||||
| HERMANO(A) | 9803 ( 1.7) | 9801 ( 1.7) | 2 ( 0.9) | ||||
| HIJO(A) | 9070 ( 1.6) | 9066 ( 1.6) | 4 ( 1.9) | ||||
| MADRASTRA | 100 ( 0.0) | 100 ( 0.0) | 0 ( 0.0) | ||||
| MADRE | 8386 ( 1.5) | 8384 ( 1.5) | 2 ( 0.9) | ||||
| MADRE HIJO COMUN | 3873 ( 0.7) | 3873 ( 0.7) | 0 ( 0.0) | ||||
| MENOR DE EDAD (bajo cuidado) | 44 ( 0.0) | 43 ( 0.0) | 1 ( 0.5) | ||||
| MINUSVALIDO (bajo cuidado) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| NIETO | 350 ( 0.1) | 350 ( 0.1) | 0 ( 0.0) | ||||
| No Definido | 118 ( 0.0) | 118 ( 0.0) | 0 ( 0.0) | ||||
| NUERA | 259 ( 0.0) | 259 ( 0.0) | 0 ( 0.0) | ||||
| PADRASTRO | 759 ( 0.1) | 759 ( 0.1) | 0 ( 0.0) | ||||
| PADRE | 4247 ( 0.8) | 4247 ( 0.8) | 0 ( 0.0) | ||||
| PADRE HIJO COMUN | 3574 ( 0.6) | 3573 ( 0.6) | 1 ( 0.5) | ||||
| SOBRINO(A) | 1445 ( 0.3) | 1445 ( 0.3) | 0 ( 0.0) | ||||
| SUEGRO(A) | 864 ( 0.2) | 864 ( 0.2) | 0 ( 0.0) | ||||
| TIO(A) | 1503 ( 0.3) | 1503 ( 0.3) | 0 ( 0.0) | ||||
| YERNO | 402 ( 0.1) | 401 ( 0.1) | 1 ( 0.5) | ||||
| [Missing] | 450076 ( 79.6) | 449909 ( 79.6) | 167 ( 79.1) | ||||
| gls_mottermino (%) | Acoge req. proced monit y proposic multa | 56871 ( 10.1) | 56854 ( 10.1) | 17 ( 8.1) | 0.549 | 0.353 | |
| Acuerdo Reparatorio (Art. 241 y 242) | 12038 ( 2.1) | 12033 ( 2.1) | 5 ( 2.4) | ||||
| Agrupado | 28025 ( 5.0) | 28020 ( 5.0) | 5 ( 2.4) | ||||
| Anulación de ingreso error de digitación | 1471 ( 0.3) | 1471 ( 0.3) | 0 ( 0.0) | ||||
| Anulación ingreso por delito acción priv | 32 ( 0.0) | 32 ( 0.0) | 0 ( 0.0) | ||||
| Archivo Provisional | 148839 ( 26.3) | 148780 ( 26.3) | 59 ( 28.0) | ||||
| Decisión de no perseverar en el proced | 33136 ( 5.9) | 33126 ( 5.9) | 10 ( 4.7) | ||||
| Incomp materias correspond sistema antig | 83 ( 0.0) | 83 ( 0.0) | 0 ( 0.0) | ||||
| Incomp tratarse materias conoc otro trib | 2263 ( 0.4) | 2263 ( 0.4) | 0 ( 0.0) | ||||
| Negativa investig caso autodenuncia 179 | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| No Inicio Investigación | 41831 ( 7.4) | 41812 ( 7.4) | 19 ( 9.0) | ||||
| Otras causales de término | 1248 ( 0.2) | 1248 ( 0.2) | 0 ( 0.0) | ||||
| Principio de Oportunidad | 45023 ( 8.0) | 45010 ( 8.0) | 13 ( 6.2) | ||||
| Rechazo querella de capítulos (art. 429) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| Rechazo req. Med. Seg. Opuest qte 462 | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| S Def (no subs oport vicios form art270) | 70 ( 0.0) | 70 ( 0.0) | 0 ( 0.0) | ||||
| S Definit (vencim plazo suspens art 240) | 44505 ( 7.9) | 44475 ( 7.9) | 30 ( 14.2) | ||||
| S. Definit (en casos del art. 465) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| S. Definit (exc previo y espec pron 271) | 22 ( 0.0) | 22 ( 0.0) | 0 ( 0.0) | ||||
| S. Definit (susp imposic de la cond 398) | 44 ( 0.0) | 44 ( 0.0) | 0 ( 0.0) | ||||
| Sentencia definitiva absolutoria | 11829 ( 2.1) | 11828 ( 2.1) | 1 ( 0.5) | ||||
| Sentencia definitiva condenatoria | 99918 ( 17.7) | 99876 ( 17.7) | 42 ( 19.9) | ||||
| Sobres Definit (en casos del art 247) | 12 ( 0.0) | 12 ( 0.0) | 0 ( 0.0) | ||||
| Sobres Definitivo (causales del art 250) | 28061 ( 5.0) | 28053 ( 5.0) | 8 ( 3.8) | ||||
| Término requerimiento internacional | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 10268 ( 1.8) | 10266 ( 1.8) | 2 ( 0.9) | ||||
| gls_motsuspension (%) | ACUERDO REPARATORIO | 15397 ( 2.7) | 15390 ( 2.7) | 7 ( 3.3) | 0.337 | 0.163 | |
| SOBRESEIMIENTO TEMPORAL | 2270 ( 0.4) | 2269 ( 0.4) | 1 ( 0.5) | ||||
| SUSPENSION CONDICIONAL DEL PROCEDIMIENTO | 55450 ( 9.8) | 55420 ( 9.8) | 30 ( 14.2) | ||||
| SUSPENSION PROCED. ART. 10 | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | ||||
| SUSPENSION PROCED. ART. 458 | 1713 ( 0.3) | 1713 ( 0.3) | 0 ( 0.0) | ||||
| [Missing] | 490761 ( 86.8) | 490588 ( 86.8) | 173 ( 82.0) | ||||
| gls_proctermino (%) | ABREVIADO | 21387 ( 3.8) | 21382 ( 3.8) | 5 ( 2.4) | 0.574 | 0.153 | |
| MONITORIO | 56924 ( 10.1) | 56907 ( 10.1) | 17 ( 8.1) | ||||
| ORDINARIO | 106499 ( 18.8) | 106455 ( 18.8) | 44 ( 20.9) | ||||
| RECLAMO | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| REQUERIMIENTO INTERNACIONAL | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| SIMPLIFICADO | 102433 ( 18.1) | 102386 ( 18.1) | 47 ( 22.3) | ||||
| SIN PROCEDIMIENTO | 278354 ( 49.2) | 278256 ( 49.2) | 98 ( 46.4) | ||||
| gls_tipo_imputado (%) | DENUNCIADO | 28317 ( 5.0) | 28312 ( 5.0) | 5 ( 2.4) | 0.632 | 0.152 | |
| IMPUTADO | 536374 ( 94.8) | 536168 ( 94.8) | 206 ( 97.6) | ||||
| INVESTIGADO | 27 ( 0.0) | 27 ( 0.0) | 0 ( 0.0) | ||||
| QUERELLADO | 560 ( 0.1) | 560 ( 0.1) | 0 ( 0.0) | ||||
| SOSPECHOSO | 233 ( 0.0) | 233 ( 0.0) | 0 ( 0.0) | ||||
| TESTIGO | 90 ( 0.0) | 90 ( 0.0) | 0 ( 0.0) | ||||
| lugar_ocurrencia (%) | BIENES NACIONALES USO PUBLICO | 220285 ( 38.9) | 220224 ( 39.0) | 61 ( 28.9) | 0.003 | 0.375 | |
| ESTABLECIMIENTO COMERCIAL | 91003 ( 16.1) | 90963 ( 16.1) | 40 ( 19.0) | ||||
| ESTABLECIMIENTO DE DIVERSION | 1845 ( 0.3) | 1843 ( 0.3) | 2 ( 0.9) | ||||
| ESTABLECIMIENTO EDUCACIONAL | 3389 ( 0.6) | 3388 ( 0.6) | 1 ( 0.5) | ||||
| ESTABLECIMIENTO PRODUCTIVO | 8178 ( 1.4) | 8171 ( 1.4) | 7 ( 3.3) | ||||
| LUGAR HABITADO O DESTINADO A LA HABITACION Y SUS DEPENDENCIAS | 212157 ( 37.5) | 212061 ( 37.5) | 96 ( 45.5) | ||||
| ORGANIZACION DE SEGURIDAD / JUSTICIA | 12160 ( 2.1) | 12160 ( 2.2) | 0 ( 0.0) | ||||
| ORGANIZACION PUBLICA Y/O SOCIAL | 7317 ( 1.3) | 7315 ( 1.3) | 2 ( 0.9) | ||||
| OTROS LUGARES NO CLASIFICADOS | 5625 ( 1.0) | 5625 ( 1.0) | 0 ( 0.0) | ||||
| [Missing] | 3642 ( 0.6) | 3640 ( 0.6) | 2 ( 0.9) | ||||
| region_delito (%) | I Región de Tarapaca | 18007 ( 3.2) | 18007 ( 3.2) | 0 ( 0.0) | <0.001 | 0.934 | |
| II Región de Antofagasta | 27189 ( 4.8) | 27172 ( 4.8) | 17 ( 8.1) | ||||
| III Región de Atacama | 17574 ( 3.1) | 17555 ( 3.1) | 19 ( 9.0) | ||||
| IV Región de Coquimbo | 22977 ( 4.1) | 22972 ( 4.1) | 5 ( 2.4) | ||||
| IX Región de la Araucanía | 15508 ( 2.7) | 15484 ( 2.7) | 24 ( 11.4) | ||||
| No Definido | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| Región Metropolitana de Santiago | 248964 ( 44.0) | 248922 ( 44.0) | 42 ( 19.9) | ||||
| RM Centro Norte | 18 ( 0.0) | 18 ( 0.0) | 0 ( 0.0) | ||||
| RM Occidente | 8 ( 0.0) | 8 ( 0.0) | 0 ( 0.0) | ||||
| RM Oriente | 9 ( 0.0) | 9 ( 0.0) | 0 ( 0.0) | ||||
| RM Sur | 36 ( 0.0) | 36 ( 0.0) | 0 ( 0.0) | ||||
| V Región de Valparaíso | 55117 ( 9.7) | 55107 ( 9.7) | 10 ( 4.7) | ||||
| VI Región del Libertador Gral. Bernardo O Higgins | 33245 ( 5.9) | 33224 ( 5.9) | 21 ( 10.0) | ||||
| VII Región del Maule | 29896 ( 5.3) | 29885 ( 5.3) | 11 ( 5.2) | ||||
| VIII Región del Bio Bio | 38456 ( 6.8) | 38437 ( 6.8) | 19 ( 9.0) | ||||
| X Región de los Lagos | 19283 ( 3.4) | 19265 ( 3.4) | 18 ( 8.5) | ||||
| XI Región Aysen del Gral. Carlos Ibañez del Campo | 5335 ( 0.9) | 5331 ( 0.9) | 4 ( 1.9) | ||||
| XII Región de Magallanes y de la Antartica Chilena | 5184 ( 0.9) | 5166 ( 0.9) | 18 ( 8.5) | ||||
| XIV Región de los Rios | 8365 ( 1.5) | 8364 ( 1.5) | 1 ( 0.5) | ||||
| XV Región de Arica y Parinacota | 13787 ( 2.4) | 13785 ( 2.4) | 2 ( 0.9) | ||||
| XVI Región del Ñuble | 5697 ( 1.0) | 5697 ( 1.0) | 0 ( 0.0) | ||||
| [Missing] | 942 ( 0.2) | 942 ( 0.2) | 0 ( 0.0) | ||||
| medidas_155 (%) | SI | 57243 ( 10.1) | 57226 ( 10.1) | 17 ( 8.1) | 0.379 | 0.072 | |
| [Missing] | 508358 ( 89.9) | 508164 ( 89.9) | 194 ( 91.9) | ||||
| medidas_pp (%) | SI | 22236 ( 3.9) | 22232 ( 3.9) | 4 ( 1.9) | 0.179 | 0.121 | |
| [Missing] | 543365 ( 96.1) | 543158 ( 96.1) | 207 ( 98.1) | ||||
| medidas_ip (%) | SI | 730 ( 0.1) | 730 ( 0.1) | 0 ( 0.0) | 1.000 | 0.051 | |
| [Missing] | 564871 ( 99.9) | 564660 ( 99.9) | 211 (100.0) | ||||
| marca_suspension_43 (%) | NO | 67050 ( 11.9) | 67022 ( 11.9) | 28 ( 13.3) | 0.058 | 0.116 | |
| SI | 2341 ( 0.4) | 2338 ( 0.4) | 3 ( 1.4) | ||||
| [Missing] | 496210 ( 87.7) | 496030 ( 87.7) | 180 ( 85.3) | ||||
| marca_pena_44 (%) | SI | 69391 ( 12.3) | 69360 ( 12.3) | 31 ( 14.7) | 0.333 | 0.071 | |
| [Missing] | 496210 ( 87.7) | 496030 ( 87.7) | 180 ( 85.3) | ||||
| marca_multa_45 (%) | NO | 35119 ( 6.2) | 35110 ( 6.2) | 9 ( 4.3) | 0.018 | 0.177 | |
| SI | 34272 ( 6.1) | 34250 ( 6.1) | 22 ( 10.4) | ||||
| [Missing] | 496210 ( 87.7) | 496030 ( 87.7) | 180 ( 85.3) | ||||
| medida_alternativa_46 (%) | Libertad Vigilada | 3200 ( 0.6) | 3200 ( 0.6) | 0 ( 0.0) | 0.493 | 0.140 | |
| Otra | 4982 ( 0.9) | 4979 ( 0.9) | 3 ( 1.4) | ||||
| Reclusión Nocturna | 14041 ( 2.5) | 14033 ( 2.5) | 8 ( 3.8) | ||||
| Remisión Condicional | 18320 ( 3.2) | 18313 ( 3.2) | 7 ( 3.3) | ||||
| [Missing] | 525058 ( 92.8) | 524865 ( 92.8) | 193 ( 91.5) | ||||
| clasificacion_pena_47 (%) | Presidio Mayor grado máximo | 83 ( 0.0) | 83 ( 0.0) | 0 ( 0.0) | 0.690 | 0.202 | |
| Presidio Mayor grado medio | 467 ( 0.1) | 467 ( 0.1) | 0 ( 0.0) | ||||
| Presidio Mayor grado mínimo | 1917 ( 0.3) | 1917 ( 0.3) | 0 ( 0.0) | ||||
| Presidio Menor grado máximo | 4960 ( 0.9) | 4960 ( 0.9) | 0 ( 0.0) | ||||
| Presidio Menor grado medio | 8774 ( 1.6) | 8770 ( 1.6) | 4 ( 1.9) | ||||
| Presidio Menor grado mínimo | 29524 ( 5.2) | 29507 ( 5.2) | 17 ( 8.1) | ||||
| Presidio Perpetuo calificado | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Perpetuo simple | 14 ( 0.0) | 14 ( 0.0) | 0 ( 0.0) | ||||
| Prisión | 23651 ( 4.2) | 23641 ( 4.2) | 10 ( 4.7) | ||||
| [Missing] | 496210 ( 87.7) | 496030 ( 87.7) | 180 ( 85.3) | ||||
| tramos_condena_48 (%) | 1 día a 60 días | 2115 ( 0.4) | 2115 ( 0.4) | 0 ( 0.0) | 0.927 | 0.114 | |
| 3 años y 1 día a 5 años | 203 ( 0.0) | 203 ( 0.0) | 0 ( 0.0) | ||||
| 541 días a 3 años | 626 ( 0.1) | 626 ( 0.1) | 0 ( 0.0) | ||||
| 61 días a 540 días | 690 ( 0.1) | 690 ( 0.1) | 0 ( 0.0) | ||||
| Desde 5 años y 1 día | 38 ( 0.0) | 38 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 561929 ( 99.4) | 561718 ( 99.4) | 211 (100.0) | ||||
| clasificacion_penarpa_1_49 (%) | Amonestación | 614 ( 0.1) | 614 ( 0.1) | 0 ( 0.0) | 0.995 | 0.114 | |
| Int. Reg. Cerrado con Prog. de Reinserción Social | 88 ( 0.0) | 88 ( 0.0) | 0 ( 0.0) | ||||
| Int. Reg. Semicerrado con Prog. de Reinserción Social | 162 ( 0.0) | 162 ( 0.0) | 0 ( 0.0) | ||||
| Libertad Asistida | 492 ( 0.1) | 492 ( 0.1) | 0 ( 0.0) | ||||
| Libertad Asistida Especial | 694 ( 0.1) | 694 ( 0.1) | 0 ( 0.0) | ||||
| Multa | 343 ( 0.1) | 343 ( 0.1) | 0 ( 0.0) | ||||
| Prestación de Servicios en Beneficio de la Comunidad | 1270 ( 0.2) | 1270 ( 0.2) | 0 ( 0.0) | ||||
| Reparación del Daño Causado | 14 ( 0.0) | 14 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 561924 ( 99.3) | 561713 ( 99.3) | 211 (100.0) | ||||
| clasificacion_penarpa_2_50 (%) | Int. Reg. Semicerrado con Prog. de Reinserción Social | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | 1.000 | 0.021 | |
| Libertad Asistida | 28 ( 0.0) | 28 ( 0.0) | 0 ( 0.0) | ||||
| Libertad Asistida Especial | 71 ( 0.0) | 71 ( 0.0) | 0 ( 0.0) | ||||
| Prestación de Servicios en Beneficio de la Comunidad | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565482 (100.0) | 565271 (100.0) | 211 (100.0) | ||||
| marca_suspension_51 (%) | NO | 74 ( 0.0) | 74 ( 0.0) | 0 ( 0.0) | 0.986 | 0.017 | |
| SI | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 565313 (100.0) | 211 (100.0) | ||||
| marca_pena_52 (%) | SI | 77 ( 0.0) | 77 ( 0.0) | 0 ( 0.0) | 1.000 | 0.017 | |
| [Missing] | 565524 (100.0) | 565313 (100.0) | 211 (100.0) | ||||
| marca_multa_53 (%) | NO | 46 ( 0.0) | 46 ( 0.0) | 0 ( 0.0) | 0.986 | 0.017 | |
| SI | 31 ( 0.0) | 31 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 565313 (100.0) | 211 (100.0) | ||||
| medida_alternativa_54 (%) | Libertad Vigilada | 8 ( 0.0) | 8 ( 0.0) | 0 ( 0.0) | 1.000 | 0.013 | |
| Otra | 5 ( 0.0) | 5 ( 0.0) | 0 ( 0.0) | ||||
| Reclusión Nocturna | 17 ( 0.0) | 17 ( 0.0) | 0 ( 0.0) | ||||
| Remisión Condicional | 15 ( 0.0) | 15 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565556 (100.0) | 565345 (100.0) | 211 (100.0) | ||||
| clasificacion_pena_55 (%) | Presidio Mayor grado medio | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | 1.000 | 0.017 | |
| Presidio Mayor grado mínimo | 5 ( 0.0) | 5 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado máximo | 12 ( 0.0) | 12 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado medio | 9 ( 0.0) | 9 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado mínimo | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| Prisión | 27 ( 0.0) | 27 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 565313 (100.0) | 211 (100.0) | ||||
| cut_com_del2 (%) | [1972-12-21,2009-12-20) | 26920 ( 4.8) | 26912 ( 4.8) | 8 ( 3.8) | 0.012 | 0.461 | |
| [2009-12-20,2010-06-23) | 26882 ( 4.8) | 26866 ( 4.8) | 16 ( 7.6) | ||||
| [2010-06-23,2010-12-18) | 26889 ( 4.8) | 26878 ( 4.8) | 11 ( 5.2) | ||||
| [2010-12-18,2011-05-27) | 26885 ( 4.8) | 26868 ( 4.8) | 17 ( 8.1) | ||||
| [2011-05-27,2011-11-04) | 27034 ( 4.8) | 27027 ( 4.8) | 7 ( 3.3) | ||||
| [2011-11-04,2012-04-04) | 26977 ( 4.8) | 26971 ( 4.8) | 6 ( 2.8) | ||||
| [2012-04-04,2012-09-16) | 26868 ( 4.8) | 26850 ( 4.7) | 18 ( 8.5) | ||||
| [2012-09-16,2013-02-23) | 26866 ( 4.7) | 26854 ( 4.7) | 12 ( 5.7) | ||||
| [2013-02-23,2013-08-12) | 26995 ( 4.8) | 26993 ( 4.8) | 2 ( 0.9) | ||||
| [2013-08-12,2014-01-27) | 26959 ( 4.8) | 26956 ( 4.8) | 3 ( 1.4) | ||||
| [2014-01-27,2014-07-21) | 26861 ( 4.7) | 26853 ( 4.7) | 8 ( 3.8) | ||||
| [2014-07-21,2015-01-06) | 26993 ( 4.8) | 26979 ( 4.8) | 14 ( 6.6) | ||||
| [2015-01-06,2015-06-30) | 26965 ( 4.8) | 26953 ( 4.8) | 12 ( 5.7) | ||||
| [2015-06-30,2015-12-25) | 26909 ( 4.8) | 26899 ( 4.8) | 10 ( 4.7) | ||||
| [2015-12-25,2016-06-22) | 26947 ( 4.8) | 26935 ( 4.8) | 12 ( 5.7) | ||||
| [2016-06-22,2016-12-23) | 26943 ( 4.8) | 26931 ( 4.8) | 12 ( 5.7) | ||||
| [2016-12-23,2017-06-28) | 26852 ( 4.7) | 26845 ( 4.7) | 7 ( 3.3) | ||||
| [2017-06-28,2018-01-03) | 26996 ( 4.8) | 26988 ( 4.8) | 8 ( 3.8) | ||||
| [2018-01-03,2018-07-19) | 26859 ( 4.7) | 26854 ( 4.7) | 5 ( 2.4) | ||||
| [2018-07-19,2019-02-06) | 26979 ( 4.8) | 26965 ( 4.8) | 14 ( 6.6) | ||||
| [2019-02-06,2019-11-13] | 26981 ( 4.8) | 26972 ( 4.8) | 9 ( 4.3) | ||||
| [Missing] | 41 ( 0.0) | 41 ( 0.0) | 0 ( 0.0) | ||||
| cut_fec_nac2 (%) | [1930-01-18,1963-06-08) | 26929 ( 4.8) | 26899 ( 4.8) | 30 ( 14.2) | <0.001 | 1.224 | |
| [1963-06-08,1967-11-30) | 26937 ( 4.8) | 26899 ( 4.8) | 38 ( 18.0) | ||||
| [1967-11-30,1970-12-12) | 26920 ( 4.8) | 26912 ( 4.8) | 8 ( 3.8) | ||||
| [1970-12-12,1973-03-18) | 26935 ( 4.8) | 26924 ( 4.8) | 11 ( 5.2) | ||||
| [1973-03-18,1975-02-23) | 26930 ( 4.8) | 26928 ( 4.8) | 2 ( 0.9) | ||||
| [1975-02-23,1977-01-21) | 26934 ( 4.8) | 26900 ( 4.8) | 34 ( 16.1) | ||||
| [1977-01-21,1978-11-01) | 26933 ( 4.8) | 26910 ( 4.8) | 23 ( 10.9) | ||||
| [1978-11-01,1980-04-05) | 26929 ( 4.8) | 26929 ( 4.8) | 0 ( 0.0) | ||||
| [1980-04-05,1981-06-11) | 26937 ( 4.8) | 26930 ( 4.8) | 7 ( 3.3) | ||||
| [1981-06-11,1982-06-18) | 26934 ( 4.8) | 26925 ( 4.8) | 9 ( 4.3) | ||||
| [1982-06-18,1983-07-04) | 26929 ( 4.8) | 26928 ( 4.8) | 1 ( 0.5) | ||||
| [1983-07-04,1984-08-16) | 26839 ( 4.7) | 26834 ( 4.7) | 5 ( 2.4) | ||||
| [1984-08-16,1985-10-03) | 27000 ( 4.8) | 27000 ( 4.8) | 0 ( 0.0) | ||||
| [1985-10-03,1986-11-21) | 26961 ( 4.8) | 26955 ( 4.8) | 6 ( 2.8) | ||||
| [1986-11-21,1988-01-10) | 26898 ( 4.8) | 26898 ( 4.8) | 0 ( 0.0) | ||||
| [1988-01-10,1989-02-03) | 26976 ( 4.8) | 26972 ( 4.8) | 4 ( 1.9) | ||||
| [1989-02-03,1990-04-02) | 26880 ( 4.8) | 26862 ( 4.8) | 18 ( 8.5) | ||||
| [1990-04-02,1991-06-11) | 26980 ( 4.8) | 26980 ( 4.8) | 0 ( 0.0) | ||||
| [1991-06-11,1992-12-13) | 26926 ( 4.8) | 26916 ( 4.8) | 10 ( 4.7) | ||||
| [1992-12-13,1994-11-24) | 26951 ( 4.8) | 26948 ( 4.8) | 3 ( 1.4) | ||||
| [1994-11-24,2001-09-29] | 26932 ( 4.8) | 26930 ( 4.8) | 2 ( 0.9) | ||||
| [Missing] | 11 ( 0.0) | 11 ( 0.0) | 0 ( 0.0) |
#kableExtra::scroll_box(width = "100%", height = "375px")
Some records had a “undefined” value in sex (n= 211, p= 49). Many of these cases did not have a date of birth and nationallity, and seem to have other characteristics that may differentiate them from cases that have a defined sex in the database. In PO everyone had consistent values along their records. The criteria to replace values were based in the presence of records with values associated to pregnancy, stay in centers for women and treatments for women. Some of them include more “DELITOS ECONÓMICOS Y TRIBUTARIOS”, “DELITOS LEY DE TRÁNSITO HOMICIDIOS”, but less “OTROS DELITOS CONTRA LA PROPIEDAD FALTAS LESIONES”. In terms of finishing the proceedings, they had more “No Inicio Investigación”, “S Definit (vencim plazo suspens art 240)”, “Sentencia definitiva absolutoria” (grouped in SUSPENSION CONDICIONAL DEL PROCEDIMIENTO ), but also “Sentencia definitiva condenatoria”. Less crimes were commited in the Metropolitan Region and less individuals were born before 1940.
message(paste0("Missing values in P.O. not replaceable by SENDAs values (both missing)= ",
Base_fiscalia_v5 %>%
dplyr::mutate(sexo=dplyr::case_when(sexo=="No Definido"~NA_character_,T~sexo)) %>%
dplyr::filter(is.na(sexo)) %>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","nacionalidad","etnia_cor","sexo_2")),by=c("rut_enc_saf"="hash_key"))%>%
dplyr::filter(is.na(sexo_2)) %>%
nrow())
)
message("Users with different values in sex between SENDA and P.O.")
differences_bet_sex_po<-
Base_fiscalia_v5 %>%
dplyr::mutate(sexo=dplyr::case_when(sexo=="No Definido"~NA_character_,T~sexo)) %>%
dplyr::group_by(rut_enc_saf) %>%
dplyr::mutate(dist_sex=n_distinct(sexo), dist_ruc=n_distinct(ruc)) %>%
dplyr::ungroup() %>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","nacionalidad","etnia_cor","sexo_2")),by=c("rut_enc_saf"="hash_key"))%>%
dplyr::mutate(sexo=dplyr::case_when(sexo=="FEMENINO"~"Women",sexo=="MASCULINO"~"Men",T~NA_character_))%>%
dplyr::select("rut_enc_saf","sexo","sexo_2","pais","nacionalidad", "etnia_cor", "ruc", "obs", "dist_sex", "dist_ruc") %>%
dplyr::mutate(step0=dplyr::case_when(is.na(sexo) & is.na(sexo_2)~1,T~0)) %>%
dplyr::filter(sexo!=as.character(sexo_2))
invisible("In PO everyone had consistent sexes in their records")
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
# - Percentage of records as different sexes (C1)
CONS_C1_res_sex<-
CONS_C1 %>%
dplyr::filter(HASH_KEY %in% unlist(differences_bet_sex_po$rut_enc_saf)) %>%
dplyr::mutate(sexo=dplyr::case_when(Sexo=="Mujer"~"Women",Sexo=="Hombre"~"Men",T~NA_character_))%>%
dplyr::group_by(HASH_KEY) %>%
dplyr::summarise(length_women_center=sum(grepl("Mujeres",`Nombre.Centro`), na.rm=T),length_preg= sum(`X.Se.trata.de.una.mujer.embarazada.`=="Si", na.rm=T), length_preg_egr= sum(`Ha.estado.embarazada.egreso.`=="si"), length_women= sum(sexo=="Women", na.rm=T), length_men= sum(sexo=="Men", na.rm=T), length_c1=n())%>%
dplyr::distinct(HASH_KEY,.keep_all = T)
# - Percentage of records as different sexes (TOP)
TOP_sex<-
CONS_TOP%>%
dplyr::filter(HASH_KEY %in% unlist(differences_bet_sex_po$rut_enc_saf)) %>%
dplyr::mutate(sexo=dplyr::case_when(Sexo=="Mujer"~"Women",Sexo=="Hombre"~"Men",T~NA_character_))%>%
dplyr::group_by(HASH_KEY) %>%
dplyr::summarise(length_women_center_top=sum(grepl("Mujeres",`Nombre.del.Centro`), na.rm=T), length_women_top= sum(sexo=="Women", na.rm=T), length_men_top= sum(sexo=="Men", na.rm=T), length_top=n())%>% dplyr::distinct(HASH_KEY,.keep_all = T)
C1_centers_SEP_2020<-
CONS_C1_df_dup_SEP_2020%>%
dplyr::filter(hash_key %in% unlist(differences_bet_sex_po$rut_enc_saf)) %>%
dplyr::mutate(across(paste0("tipo_de_plan_2_",1:10),~dplyr::case_when(grepl("M\\-",as.character(.))~1,TRUE~0), .names="instudy_{col}")) %>% dplyr::mutate(sum_m_tipo_trat=base::rowSums(dplyr::select(.,paste0("instudy_tipo_de_plan_2_",1:10)), na.rm=T))%>%
dplyr::distinct(hash_key, .keep_all = T) %>%
dplyr::select(hash_key, duplicates_filtered, sum_m_tipo_trat)
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#Integrate
differences_bet_sex_po2<-
differences_bet_sex_po %>%
#there are no duplicated hashes
dplyr::left_join(dplyr::left_join(CONS_C1_res_sex,TOP_sex,by="HASH_KEY"), by=c("rut_enc_saf"="HASH_KEY"))%>%
dplyr::left_join(C1_centers_SEP_2020, by=c("rut_enc_saf"="hash_key"))%>%
#generate a summary of records of C1 & TOP
dplyr::mutate(sum_n=rowSums(dplyr::select(.,length_c1,length_top),na.rm=T), perc_women_center= rowSums(dplyr::select(.,length_women_center,length_women_center_top),na.rm=T)/sum_n, perc_women= rowSums(dplyr::select(.,length_women_center,length_women_center_top),na.rm=T)/sum_n, perc_m_tipo_trat=sum_m_tipo_trat/duplicates_filtered) %>%
dplyr::select("rut_enc_saf","sexo","sexo_2","pais","nacionalidad","etnia_cor","ruc", "dist_ruc","obs","sum_n","perc_women_center","perc_women", "length_preg", "length_preg_egr", "sum_m_tipo_trat") %>%
dplyr::mutate(step1=dplyr::case_when(grepl("2.6.01|3.03",obs)~1,T~0), step2a= dplyr::case_when(step1==0 & sum_n>2 & (perc_women_center>=.5| perc_women>=.5)~1,T~0), step2b= dplyr::case_when(step1==0 & sum_n>1 & perc_women_center>=.5 & perc_women>=.5~1,T~0), step2c= dplyr::case_when(step1==0 & sum_n>0 & (perc_women_center>=.5 & perc_women>=.5) & (length_preg>0|length_preg_egr>0)~1,T~0), step2d= dplyr::case_when(step1==0 & (perc_women_center>=.5 & perc_women>=.5) & sum_m_tipo_trat>0~1,T~0), step2e= dplyr::case_when(step1==0 & dist_ruc<2 & sum_m_tipo_trat>0~1, T~0), step2f=dplyr::case_when(step1==0 & step2a==0& step2b==0& step2c==0& step2d==0& step2e==0~1,T~0))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_
message(paste0('No discrepancies in sex (& missings) (22_2_b) \n(n = ',format(nrow(dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_sex_po$rut_enc_saf))),big.mark=","),
';\nCauses= ',dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_sex_po$rut_enc_saf))%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),
';\nindividuals= ',dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_sex_po$rut_enc_saf))%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Missings (22_2_b1) \n(n = ',format(nrow(dplyr::filter(Base_fiscalia_v5, sexo =="No Definido")),big.mark=","),
';\nCauses= ',dplyr::filter(Base_fiscalia_v5, sexo =="No Definido")%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),
';\nindividuals= ',dplyr::filter(Base_fiscalia_v5, sexo =="No Definido")%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
#_#_#_#_#_#_#_
message(paste0('Discrepancies in sex (22_2_a) \n(n = ',format(nrow(differences_bet_sex_po),big.mark=","),
';\nCauses= ',differences_bet_sex_po%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),
';\nindividuals= ',differences_bet_sex_po%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
#_#_#_#_#_#_#_
message(paste0('Differences in sex w/ imputed earlier (22_2_a2) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po,grepl("2.6.01|3.03",obs))),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po,grepl("2.6.01|3.03",obs))%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po,grepl("2.6.01|3.03",obs))%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier (22_2_a1) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po,!grepl("2.6.01|3.03",obs))),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po,!grepl("2.6.01|3.03",obs))%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po,!grepl("2.6.01|3.03",obs))%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier, >2 records in TOP or C1,\n>=50% of records in a center for women or stated as a woman, but PO==man (22_2_a1a) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2a==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2a==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2a==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier,>1 records in TOP or C1,\n>=50% of records in a center for women and stated as a woman, but PO==man (22_2_a1b) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2b==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2b==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2b==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier, >=50% of records in a center for women or stated as a woman,\nat least one record pregnant at admission or discharge, but PO==man (22_2_a1c) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2c==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2c==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2c==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier, >=50% of records in a center\nfor women or stated as a woman, at least one record in women-only treatments, but PO==man (22_2_a1d) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2d==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2d==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2d==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier but PO==man, at least one record\nin women-only treatments vs. <2 distinct causes in PO (22_2_a1e) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2e==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2e==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2e==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Differences in sex w/o imputed earlier but PO==man, else (22_2_a1f) \n(n = ',format(nrow(dplyr::filter(differences_bet_sex_po2,step2f==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_sex_po2,step2f==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_sex_po2,step2f==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
invisible("Else could overlap the other counts because alternatives are not mutually exclusive")
# porque cuando saco la diferencia de los casos tengo 7493 y 8687
# 619 son los ocasos que sumo en la figura, pero aquí sumo
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
differences_bet_sex_po3<-
differences_bet_sex_po2 %>%
dplyr::distinct(rut_enc_saf, .keep_all=T) %>%
dplyr::mutate(flowch_sex= dplyr::case_when(step1==1~"22_2_a2- discordant sex, but imputed previously", step1==0 & step2a==1~"22_2_a1a",step1==0 & step2a==0 & step2b==1~"22_2_a1b",step1==0 & step2a==0 & step2b==0 & step2c==1~"22_2_a1c",step1==0 & step2a==0 & step2b==0 & step2c==0 & step2d==1~"22_2_a1d", step1==0 & step2a==0 & step2b==0 & step2c==0 & step2d==0 & step2e==1~"22_2_a1e",T~"22_2_a1f"))
#2.6.01.2b1.HASH w/ more than one distinct Sex. Recent db (>1) --> 2.6.01, correspondiente a sexo
#"{obs};3.03.1.XX.HASH w/ more than one distinct Sex.2 cases, same yearly dataset.Neural network imputation"
#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ
#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ#Ñ++++++▼
#knitr::include_graphics(paste0(sub("2019 \\(github\\)/SUD_CL","2022 \\(github\\)",path), "/_figs/diagram_sex_differences.bpmn"))
bpmn_file <- system.file(paste0(sub("2019 \\(github\\)/SUD_CL","2022 \\(github\\)",path), "/_figs/diagram_sex_differences.bpmn"), package = "bpmn")
bpmn::bpmn(paste0(sub("2019 \\(github\\)/SUD_CL","2022 \\(github\\)",path), "/_figs/diagram_sex_differences.bpmn"))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
CONS_C1_tr_sex<-
CONS_C1 %>%
dplyr::filter(HASH_KEY %in% unlist(differences_bet_sex_po$rut_enc_saf)) %>%
dplyr::group_by(HASH_KEY) %>%
dplyr::mutate(sexo=dplyr::case_when(Sexo=="Mujer"~"Women",Sexo=="Hombre"~"Men",T~NA_character_))%>%
dplyr::summarise(length_women_tr=sum(grepl("M\\-",`Tipo.de.Plan`)), length_c1=n(), perc_women_tr= length_women_tr/length_c1, length_women= sum(sexo=="Women"))%>%
dplyr::distinct(HASH_KEY,.keep_all = T)
#1b7e964a46082cca61540f18ef51ff07 es femenino pero sale como masculino
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
invisible("Users that must need to change")
Base_fiscalia_v6<-
Base_fiscalia_v5%>%
dplyr::left_join(differences_bet_sex_po3[c("rut_enc_saf","flowch_sex")], by="rut_enc_saf")%>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","sexo_2")), by=c("rut_enc_saf"="hash_key"))%>%#22_2_b1
dplyr::mutate(sex_imp= dplyr::case_when(sexo=="FEMENINO"~"Women",sexo=="MASCULINO"~"Men",T~NA_character_))%>%
dplyr::mutate(obs=case_when(is.na(sex_imp)& !is.na(obs)~ glue::glue("{obs};22_2_b1"),
is.na(sex_imp)& is.na(obs)~ glue::glue("{flowch_sex}"),
TRUE~obs)) %>%
dplyr::mutate(sex_imp= dplyr::case_when(is.na(sex_imp)~ as.character(sexo_2),
grepl("a1a|a1b|a1c1|a1d|a1e",flowch_sex)~ "Women",
grepl("a1f",flowch_sex)~ "Men",
T~ sex_imp)) %>%
dplyr::mutate(obs=case_when(!is.na(flowch_sex)& !is.na(obs)~ glue::glue("{obs};{flowch_sex}"),
!is.na(flowch_sex)& is.na(obs)~ glue::glue("{flowch_sex}"),
TRUE~obs)) %>%
dplyr::select(-flowch_sex, -sexo_2)
#paste0("Number of records finally imputed (22_2_a1f)= ",table(grepl("22_2_a1f",Base_fiscalia_v6$obs))[[2]],"\n individuals= ", nrow(Base_fiscalia_v6[grepl("22_2_a1f",Base_fiscalia_v6$obs),] %>% distinct(rut_enc_saf)))
#check if added rows
if(nrow(Base_fiscalia_v6)-nrow(Base_fiscalia_v5)>0){
stop("Some rows were added in the imputation")}
There are 2,162 records (individuals= 222) corresponding to men receiving women-only treatments. These should be replaced once merging is done.
message(paste0("Missing values in P.O. not replaceable by \nSENDAs values (both missing)= ",
Base_fiscalia_v6 %>%
dplyr::mutate(pais=dplyr::case_when(pais=="No Definido"~NA_character_,T~pais)) %>%
dplyr::filter(is.na(pais)) %>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","nacionalidad","etnia_cor")),by=c("rut_enc_saf"="hash_key"))%>%
dplyr::filter(is.na(nacionalidad)) %>%
nrow())
)
as.data.frame.TableOne(CreateTableOne(vars= setdiff(c(myVars,"cut_com_del2","cut_fec_nac2"), c("gls_comuna", "gls_sitiosuceso", "gls_materia", "reg")), data= dplyr::mutate(Base_fiscalia_v6, nat_nodef=ifelse(pais=="No Definido",1,0), cut_fec_nac2=cut2(imp_birth_date, cuts=as.Date(attr(binning(as.numeric(imp_birth_date)),"breaks"))),cut_com_del2=cut2(fec_comision_simple, cuts=as.Date(attr(binning(as.numeric(fec_comision_simple)),"breaks")))), factorVars = catVars, smd=T, strata="nat_nodef", addOverall = T, includeNA=T,test=T), smd=T)%>%
dplyr::mutate(char2=characteristic) %>%
tidyr::fill(char2) %>%
dplyr::select(char2,everything()) %>%
dplyr::mutate(level=ifelse(is.na(level),"[Missing]",level)) %>%
dplyr::mutate(char2=dplyr::case_when(characteristic=="NA"~NA_character_,T~as.character(characteristic)))%>%
format_cells(1, 1:9, "bold") %>%
dplyr::select(-1) %>%
kable(size=10, format="markdown",caption= "Summary descriptives, if nationality is not defined (1)")
| characteristic | level | Overall | 0 | 1 | p | test | SMD |
|---|---|---|---|---|---|---|---|
| n | 565601 | 563507 | 2094 | ||||
| encontrado_como_victima (%) | NO | 375616 ( 66.4) | 374304 ( 66.4) | 1312 ( 62.7) | <0.001 | 0.079 | |
| SI | 189985 ( 33.6) | 189203 ( 33.6) | 782 ( 37.3) | ||||
| encontrado_como_imputado (%) | NO | 189624 ( 33.5) | 188843 ( 33.5) | 781 ( 37.3) | <0.001 | 0.079 | |
| SI | 375977 ( 66.5) | 374664 ( 66.5) | 1313 ( 62.7) | ||||
| tipo_sujeto_vic (%) | 1 | 304 ( 0.1) | 302 ( 0.1) | 2 ( 0.1) | 0.267 | 0.074 | |
| 15 | 226 ( 0.0) | 225 ( 0.0) | 1 ( 0.0) | ||||
| 19 | 328 ( 0.1) | 326 ( 0.1) | 2 ( 0.1) | ||||
| 2 | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| 3 | 13 ( 0.0) | 13 ( 0.0) | 0 ( 0.0) | ||||
| 5 | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| 6 | 546716 ( 96.7) | 544670 ( 96.7) | 2046 ( 97.7) | ||||
| 8 | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 18007 ( 3.2) | 17964 ( 3.2) | 43 ( 2.1) | ||||
| gls_tipo_sujeto_vic (%) | ABOGADO QUERELLANTE | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | 0.267 | 0.074 | |
| DENUNCIADO | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| DENUNCIANTE | 304 ( 0.1) | 302 ( 0.1) | 2 ( 0.1) | ||||
| IMPUTADO | 13 ( 0.0) | 13 ( 0.0) | 0 ( 0.0) | ||||
| QUERELLANTE | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| TESTIGO | 226 ( 0.0) | 225 ( 0.0) | 1 ( 0.0) | ||||
| VICTIMA | 546716 ( 96.7) | 544670 ( 96.7) | 2046 ( 97.7) | ||||
| VICTIMA 108i.2 | 328 ( 0.1) | 326 ( 0.1) | 2 ( 0.1) | ||||
| [Missing] | 18007 ( 3.2) | 17964 ( 3.2) | 43 ( 2.1) | ||||
| gls_region (%) | I Región de Tarapaca | 17981 ( 3.2) | 17967 ( 3.2) | 14 ( 0.7) | <0.001 | 0.377 | |
| II Región de Antofagasta | 27197 ( 4.8) | 27136 ( 4.8) | 61 ( 2.9) | ||||
| III Región de Atacama | 17584 ( 3.1) | 17538 ( 3.1) | 46 ( 2.2) | ||||
| IV Región de Coquimbo | 23003 ( 4.1) | 22962 ( 4.1) | 41 ( 2.0) | ||||
| IX Región de la Araucanía | 15499 ( 2.7) | 15407 ( 2.7) | 92 ( 4.4) | ||||
| RM Centro Norte | 78291 ( 13.8) | 77956 ( 13.8) | 335 ( 16.0) | ||||
| RM Occidente | 63504 ( 11.2) | 63177 ( 11.2) | 327 ( 15.6) | ||||
| RM Oriente | 43972 ( 7.8) | 43822 ( 7.8) | 150 ( 7.2) | ||||
| RM Sur | 63576 ( 11.2) | 63316 ( 11.2) | 260 ( 12.4) | ||||
| V Región de Valparaíso | 55192 ( 9.8) | 55052 ( 9.8) | 140 ( 6.7) | ||||
| VI Región del Libertador Gral. Bernardo O Higgins | 33361 ( 5.9) | 33275 ( 5.9) | 86 ( 4.1) | ||||
| VII Región del Maule | 30042 ( 5.3) | 29871 ( 5.3) | 171 ( 8.2) | ||||
| VIII Región del Bio Bio | 38462 ( 6.8) | 38281 ( 6.8) | 181 ( 8.6) | ||||
| X Región de los Lagos | 19279 ( 3.4) | 19211 ( 3.4) | 68 ( 3.2) | ||||
| XI Región Aysen del Gral. Carlos Ibañez del Campo | 5354 ( 0.9) | 5344 ( 0.9) | 10 ( 0.5) | ||||
| XII Región de Magallanes y de la Antartica Chilena | 5183 ( 0.9) | 5146 ( 0.9) | 37 ( 1.8) | ||||
| XIV Región de los Rios | 8405 ( 1.5) | 8377 ( 1.5) | 28 ( 1.3) | ||||
| XV Región de Arica y Parinacota | 13907 ( 2.5) | 13870 ( 2.5) | 37 ( 1.8) | ||||
| XVI Región del Ñuble | 5809 ( 1.0) | 5799 ( 1.0) | 10 ( 0.5) | ||||
| tipo_termino (%) | OTROS T¿RMINOS | 31693 ( 5.6) | 31574 ( 5.6) | 119 ( 5.7) | 0.762 | 0.024 | |
| SALIDA JUDICIAL | 304543 ( 53.8) | 303439 ( 53.8) | 1104 ( 52.7) | ||||
| SALIDA NO JUDICIAL | 229344 ( 40.5) | 228473 ( 40.5) | 871 ( 41.6) | ||||
| [Missing] | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| agrupa_terminos (%) | ACUERDO REPARATORIO | 13622 ( 2.4) | 13561 ( 2.4) | 61 ( 2.9) | <0.001 | 0.351 | |
| AGRUPACI¿N A OTRO CASO | 28024 ( 5.0) | 27912 ( 5.0) | 112 ( 5.3) | ||||
| ANULACI¿N ADMINISTRATIVA | 1503 ( 0.3) | 1500 ( 0.3) | 3 ( 0.1) | ||||
| ARCHIVO PROVISIONAL | 148839 ( 26.3) | 148242 ( 26.3) | 597 ( 28.5) | ||||
| DECISI¿N DE NO PERSEVERAR | 33136 ( 5.9) | 33011 ( 5.9) | 125 ( 6.0) | ||||
| FACULTAD PARA NO INVESTIGAR | 41831 ( 7.4) | 41585 ( 7.4) | 246 ( 11.7) | ||||
| INCOMPETENCIA | 2346 ( 0.4) | 2333 ( 0.4) | 13 ( 0.6) | ||||
| OTRAS CAUSALES DE SUSPENSI¿N | 913 ( 0.2) | 911 ( 0.2) | 2 ( 0.1) | ||||
| OTRAS CAUSALES DE T¿RMINO | 1253 ( 0.2) | 1251 ( 0.2) | 2 ( 0.1) | ||||
| PRINCIPIO DE OPORTUNIDAD | 45023 ( 8.0) | 44887 ( 8.0) | 136 ( 6.5) | ||||
| SENTENCIA DEFINITIVA ABSOLUTORIA | 11829 ( 2.1) | 11804 ( 2.1) | 25 ( 1.2) | ||||
| SENTENCIA DEFINITIVA CONDENATORIA | 156788 ( 27.7) | 156429 ( 27.8) | 359 ( 17.1) | ||||
| SOBRESEIMIENTO DEFINITIVO | 28215 ( 5.0) | 28068 ( 5.0) | 147 ( 7.0) | ||||
| SOBRESEIMIENTO DEFINITIVO 240 | 44505 ( 7.9) | 44323 ( 7.9) | 182 ( 8.7) | ||||
| SOBRESEIMIENTO TEMPORAL | 657 ( 0.1) | 655 ( 0.1) | 2 ( 0.1) | ||||
| SUSPENSI¿N CONDICIONAL DEL PROCEDIMIENTO | 7096 ( 1.3) | 7014 ( 1.2) | 82 ( 3.9) | ||||
| [Missing] | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| familia_delito (%) | CUASIDELITOS | 3823 ( 0.7) | 3807 ( 0.7) | 16 ( 0.8) | <0.001 | 0.387 | |
| DELITOS CONTRA LA FE PÚBLICA | 15927 ( 2.8) | 15850 ( 2.8) | 77 ( 3.7) | ||||
| DELITOS CONTRA LA LIBERTAD E INTIMIDAD DE LAS PERSONAS | 98560 ( 17.4) | 98134 ( 17.4) | 426 ( 20.3) | ||||
| DELITOS CONTRA LEYES DE PROPIEDAD INTELECTUAL E INDUSTRIAL | 1469 ( 0.3) | 1469 ( 0.3) | 0 ( 0.0) | ||||
| DELITOS DE JUSTICIA MILITAR | 47 ( 0.0) | 46 ( 0.0) | 1 ( 0.0) | ||||
| DELITOS DE LEYES ESPECIALES | 13176 ( 2.3) | 13009 ( 2.3) | 167 ( 8.0) | ||||
| DELITOS DE TORTURA, MALOS TRATOS, GENOCIDIO Y LESA HUMANIDAD | 447 ( 0.1) | 446 ( 0.1) | 1 ( 0.0) | ||||
| DELITOS ECONÓMICOS Y TRIBUTARIOS | 14190 ( 2.5) | 14107 ( 2.5) | 83 ( 4.0) | ||||
| DELITOS FUNCIONARIOS | 732 ( 0.1) | 730 ( 0.1) | 2 ( 0.1) | ||||
| DELITOS LEY DE DROGAS | 9543 ( 1.7) | 9501 ( 1.7) | 42 ( 2.0) | ||||
| DELITOS LEY DE TRÁNSITO | 16082 ( 2.8) | 16026 ( 2.8) | 56 ( 2.7) | ||||
| DELITOS SEXUALES | 5625 ( 1.0) | 5581 ( 1.0) | 44 ( 2.1) | ||||
| FALTAS | 80627 ( 14.3) | 80452 ( 14.3) | 175 ( 8.4) | ||||
| HECHOS DE RELEVANCIA CRIMINAL | 31835 ( 5.6) | 31684 ( 5.6) | 151 ( 7.2) | ||||
| HOMICIDIOS | 1106 ( 0.2) | 1104 ( 0.2) | 2 ( 0.1) | ||||
| HURTOS | 51916 ( 9.2) | 51767 ( 9.2) | 149 ( 7.1) | ||||
| LESIONES | 118219 ( 20.9) | 117829 ( 20.9) | 390 ( 18.6) | ||||
| OTROS DELITOS | 12553 ( 2.2) | 12529 ( 2.2) | 24 ( 1.1) | ||||
| OTROS DELITOS CONTRA LA PROPIEDAD | 28584 ( 5.1) | 28485 ( 5.1) | 99 ( 4.7) | ||||
| ROBOS | 31102 ( 5.5) | 31006 ( 5.5) | 96 ( 4.6) | ||||
| ROBOS NO VIOLENTOS | 30038 ( 5.3) | 29945 ( 5.3) | 93 ( 4.4) | ||||
| relacion_vifsaf (%) | NO | 450076 ( 79.6) | 448521 ( 79.6) | 1555 ( 74.3) | <0.001 | 0.127 | |
| SI | 115525 ( 20.4) | 114986 ( 20.4) | 539 ( 25.7) | ||||
| gls_parentesco (%) | ABUELO(A) | 744 ( 0.1) | 743 ( 0.1) | 1 ( 0.0) | <0.001 | 0.205 | |
| ADOPTADO | 41 ( 0.0) | 41 ( 0.0) | 0 ( 0.0) | ||||
| ADOPTANTE | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| CONVIVIENTE | 30410 ( 5.4) | 30285 ( 5.4) | 125 ( 6.0) | ||||
| CÓNYUGE | 15083 ( 2.7) | 14972 ( 2.7) | 111 ( 5.3) | ||||
| CUÑADO(A) | 1695 ( 0.3) | 1689 ( 0.3) | 6 ( 0.3) | ||||
| EX CONVIVIENTE | 21335 ( 3.8) | 21234 ( 3.8) | 101 ( 4.8) | ||||
| EX CONYUGE | 1413 ( 0.2) | 1401 ( 0.2) | 12 ( 0.6) | ||||
| HERMANO(A) | 9803 ( 1.7) | 9773 ( 1.7) | 30 ( 1.4) | ||||
| HIJO(A) | 9070 ( 1.6) | 9021 ( 1.6) | 49 ( 2.3) | ||||
| MADRASTRA | 100 ( 0.0) | 100 ( 0.0) | 0 ( 0.0) | ||||
| MADRE | 8386 ( 1.5) | 8357 ( 1.5) | 29 ( 1.4) | ||||
| MADRE HIJO COMUN | 3873 ( 0.7) | 3859 ( 0.7) | 14 ( 0.7) | ||||
| MENOR DE EDAD (bajo cuidado) | 44 ( 0.0) | 43 ( 0.0) | 1 ( 0.0) | ||||
| MINUSVALIDO (bajo cuidado) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| NIETO | 350 ( 0.1) | 347 ( 0.1) | 3 ( 0.1) | ||||
| No Definido | 118 ( 0.0) | 118 ( 0.0) | 0 ( 0.0) | ||||
| NUERA | 259 ( 0.0) | 258 ( 0.0) | 1 ( 0.0) | ||||
| PADRASTRO | 759 ( 0.1) | 757 ( 0.1) | 2 ( 0.1) | ||||
| PADRE | 4247 ( 0.8) | 4218 ( 0.7) | 29 ( 1.4) | ||||
| PADRE HIJO COMUN | 3574 ( 0.6) | 3562 ( 0.6) | 12 ( 0.6) | ||||
| SOBRINO(A) | 1445 ( 0.3) | 1443 ( 0.3) | 2 ( 0.1) | ||||
| SUEGRO(A) | 864 ( 0.2) | 861 ( 0.2) | 3 ( 0.1) | ||||
| TIO(A) | 1503 ( 0.3) | 1500 ( 0.3) | 3 ( 0.1) | ||||
| YERNO | 402 ( 0.1) | 397 ( 0.1) | 5 ( 0.2) | ||||
| [Missing] | 450076 ( 79.6) | 448521 ( 79.6) | 1555 ( 74.3) | ||||
| gls_mottermino (%) | Acoge req. proced monit y proposic multa | 56871 ( 10.1) | 56748 ( 10.1) | 123 ( 5.9) | <0.001 | 0.346 | |
| Acuerdo Reparatorio (Art. 241 y 242) | 12038 ( 2.1) | 11987 ( 2.1) | 51 ( 2.4) | ||||
| Agrupado | 28025 ( 5.0) | 27913 ( 5.0) | 112 ( 5.3) | ||||
| Anulación de ingreso error de digitación | 1471 ( 0.3) | 1468 ( 0.3) | 3 ( 0.1) | ||||
| Anulación ingreso por delito acción priv | 32 ( 0.0) | 32 ( 0.0) | 0 ( 0.0) | ||||
| Archivo Provisional | 148839 ( 26.3) | 148242 ( 26.3) | 597 ( 28.5) | ||||
| Decisión de no perseverar en el proced | 33136 ( 5.9) | 33011 ( 5.9) | 125 ( 6.0) | ||||
| Incomp materias correspond sistema antig | 83 ( 0.0) | 82 ( 0.0) | 1 ( 0.0) | ||||
| Incomp tratarse materias conoc otro trib | 2263 ( 0.4) | 2251 ( 0.4) | 12 ( 0.6) | ||||
| Negativa investig caso autodenuncia 179 | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| No Inicio Investigación | 41831 ( 7.4) | 41585 ( 7.4) | 246 ( 11.7) | ||||
| Otras causales de término | 1248 ( 0.2) | 1246 ( 0.2) | 2 ( 0.1) | ||||
| Principio de Oportunidad | 45023 ( 8.0) | 44887 ( 8.0) | 136 ( 6.5) | ||||
| Rechazo querella de capítulos (art. 429) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| Rechazo req. Med. Seg. Opuest qte 462 | 2 ( 0.0) | 2 ( 0.0) | 0 ( 0.0) | ||||
| S Def (no subs oport vicios form art270) | 70 ( 0.0) | 70 ( 0.0) | 0 ( 0.0) | ||||
| S Definit (vencim plazo suspens art 240) | 44505 ( 7.9) | 44323 ( 7.9) | 182 ( 8.7) | ||||
| S. Definit (en casos del art. 465) | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| S. Definit (exc previo y espec pron 271) | 22 ( 0.0) | 22 ( 0.0) | 0 ( 0.0) | ||||
| S. Definit (susp imposic de la cond 398) | 44 ( 0.0) | 43 ( 0.0) | 1 ( 0.0) | ||||
| Sentencia definitiva absolutoria | 11829 ( 2.1) | 11804 ( 2.1) | 25 ( 1.2) | ||||
| Sentencia definitiva condenatoria | 99918 ( 17.7) | 99682 ( 17.7) | 236 ( 11.3) | ||||
| Sobres Definit (en casos del art 247) | 12 ( 0.0) | 12 ( 0.0) | 0 ( 0.0) | ||||
| Sobres Definitivo (causales del art 250) | 28061 ( 5.0) | 27915 ( 5.0) | 146 ( 7.0) | ||||
| Término requerimiento internacional | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 10268 ( 1.8) | 10172 ( 1.8) | 96 ( 4.6) | ||||
| gls_motsuspension (%) | ACUERDO REPARATORIO | 15397 ( 2.7) | 15332 ( 2.7) | 65 ( 3.1) | <0.001 | 0.143 | |
| SOBRESEIMIENTO TEMPORAL | 2270 ( 0.4) | 2263 ( 0.4) | 7 ( 0.3) | ||||
| SUSPENSION CONDICIONAL DEL PROCEDIMIENTO | 55450 ( 9.8) | 55151 ( 9.8) | 299 ( 14.3) | ||||
| SUSPENSION PROCED. ART. 10 | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | ||||
| SUSPENSION PROCED. ART. 458 | 1713 ( 0.3) | 1706 ( 0.3) | 7 ( 0.3) | ||||
| [Missing] | 490761 ( 86.8) | 489045 ( 86.8) | 1716 ( 81.9) | ||||
| gls_proctermino (%) | ABREVIADO | 21387 ( 3.8) | 21305 ( 3.8) | 82 ( 3.9) | <0.001 | 0.251 | |
| MONITORIO | 56924 ( 10.1) | 56801 ( 10.1) | 123 ( 5.9) | ||||
| ORDINARIO | 106499 ( 18.8) | 106064 ( 18.8) | 435 ( 20.8) | ||||
| RECLAMO | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| REQUERIMIENTO INTERNACIONAL | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| SIMPLIFICADO | 102433 ( 18.1) | 102182 ( 18.1) | 251 ( 12.0) | ||||
| SIN PROCEDIMIENTO | 278354 ( 49.2) | 277151 ( 49.2) | 1203 ( 57.4) | ||||
| gls_tipo_imputado (%) | DENUNCIADO | 28317 ( 5.0) | 28251 ( 5.0) | 66 ( 3.2) | 0.008 | 0.096 | |
| IMPUTADO | 536374 ( 94.8) | 534349 ( 94.8) | 2025 ( 96.7) | ||||
| INVESTIGADO | 27 ( 0.0) | 27 ( 0.0) | 0 ( 0.0) | ||||
| QUERELLADO | 560 ( 0.1) | 558 ( 0.1) | 2 ( 0.1) | ||||
| SOSPECHOSO | 233 ( 0.0) | 232 ( 0.0) | 1 ( 0.0) | ||||
| TESTIGO | 90 ( 0.0) | 90 ( 0.0) | 0 ( 0.0) | ||||
| lugar_ocurrencia (%) | BIENES NACIONALES USO PUBLICO | 220285 ( 38.9) | 219634 ( 39.0) | 651 ( 31.1) | <0.001 | 0.304 | |
| ESTABLECIMIENTO COMERCIAL | 91003 ( 16.1) | 90763 ( 16.1) | 240 ( 11.5) | ||||
| ESTABLECIMIENTO DE DIVERSION | 1845 ( 0.3) | 1838 ( 0.3) | 7 ( 0.3) | ||||
| ESTABLECIMIENTO EDUCACIONAL | 3389 ( 0.6) | 3366 ( 0.6) | 23 ( 1.1) | ||||
| ESTABLECIMIENTO PRODUCTIVO | 8178 ( 1.4) | 8094 ( 1.4) | 84 ( 4.0) | ||||
| LUGAR HABITADO O DESTINADO A LA HABITACION Y SUS DEPENDENCIAS | 212157 ( 37.5) | 211161 ( 37.5) | 996 ( 47.6) | ||||
| ORGANIZACION DE SEGURIDAD / JUSTICIA | 12160 ( 2.1) | 12128 ( 2.2) | 32 ( 1.5) | ||||
| ORGANIZACION PUBLICA Y/O SOCIAL | 7317 ( 1.3) | 7280 ( 1.3) | 37 ( 1.8) | ||||
| OTROS LUGARES NO CLASIFICADOS | 5625 ( 1.0) | 5609 ( 1.0) | 16 ( 0.8) | ||||
| [Missing] | 3642 ( 0.6) | 3634 ( 0.6) | 8 ( 0.4) | ||||
| region_delito (%) | I Región de Tarapaca | 18007 ( 3.2) | 17992 ( 3.2) | 15 ( 0.7) | <0.001 | 0.364 | |
| II Región de Antofagasta | 27189 ( 4.8) | 27129 ( 4.8) | 60 ( 2.9) | ||||
| III Región de Atacama | 17574 ( 3.1) | 17528 ( 3.1) | 46 ( 2.2) | ||||
| IV Región de Coquimbo | 22977 ( 4.1) | 22936 ( 4.1) | 41 ( 2.0) | ||||
| IX Región de la Araucanía | 15508 ( 2.7) | 15417 ( 2.7) | 91 ( 4.3) | ||||
| No Definido | 4 ( 0.0) | 4 ( 0.0) | 0 ( 0.0) | ||||
| Región Metropolitana de Santiago | 248964 ( 44.0) | 247892 ( 44.0) | 1072 ( 51.2) | ||||
| RM Centro Norte | 18 ( 0.0) | 18 ( 0.0) | 0 ( 0.0) | ||||
| RM Occidente | 8 ( 0.0) | 8 ( 0.0) | 0 ( 0.0) | ||||
| RM Oriente | 9 ( 0.0) | 9 ( 0.0) | 0 ( 0.0) | ||||
| RM Sur | 36 ( 0.0) | 36 ( 0.0) | 0 ( 0.0) | ||||
| V Región de Valparaíso | 55117 ( 9.7) | 54977 ( 9.8) | 140 ( 6.7) | ||||
| VI Región del Libertador Gral. Bernardo O Higgins | 33245 ( 5.9) | 33159 ( 5.9) | 86 ( 4.1) | ||||
| VII Región del Maule | 29896 ( 5.3) | 29725 ( 5.3) | 171 ( 8.2) | ||||
| VIII Región del Bio Bio | 38456 ( 6.8) | 38275 ( 6.8) | 181 ( 8.6) | ||||
| X Región de los Lagos | 19283 ( 3.4) | 19215 ( 3.4) | 68 ( 3.2) | ||||
| XI Región Aysen del Gral. Carlos Ibañez del Campo | 5335 ( 0.9) | 5325 ( 0.9) | 10 ( 0.5) | ||||
| XII Región de Magallanes y de la Antartica Chilena | 5184 ( 0.9) | 5147 ( 0.9) | 37 ( 1.8) | ||||
| XIV Región de los Rios | 8365 ( 1.5) | 8337 ( 1.5) | 28 ( 1.3) | ||||
| XV Región de Arica y Parinacota | 13787 ( 2.4) | 13750 ( 2.4) | 37 ( 1.8) | ||||
| XVI Región del Ñuble | 5697 ( 1.0) | 5687 ( 1.0) | 10 ( 0.5) | ||||
| [Missing] | 942 ( 0.2) | 941 ( 0.2) | 1 ( 0.0) | ||||
| medidas_155 (%) | SI | 57243 ( 10.1) | 57047 ( 10.1) | 196 ( 9.4) | 0.263 | 0.026 | |
| [Missing] | 508358 ( 89.9) | 506460 ( 89.9) | 1898 ( 90.6) | ||||
| medidas_pp (%) | SI | 22236 ( 3.9) | 22184 ( 3.9) | 52 ( 2.5) | 0.001 | 0.083 | |
| [Missing] | 543365 ( 96.1) | 541323 ( 96.1) | 2042 ( 97.5) | ||||
| medidas_ip (%) | SI | 730 ( 0.1) | 728 ( 0.1) | 2 ( 0.1) | 0.902 | 0.010 | |
| [Missing] | 564871 ( 99.9) | 562779 ( 99.9) | 2092 ( 99.9) | ||||
| marca_suspension_43 (%) | NO | 67050 ( 11.9) | 66904 ( 11.9) | 146 ( 7.0) | <0.001 | 0.170 | |
| SI | 2341 ( 0.4) | 2335 ( 0.4) | 6 ( 0.3) | ||||
| [Missing] | 496210 ( 87.7) | 494268 ( 87.7) | 1942 ( 92.7) | ||||
| marca_pena_44 (%) | SI | 69391 ( 12.3) | 69239 ( 12.3) | 152 ( 7.3) | <0.001 | 0.170 | |
| [Missing] | 496210 ( 87.7) | 494268 ( 87.7) | 1942 ( 92.7) | ||||
| marca_multa_45 (%) | NO | 35119 ( 6.2) | 35034 ( 6.2) | 85 ( 4.1) | <0.001 | 0.173 | |
| SI | 34272 ( 6.1) | 34205 ( 6.1) | 67 ( 3.2) | ||||
| [Missing] | 496210 ( 87.7) | 494268 ( 87.7) | 1942 ( 92.7) | ||||
| medida_alternativa_46 (%) | Libertad Vigilada | 3200 ( 0.6) | 3171 ( 0.6) | 29 ( 1.4) | <0.001 | 0.177 | |
| Otra | 4982 ( 0.9) | 4975 ( 0.9) | 7 ( 0.3) | ||||
| Reclusión Nocturna | 14041 ( 2.5) | 14021 ( 2.5) | 20 ( 1.0) | ||||
| Remisión Condicional | 18320 ( 3.2) | 18276 ( 3.2) | 44 ( 2.1) | ||||
| [Missing] | 525058 ( 92.8) | 523064 ( 92.8) | 1994 ( 95.2) | ||||
| clasificacion_pena_47 (%) | Presidio Mayor grado máximo | 83 ( 0.0) | 83 ( 0.0) | 0 ( 0.0) | <0.001 | 0.216 | |
| Presidio Mayor grado medio | 467 ( 0.1) | 467 ( 0.1) | 0 ( 0.0) | ||||
| Presidio Mayor grado mínimo | 1917 ( 0.3) | 1915 ( 0.3) | 2 ( 0.1) | ||||
| Presidio Menor grado máximo | 4960 ( 0.9) | 4930 ( 0.9) | 30 ( 1.4) | ||||
| Presidio Menor grado medio | 8774 ( 1.6) | 8751 ( 1.6) | 23 ( 1.1) | ||||
| Presidio Menor grado mínimo | 29524 ( 5.2) | 29462 ( 5.2) | 62 ( 3.0) | ||||
| Presidio Perpetuo calificado | 1 ( 0.0) | 1 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Perpetuo simple | 14 ( 0.0) | 14 ( 0.0) | 0 ( 0.0) | ||||
| Prisión | 23651 ( 4.2) | 23616 ( 4.2) | 35 ( 1.7) | ||||
| [Missing] | 496210 ( 87.7) | 494268 ( 87.7) | 1942 ( 92.7) | ||||
| tramos_condena_48 (%) | 1 día a 60 días | 2115 ( 0.4) | 2090 ( 0.4) | 25 ( 1.2) | <0.001 | 0.103 | |
| 3 años y 1 día a 5 años | 203 ( 0.0) | 203 ( 0.0) | 0 ( 0.0) | ||||
| 541 días a 3 años | 626 ( 0.1) | 621 ( 0.1) | 5 ( 0.2) | ||||
| 61 días a 540 días | 690 ( 0.1) | 688 ( 0.1) | 2 ( 0.1) | ||||
| Desde 5 años y 1 día | 38 ( 0.0) | 38 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 561929 ( 99.4) | 559867 ( 99.4) | 2062 ( 98.5) | ||||
| clasificacion_penarpa_1_49 (%) | Amonestación | 614 ( 0.1) | 607 ( 0.1) | 7 ( 0.3) | <0.001 | 0.100 | |
| Int. Reg. Cerrado con Prog. de Reinserción Social | 88 ( 0.0) | 88 ( 0.0) | 0 ( 0.0) | ||||
| Int. Reg. Semicerrado con Prog. de Reinserción Social | 162 ( 0.0) | 162 ( 0.0) | 0 ( 0.0) | ||||
| Libertad Asistida | 492 ( 0.1) | 488 ( 0.1) | 4 ( 0.2) | ||||
| Libertad Asistida Especial | 694 ( 0.1) | 691 ( 0.1) | 3 ( 0.1) | ||||
| Multa | 343 ( 0.1) | 340 ( 0.1) | 3 ( 0.1) | ||||
| Prestación de Servicios en Beneficio de la Comunidad | 1270 ( 0.2) | 1255 ( 0.2) | 15 ( 0.7) | ||||
| Reparación del Daño Causado | 14 ( 0.0) | 14 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 561924 ( 99.3) | 559862 ( 99.4) | 2062 ( 98.5) | ||||
| clasificacion_penarpa_2_50 (%) | Int. Reg. Semicerrado con Prog. de Reinserción Social | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | 0.979 | 0.021 | |
| Libertad Asistida | 28 ( 0.0) | 28 ( 0.0) | 0 ( 0.0) | ||||
| Libertad Asistida Especial | 71 ( 0.0) | 71 ( 0.0) | 0 ( 0.0) | ||||
| Prestación de Servicios en Beneficio de la Comunidad | 10 ( 0.0) | 10 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565482 (100.0) | 563388 (100.0) | 2094 (100.0) | ||||
| marca_suspension_51 (%) | NO | 74 ( 0.0) | 74 ( 0.0) | 0 ( 0.0) | 0.867 | 0.017 | |
| SI | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 563430 (100.0) | 2094 (100.0) | ||||
| marca_pena_52 (%) | SI | 77 ( 0.0) | 77 ( 0.0) | 0 ( 0.0) | 1.000 | 0.017 | |
| [Missing] | 565524 (100.0) | 563430 (100.0) | 2094 (100.0) | ||||
| marca_multa_53 (%) | NO | 46 ( 0.0) | 46 ( 0.0) | 0 ( 0.0) | 0.867 | 0.017 | |
| SI | 31 ( 0.0) | 31 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 563430 (100.0) | 2094 (100.0) | ||||
| medida_alternativa_54 (%) | Libertad Vigilada | 8 ( 0.0) | 8 ( 0.0) | 0 ( 0.0) | 0.997 | 0.013 | |
| Otra | 5 ( 0.0) | 5 ( 0.0) | 0 ( 0.0) | ||||
| Reclusión Nocturna | 17 ( 0.0) | 17 ( 0.0) | 0 ( 0.0) | ||||
| Remisión Condicional | 15 ( 0.0) | 15 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565556 (100.0) | 563462 (100.0) | 2094 (100.0) | ||||
| clasificacion_pena_55 (%) | Presidio Mayor grado medio | 3 ( 0.0) | 3 ( 0.0) | 0 ( 0.0) | 1.000 | 0.017 | |
| Presidio Mayor grado mínimo | 5 ( 0.0) | 5 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado máximo | 12 ( 0.0) | 12 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado medio | 9 ( 0.0) | 9 ( 0.0) | 0 ( 0.0) | ||||
| Presidio Menor grado mínimo | 21 ( 0.0) | 21 ( 0.0) | 0 ( 0.0) | ||||
| Prisión | 27 ( 0.0) | 27 ( 0.0) | 0 ( 0.0) | ||||
| [Missing] | 565524 (100.0) | 563430 (100.0) | 2094 (100.0) | ||||
| cut_com_del2 (%) | [1972-12-21,2009-12-20) | 26920 ( 4.8) | 26904 ( 4.8) | 16 ( 0.8) | <0.001 | 0.959 | |
| [2009-12-20,2010-06-23) | 26882 ( 4.8) | 26862 ( 4.8) | 20 ( 1.0) | ||||
| [2010-06-23,2010-12-18) | 26889 ( 4.8) | 26877 ( 4.8) | 12 ( 0.6) | ||||
| [2010-12-18,2011-05-27) | 26885 ( 4.8) | 26854 ( 4.8) | 31 ( 1.5) | ||||
| [2011-05-27,2011-11-04) | 27034 ( 4.8) | 27018 ( 4.8) | 16 ( 0.8) | ||||
| [2011-11-04,2012-04-04) | 26977 ( 4.8) | 26951 ( 4.8) | 26 ( 1.2) | ||||
| [2012-04-04,2012-09-16) | 26868 ( 4.8) | 26835 ( 4.8) | 33 ( 1.6) | ||||
| [2012-09-16,2013-02-23) | 26866 ( 4.7) | 26840 ( 4.8) | 26 ( 1.2) | ||||
| [2013-02-23,2013-08-12) | 26995 ( 4.8) | 26974 ( 4.8) | 21 ( 1.0) | ||||
| [2013-08-12,2014-01-27) | 26959 ( 4.8) | 26927 ( 4.8) | 32 ( 1.5) | ||||
| [2014-01-27,2014-07-21) | 26861 ( 4.7) | 26810 ( 4.8) | 51 ( 2.4) | ||||
| [2014-07-21,2015-01-06) | 26993 ( 4.8) | 26919 ( 4.8) | 74 ( 3.5) | ||||
| [2015-01-06,2015-06-30) | 26965 ( 4.8) | 26778 ( 4.8) | 187 ( 8.9) | ||||
| [2015-06-30,2015-12-25) | 26909 ( 4.8) | 26760 ( 4.7) | 149 ( 7.1) | ||||
| [2015-12-25,2016-06-22) | 26947 ( 4.8) | 26745 ( 4.7) | 202 ( 9.6) | ||||
| [2016-06-22,2016-12-23) | 26943 ( 4.8) | 26714 ( 4.7) | 229 ( 10.9) | ||||
| [2016-12-23,2017-06-28) | 26852 ( 4.7) | 26656 ( 4.7) | 196 ( 9.4) | ||||
| [2017-06-28,2018-01-03) | 26996 ( 4.8) | 26797 ( 4.8) | 199 ( 9.5) | ||||
| [2018-01-03,2018-07-19) | 26859 ( 4.7) | 26647 ( 4.7) | 212 ( 10.1) | ||||
| [2018-07-19,2019-02-06) | 26979 ( 4.8) | 26797 ( 4.8) | 182 ( 8.7) | ||||
| [2019-02-06,2019-11-13] | 26981 ( 4.8) | 26802 ( 4.8) | 179 ( 8.5) | ||||
| [Missing] | 41 ( 0.0) | 40 ( 0.0) | 1 ( 0.0) | ||||
| cut_fec_nac2 (%) | [1930-01-18,1963-06-08) | 26929 ( 4.8) | 26668 ( 4.7) | 261 ( 12.5) | <0.001 | 0.678 | |
| [1963-06-08,1967-11-30) | 26937 ( 4.8) | 26802 ( 4.8) | 135 ( 6.4) | ||||
| [1967-11-30,1970-12-12) | 26920 ( 4.8) | 26798 ( 4.8) | 122 ( 5.8) | ||||
| [1970-12-12,1973-03-18) | 26935 ( 4.8) | 26838 ( 4.8) | 97 ( 4.6) | ||||
| [1973-03-18,1975-02-23) | 26930 ( 4.8) | 26869 ( 4.8) | 61 ( 2.9) | ||||
| [1975-02-23,1977-01-21) | 26934 ( 4.8) | 26824 ( 4.8) | 110 ( 5.3) | ||||
| [1977-01-21,1978-11-01) | 26933 ( 4.8) | 26813 ( 4.8) | 120 ( 5.7) | ||||
| [1978-11-01,1980-04-05) | 26929 ( 4.8) | 26881 ( 4.8) | 48 ( 2.3) | ||||
| [1980-04-05,1981-06-11) | 26937 ( 4.8) | 26889 ( 4.8) | 48 ( 2.3) | ||||
| [1981-06-11,1982-06-18) | 26934 ( 4.8) | 26889 ( 4.8) | 45 ( 2.1) | ||||
| [1982-06-18,1983-07-04) | 26929 ( 4.8) | 26888 ( 4.8) | 41 ( 2.0) | ||||
| [1983-07-04,1984-08-16) | 26839 ( 4.7) | 26816 ( 4.8) | 23 ( 1.1) | ||||
| [1984-08-16,1985-10-03) | 27000 ( 4.8) | 26947 ( 4.8) | 53 ( 2.5) | ||||
| [1985-10-03,1986-11-21) | 26961 ( 4.8) | 26880 ( 4.8) | 81 ( 3.9) | ||||
| [1986-11-21,1988-01-10) | 26898 ( 4.8) | 26851 ( 4.8) | 47 ( 2.2) | ||||
| [1988-01-10,1989-02-03) | 26976 ( 4.8) | 26916 ( 4.8) | 60 ( 2.9) | ||||
| [1989-02-03,1990-04-02) | 26880 ( 4.8) | 26824 ( 4.8) | 56 ( 2.7) | ||||
| [1990-04-02,1991-06-11) | 26980 ( 4.8) | 26901 ( 4.8) | 79 ( 3.8) | ||||
| [1991-06-11,1992-12-13) | 26926 ( 4.8) | 26807 ( 4.8) | 119 ( 5.7) | ||||
| [1992-12-13,1994-11-24) | 26951 ( 4.8) | 26815 ( 4.8) | 136 ( 6.5) | ||||
| [1994-11-24,2001-09-29] | 26932 ( 4.8) | 26580 ( 4.7) | 352 ( 16.8) | ||||
| [Missing] | 11 ( 0.0) | 11 ( 0.0) | 0 ( 0.0) |
if(no_mostrar==0){
DT::datatable(#extensions = c('FixedColumns',"FixedHeader"),
rownames = F,
filter = 'top',
caption = htmltools::tags$caption(
style = 'caption-side: top; text-align: left; font-size:100%;',
'Table: ', htmltools::em('Summary descriptives, if nationality is not defined (1)')),
options = list(searching = T, #remove search box
info = F,
searchHighlight = T,
scrollX = TRUE,
scrollY = "450px",
paging=FALSE,
fixedHeader=T,
lengthMenu = c(2, 12, 18),
autoHideNavigation = F,
escape = 1, # escape the first column
buttons=c('copy', 'csv'),
class = "display",
initComplete = DT::JS(
"function(settings, json) {",
"$(this.api().tables().body()).css({
'font-family': 'Helvetica Neue',
'font-size': '50%',
'code-inline-font-size': '15%',
'white-space': 'nowrap',
'line-height': '0.75em',
'min-height': '0.5em'
});",#;
"}"))) %>%
DT::formatStyle(1:1e5,fontWeight= DT::styleRow(1, "bold"))
}
Some records had a “undefined” value in nationality (n= 2094, p= 738). This were more frequent in the Metropolitan Region, Bio Bio & Maule, occurred less in individuals with “SENTENCIA DEFINITIVA CONDENATORIA”, but more in suspended finishings of the proceedings (e.g., ARCHIVO PROVISIONAL, FACULTAD PARA NO INVESTIGAR, SUSPENSION CONDICIONAL DEL PROCEDIMIENTO, and SOBRESEIMIENTO DEFINITIVO). Also, crimes were more frequent in “DELITOS CONTRA LA LIBERTAD E INTIMIDAD DE LAS PERSONAS”, “DELITOS ECONÓMICOS Y TRIBUTARIOS”, “DELITOS DE LEYES ESPECIALES”, but less frequent in “FALTAS”. The sentences concluded more in “presidio maenor grado máximo”, but less in “Presidio Menor grado mínimo” and “Prisión”. More of them were committed after 2010, and there are less people born in between 1957-09-25 and 1940-01-11, but those were born between 1936-12-21 and 1930-01-18 were more frequent.
message("Users with different values in nationality between SENDA and P.O.")
differences_bet_nat_po<-
Base_fiscalia_v6 %>%
dplyr::mutate(pais=dplyr::case_when(pais=="No Definido"~NA_character_,T~pais)) %>%
#IMPORTANTE, ACTUALIZAR
dplyr::mutate(pais= dplyr::case_when(pais=="CHECOLOVAQUIA"~"REPUBLICA CHECA", T~pais)) %>%
dplyr::group_by(rut_enc_saf) %>%
dplyr::mutate(dist_nat= n_distinct(pais), dist_ruc= n_distinct(ruc)) %>%
dplyr::ungroup() %>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","nacionalidad","nacionalidad_2","etnia_cor")),by=c("rut_enc_saf"="hash_key"))%>%
dplyr::mutate(nacionalidad= toupper(stringi::stri_trans_general(as.character(nacionalidad),"Latin-ASCII"))) %>%
dplyr::mutate(mix=paste0(pais,"-",nacionalidad)) %>%
dplyr::select("rut_enc_saf","pais","nacionalidad", "etnia_cor", "ruc", "obs", "dist_nat", "dist_ruc", "mix")%>%
dplyr::mutate(step0=dplyr::case_when(is.na(pais) & is.na(nacionalidad)~1,T~0)) %>%
dplyr::filter(pais!=as.character(nacionalidad))
invisible("In step2 I corrected this difference in observations, so in case that i am working with a database from 2022-08-10 or earlier, I need to get the obs column.")
if(as.Date("2022-08-10")-as.Date(substr(file.info("./Fiscalia_merge2.html")$mtime,1,10))==0){
differences_bet_nat_po<-
differences_bet_nat_po %>%
#now, we merged with the actual observation labels from february 2020
dplyr::left_join(dplyr::rename(CONS_C1_df_dup_FEB_2020[,c("hash_key","obs")],"obs_FEB"="obs") %>% dplyr::group_by(hash_key) %>% dplyr::slice(1) %>% dplyr::ungroup(),by=c("rut_enc_saf"="hash_key")) %>%
dplyr::mutate(obs=dplyr::case_when(obs==obs_FEB~obs_FEB,
is.na(obs)~obs_FEB,
!is.na(obs)& grepl("^;",obs_FEB)~paste0(obs,obs_FEB),
!is.na(obs)& !grepl("^;",obs_FEB)~paste0(obs,";",obs_FEB),
T~obs)) %>%
dplyr::select(-obs_FEB)
}
message(paste0("Number of records with more than one nationality among POs= ", nrow(dplyr::filter(differences_bet_nat_po, dist_nat>1))))
invisible("In PO everyone had consistent nationalities in their records")
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
invisible("Under the assumption that a nationality other than Chile is more informative thus less probabilities of errors due to, for example, misstyping")
# - Percentage of records of different nationalities other than Chilean (C1)
CONS_C1_res_nat<-
CONS_C1 %>%
dplyr::filter(HASH_KEY %in% unlist(differences_bet_nat_po$rut_enc_saf)) %>%
dplyr::mutate(nacionalidad= toupper(stringi::stri_trans_general(as.character(Nacionalidad),"Latin-ASCII")),n=1)%>%
dplyr::select(HASH_KEY, nacionalidad,n, Etnia) %>%
dplyr::group_by(HASH_KEY) %>%
dplyr::mutate(length_etnia= sum(`Etnia`!="No pertenece", na.rm=T)) %>%
dplyr::ungroup() %>%
dplyr::select(-Etnia) %>%
tidyr::pivot_wider(names_from=nacionalidad, values_from=n, values_fn = ~sum(.x, na.rm = TRUE), values_fill=0) %>%
dplyr::select(HASH_KEY, length_etnia, CHILE, everything()) %>%
dplyr::mutate(length_diff_chile=rowSums(dplyr::select(., -any_of(c("HASH_KEY","length_etnia","CHILE"))), na.rm=T),length_c1= rowSums(dplyr::select(., -any_of(c("HASH_KEY","length_etnia"))), na.rm=T))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
invisible("All ethnics are chilean native. However, we may want to keep other nationalities than chile")
invisible("CASE WITH 2 DIFFERENT NATIONALITIES OTHER THAN CHILE")
diff_nat_other_ch<-
differences_bet_nat_po[which(!grepl("CHILE",differences_bet_nat_po$pais)&!grepl("CHILE", differences_bet_nat_po$nacionalidad)),]
if(no_mostrar==F){
CONS_C1_res_nat[which(diff_nat_other_ch$rut_enc_saf),]
CONS_C1_res_nat %>%
dplyr::filter(HASH_KEY %in% unlist(diff_nat_other_ch$rut_enc_saf))
}
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
invisible("What happens with original databases?")
message(paste0("Cases with discrepancies in PO & SENDA that had\nmore than one value in nationality different than CHILE= ",
CONS_C1_res_nat %>%
rowwise %>%
dplyr::mutate_at(.vars = vars(setdiff(names(CONS_C1_res_nat),c("HASH_KEY","CHILE", "length_diff_chile","length_etnia", "length_c1"))),
.funs = ~ifelse(is.na(.), 1, 0)) %>%
dplyr::ungroup() %>%
dplyr::mutate(length_diff_diff_ch=rowSums(dplyr::select(., any_of(setdiff(names(CONS_C1_res_nat),c("HASH_KEY","CHILE", "length_diff_chile","length_etnia", "length_c1")))))) %>%
dplyr::filter(length_diff_diff_ch>0) %>%
nrow()))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#Integrate
differences_bet_nat_po2<-
differences_bet_nat_po %>%
#there are no duplicated hashes
dplyr::left_join(CONS_C1_res_nat[,c("HASH_KEY","length_etnia", "length_diff_chile", "length_c1")],by=c("rut_enc_saf"="HASH_KEY")) %>%
#generate a summary of records of C1
dplyr::mutate(perc_etnia=length_etnia/length_c1, perc_diff_ch= length_diff_chile/length_c1) %>%
dplyr::mutate(step1=dplyr::case_when(grepl("2.6.02.",obs)~1,T~0), step2= dplyr::case_when(rut_enc_saf %in% unlist(diff_nat_other_ch$rut_enc_saf)~1,T~0))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_
message(paste0('No discrepancies in sex (& missings) (22_3_b2) \n(n = ',format(nrow(dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_nat_po$rut_enc_saf))),big.mark=","),
';\nCauses= ',dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_nat_po$rut_enc_saf))%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),
';\nindividuals= ',dplyr::filter(Base_fiscalia_v5, !rut_enc_saf %in% unlist(differences_bet_nat_po$rut_enc_saf))%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
#_#_#_#_#_#_#_
message(paste0('Discrepancies in sex (22_3_a) \n(n = ',format(nrow(differences_bet_nat_po),big.mark=","),
';\nCauses= ',dplyr::distinct(differences_bet_nat_po, ruc)%>% nrow() %>% format(big.mark=','),
';\nindividuals= ',dplyr::distinct(differences_bet_nat_po,rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
#_#_#_#_#_#_#_
message(paste0('Discrepancies with other nationality other than Chile (22_3_a1) \n(n = ',format(nrow(dplyr::filter(differences_bet_nat_po2,step2==1)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_nat_po2,step2==1)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_nat_po2,step2==1)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
message(paste0('Discrepancies with different nationalities but includes Chile (22_3_a2) \n(n = ',format(nrow(dplyr::filter(differences_bet_nat_po2,step2==0)),big.mark=","), ';\nCauses= ',dplyr::filter(differences_bet_nat_po2,step2==0)%>% dplyr::distinct(ruc)%>% nrow() %>% format(big.mark=','),';\nindividuals= ',dplyr::filter(differences_bet_nat_po2,step2==0)%>% dplyr::distinct(rut_enc_saf)%>% nrow() %>% format(big.mark=','),')'))
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
invisible("Users that must need to change")
Base_fiscalia_v7<-
Base_fiscalia_v6%>%
dplyr::left_join(dplyr::distinct(differences_bet_nat_po2, rut_enc_saf, .keep_all = T)[c("rut_enc_saf","nacionalidad","step2")], by="rut_enc_saf")%>%
dplyr::mutate(pais=dplyr::case_when(pais=="No Definido"~NA_character_,T~pais)) %>%
#IMPORTANTE, ACTUALIZAR
dplyr::mutate(pais= dplyr::case_when(pais=="CHECOLOVAQUIA"~"REPUBLICA CHECA", T~pais)) %>%
dplyr::left_join(subset(CONS_C1_df_dup_SEP_2020, dup==1, c("hash_key","nacionalidad_2")), by=c("rut_enc_saf"="hash_key"))%>%#22_2_b1
dplyr::mutate(nacionalidad_2= toupper(stringi::stri_trans_general(nacionalidad_2,"Latin-ASCII")))%>%
dplyr::mutate(obs= dplyr::case_when(
step2==0 & pais!="CHILE" & nacionalidad=="CHILE"~ glue::glue("{obs};22_3_a2"),
step2==0 & is.na(pais)~ glue::glue("{obs};22_3_b1"),
step2==0 & nacionalidad!="CHILE" & pais=="CHILE"~ glue::glue("{obs};22_3_a2"),
#peru-bolivian case
step2==1~glue::glue("{obs};22_3_a1"),
T~obs
)) %>%
dplyr::mutate(nat_imp= dplyr::case_when(
step2==0 & pais!="CHILE" & nacionalidad=="CHILE"~ pais,
step2==0 & is.na(pais)~ nacionalidad,
step2==0 & nacionalidad!="CHILE" & pais=="CHILE"~ nacionalidad,
#peru-bolivian case
step2==1~pais,
T~pais
)) %>%
dplyr::select(-nacionalidad) %>%
dplyr::rename("nat_imp2"="nacionalidad_2") %>%
#add step 2 SENDA value
dplyr::left_join(subset(dplyr::distinct(differences_bet_nat_po2,.keep_all= T),step2==1,c("rut_enc_saf","nacionalidad")), by="rut_enc_saf") %>%
dplyr::mutate(nat_imp2=dplyr::case_when(step2==0 & nat_imp==nat_imp2~NA_character_,
step2==1 & is.na(nat_imp2)~nacionalidad,
T~nat_imp2)) %>%
dplyr::select(-nacionalidad, -step2)
#as.character(subset(differences_bet_nat_po2,step2==1,"rut_enc_saf"))
#table(Base_fiscalia_v5$sexo, Base_fiscalia_v6$sex_imp, exclude=NULL)
#table(Base_fiscalia_v6$pais, Base_fiscalia_v7$nat_imp, exclude=NULL) %>% data.frame() %>% melt()%>% arrange(desc(value))
#check if added rows
if(nrow(Base_fiscalia_v7)-nrow(Base_fiscalia_v6)>0){
warning("Some rows were added in the imputation")}
We added a second variable of nationality, called
nat_imp2, which includes information from SENDA that was
not compatible with PO data regarding nationality.
invisible("Temporarily useless")
Base_fiscalia_v7%>%
dplyr::mutate_at(c('dg_trs_psiq_cie_10_or','x2_dg_trs_psiq_cie_10_or','x3_dg_trs_psiq_cie_10_or','x2_dg_trs_psiq_sub_cie_10_or','x3_dg_trs_psiq_sub_cie_10_or','compromiso_biopsicosocial','pais_nacimiento','nacionalidad','dg_trs_psiq_sub_dsm_iv_or','x2_dg_trs_psiq_sub_dsm_iv_or','x3_dg_trs_psiq_sub_dsm_iv_or','dg_trs_psiq_sub_cie_10_or','etnia_cor_2','motivodeegreso_mod_imp','fecha_ultimo_tratamiento','fecha_ultimo_tratamiento','tiene_menores_de_edad_a_cargo'),~as.factor(.)) %>%
dplyr::group_by(hash_key)%>%
dplyr::mutate(at_least_one_cont_entry=sum(!is.na(diff_bet_treat)))%>%
ungroup()%>%
dplyr::mutate(at_least_one_cont_entry= ifelse(at_least_one_cont_entry>0,1,0))%>%
dplyr::mutate(menor_45_dias_diff= ifelse(diff_bet_treat<45,1,0))%>%
dplyr::mutate(at_least_one_cont_entry= recode(as.character(at_least_one_cont_entry),"0"="User with no cont. entry","1"="User with cont. entry"))%>%
dplyr::mutate(menor_45_dias_diff= recode(as.character(menor_45_dias_diff),"0"=">= 45 Days of Difference Between Entries","1"="<45 Days of Difference Between Entries"))%>%
dplyr::mutate(menor_60_dias_diff= recode(as.character(menor_60_dias_diff),"0"=">= 60 Days of Difference Between Entries","1"="<60 Days of Difference Between Entries"))%>%
dplyr::mutate(obs_cambios_ninguno= recode(as.character(obs_cambios_ninguno),"0"="At least 1 Change w/ the Next Entry","1"="No Changes w/ the Next Entry"))%>%
dplyr::mutate(motivoegreso_derivacion= recode(as.character(motivoegreso_derivacion),"0"="Other causes of discharge","1"="Referral"))%>%
dplyr::mutate_at(vars(at_least_one_cont_entry,menor_45_dias_diff,menor_60_dias_diff,obs_cambios_ninguno,motivoegreso_derivacion,obs_cambios),~as.factor(.))%>%
assign("Base_fiscalia_v7",., envir = .GlobalEnv)
#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_
codebook::var_label(Base_fiscalia_v7) <- list(
row= 'Numerador de los eventos presentes en la Base de Datos/Events in the Dataset',
table= 'Origen de los Datos (de los archivos por año)/Source of Data (of files per year)',
hash_key= 'Codificación del RUN/Masked Identifier (RUN)',
ano_bd= 'Año de la Base de Datos/Year of the Dataset (Source)',
id= 'Codigo Identificación de SENDA/SENDA ID',
nombre_centro= 'Nombre del Centro de Tratamiento/Treatment Center',
tipo_centro= 'Tipo de Centro/Type of Center',
region_del_centro= '(original, Recodificado en nombre_region)/',
servicio_de_salud= 'Servicio de Salud/Health Service',
tipo_de_programa= '(original, Recodificado en tipo_de_programa_2)/',
tipo_de_plan= '(original, Recodificado en tipo_de_plan_2)/',
senda= 'SENDA/SENDA',
dias_trat= 'Días de Tratamiento/Days of Treatment',
nmesesentratamiento= 'Número de Meses en Tratamiento/Number of Months in Treatment',
dias_en_senda= 'Días en SENDA/Days in SENDA',
n_meses_en_senda= 'Número de Meses en SENDA/Number of Months in SENDA',
sexo= '(original, Recodificado en sexo_2)/',
edad= 'Edad (número entero)/Age (In years, Discrete Number)',
nombre_usuario= 'Nombre del Usuario (OCULTO y no accesible)/Name of the User (Not Accessible)',
comuna_residencia= '(original, Recodificado en comuna_residencia_cod)/',
origen_de_ingreso= '(original, Recodificado en origen_ingreso)/',
pais_nacimiento= 'País de Nacimiento/Country of Birth',
nacionalidad= 'Nacionalidad/Nationality',
etnia= '(original, recodificado en etnia_cor)/',
estado_conyugal= '(original, Recodificado en estado_conyugal_2)/',
numero_de_hijos= 'Número de Hijos/Number of Children',
num_hijos_ing_trat_res= 'Número de Hijos para Ingreso a Tratamiento Residencial/Number of Children to Residential Treatment',
parentesco_con_el_jefe_de_hogar= '(Sólo presenta valores perdidos)/',
num_trat_ant= 'Número de Tratamientos Anteriores/Number of Previous Treatments',
fecha_ultimo_tratamiento= 'Fecha del Último Tratamiento/Date of the Last Treatment',
sustancia_de_inicio= '(original, Recodificado en sus_ini)/',
edad_inicio_consumo= '(original, Recodificado en edad_ini_cons)/',
x_se_trata_mujer_emb= 'Mujer Embarazada al Ingreso/Pregnant at Admission',
escolaridad_ultimo_ano_cursado= '(original, Recodificado en escolaridad)/',
condicion_ocupacional= '(original, Recodificado en estatus_ocupacional)/',
categoria_ocupacional= '(original, Recodificado en cat_ocupacional)/',
rubro_trabaja= '(original, Recodificado en rubro_trabaja_mod)/',
con_quien_vive= 'Persona con la que vive el Usuario/People that Share Household with the User',
tipo_de_vivienda= '(original, Recodificado en tipo_de_vivienda_mod)/',
tenencia_de_la_vivienda= '(original, Recodificado en tenencia_de_la_vivienda_mod)/',
sustancia_principal= '(original, Recodificado en sus_principal)/',
`otras_sustancias_nº1`= '(original, Recodificado en otras_sus1)/',
`otras_sustancias_nº2`= '(original, Recodificado en otras_sus2)/',
`otras_sustancias_nº3`= '(original, Recodificado en otras_sus3)/',
freq_cons_sus_prin_original= '(original, Recodificado en freq_cons_sus_prin)/',
edad_inicio_sustancia_principal= '(original, Recodificado en edad_ini_sus_prin)/',
via_adm_sus_prin_original= '(original, Recodificado en via_adm_sus_prin)/',
dg_trs_cons_sus_or= 'Diagnósico de Trastorno por Consumo de Sustancias/Diagnosed of Substance Use Disorder',
dg_trs_psiq_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV/Diagnosis of Psychiatric Disorders, DSM-IV criteria',
dg_trs_psiq_sub_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV (Subclasificacion)/Diagnosis of Psychiatric Disorders, DSM-IV criteria (sub-classification)',
x2_dg_trs_psiq_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV (2)/Diagnosis of Psychiatric Disorders, DSM-IV criteria (2)',
x2_dg_trs_psiq_sub_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV (Subclasificacion) (2)/Diagnosis of Psychiatric Disorders, DSM-IV criteria (sub-classification) (2)',
x3_dg_trs_psiq_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV (3)/Diagnosis of Psychiatric Disorders, DSM-IV criteria (3)',
x3_dg_trs_psiq_sub_dsm_iv_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios DSM IV (Subclasificacion) (3)/Diagnosis of Psychiatric Disorders, DSM-IV criteria (sub-classification) (3)',
dg_trs_psiq_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10/Diagnosis of Psychiatric Disorders, CIE-10 criteria',
dg_trs_psiq_sub_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10 (Subclasificacion)/Diagnosis of Psychiatric Disorders, CIE-10 criteria (subclassification)',
x2_dg_trs_psiq_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10 (2)/Diagnosis of Psychiatric Disorders, CIE-10 criteria (2)',
x2_dg_trs_psiq_sub_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10 (Subclasificacion) (2)/Diagnosis of Psychiatric Disorders, CIE-10 criteria (subclassification) (2)',
x3_dg_trs_psiq_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10 (3)/Diagnosis of Psychiatric Disorders, CIE-10 criteria (3)',
x3_dg_trs_psiq_sub_cie_10_or= 'Diagnóstico de Trastorno Psiquiátrico, Criterios CIE-10 (Subclasificacion) (3)/Diagnosis of Psychiatric Disorders, CIE-10 criteria (subclassification) (3)',
diagnostico_trs_fisico= 'Diagnóstico de Trastorno Físico/Diagnosis of Physical Disorder',
otros_probl_at_sm_or= 'Otros Problemas de Atención Vinculados a Salud Mental/Other problems linked to Mental Health',
compromiso_biopsicosocial= 'Compromiso Biopsicosocial/Biopsychosocial Involvement',
dg_global_nec_int_soc_or= 'Diagnóstico Global de Necesidades de Integración Social (Al Ingreso)/Global Diagnosis of Social Integration (At Admission)',
dg_nec_int_soc_cap_hum_or= 'Diagnóstico de Necesidades de Integración Social en Capital Humano (Al Ingreso)/Global Diagnosis of Social Integration in Human Capital (At Admission)',
dg_nec_int_soc_cap_fis_or= 'Diagnóstico de Necesidades de Integración Social en Capital Físico (Al Ingreso)/Global Diagnosis of Social Integration in Physical Capital (At Admission)',
dg_nec_int_soc_cap_soc_or= 'Diagnóstico de Necesidades de Integración Social en Capital Social (Al Ingreso)/Global Diagnosis of Social Integration in Social Capital (At Admission)',
fech_ing= 'Fecha de Ingreso a Tratamiento/Date of Admission to Treatment',
fecha_ingreso_a_convenio_senda= 'Fecha de Ingreso a Convenio SENDA (aún no formateada como fecha)/Date of Admission to SENDA Agreement',
usuario_tribunal_trat_droga= 'Usuario de modalidad Tribunales de Tratamiento de Drogas/User of Drug Treatment Courts Modality',
consentimiento_informado= 'Consentimiento Informado/Informed Consent',
fech_egres= 'Fecha de Egreso de Tratamiento/Date of Discharge from Treatment',
motivodeegreso= 'Motivo de Egreso/Cause of Discharge',
tipo_centro_derivacion= 'Tipo de Centro al que el Usuario es Derivado/Type of Center of Derivation',
evaluacindelprocesoteraputico= 'Evaluación del Proceso Terapéutico/Evaluation of the Therapeutic Process',
eva_consumo= 'Evaluación al Egreso Respecto al Patrón de consumo/Evaluation at Discharge regarding to Consumption Pattern',
eva_fam= 'Evaluación al Egreso Respecto a Situación Familiar/Evaluation at Discharge regarding to Family Situation',
eva_relinterp= 'Evaluación al Egreso Respecto a Relaciones Interpersonales/Evaluation at Discharge regarding to Interpersonal Relations',
eva_ocupacion= 'Evaluación al Egreso Respecto a Situación Ocupacional/Evaluation at Discharge regarding to Occupational Status',
eva_sm= 'Evaluación al Egreso Respecto a Salud Mental/Evaluation at Discharge regarding to Mental Health',
eva_fisica= 'Evaluación al Egreso Respecto a Salud Física/Evaluation at Discharge regarding to Physical Health',
eva_transgnorma= 'Evaluación al Egreso Respecto a Trasgresión a la Norma Social/Evaluation at Discharge regarding to Transgression to the Norm',
dg_trs_psiq_cie_10_egres_or= '(Sólo presenta valores perdidos)/',
dg_global_nec_int_soc_or_1= 'Diagnóstico Global de Necesidades de Integración Social (Al Egreso)/Global Diagnosis of Social Integration (At Discharge)',
dg_nec_int_soc_cap_hum_or_1= 'Diagnóstico de Necesidades de Integración Social en Capital Humano (Al Egreso)/Global Diagnosis of Social Integration in Human Capital (At Discharge)',
dg_nec_int_soc_cap_fis_or_1= 'Diagnóstico de Necesidades de Integración Social en Capital Físico (Al Egreso)/Global Diagnosis of Social Integration in Physical Capital (At Discharge)',
dg_nec_int_soc_cap_soc_or_1= 'Diagnóstico de Necesidades de Integración Social en Capital Social (Al Egreso)/Global Diagnosis of Social Integration in Social Capital (At Discharge)',
tiene_menores_de_edad_a_cargo= 'Menores de Edad A Cargo/Minor Dependants',
mot_egres_alt_adm_or= 'Motivo de Egreso Alta Administrativa/Cause of Administrative Discharge',
consorcio= 'Sociedades de Tratamiento Servicios de Salud- Fundaciones- entre otras entidades encargadas de los centros/Consortium',
id_centro= 'ID de Centro/Treatment center ID',
ha_estado_embarazada_egreso= '¿Ha estado embarazada? (al Egreso)/Have you been Pregnant (at Discharge)',
identidad_de_genero= 'Identidad de Género/Gender Identity',
discapacidad= 'Presenta Discapacidad/Disability',
hash_rut_completo= 'HASH alternativo, en el escenario en que se asuma que el individuo al que se le codificó el RUN presente mayor edad/Alternative HASH-Key',
opcion_discapacidad= 'Origen de Discapacidad/Cause of Disability',
sexo_2= 'Sexo Usuario/Sex of User',
embarazo= 'Embarazo al Ingreso /Pregnant at Admission',
tipo_de_plan_2= 'Tipo de Plan/Type of Plan',
tipo_de_programa_2= 'Tipo de Programa de Tratamiento/Type of Program',
fech_egres_sin_fmt= 'Fecha de Egreso de Tratamiento (Sin Formato de Fecha)/Date of Discharge',
id_mod= 'ID de SENDA para Presentación en Página Web (enmascara caracteres 5 y 6)/SENDA ID (mask characters 5 & 6)',
ano_nac= 'Año de Nacimiento (numérico)/Year of Birth (numeric)',
fech_ing_ano= 'Año de Ingreso (numérico)/Year of Admission (numeric)',
fech_ing_mes= 'Mes de Ingreso (numérico)/Month of Admission (numeric)',
fech_ing_dia= 'Día de Ingreso (numérico)/Day of Admission (numeric)',
concat= 'ID de SENDA y HASH Concatenado (permite discriminar más de un HASH en un mismo ID)/Combination of SENDA ID & HASH',
obs= 'Observaciones al Proceso de Limpieza y Estandarización de Casos/Observations to the Process of Data Tidying & Standardization',
dias_trat_inv= 'Días de Tratamiento Invertidos (fecha más reciente, menor valor numérico)/Treatment Days (Reversed)',
fech_nac= 'Fecha de Nacimiento/Date of Birth',
edad_al_ing= 'Edad a la Fecha de Ingreso a Tratamiento (numérico continuo)/Age at Admission to Treatment',
edad_ini_cons= 'Edad de Inicio de Consumo/Age of the Onset of Drug Use',
edad_ini_sus_prin= 'Edad de Inicio de Consumo Sustancia Principal/Age of the Onset of Drug Use of Primary Substance',
dias_trat_alta_temprana= 'Días de tratamiento (<90)/Less than 90 days in treatment',
motivodeegreso_mod= 'Motivo de Egreso (con abandono temprano y tardío)/Cause of Discharge (with late and early withdrawal)',
sus_principal= 'Sustancia Principal de Consumo/Primary or Main Substance of Consumption at Admission',
otras_sus1= 'Otras Sustancias (1)/Other Substances (1)',
otras_sus2= 'Otras Sustancias (2)/Other Substances (2)',
otras_sus3= 'Otras Sustancias (3)/Other Substances (3)',
sus_ini= 'Sustancia de Inicio/Starting Substance',
estado_conyugal_2= 'Estado Conyugal/Marital Status',
estatus_ocupacional= 'Condición Ocupacional/Occupational Status',
cat_ocupacional= 'Categoría Ocupacional/Occupational Category',
edad_grupos= 'Edad agrupada/Age in groups',
origen_ingreso= "(modificado en origen_ingreso_mod)/",
escolaridad= 'Escolaridad: Nivel Eduacional/Educational Attainment',
via_adm_sus_prin= 'Vía de Administración de la Sustancia Principal/Route of Administration of the Primary or Main Substance',
freq_cons_sus_prin= 'Frecuencia de Consumo de la Sustancia Principal (30 días previos a la admisión)/Frequency of Consumption of the Primary or Main Substance (30 days previous to admission)',
dias_trat_knn_imp= 'Días de Tratamiento (Imputados KNN)/Days of Treatment (Imputed KNN)',
fech_egres_knn_imp= 'Fecha de Egreso (Imputados KNN)/Date of Discharge (Imputed KNN)',
dias_trat_alta_temprana_knn_imp= 'Días de Tratamiento con Alta Temprana (<90) (Imputados KNN)/Days of Treatment w Early Withdrawal (Imputed KNN)',
fech_egres_imp= 'Fecha de Egreso (Imputados KNN & Lógico)/Date of Discharge (Imputed KNN & Logic)',
motivodeegreso_imp= 'Motivo de Egreso(Imputados KNN & Lógico)/Cause of Discharge (Imputed KNN & Logic)',
motivodeegreso_mod_imp= 'Motivo de Egreso (con abandono temprano y tardío)(Imputados KNN & Lógico)/Cause of Discharge (with late and early withdrawal)(Imputed KNN & Logic)',
dias_trat_imp= 'Días de Tratamiento (Imputados KNN & Lógico)/Days of Treatment (Imputed KNN & Logic)',
dias_trat_alta_temprana_imp= 'Días de Tratamiento con Alta Temprana (<90) (Imputados KNN & Lógico)/Days of Treatment w Early Withdrawal (Imputed KNN & Logic)',
via_adm_sus_prin_act= 'Vía de Administración de la Sustancia Principal (Se aplicaron criterios de limpieza)/Route of Administration of the Primary or Main Substance (Tidy)',
etnia_cor= 'Etnia/Ethnic Group',
nacionalidad_2= 'Segunda Nacionalidad/Second Nationality',
etnia_cor_2= 'Etnia (2)/Second Ethnic Group',
sus_ini_2= 'Segunda Sustancia de Inicio/Second Starting Substance',
sus_ini_3= 'Tercera Sustancia de Inicio/Third Starting Substance',
concat_hash_sus_prin= 'Combination of User & Primary Substance',
macrozona= "Macrozona/Macrozones",
nombre_region= " Región del Centro/Chilean Region of the Center",
comuna_residencia_cod= "Comuna de Residencia/Municipality or District of Residence",
sus_ini_mod= "Sustancia de Inicio (Sólo más frecuentes)/Starting Substance (Only more frequent)",
sus_principal_mod= 'Sustancia Principal de Consumo (Sólo más frecuentes)/Primary or Main Substance of Consumption at Admission (Only more frequent)',
origen_ingreso_mod= 'Origen de Ingreso/Motive of Admission to Treatment',
tipo_de_vivienda_mod= 'Tipo de Vivienda/Type of Housing',
tenencia_de_la_vivienda_mod= 'Tenencia de la Vivienda/Tenure status of Households',
rubro_trabaja_mod= 'Rubro de Trabajo/Area of Work',
edad_al_ing_grupos= 'Edad a la Fecha de Ingreso a Tratamiento en Grupos/Age at Admission to Treatment In Groups',
menor_60_dias_diff= 'Menor a 60 días de diferencia con el registro posterior/Menor a 60 days of difference between the next entry',
menor_45_dias_diff= 'Menor a 45 días de diferencia con el registro posterior/Less than 45 days of difference between the next entry',
diff_bet_treat= 'Días de diferencia con el registro posterior/Days of difference between the next entry',
id_centro_sig_trat= "ID del Centro del registro posterior/Center ID of the Next Treatment",
tipo_plan_sig_trat= "Tipo de Plan del registro posterior/Type of Plan of the Next Entry",
tipo_programa_sig_trat= "Tipo de Programa del registro posterior/Type of Program of the Next Entry",
senda_sig_trat= "SENDA del registro posterior/SENDA of the Next Entry",
motivoegreso_derivacion= "Motivo de Egreso= Derivación/Cause of Discharge= Derivación",
obs_cambios= "Cambios del tratamiento en comparación al registro posterior/Changes in treatment compared to the Next Entry",
obs_cambios_ninguno= "Sin cambios del tratamiento en comparación al registro posterior/No changes in treatment compared to the Next Entry",
obs_cambios_num= "Recuento de cambios del tratamiento en comparación al registro posterior/Count of changes in treatment compared to the Next Entry",
obs_cambios_fac= "Recuento de cambios del tratamiento en comparación al registro posterior(factor)/Count of changes in treatment compared to the Next Entry(factor)",
at_least_one_cont_entry= "Casos de Usuarios con más de una entrada después de otra/Cases of users with more than one entry after another one"
)
message(Sys.getenv("R_LIBS_USER"))
Sys.Date()
[1] "2022-08-31"
if (grepl("CISS Fondecyt",rstudioapi::getSourceEditorContext()$path)==T){
save.image("C:/Users/CISS Fondecyt/Mi unidad/Alvacast/SISTRAT 2022 (github)/12.RData")
} else if (grepl("andre",rstudioapi::getSourceEditorContext()$path)==T){
save.image("C:/Users/andre/Desktop/SUD_CL/12.RData")
} else if (grepl("E:",rstudioapi::getSourceEditorContext()$path)==T){
save.image("E:/Mi unidad/Alvacast/SISTRAT 2022 (github)/12.RData")
} else {
save.image(paste0(sub("2019","2022",sub("SUD_CL","",path)),"12.RData"))
}
sesion_info <- devtools::session_info()
dplyr::select(
tibble::as_tibble(sesion_info$packages),
c(package, loadedversion, source)
) %>%
DT::datatable(filter = 'top', colnames = c('Row number' =1,'Variable' = 2, 'Percentage'= 3),
caption = htmltools::tags$caption(
style = 'caption-side: top; text-align: left;',
'', htmltools::em('Packages')),
options=list(
initComplete = htmlwidgets::JS(
"function(settings, json) {",
"$(this.api().tables().body()).css({
'font-family': 'Helvetica Neue',
'font-size': '50%',
'code-inline-font-size': '15%',
'white-space': 'nowrap',
'line-height': '0.75em',
'min-height': '0.5em'
});",#;
"}")))
Base_fiscalia_v7 %>%
rio::export(file = paste0("fiscalia_mariel_aug_2022.dta"))
invisible("Temporarily useless")
# ```{r label_to_stata, echo=T, paged.print=TRUE}
#
# export_lab_stata_merge<-
# tibble::rownames_to_column(data.frame(Hmisc::label(Base_fiscalia_v2)))%>% data.frame() %>%
# dplyr::rename("code" = !!names(.[1]), "label" = !!names(.[2]))%>% data.frame()%>%
# dplyr::mutate(first= "cap noi label variable")%>%
# dplyr::mutate(final= paste0(first, " ",code,' "',label,'"'))%>%
# dplyr::select(-code,-label,-first)%>%
# dplyr::rename("*clear all"="final") %>%
# rbind(paste0('cap noi save "', gsub('/', '\\', path, fixed=T),'\\fiscalia_mariel_ago_2022.dta", replace'))%>%
# rbind('cap noi drop id id_mod nombre_centro consentimiento_informado')%>%
# rbind('cap noi drop id id_mod nombre_centro')%>%
# rbind(paste0('cap noi save "', gsub('/', '\\', path, fixed=T),'\\fiscalia_mariel_ago_2022.dta", replace'))
#
# rbind(paste0('cap noi use "', gsub('/', '\\', path, fixed=T),'\\fiscalia_mariel_ago_2022.dta", clear'),export_lab_stata_merge) %>% knitr::kable("html") %>%
# kableExtra::kable_styling(bootstrap_options = c("striped", "hover"),font_size =10) %>%
# kableExtra::scroll_box(width = "100%", height = "375px")
#
# write.table(rbind(paste0('cap noi use "', gsub('/', '\\', path, fixed=T),'\\fiscalia_mariel_ago_2022.dta", clear'),export_lab_stata_merge), file = paste0(path,"/SUD_CL/_label_var_to_stata.do"), sep = "",row.names = FALSE, quote = FALSE, fileEncoding="UTF-8")
# ```
#
# <br>
#
# <div style="border: 1px solid #ddd; padding: 5px; overflow-y: scroll; height:350px; overflow-x: scroll; width:100%">
#
# ```{stata 2, collectcode=F, include=T, error=T, cleanlog=F}
# *should be in the same folder of the .Rmd to work
# cap noi do _label_var_to_stata.do
# ```
#
# </div>