# PAQUETES
#
library(DT) # xie2020
library(foreign) # rcoreteam2020b
library(ggplot2) # wickham2016
library(reshape2) # wickham2007
library(scales) # wickham2020La Encuesta Nacional de Victimización y Percepción sobre Seguridad Pública (ENVIPE) es una encuesta levantada anualmente por el INEGI “para generar información con representatividad a nivel nacional y estatal que permita realizar estimaciones de la incidencia delictiva […], las características del delito, el impacto económico y social del mismo, junto con las características de las víctimas y el contexto de la victimización” (Instituto Nacional de Estadistica y Geografia 2022).
Todos los datos que se muestran en este reporte provienen, salvo que se indique otra cosa, de los microdatos de la ENVIPE, publicados por el INEGI.
Dado que la encuesta pregunta por los delitos sufridos durante el año inmediato anterior, los datos se presentan con fecha de mediados del año anterior al levantamiento de la encuesta.
cat.entidades <-
read.table(
file = 'cat_entidades.txt'
, sep = '|'
, fileEncoding = 'UTF-8'
, header = TRUE
, stringsAsFactors = FALSE
)
cat.municipios <-
read.table(
file = 'cat_municipios.txt'
, sep = '|'
, fileEncoding = 'UTF-8'
, header = TRUE
, stringsAsFactors = FALSE
)
cat_delitos <-
read.table(
file = 'cat_delitos',
sep = '|',
fileEncoding = 'UTF-8',
header = TRUE,
skip = 2,
stringsAsFactors = FALSE)
cat_delitos$CLAVE.DELITO.2 <- NA
cat_delitos$CLAVE.DELITO.2 <-
lapply(
X = cat_delitos$CLAVE.DELITO
, FUN = function(x){substr(x = x, start = nchar(x)-1, stop = nchar(x))}
)
# pendiente: lectura del catálogo de entidades y catálogo de municipios.
#
# LECTURA DATOS FUENTE ----
# 2022 ----
#
datos.2022 <-
read.dbf(file = './bd_envipe_2021_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2022 <-
transform(
datos.2022
, NOM_ENT = iconv(NOM_ENT, "ISO_8859-2", "UTF-8")
, NOM_MUN = iconv(NOM_MUN, "ISO_8859-2", "UTF-8")
)
datos.2022.tmodvic <-
read.dbf(file = './bd_envipe_2022_dbf/TMod_Vic.dbf', as.is = TRUE)
# 2021 ----
#
datos.2021 <-
read.dbf(file = './bd_envipe_2021_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2020 <-
read.dbf(file = './bd_envipe_2020_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2019 <-
read.dbf(file = './bd_envipe_2019_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2018 <-
read.dbf(file = './bd_envipe_2018_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2017 <-
read.dbf(file = './bd_envipe_2017_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2016 <-
read.dbf(file = './bd_envipe_2016_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2016.tvivienda <-
read.dbf(file = './bd_envipe_2016_dbf/TVivienda.dbf', as.is = TRUE)
# 2015 ----
#
datos.2015 <-
read.dbf(file = './bd_envipe_2015_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2015$ID_VIV <- paste(datos.2015$UPM, datos.2015$VIV_SEL, sep = '.')
datos.2015.tvivienda <-
read.dbf(file = './bd_envipe_2015_dbf/TVivienda.dbf', as.is = TRUE)
datos.2015.tmodvic <-
read.dbf(file = './bd_envipe_2015_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2015.tmodvic$ID_VIV <-
paste(datos.2015.tmodvic$UPM, datos.2015.tmodvic$VIV_SEL, sep = '.')
datos.2015.tper_vic1 <-
read.dbf(file = './bd_envipe_2015_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2015.tper_vic1$ID_VIV <-
paste(datos.2015.tper_vic1$UPM, datos.2015.tper_vic1$VIV_SEL, sep = '.')
# 2014 ----
#
datos.2014 <-
read.dbf(file = './bd_envipe_2014_dbf/TPer_Vic2.dbf', as.is = TRUE)
datos.2014.tvivienda <-
read.dbf(file = './bd_envipe_2014_dbf/TVivienda.dbf', as.is = TRUE)
datos.2014.tmodvic <-
read.dbf(file = './bd_envipe_2014_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2014.tmodvic$ID_VIV <-
paste(datos.2014.tmodvic$UPM, datos.2014.tmodvic$VIV_SEL, sep = '.')
# 2013 ----
#
datos.2013.tvivienda <-
read.dbf(file = './bd_envipe_2013_dbf/TViviend.dbf', as.is = TRUE)
datos.2013.tmodvic <-
read.dbf(file = './bd_envipe_2013_dbf/tmod_vic.dbf', as.is = TRUE)
datos.2013.tmodvic$ID_VIV <-
paste(datos.2013.tmodvic$UPM, datos.2013.tmodvic$VIV_SEL, sep = '.')
# 2012 ----
#
datos.2012.tsdem <-
read.dbf(file = './bd_envipe_2012_dbf/tsdem.DBF', as.is = TRUE)
datos.2012.tvivienda <-
read.dbf(file = './bd_envipe_2012_dbf/tvivienda.dbf', as.is = TRUE)
datos.2012.tmodvic <-
read.dbf(file = './bd_envipe_2012_dbf/Tmod_Vic.DBF', as.is = TRUE)
datos.2012.tmodvic$ID_VIV <-
paste(datos.2012.tmodvic$UPM, datos.2012.tmodvic$VIV_SEL, sep = '.')
datos.2012.tper_vic1 <-
read.dbf(file = './bd_envipe_2012_dbf/tper_vic.dbf', as.is = TRUE)
# Agrega la fecha de los datos.
#
datos.2012.tper_vic1$Fecha <- as.Date(x = '2011-06-30')
# 2011 #########################################################################
#
# TSDEM ########################################################################
#
datos.2011.tsdem <-
read.dbf(file = './bd_envipe_2011_dbf/tsdem.DBF', as.is = TRUE)
# TVIVIENDA ####################################################################
#
datos.2011.tvivienda <-
read.dbf(file = './bd_envipe_2011_dbf/tvivien.DBF', as.is = TRUE)
datos.2011.tvivienda$ID_VIV <-
paste(datos.2011.tvivienda$UPM, datos.2011.tvivienda$VIV_SEL, sep = '.')
# TMODVIC ######################################################################
#
datos.2011.tmodvic <-
read.dbf(file = './bd_envipe_2011_dbf/tmod_vic.DBF', as.is = TRUE)
datos.2011.tmodvic$ID_VIV <-
paste(datos.2011.tmodvic$UPM, datos.2011.tmodvic$VIV_SEL, sep = '.')
datos.2011.tmodvic$Fecha <- as.Date(x = '2010-06-30')
datos.2011.tmodvic$FAC_DEL <- as.numeric(datos.2011.tmodvic$FAC_DEL)
# TPER_VIC #####################################################################
#
datos.2011.tper_vic1 <-
read.dbf(file = './bd_envipe_2011_dbf/tper_vic.dbf', as.is = TRUE)
datos.2011.tper_vic1$ID_VIV <-
paste(datos.2011.tper_vic1$UPM, datos.2011.tper_vic1$VIV_SEL, sep = '.')
datos.2011.tper_vic1 <-
merge(
x = datos.2011.tper_vic1,
y = unique(datos.2011.tvivienda[, c('ID_VIV', 'ENT', 'MUN')]),
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2011.tper_vic1 <-
merge(
x = datos.2011.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2011.tper_vic1)[colnames(datos.2011.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2011.tper_vic1)[colnames(datos.2011.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2011.tper_vic1$NOM_MUN <- NA
# Agrega la fecha de los datos.
#
datos.2011.tper_vic1$Fecha <- as.Date(x = '2010-06-30')
#
################################################################################
# Módulo de victimización ----
#
datos.2021.tmodvic <-
read.dbf(file = './bd_envipe_2021_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2020.tmodvic <-
read.dbf(file = './bd_envipe_2020_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2019.tmodvic <-
read.dbf(file = './bd_envipe_2019_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2018.tmodvic <-
read.dbf(file = './bd_envipe_2018_dbf/TMod_Vic.dbf', as.is = TRUE)
datos.2017.tmodvic <-
read.dbf(file = './bd_envipe_2017_dbf/TMod_Vic.dbf', as.is = TRUE)
# Homologa la BP1_24 a la manera en la que se pregunta de 2018 en adelante.
#
datos.2017.tmodvic$BP1_24 <- 9
datos.2017.tmodvic$BP1_24[
which(datos.2017.tmodvic$BP1_24_1 == 1 | datos.2017.tmodvic$BP1_24_2 == 1)
] <- 1
datos.2016.tmodvic <-
read.dbf(file = './bd_envipe_2016_dbf/TMod_Vic.dbf', as.is = TRUE)
# ..............................................................................
# TPer_Vic_1 ----
# variables correspondientes a la percepción de seguridad pública y
# el desempeño institucional.
#
datos.2022.tper_vic1 <-
read.dbf(file = './bd_envipe_2022_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2021.tper_vic1 <-
read.dbf(file = './bd_envipe_2021_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2020.tper_vic1 <-
read.dbf(file = './bd_envipe_2020_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2019.tper_vic1 <-
read.dbf(file = './bd_envipe_2019_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2018.tper_vic1 <-
read.dbf(file = './bd_envipe_2018_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2017.tper_vic1 <-
read.dbf(file = './bd_envipe_2017_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2016.tper_vic1 <-
read.dbf(file = './bd_envipe_2016_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2014.tper_vic1 <-
read.dbf(file = './bd_envipe_2014_dbf/TPer_Vic1.dbf', as.is = TRUE)
datos.2013.tper_vic1 <-
read.dbf(file = './bd_envipe_2013_dbf/tper_vic.dbf', as.is = TRUE)
# Agrega la fecha de los datos.
#
datos.2022.tper_vic1$Fecha <- as.Date(x = '2021-06-30')
datos.2021.tper_vic1$Fecha <- as.Date(x = '2020-06-30')
datos.2020.tper_vic1$Fecha <- as.Date(x = '2019-06-30')
datos.2019.tper_vic1$Fecha <- as.Date(x = '2018-06-30')
datos.2018.tper_vic1$Fecha <- as.Date(x = '2017-06-30')
datos.2017.tper_vic1$Fecha <- as.Date(x = '2016-06-30')
datos.2016.tper_vic1$Fecha <- as.Date(x = '2015-06-30')
datos.2015.tper_vic1$Fecha <- as.Date(x = '2014-06-30')
datos.2014.tper_vic1$Fecha <- as.Date(x = '2013-06-30')
datos.2013.tper_vic1$Fecha <- as.Date(x = '2012-06-30')
#
# ..............................................................................
# ..............................................................................
# Agrega la fecha a cada tabla de datos.
#
datos.2012.tmodvic$Fecha <- as.Date(x = '2011-06-30')
datos.2013.tmodvic$Fecha <- as.Date(x = '2012-06-30')
datos.2014.tmodvic$Fecha <- as.Date(x = '2013-06-30')
datos.2015.tmodvic$Fecha <- as.Date(x = '2014-06-30')
datos.2016.tmodvic$Fecha <- as.Date(x = '2015-06-30')
datos.2017.tmodvic$Fecha <- as.Date(x = '2016-06-30')
datos.2018.tmodvic$Fecha <- as.Date(x = '2017-06-30')
datos.2019.tmodvic$Fecha <- as.Date(x = '2018-06-30')
datos.2020.tmodvic$Fecha <- as.Date(x = '2019-06-30')
datos.2021.tmodvic$Fecha <- as.Date(x = '2020-06-30')
datos.2022.tmodvic$Fecha <- as.Date(x = '2021-06-30')
# Convierte factores de expansión a numérico.
datos.2022.tmodvic$FAC_DEL <- as.numeric(datos.2022.tmodvic$FAC_DEL)
datos.2021.tmodvic$FAC_DEL <- as.numeric(datos.2021.tmodvic$FAC_DEL)
datos.2020.tmodvic$FAC_DEL <- as.numeric(datos.2020.tmodvic$FAC_DEL)
datos.2019.tmodvic$FAC_DEL <- as.numeric(datos.2019.tmodvic$FAC_DEL)
datos.2018.tmodvic$FAC_DEL <- as.numeric(datos.2018.tmodvic$FAC_DEL)
datos.2017.tmodvic$FAC_DEL <- as.numeric(datos.2017.tmodvic$FAC_DEL)
datos.2016.tmodvic$FAC_DEL <- as.numeric(datos.2016.tmodvic$FAC_DEL)
datos.2015.tmodvic$FAC_DEL <- as.numeric(datos.2015.tmodvic$FAC_DEL)
datos.2014.tmodvic$FAC_DEL <- as.numeric(datos.2014.tmodvic$FAC_DEL)
datos.2013.tmodvic$FAC_DEL <- as.numeric(datos.2013.tmodvic$FAC_DEL)
datos.2012.tmodvic$FAC_DEL <- as.numeric(datos.2012.tmodvic$FAC_DEL)# Agrega columna faltante a estructura de 2014, 2015, 2016.
#
# 2012
#
datos.2012.tper_vic1$ID_VIV <-
paste(datos.2012.tper_vic1$UPM, datos.2012.tper_vic1$VIV_SEL, sep = '.')
datos.2012.tvivienda$ID_VIV <-
paste(datos.2012.tvivienda$UPM, datos.2012.tvivienda$VIV_SEL, sep = '.')
datos.2012.tper_vic1 <-
merge(
x = datos.2012.tper_vic1,
y = datos.2012.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2012.tper_vic1 <-
merge(
x = datos.2012.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2012.tper_vic1)[colnames(datos.2012.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2012.tper_vic1)[colnames(datos.2012.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2012.tper_vic1$NOM_MUN <- NA
# 2013
#
datos.2013.tper_vic1$ID_VIV <-
paste(datos.2013.tper_vic1$UPM, datos.2013.tper_vic1$VIV_SEL, sep = '.')
datos.2013.tvivienda$ID_VIV <-
paste(datos.2013.tvivienda$UPM, datos.2013.tvivienda$VIV_SEL, sep = '.')
datos.2013.tper_vic1 <-
merge(
x = datos.2013.tper_vic1,
y = datos.2013.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2013.tper_vic1 <-
merge(
x = datos.2013.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2013.tper_vic1)[colnames(datos.2013.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2013.tper_vic1)[colnames(datos.2013.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2013.tper_vic1$NOM_MUN <- NA
# 2014
#
datos.2014$ID_VIV <- paste(datos.2014$UPM, datos.2014$VIV_SEL, sep = '.')
datos.2014.tper_vic1$ID_VIV <-
paste(datos.2014.tper_vic1$UPM, datos.2014.tper_vic1$VIV_SEL, sep = '.')
datos.2014.tvivienda$ID_VIV <-
paste(datos.2014.tvivienda$UPM, datos.2014.tvivienda$VIV_SEL, sep = '.')
datos.2014 <-
merge(
x = datos.2014,
y = datos.2014.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2014.tper_vic1 <-
merge(
x = datos.2014.tper_vic1,
y = datos.2014.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2014 <-
merge(
x = datos.2014,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
datos.2014.tper_vic1 <-
merge(
x = datos.2014.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2014)[colnames(datos.2014) == 'ENT'] <- 'CVE_ENT'
colnames(datos.2014)[colnames(datos.2014) == 'MUN'] <- 'CVE_MUN'
colnames(datos.2014.tper_vic1)[colnames(datos.2014.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2014.tper_vic1)[colnames(datos.2014.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2014$NOM_MUN <- NA
datos.2014.tper_vic1$NOM_MUN <- NA
# 2015
#
datos.2015 <-
merge(
x = datos.2015,
y = datos.2015.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2015.tper_vic1 <-
merge(
x = datos.2015.tper_vic1,
y = datos.2015.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2015 <-
merge(
x = datos.2015,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
datos.2015.tper_vic1 <-
merge(
x = datos.2015.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2015)[colnames(datos.2015) == 'ENT'] <- 'CVE_ENT'
colnames(datos.2015)[colnames(datos.2015) == 'MUN'] <- 'CVE_MUN'
colnames(datos.2015.tper_vic1)[colnames(datos.2015.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2015.tper_vic1)[colnames(datos.2015.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2015$NOM_MUN <- NA
datos.2015.tper_vic1$NOM_MUN <- NA
# 2016
#
datos.2016 <-
merge(
x = datos.2016,
y = datos.2016.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2016 <-
merge(
x = datos.2016,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2016)[colnames(datos.2016) == 'ENT'] <- 'CVE_ENT'
colnames(datos.2016)[colnames(datos.2016) == 'MUN'] <- 'CVE_MUN'
datos.2016$NOM_MUN <- NA
datos.2016.tper_vic1 <-
merge(
x = datos.2016.tper_vic1,
y = datos.2016.tvivienda[, c('ID_VIV', 'ENT', 'MUN')],
by.x = 'ID_VIV',
by.y = 'ID_VIV',
all.x = TRUE)
datos.2016.tper_vic1 <-
merge(
x = datos.2016.tper_vic1,
y = cat.entidades,
by.x = 'ENT',
by.y = 'CVE_ENT',
all.x = TRUE)
colnames(datos.2016.tper_vic1)[colnames(datos.2016.tper_vic1) == 'ENT'] <-
'CVE_ENT'
colnames(datos.2016.tper_vic1)[colnames(datos.2016.tper_vic1) == 'MUN'] <-
'CVE_MUN'
datos.2016.tper_vic1$NOM_MUN <- NApoblacion <-
rbind(
datos.2022.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2021.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2020.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2019.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2018.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2017.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2016.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2015.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2014.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2013.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2012.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
, datos.2011.tper_vic1[, c('Fecha', 'CVE_ENT', 'CVE_MUN', 'FAC_ELE')]
)
# POBLACIÓN NACIONAL ----
#
pob.18.mas.nacional <-
aggregate(
x = list(POB.18.MAS = as.numeric(poblacion$FAC_ELE)),
by = list(FECHA = poblacion$Fecha),
FUN = sum)
# POBLACIÓN ESTATAL ----
#
pob.18.mas.estado <-
aggregate(
x = list(POB.18.MAS = as.numeric(poblacion$FAC_ELE)),
by = list(FECHA = poblacion$Fecha, CVE_ENT = poblacion$CVE_ENT),
FUN = sum
)
# POBLACIÓN MUNICIPAL ----
#
pob.18.mas.municipio <-
aggregate(
x = list(POB.18.MAS = as.numeric(poblacion$FAC_ELE)),
by =
list(
FECHA = poblacion$Fecha
, CVE_ENT = poblacion$CVE_ENT
, CVE_MUN = poblacion$CVE_MUN
),
FUN = sum
)La incidencia es definida en la ENVIPE como el número de eventos individuales de victimización delictiva reportados durante un periodo específico en el periodo de referencia (Instituto Nacional de Estadistica y Geografia 2020b). La incidencia de criminalidad (o delictiva) es presentada típicamente como una tasa que se calcula dividiendo el total de delitos estimados en la entidad federativa de ocurrencia entre la población de 18 años y más, multiplicado por 100,000 habitantes.
columnas <-
c(
'Fecha'
, 'BP1_2C'
, 'BP1_3C'
, 'FAC_DEL'
)
# Junta los datos de delitos. Se filtran los delitos de vandalismo porque el
# INEGI los excluye de la estadística.
#
temp <-
rbind(
datos.2022.tmodvic[which(datos.2022.tmodvic$BPCOD != '03'), columnas]
, datos.2021.tmodvic[which(datos.2021.tmodvic$BPCOD != '03'), columnas]
, datos.2020.tmodvic[which(datos.2020.tmodvic$BPCOD != '03'), columnas]
, datos.2019.tmodvic[which(datos.2019.tmodvic$BPCOD != '03'), columnas]
, datos.2018.tmodvic[which(datos.2018.tmodvic$BPCOD != '03'), columnas]
, datos.2017.tmodvic[which(datos.2017.tmodvic$BPCOD != '03'), columnas]
, datos.2016.tmodvic[which(datos.2016.tmodvic$BPCOD != '03'), columnas]
, datos.2015.tmodvic[which(datos.2015.tmodvic$BPCOD != '03'), columnas]
, datos.2014.tmodvic[which(datos.2014.tmodvic$BPCOD != '03'), columnas]
, datos.2013.tmodvic[which(datos.2013.tmodvic$BPCOD != '03'), columnas]
, datos.2012.tmodvic[, columnas] # Ver nota sobre vandalismo.
, datos.2011.tmodvic[, columnas] # Ver nota sobre vandalismo.
)
# Estimación del número de delitos a nivel nacional.
#
incidencia.nacional <-
aggregate(
x = list(DELITOS = temp$FAC_DEL)
, by = list(FECHA = temp$Fecha)
, FUN = sum
)
# Estimación del número de delitos a nivel municipal.
#
incidencia.municipal <-
aggregate(
x = list(DELITOS = temp$FAC_DEL)
, by =
list(FECHA = temp$Fecha, CVE_ENT = temp$BP1_2C, CVE_MUN = temp$BP1_3C)
, FUN = sum
)
# Agrega las poblaciones:
#
# Nacional:
#
incidencia.nacional <-
merge(
x = incidencia.nacional,
y = pob.18.mas.nacional,
by.x = 'FECHA',
by.y = 'FECHA',
all.x = TRUE)
# Municipal:
#
incidencia.municipal <-
merge(
x = incidencia.municipal,
y = pob.18.mas.municipio,
by.x = c('FECHA', 'CVE_ENT', 'CVE_MUN'),
by.y = c('FECHA', 'CVE_ENT', 'CVE_MUN'),
all.x = TRUE)
# Calcula la incidencia delictiva.
#
# Nacional:
#
incidencia.nacional$INCIDENCIA <-
100000 * incidencia.nacional$DELITOS / incidencia.nacional$POB.18.MAS
# Municipal:
#
incidencia.municipal$INCIDENCIA <-
100000 * incidencia.municipal$DELITOS / incidencia.municipal$POB.18.MASLa incidencia delictiva media histórica a nivel nacional es de 35,236.
# Presenta la tabla de incidencia delictiva nacional:
#
datatable(
data =
incidencia.nacional[order(incidencia.nacional$FECHA, decreasing = TRUE), ],
rownames = FALSE,
caption = 'Estimación de la incidencia delictiva nacional por año.'
, colnames = c('POBLACIÓN' = 3)
) %>%
formatRound(columns = 2:4, digits = 0)ggplot(data = incidencia.nacional, mapping = aes(x = FECHA, y = INCIDENCIA)) +
geom_line() +
geom_hline(
yintercept = mean(incidencia.nacional$INCIDENCIA), colour = 'red'
) +
theme_minimal() +
scale_y_continuous(labels = comma)# Guarda el cálculo de la tasa de incidencia delictiva para uso en otros proyec-
# tos.
#
write.table(
x = incidencia.nacional,
file = 'envipe_incidencia_nacional.txt',
sep = '|',
row.names = FALSE,
fileEncoding = 'UTF-8'
)La tabla que se muestra a continuación contiene la estimación del número total de delitos con base en los resultados de la ENVIPE para cada año y el número total de delitos registrados en los datos publicados por el SESNSP incluyendo delitos del fuero federal y del fuero común.
datos.sesnsp <-
read.table(
file = '../../incidencia/incidencia_delictiva_total_anual.txt',
sep = '|',
encoding = 'UTF-8',
header = TRUE)
colnames(datos.sesnsp)[2] <- 'DELITOS SESNSP'
temp <- incidencia.nacional
temp$AÑO <- substr(incidencia.nacional$FECHA, start = 1, stop = 4)
temp <-
merge(
x = temp
, y = datos.sesnsp
, by.x = 'AÑO'
, by.y = 'FECHA'
, all.x = TRUE
)
temp$`INCIDENCIA SESNSP` <- 100000 * temp$`DELITOS SESNSP`/temp$POB.18.MAS
temp <- temp[order(temp$FECHA, decreasing = TRUE), ]
datatable(data = temp[, -2], rownames = FALSE, colnames = c('POBLACIÓN' = 3)) %>%
formatRound(columns = 2:6, digits = 0)Las series de incidencia delictiva presentan una correlación de -0.5587763.
temp <-
melt(
data = temp
, id.vars = 'FECHA'
, variable.name = 'FUENTE'
, value.name = 'VALOR'
)
temp$FECHA <- as.Date(x = temp$FECHA, format = '%Y')
temp <-
temp[
which(temp$FUENTE %in% c('INCIDENCIA', 'INCIDENCIA SESNSP', 'POB.18.MAS'))
,
]
temp$VALOR <- as.numeric(temp$VALOR)
ggplot(data = temp[complete.cases(temp),]) +
aes(x = FECHA, y = VALOR, group = 1) +
geom_line() +
scale_y_continuous(labels = comma) +
facet_wrap(facets = 'FUENTE', ncol = 2, scales = 'free') +
theme_minimal()columnas <-
c(
'Fecha'
, 'BP1_2C'
, 'BP1_3C'
, 'BPCOD'
, 'FAC_DEL'
)
# Junta los datos de delitos. Se filtran los delitos de vandalismo porque el
# INEGI los excluye de la estadística.
#
temp <-
rbind(
datos.2022.tmodvic[which(datos.2022.tmodvic$BPCOD != '03'), columnas]
, datos.2021.tmodvic[which(datos.2021.tmodvic$BPCOD != '03'), columnas]
, datos.2020.tmodvic[which(datos.2020.tmodvic$BPCOD != '03'), columnas]
, datos.2019.tmodvic[which(datos.2019.tmodvic$BPCOD != '03'), columnas]
, datos.2018.tmodvic[which(datos.2018.tmodvic$BPCOD != '03'), columnas]
, datos.2017.tmodvic[which(datos.2017.tmodvic$BPCOD != '03'), columnas]
, datos.2016.tmodvic[which(datos.2016.tmodvic$BPCOD != '03'), columnas]
, datos.2015.tmodvic[which(datos.2015.tmodvic$BPCOD != '03'), columnas]
, datos.2014.tmodvic[which(datos.2014.tmodvic$BPCOD != '03'), columnas]
, datos.2013.tmodvic[which(datos.2013.tmodvic$BPCOD != '03'), columnas]
, datos.2012.tmodvic[which(datos.2012.tmodvic$BPCOD != '03'), columnas]
, datos.2011.tmodvic[which(datos.2011.tmodvic$BPCOD != '03'), columnas]
)
# Estimación del número de delitos a nivel nacional por tipo de delito.
#
temp <-
aggregate(
x = list(DELITOS = temp$FAC_DEL)
, by = list(FECHA = temp$Fecha, BPCOD = temp$BPCOD)
, FUN = sum
)
# Agrega la descripción del tipo de delito.
#
temp <-
merge(
x = temp
, y = cat_delitos[, c('CLAVE.DELITO.2', 'DESCRIPCION')]
, by.x = 'BPCOD'
, by.y = 'CLAVE.DELITO.2'
, all.x = TRUE
)
datatable(
data =
dcast(
data = temp[, c('FECHA', 'DESCRIPCION', 'DELITOS')]
, formula = DESCRIPCION ~ FECHA
, fill = 0
, value.var = 'DELITOS'
)
, rownames = FALSE
, caption = 'Estimación del número total de delitos a nivel nacional por tipo de delito y año.'
) %>%
formatRound(columns = -1, digits = 0)# Nacional:
#
temp <-
merge(
x = temp,
y = pob.18.mas.nacional,
by.x = 'FECHA',
by.y = 'FECHA',
all.x = TRUE)
# Calcula la incidencia delictiva.
#
# Nacional:
#
temp$INCIDENCIA <-
100000 * temp$DELITOS / temp$POB.18.MAS
# Presenta la tabla de incidencia delictiva nacional:
#
datatable(
data =
dcast(
data = temp[, c('FECHA', 'DESCRIPCION', 'INCIDENCIA')]
, formula = DESCRIPCION ~ FECHA
, fill = 0
, value.var = 'INCIDENCIA'
),
rownames = FALSE,
caption = 'Estimación de la incidencia delictiva nacional por tipo de delito y por año.'
) %>%
formatRound(columns = -1, digits = 2)Con base en los datos de la incidencia delictiva, el delito que históricamente ha presentado el mayor índice corresponde al delito de ROBO EN CALLE en el año 2013-06-30 (12,294 delitos por cada 100,000 adultos mayores de 18 años). El delito con la menor incidencia histórica, por otra parte, es HOSTIGAMIENTO SEXUAL (21 delitos por cada 100,000 adultos mayores de 18 años en el año 2010-06-30).
A continuación se muestra la estimación de la incidencia delictiva a nivel estatal.
columnas <-
c(
'Fecha'
, 'BP1_2C'
, 'BP1_3C'
, 'FAC_DEL'
)
# Junta los datos de delitos. Se filtran los delitos de vandalismo porque el
# INEGI los excluye de la estadística.
#
temp <-
rbind(
datos.2022.tmodvic[which(datos.2022.tmodvic$BPCOD != '03'), columnas]
, datos.2021.tmodvic[which(datos.2021.tmodvic$BPCOD != '03'), columnas]
, datos.2020.tmodvic[which(datos.2020.tmodvic$BPCOD != '03'), columnas]
, datos.2019.tmodvic[which(datos.2019.tmodvic$BPCOD != '03'), columnas]
, datos.2018.tmodvic[which(datos.2018.tmodvic$BPCOD != '03'), columnas]
, datos.2017.tmodvic[which(datos.2017.tmodvic$BPCOD != '03'), columnas]
, datos.2016.tmodvic[which(datos.2016.tmodvic$BPCOD != '03'), columnas]
, datos.2015.tmodvic[which(datos.2015.tmodvic$BPCOD != '03'), columnas]
, datos.2014.tmodvic[which(datos.2014.tmodvic$BPCOD != '03'), columnas]
, datos.2013.tmodvic[which(datos.2013.tmodvic$BPCOD != '03'), columnas]
, datos.2012.tmodvic[which(datos.2012.tmodvic$BPCOD != '03'), columnas]
, datos.2011.tmodvic[which(datos.2011.tmodvic$BPCOD != '03'), columnas]
)
# Estimación del número de delitos a nivel estatal.
#
incidencia.estatal <-
aggregate(
x = list(DELITOS = temp$FAC_DEL)
, by = list(FECHA = temp$Fecha, CVE_ENT = temp$BP1_2C)
, FUN = sum
)
# Agrega las poblaciones:
#
# Estatal:
#
incidencia.estatal <-
merge(
x = incidencia.estatal,
y = pob.18.mas.estado,
by.x = c('FECHA', 'CVE_ENT'),
by.y = c('FECHA', 'CVE_ENT'),
all.x = TRUE)
# Agrega el nombre del estado.
#
incidencia.estatal <-
merge(
x = incidencia.estatal |> transform(CVE_ENT = as.numeric(CVE_ENT))
, y = cat.entidades
, by.x = c('CVE_ENT')
, by.y = c('CVE_ENT')
, all.x = TRUE
)
# Calcula la incidencia delictiva.
#
# Estatal:
#
incidencia.estatal$INCIDENCIA <-
100000 * incidencia.estatal$DELITOS / incidencia.estatal$POB.18.MAS
incidencia.estatal <-
incidencia.estatal[which(incidencia.estatal$CVE_ENT != '99'),]
temp <-
data.frame(
MEDIA = mean(incidencia.estatal$INCIDENCIA)
, MEDIANA = median(incidencia.estatal$INCIDENCIA)
, MINIMO = min(incidencia.estatal$INCIDENCIA)
, Q25 = quantile(incidencia.estatal$INCIDENCIA, probs = 0.25)
, Q75 = quantile(incidencia.estatal$INCIDENCIA, probs = 0.75)
, MAXIMO = max(incidencia.estatal$INCIDENCIA)
, DESV.EST. = sd(incidencia.estatal$INCIDENCIA)
)
datatable(data = temp, rownames = FALSE) %>% formatRound(columns = 1:ncol(temp))ggplot(data = incidencia.estatal) +
aes(y = INCIDENCIA) +
geom_boxplot() +
scale_y_continuous(labels = comma) +
theme_minimal()# Presenta la tabla de incidencia delictiva:
#
datatable(
data = incidencia.estatal[, c(2, 5, 3, 4, 6)]
, rownames = FALSE
, colnames =
c('FECHA', 'ENTIDAD', 'DELITOS', 'POBLACIÓN 18 O MÁS', 'INCIDENCIA')
, caption = 'Estimación de la incidencia delictiva estatal por año.'
)# Guarda el cálculo de la tasa de incidencia delictiva para uso en otros proyec-
# tos.
#
write.table(
x = incidencia.estatal,
file = 'envipe_incidencia_estatal.txt',
sep = '|',
row.names = FALSE,
fileEncoding = 'UTF-8')
ggplot(
data = incidencia.estatal,
mapping =
aes(
x = FECHA,
y = INCIDENCIA,
colour = factor(CVE_ENT))) +
geom_line() +
xlab(label = 'FECHA') +
ylab(label = 'INCIDENCIA DELICTIVA ESTATAL') +
labs(
title = 'ESTIMACIÓN DE LA INCIDENCIA DELICTIVA ESTATAL',
color = 'ENTIDAD') +
theme_minimal() +
theme(legend.position = 'none') +
scale_y_continuous(labels = comma)entidad <-
incidencia.estatal$NOM_ENT[
which(incidencia.estatal$INCIDENCIA == max(incidencia.estatal$INCIDENCIA))
]
fecha <-
incidencia.estatal$FECHA[
which(incidencia.estatal$INCIDENCIA == max(incidencia.estatal$INCIDENCIA))
]
incidencia <-
incidencia.estatal$INCIDENCIA[
which(incidencia.estatal$INCIDENCIA == max(incidencia.estatal$INCIDENCIA))
]temp <- incidencia.estatal[which(incidencia.estatal$NOM_ENT == entidad),]
ggplot(
data = temp,
mapping =
aes(
x = FECHA,
y = INCIDENCIA
)
) +
geom_line() +
geom_hline(
yintercept = median(incidencia.estatal$INCIDENCIA), colour = 'red'
) +
xlab(label = 'FECHA') +
ylab(label = 'INCIDENCIA DELICTIVA ESTATAL') +
labs(
title = 'ESTIMACIÓN DE LA INCIDENCIA DELICTIVA ESTATAL'
, subtitle = entidad
, caption =
'La línea horizonal representa la mediana de la incidencia delictiva estatal histórica.'
) +
theme_minimal() +
theme(legend.position = 'none') +
scale_y_continuous(labels = comma)ggplot(data = temp) +
aes(y = INCIDENCIA) +
geom_boxplot() +
scale_y_continuous(labels = comma) +
theme_minimal()datatable(
data =
data.frame(
MEDIA = mean(temp$INCIDENCIA)
, MEDIANA = median(temp$INCIDENCIA)
, MINIMO = min(temp$INCIDENCIA)
, Q25 = quantile(temp$INCIDENCIA, probs = 0.25)
, Q75 = quantile(temp$INCIDENCIA, probs = 0.75)
, MAXIMO = max(temp$INCIDENCIA)
, DESV.EST. = sd(temp$INCIDENCIA)
)
, rownames = FALSE
) %>%
formatRound(columns = 1:7)Entidad con la mayor incidencia delictiva media:
Entidad con el mayor incremento anual en incidencia delictiva:
Entidad con el mayor decremento anual en incidencia delictiva:
Entidad con el mayor incremento anual en el último año:
Entidad con el mayor decremento anual en el último año:
Entidad con la mayor tendencia histórica a la alza (pendiente):
Entidad con la mayor tendencia histórica a la baja (pendiente):
# Guarda el cálculo de la tasa de incidencia delictiva para uso en otros proyec-
# tos.
#
write.table(
x = incidencia.municipal,
file = 'envipe_incidencia_municipal.txt',
sep = '|',
row.names = FALSE,
fileEncoding = 'UTF-8')En la sección 1 del módulo de victimización se plantea la siguiente pregunta (20):
“¿Acudió ante el ministerio público para denunciar el delito?”
A continuación se presentan2 las estimaciones correspondientes. Es importante señalar que para determinar el número de delitos, el INEGI señala que, siguiendo la práctica internacional, los delitos correspondientes a robo total de vehículo, robo parcial de vehículo y robo en casa habitación son calculados utilizando los factores de expansión a nivel hogar.
# ..............................................................................
# Respuestas pregunta 20.
#
columnas <-
c(
'BPCOD'
, 'BP1_20',
'BP1_21',
'BP1_24',
'FAC_DEL'
, 'Fecha'
)
temp <-
rbind(
datos.2022.tmodvic[
which(datos.2022.tmodvic$BPCOD != '03')
, columnas]
, datos.2021.tmodvic[
which(datos.2021.tmodvic$BPCOD != '03')
, columnas]
, datos.2020.tmodvic[
which(datos.2020.tmodvic$BPCOD != '03')
, columnas]
, datos.2019.tmodvic[
which(datos.2019.tmodvic$BPCOD != '03')
, columnas]
, datos.2018.tmodvic[
which(datos.2018.tmodvic$BPCOD != '03')
, columnas]
, datos.2017.tmodvic[
which(datos.2017.tmodvic$BPCOD != '03')
, columnas]
, datos.2016.tmodvic[
which(datos.2016.tmodvic$BPCOD != '03')
, columnas]
, datos.2015.tmodvic[
which(datos.2015.tmodvic$BPCOD != '03')
, columnas]
, datos.2014.tmodvic[
which(datos.2014.tmodvic$BPCOD != '03')
, columnas]
, datos.2013.tmodvic[
which(datos.2013.tmodvic$BPCOD != '03')
, columnas]
, datos.2012.tmodvic[, columnas] # Ver nota sobre vandalismo.
, datos.2011.tmodvic[, columnas] # Ver nota sobre vandalismo.
)
# ..............................................................................
# Construye las variables para denuncia y carpeta de investigación
#
temp$DENUNCIA <- 2
temp$DENUNCIA[which(temp$BP1_20 == 1 | temp$BP1_21 == 1)] <- 1
temp$CARPETA <- 2
temp$CARPETA[which(temp$BP1_24 == 1)] <- 1
#...............................................................................
# Calcula la estimación del número de delitos denunciados y no denunciados a
# nivel nacional por año.
#
temp <-
aggregate(
x = list(DELITOS = as.numeric(temp$FAC_DEL)),
by =
list(
FECHA = temp$Fecha,
DENUNCIA = temp$DENUNCIA,
CARPETA = temp$CARPETA),
FUN = sum)
temp <-
dcast(
data = temp,
formula = FECHA ~ DENUNCIA + CARPETA,
value.var = 'DELITOS')
temp$TOTAL <- apply(X = temp[, 2:ncol(temp)], MARGIN = 1, FUN = sum)
temp$CN <- temp$TOTAL - temp$`1_1`
temp <- temp[order(temp$FECHA, decreasing = TRUE),]
temp <- temp[, c('FECHA', '1_1', 'CN', 'TOTAL')]
temp$CN.REL <- temp$CN / temp$TOTAL
datatable(
data = temp,
rownames = FALSE,
colnames = c('PERSEGUIDOS' = 2, 'CIFRA NEGRA' = 3, 'CIFRA NEGRA REL.' = 5),
caption =
'Estimación del número de delitos totales, cifra negra y perseguidos, a nivel nacional por año.'
) %>%
formatRound(columns = c(2:4), digits = 0) %>%
formatPercentage(columns = 5, digits = 2)ggplot(data = temp, mapping = aes(x = FECHA, y = TOTAL)) +
geom_col(fill = 'blue') +
geom_col(mapping = aes(y = CN), fill = 'red') +
theme_minimal() +
scale_y_continuous(labels = comma) +
labs(
title = 'INCIDENCIA DELICTIVA NACIONAL'
, subtitle = 'Total de delitos y cifra negra'
, y = 'INCIDENCIA'
)ggplot(data = temp, mapping = aes(x = FECHA, y = CN.REL)) +
geom_line() +
theme_minimal() +
scale_y_continuous(labels = percent) +
labs(
title = 'INCIDENCIA DELICTIVA NACIONAL'
, subtitle = 'Cifra negra relativa'
, y = 'CIFRA NEGRA RELATIVA'
)# Respuestas pregunta 20.
#
columnas <-
c(
'BP1_2C',
'BP1_20',
'BP1_21',
'BP1_24'
, 'FAC_DEL'
, 'Fecha'
)
temp <-
rbind(
datos.2022.tmodvic[
which(datos.2022.tmodvic$BPCOD != '03')
, columnas]
, datos.2021.tmodvic[
which(datos.2021.tmodvic$BPCOD != '03')
, columnas]
, datos.2020.tmodvic[
which(datos.2020.tmodvic$BPCOD != '03')
, columnas]
, datos.2019.tmodvic[
which(datos.2019.tmodvic$BPCOD != '03')
, columnas]
, datos.2018.tmodvic[
which(datos.2018.tmodvic$BPCOD != '03')
, columnas]
, datos.2017.tmodvic[
which(datos.2017.tmodvic$BPCOD != '03')
, columnas]
, datos.2016.tmodvic[
which(datos.2016.tmodvic$BPCOD != '03')
, columnas]
, datos.2015.tmodvic[
which(datos.2015.tmodvic$BPCOD != '03')
, columnas]
, datos.2014.tmodvic[
which(datos.2014.tmodvic$BPCOD != '03')
, columnas]
, datos.2013.tmodvic[
which(datos.2013.tmodvic$BPCOD != '03')
, columnas]
, datos.2012.tmodvic[, columnas] # Ver nota sobre vandalismo.
, datos.2011.tmodvic[, columnas] # Ver nota sobre vandalismo.
)
# ..............................................................................
# Construye las variables para denuncia y carpeta de investigación
#
temp$DENUNCIA <- 2
temp$DENUNCIA[
which(temp$BP1_20 == 1 | temp$BP1_21 == 1)] <- 1
temp$CARPETA <- 2
temp$CARPETA[
which(temp$BP1_24 == 1)] <- 1
#
#...............................................................................
# Calcula la estimación del número de delitos denunciados y no denunciados a
# nivel estatal por año.
#
temp <-
aggregate(
x = list(DELITOS = as.numeric(temp$FAC_DEL)),
by =
list(
FECHA = temp$Fecha
, CVE_ENT = temp$BP1_2C
, DENUNCIA = temp$DENUNCIA
, CARPETA = temp$CARPETA
)
, FUN = sum)
temp <-
dcast(
data = temp
, fill = 0
, formula = FECHA + CVE_ENT ~ DENUNCIA + CARPETA,
value.var = 'DELITOS')
temp$TOTAL <- rowSums(temp[, 3:ncol(temp)])
temp$CN <- temp$TOTAL - temp$`1_1`
temp$ENTIDAD <-
cat.entidades$NOM_ENT[match(x = temp$CVE_ENT, table = cat.entidades$CVE_ENT)]
temp$CN.REL <- temp$CN / temp$TOTAL
# no ordena bien, probar usando do.call.
#
temp <-
temp[
order(
temp$FECHA, temp$CVE_ENT, decreasing = c(TRUE, FALSE), method = 'radix'
)
,
]
temp <- temp[, c('FECHA', 'ENTIDAD', 'TOTAL', '1_1', 'CN', 'CN.REL')]
datatable(
data = temp
, rownames = FALSE
, colnames =
c(
'PERSEGUIDOS' = 4
, 'CIFRA NEGRA' = 5
, 'CIFRA NEGRA REL.' = 6
)
, caption =
'Estimación del número de delitos totales, cifra negra y perseguidos, a nivel municipal por año.'
) %>%
formatRound(columns = c(3:5), digits = 0) %>%
formatPercentage(columns = 6, digits = 2)write.table(
x = temp
, file = 'envipe_cifra_negra_estatal.txt'
, sep = '|'
, row.names = FALSE
, fileEncoding = 'utf-8'
)# Respuestas pregunta 20.
#
columnas <-
c(
'BP1_20',
'BP1_21',
'BP1_24'
, 'BP1_2C'
, 'BP1_3C'
, 'FAC_DEL'
, 'Fecha'
)
temp <-
rbind(
datos.2022.tmodvic[
which(datos.2022.tmodvic$BPCOD != '03')
, columnas]
, datos.2021.tmodvic[
which(datos.2021.tmodvic$BPCOD != '03')
, columnas]
# ,datos.2020.tmodvic[
# which(!(datos.2020.tmodvic$BPCOD %in% c('01', '02', '03', '04'))),
# c('ID_VIV', 'ID_DEL', 'BP1_20', 'FAC_DEL', 'Fecha')],
# datos.2019.tmodvic[
# which(!(datos.2019.tmodvic$BPCOD %in% c('01', '02', '03', '04'))),
# c('ID_VIV', 'ID_DEL', 'BP1_20', 'FAC_DEL', 'Fecha')],
# datos.2018.tmodvic[
# which(!(datos.2018.tmodvic$BPCOD %in% c('01', '02', '03', '04'))),
# c('ID_VIV', 'ID_DEL', 'BP1_20', 'FAC_DEL', 'Fecha')],
# datos.2017.tmodvic[
# which(!(datos.2017.tmodvic$BPCOD %in% c('01', '02', '03', '04'))),
# c('ID_VIV', 'ID_DEL', 'BP1_20', 'FAC_DEL', 'Fecha')],
# datos.2016.tmodvic[
# which(!(datos.2016.tmodvic$BPCOD %in% c('01', '02', '03', '04'))),
# c('ID_VIV', 'ID_DEL', 'BP1_20', 'FAC_DEL', 'Fecha')]
, datos.2011.tmodvic[
which(datos.2011.tmodvic$BPCOD != '03')
, columnas]
)
# ..............................................................................
# Construye las variables para denuncia y carpeta de investigación
#
temp$DENUNCIA <- 2
temp$DENUNCIA[
which(temp$BP1_20 == 1 | temp$BP1_21 == 1)] <- 1
temp$CARPETA <- 2
temp$CARPETA[
which(temp$BP1_24 == 1)] <- 1
#
#...............................................................................
# Calcula la estimación del número de delitos denunciados y no denunciados a
# nivel municipal por año.
#
temp <-
aggregate(
x = list(DELITOS = as.numeric(temp$FAC_DEL)),
by =
list(
FECHA = temp$Fecha
, CVE_ENT = temp$BP1_2C
, CVE_MUN = temp$BP1_3C
, DENUNCIA = temp$DENUNCIA
, CARPETA = temp$CARPETA
)
, FUN = sum)
temp <-
dcast(
data = temp
, fill = 0
, formula = FECHA + CVE_ENT + CVE_MUN ~ DENUNCIA + CARPETA,
value.var = 'DELITOS')
temp$TOTAL <- rowSums(temp[, 4:ncol(temp)])
temp$CN <- temp$TOTAL - temp$`1_1`
temp <-
temp[order(temp$FECHA, decreasing = TRUE),]
temp <- temp[, c('FECHA', 'CVE_ENT', 'CVE_MUN', '1_1', 'CN', 'TOTAL')]
temp$CN.REL <- temp$CN / temp$TOTAL
datatable(
data = temp
, rownames = FALSE
, colnames =
c(
'CLAVE ENTIDAD' = 2
, 'CLAVE MUNICIPIO' = 3
, 'PERSEGUIDOS' = 4
, 'CIFRA NEGRA' = 5
, 'CIFRA NEGRA REL.' = 7
)
, caption = 'Estimación del número de delitos totales, cifra negra y perseguidos, a nivel municipal por año.') %>%
formatRound(columns = c(4:6), digits = 0) %>%
formatPercentage(columns = 7, digits = 2)write.table(
x = temp
, file = 'envipe_cifra_negra_municipal.txt'
, sep = '|'
, row.names = FALSE
, fileEncoding = 'utf-8'
)Incidencia delictiva:
Denuncia: falta complementar con la pregunta sobre si algún pariente realizó la denuncia. También falta explorar los motivos de la no denuncia y la no-denuncia/denuncia por tipo de delito y estado.
Verificar el dato, la serie de incidencia delictiva nacional tiene una correlación negativa fuerte con la incidencia delictiva del inegi.
Continuar la lectura de Instituto Nacional de Estadistica y Geografia (2022).
Revisar evolución histórica de la pregunta BP1_24.
Procedimiento de actualización/revisión de catálogos.
Datos atípicos.
Para el cálculo de la tasa de incidencia delictiva, el INEGI no incluye los delitos registrados bajo el concepto de vandalismo (“pinta de barda o grafiti en su casa, rayones intencionales en su vehículo u otro tipo de vandalismo”), delito que fué incluido en el módulo de victimización de la encuesta hasta el 2013 ((Instituto Nacional de Estadística y Geografía 2011); (Instituto Nacional de Estadística y Geografía 2013)).↩︎
Se eliminaron registros con respuestas diferentes a “Sí” o “No”.↩︎