Un Análisis Exploratorio de Datos Espaciales (ESDA) es como una primera inmersión profunda en datos que tienen una ubicación geográfica asociada. Su propósito principal es descubrir patrones espaciales que no serían evidentes al analizar los datos de forma tradicional (sin considerar dónde están ubicados). Esto incluye identificar:
Dependencia espacial (autocorrelación espacial): ¿Los valores de una variable en lugares cercanos tienden a ser similares (clústeres de valores altos o bajos) o diferentes?
Heterogeneidad espacial: ¿Varía la relación entre variables en diferentes partes del territorio?
Outliers espaciales: ¿Hay lugares con valores muy diferentes a los de sus vecinos?
En resumen, el ESDA nos ayuda a entender si la ubicación importa en nuestros datos y a generar hipótesis para análisis más avanzados.
La autocorrelación espacial se refiere al grado en que los valores de una variable están relacionados con los valores de esa misma variable en ubicaciones vecinas. En otras palabras, es la medida de cuánto se parecen o se diferencian entre sí las cosas que están cerca en el espacio.
Ejemplos:
Positiva: Imagina una enfermedad contagiosa. Es probable que las personas que viven cerca de alguien infectado tengan una mayor probabilidad de contagiarse también. Aquí, la presencia de la enfermedad en un lugar está positivamente correlacionada con su presencia en lugares cercanos.
Negativa: Considera la ubicación de supermercados de la misma cadena en una ciudad. Es menos probable que encuentres dos supermercados de la misma cadena justo uno al lado del otro, ya que se “compiten” entre sí. Aquí, la presencia de un supermercado en un lugar está negativamente correlacionada con la presencia de otro de la misma cadena muy cerca.
library(foreign) # import external files
library(dplyr) # data manipulation
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(spdep) # a collection of functions to create spatial weight matrix
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## Loading required package: sf
## Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(tigris) # allows to work with shapefiles
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
library(rgeoda) # spatial data analysis based on GeoDa
## Loading required package: digest
##
## Attaching package: 'rgeoda'
## The following object is masked from 'package:spdep':
##
## skater
library(RColorBrewer) # offers several color palettes
library(viridis) # offers several color palettes
## Loading required package: viridisLite
library(ggplot2) # to create plots and graphics from dataset
library(tmap) # making maps so spatial data distributions are visualized
library(sf) # functions to encode spatial vector data
library(sp)
library(readxl)
# classes and methods for spatial data
# Importar datos de turismo a nivel estatal
tourism_data <- read_excel("Desktop/tourism_state_data.xlsx")
## New names:
## • `region` -> `region...17`
## • `region` -> `region...18`
# Importar datos históricos de hoteles por estado
hotel_data <- read_excel("Desktop/desempeno_historico_hoteles_estados.xlsx")
## New names:
## • `` -> `...2`
# Asegúrate de que la ruta sea correcta y que el archivo .shp esté en esa ubicación
mx_state_map <- st_read("Desktop/mexlatlong.shp") # Reemplaza con tu ruta
## Reading layer `mexlatlong' from data source
## `/Users/josereneolea/Desktop/mexlatlong.shp' using driver `ESRI Shapefile'
## Simple feature collection with 32 features and 19 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -118.4042 ymin: 14.55055 xmax: -86.73862 ymax: 32.71846
## Geodetic CRS: WGS 84
mx_mun_map <- read_sf("Desktop/Mexican Municipalities.shp") # Otra forma de leer shapefiles
# Filtrar tourism_data para el año 2016
tourism_data_2016_filtered <- dplyr::filter(tourism_data, year == 2016)
# Ver las dimensiones del dataframe resultante para 2016
#dim(tourism_data_2016_filtered)
# Ver las primeras filas del dataframe resultante para 2016
#head(tourism_data_2016_filtered)
# Filtrar tourism_data para el año 2022
tourism_data_2022_filtered <- dplyr::filter(tourism_data, year == 2022)
# Ver las primeras filas del dataframe resultante para 2022
#head(tourism_data_2022_filtered)
tm_shape(mx_state_map) +
tm_polygons(col = "lightgray") +
tm_compass(position=c("left","bottom")) +
tm_layout(main.title = "Mexico's States") +
tm_text("ADMIN_NAME", size = "AREA")
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
tm_shape(mx_mun_map) +
tm_polygons(col = "lightgray") +
tm_compass(position=c("left","bottom")) +
tm_layout(main.title = "Mexico's Municipios")
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
names(tourism_data_2016_filtered)
## [1] "state" "year"
## [3] "state_id" "tourism_gdp"
## [5] "crime_rate" "college_education"
## [7] "unemployment" "employment"
## [9] "business_activity" "real_wage"
## [11] "pop_density" "good_governance"
## [13] "ratio_public_investment" "exchange_rate"
## [15] "inpc" "border_distance"
## [17] "region...17" "region...18"
## [19] "Llegada de turistas extranjeros"
names(tourism_data_2022_filtered)
## [1] "state" "year"
## [3] "state_id" "tourism_gdp"
## [5] "crime_rate" "college_education"
## [7] "unemployment" "employment"
## [9] "business_activity" "real_wage"
## [11] "pop_density" "good_governance"
## [13] "ratio_public_investment" "exchange_rate"
## [15] "inpc" "border_distance"
## [17] "region...17" "region...18"
## [19] "Llegada de turistas extranjeros"
names(mx_state_map)
## [1] "OBJECTID" "FIPS_ADMIN" "GMI_ADMIN" "ADMIN_NAME" "FIPS_CNTRY"
## [6] "GMI_CNTRY" "CNTRY_NAME" "POP_ADMIN" "TYPE_ENG" "TYPE_LOC"
## [11] "SQKM" "SQMI" "COLOR_MAP" "Shape_Leng" "Shape_Area"
## [16] "OBJECTID_1" "OBJECTID_2" "longitude" "latitude" "geometry"
##2016
state_geodata2016 <- geo_join(mx_state_map,tourism_data_2016_filtered,'OBJECTID','state_id',how='inner')
## Warning in geo_join(mx_state_map, tourism_data_2016_filtered, "OBJECTID", : We
## recommend using the dplyr::*_join() family of functions instead.
summary(state_geodata2016)
## OBJECTID FIPS_ADMIN GMI_ADMIN ADMIN_NAME
## Min. : 888 Length:32 Length:32 Length:32
## 1st Qu.:1047 Class :character Class :character Class :character
## Median :1081 Mode :character Mode :character Mode :character
## Mean :1219
## 3rd Qu.:1118
## Max. :2357
## FIPS_CNTRY GMI_CNTRY CNTRY_NAME POP_ADMIN
## Length:32 Length:32 Length:32 Min. : 345682
## Class :character Class :character Class :character 1st Qu.: 1260840
## Mode :character Mode :character Mode :character Median : 2099768
## Mean : 2782852
## 3rd Qu.: 3409309
## Max. :10662420
## TYPE_ENG TYPE_LOC SQKM SQMI
## Length:32 Length:32 Min. : 1343 Min. : 518.4
## Class :character Class :character 1st Qu.: 23484 1st Qu.: 9067.4
## Mode :character Mode :character Median : 58628 Median :22636.4
## Mean : 61289 Mean :23663.8
## 3rd Qu.: 74078 3rd Qu.:28601.3
## Max. :247935 Max. :95727.7
## COLOR_MAP Shape_Leng Shape_Area OBJECTID_1
## Length:32 Min. : 1.313 Min. : 0.115 Min. : 1.00
## Class :character 1st Qu.: 8.544 1st Qu.: 2.000 1st Qu.: 8.75
## Mode :character Median :13.341 Median : 5.126 Median :16.50
## Mean :13.385 Mean : 5.441 Mean :16.50
## 3rd Qu.:18.266 3rd Qu.: 6.662 3rd Qu.:24.25
## Max. :26.273 Max. :22.891 Max. :32.00
## OBJECTID_2 longitude latitude state
## Min. : 888 Min. :-115.10 Min. :16.50 Length:32
## 1st Qu.:1047 1st Qu.:-103.70 1st Qu.:19.07 Class :character
## Median :1081 Median : -99.87 Median :20.69 Mode :character
## Mean :1219 Mean :-100.50 Mean :21.76
## 3rd Qu.:1118 3rd Qu.: -98.08 3rd Qu.:24.46
## Max. :2357 Max. : -88.27 Max. :30.58
## year tourism_gdp crime_rate college_education
## Min. :2016 Min. : 9032 Min. : 2.94 Min. :0.1457
## 1st Qu.:2016 1st Qu.: 29752 1st Qu.:11.19 1st Qu.:0.1863
## Median :2016 Median : 35497 Median :16.41 Median :0.2200
## Mean :2016 Mean : 61085 Mean :22.49 Mean :0.2198
## 3rd Qu.:2016 3rd Qu.: 63175 3rd Qu.:31.72 3rd Qu.:0.2448
## Max. :2016 Max. :386069 Max. :87.43 Max. :0.3649
## unemployment employment business_activity real_wage
## Min. :0.02000 Min. :0.9200 Min. :-2.610 Min. :253.7
## 1st Qu.:0.03000 1st Qu.:0.9600 1st Qu.:-2.175 1st Qu.:291.7
## Median :0.04000 Median :0.9700 Median :-2.050 Median :312.2
## Mean :0.03875 Mean :0.9684 Mean :-1.795 Mean :318.0
## 3rd Qu.:0.04000 3rd Qu.:0.9800 3rd Qu.:-1.855 3rd Qu.:336.1
## Max. :0.07000 Max. :0.9900 Max. : 2.400 Max. :441.9
## pop_density good_governance ratio_public_investment exchange_rate
## Min. : 9.79 Min. : 0.000 Min. :0.000000 Min. :20.52
## 1st Qu.: 40.87 1st Qu.: 0.325 1st Qu.:0.000000 1st Qu.:20.52
## Median : 62.96 Median : 0.750 Median :0.000000 Median :20.52
## Mean : 302.79 Mean : 7.378 Mean :0.003438 Mean :20.52
## 3rd Qu.: 152.33 3rd Qu.: 1.508 3rd Qu.:0.010000 3rd Qu.:20.52
## Max. :6106.22 Max. :200.020 Max. :0.010000 Max. :20.52
## inpc border_distance region...17 region...18
## Min. :92.04 Min. : 8.83 Length:32 Min. :1.000
## 1st Qu.:92.04 1st Qu.: 613.26 Class :character 1st Qu.:2.000
## Median :92.04 Median : 751.64 Mode :character Median :3.000
## Mean :92.04 Mean : 704.92 Mean :3.188
## 3rd Qu.:92.04 3rd Qu.: 875.76 3rd Qu.:4.250
## Max. :92.04 Max. :1252.66 Max. :5.000
## Llegada de turistas extranjeros geometry
## Min. : 6661 MULTIPOLYGON :32
## 1st Qu.: 67975 epsg:4326 : 0
## Median : 169111 +proj=long...: 0
## Mean : 733681
## 3rd Qu.: 415222
## Max. :12080008
# Mapa de Distribución Espacial de Gdp de Turismo (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "tourism_gdp",
palette = "viridis",
style = "quantile",
n = 5,
title = "Gdp de Turismo (2016)") +
tm_layout(main.title = "Distribución Espacial de Gdp de Turismo (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: use 'fill' for the fill color of polygons/symbols
## (instead of 'col'), and 'col' for the outlines (instead of 'border.col').
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Distribución Espacial de Llegada de turistas extranjeros (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "Llegada de turistas extranjeros",
palette = "viridis",
style = "quantile",
n = 5,
title = "Llegada de turistas extranjeros (2016)") +
tm_layout(main.title = "Distribución Espacial de Llegada de turistas extranjeros (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Distribución Espacial de Actividad Empresarial (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "business_activity",
palette = "YlGnBu",
style = "quantile",
n = 5,
title = "Actividad Empresarial (2016)") +
tm_layout(main.title = "Distribución Espacial de Actividad Empresarial (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## [cols4all] color palettes: use palettes from the R package cols4all. Run
## `cols4all::c4a_gui()` to explore them. The old palette name "YlGnBu" is named
## "brewer.yl_gn_bu"
## Multiple palettes called "yl_gn_bu" found: "brewer.yl_gn_bu", "matplotlib.yl_gn_bu". The first one, "brewer.yl_gn_bu", is returned.
# Mapa de Distribución Espacial de Tasa de Criminalidad (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "pop_density",
palette = "OrRd",
style = "quantile",
n = 5,
title = "Densidad de población (2016)") +
tm_layout(main.title = "Distribución Espacial de densidad de poblacion (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## [cols4all] color palettes: use palettes from the R package cols4all. Run
## `cols4all::c4a_gui()` to explore them. The old palette name "OrRd" is named
## "brewer.or_rd"
## Multiple palettes called "or_rd" found: "brewer.or_rd", "matplotlib.or_rd". The first one, "brewer.or_rd", is returned.
##2022
state_geodata2022 <- geo_join(mx_state_map,tourism_data_2022_filtered,'OBJECTID','state_id',how='inner')
## Warning in geo_join(mx_state_map, tourism_data_2022_filtered, "OBJECTID", : We
## recommend using the dplyr::*_join() family of functions instead.
summary(state_geodata2022)
## OBJECTID FIPS_ADMIN GMI_ADMIN ADMIN_NAME
## Min. : 888 Length:32 Length:32 Length:32
## 1st Qu.:1047 Class :character Class :character Class :character
## Median :1081 Mode :character Mode :character Mode :character
## Mean :1219
## 3rd Qu.:1118
## Max. :2357
## FIPS_CNTRY GMI_CNTRY CNTRY_NAME POP_ADMIN
## Length:32 Length:32 Length:32 Min. : 345682
## Class :character Class :character Class :character 1st Qu.: 1260840
## Mode :character Mode :character Mode :character Median : 2099768
## Mean : 2782852
## 3rd Qu.: 3409309
## Max. :10662420
## TYPE_ENG TYPE_LOC SQKM SQMI
## Length:32 Length:32 Min. : 1343 Min. : 518.4
## Class :character Class :character 1st Qu.: 23484 1st Qu.: 9067.4
## Mode :character Mode :character Median : 58628 Median :22636.4
## Mean : 61289 Mean :23663.8
## 3rd Qu.: 74078 3rd Qu.:28601.3
## Max. :247935 Max. :95727.7
## COLOR_MAP Shape_Leng Shape_Area OBJECTID_1
## Length:32 Min. : 1.313 Min. : 0.115 Min. : 1.00
## Class :character 1st Qu.: 8.544 1st Qu.: 2.000 1st Qu.: 8.75
## Mode :character Median :13.341 Median : 5.126 Median :16.50
## Mean :13.385 Mean : 5.441 Mean :16.50
## 3rd Qu.:18.266 3rd Qu.: 6.662 3rd Qu.:24.25
## Max. :26.273 Max. :22.891 Max. :32.00
## OBJECTID_2 longitude latitude state
## Min. : 888 Min. :-115.10 Min. :16.50 Length:32
## 1st Qu.:1047 1st Qu.:-103.70 1st Qu.:19.07 Class :character
## Median :1081 Median : -99.87 Median :20.69 Mode :character
## Mean :1219 Mean :-100.50 Mean :21.76
## 3rd Qu.:1118 3rd Qu.: -98.08 3rd Qu.:24.46
## Max. :2357 Max. : -88.27 Max. :30.58
## year tourism_gdp crime_rate college_education
## Min. :2022 Min. : 8618 Min. : 1.984 Min. :0.1915
## 1st Qu.:2022 1st Qu.: 22066 1st Qu.: 9.585 1st Qu.:0.2560
## Median :2022 Median : 34023 Median : 17.346 Median :0.2822
## Mean :2022 Mean : 60344 Mean : 28.636 Mean :0.2848
## 3rd Qu.:2022 3rd Qu.: 62411 3rd Qu.: 40.571 3rd Qu.:0.3174
## Max. :2022 Max. :365959 Max. :111.064 Max. :0.4376
## unemployment employment business_activity real_wage
## Min. :0.01400 Min. :0.9541 Min. :-0.0037923 Min. :282.6
## 1st Qu.:0.02500 1st Qu.:0.9695 1st Qu.: 0.0008453 1st Qu.:314.0
## Median :0.02900 Median :0.9759 Median : 0.0060581 Median :341.6
## Mean :0.03050 Mean :0.9748 Mean : 0.0185571 Mean :348.9
## 3rd Qu.:0.03475 3rd Qu.:0.9799 3rd Qu.: 0.0112165 3rd Qu.:372.7
## Max. :0.05700 Max. :0.9928 Max. : 0.4093354 Max. :481.7
## pop_density good_governance ratio_public_investment exchange_rate
## Min. : 11.36 Min. : 0.0000 Min. :0.000000 Min. :19.47
## 1st Qu.: 42.83 1st Qu.: 0.5026 1st Qu.:0.001399 1st Qu.:19.47
## Median : 68.54 Median : 1.1424 Median :0.003060 Median :19.47
## Mean : 315.07 Mean : 4.6496 Mean :0.007506 Mean :19.47
## 3rd Qu.: 163.03 3rd Qu.: 4.3422 3rd Qu.:0.005995 3rd Qu.:19.47
## Max. :6211.45 Max. :46.0277 Max. :0.067644 Max. :19.47
## inpc border_distance region...17 region...18
## Min. :126.5 Min. : 8.83 Length:32 Min. :1.000
## 1st Qu.:126.5 1st Qu.: 613.26 Class :character 1st Qu.:2.000
## Median :126.5 Median : 751.64 Mode :character Median :3.000
## Mean :126.5 Mean : 704.92 Mean :3.188
## 3rd Qu.:126.5 3rd Qu.: 875.76 3rd Qu.:4.250
## Max. :126.5 Max. :1252.66 Max. :5.000
## Llegada de turistas extranjeros geometry
## Min. : 21207 MULTIPOLYGON :32
## 1st Qu.: 162870 epsg:4326 : 0
## Median : 237114 +proj=long...: 0
## Mean : 871694
## 3rd Qu.: 526229
## Max. :12589247
# Mapa de Distribución Espacial de Gdp de Turismo (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "tourism_gdp", # Asegúrate que esta columna exista en state_geodata2022
palette = "viridis",
style = "quantile",
n = 5,
title = "Gdp de Turismo (2022)") +
tm_layout(main.title = "Distribución Espacial de Gdp de Turismo (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Distribución Espacial de Llegada de turistas extranjeros (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "Llegada de turistas extranjeros", # Asegúrate que esta columna exista
palette = "viridis",
style = "quantile",
n = 5,
title = "Llegada de turistas extranjeros (2022)") +
tm_layout(main.title = "Distribución Espacial de Llegada de turistas extranjeros (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Distribución Espacial de Actividad Empresarial (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "business_activity", # Asegúrate que esta columna exista
palette = "YlGnBu",
style = "quantile",
n = 5,
title = "Actividad Empresarial (2022)") +
tm_layout(main.title = "Distribución Espacial de Actividad Empresarial (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## [cols4all] color palettes: use palettes from the R package cols4all. Run
## `cols4all::c4a_gui()` to explore them. The old palette name "YlGnBu" is named
## "brewer.yl_gn_bu"
## Multiple palettes called "yl_gn_bu" found: "brewer.yl_gn_bu", "matplotlib.yl_gn_bu". The first one, "brewer.yl_gn_bu", is returned.
# Mapa de Distribución Espacial de Tasa de Criminalidad (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "pop_density", # Asegúrate que esta columna exista
palette = "OrRd",
style = "quantile",
n = 5,
title = "Densidad de Población (2022)") +
tm_layout(main.title = "Distribución Espacial de Densidad de Población (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
## `tm_scale_intervals()`.
## ℹ Migrate the argument(s) 'style', 'n', 'palette' (rename to 'values') to
## 'tm_scale_intervals(<HERE>)'
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## [cols4all] color palettes: use palettes from the R package cols4all. Run
## `cols4all::c4a_gui()` to explore them. The old palette name "OrRd" is named
## "brewer.or_rd"
## Multiple palettes called "or_rd" found: "brewer.or_rd", "matplotlib.or_rd". The first one, "brewer.or_rd", is returned.
#Matriz de Conectividad
#2016
# Convertir el objeto sf a Spatial (necesario para poly2nb)
state_spatial_2016 <- as(state_geodata2016, "Spatial")
# Crear la lista de vecinos basada en la contigüidad (Queen's case)
swm_2016 <- poly2nb(state_spatial_2016, queen = TRUE)
# Ver un resumen de la matriz de vecinos (número de vecinos por estado, etc.)
summary(swm_2016)
## Neighbour list object:
## Number of regions: 32
## Number of nonzero links: 138
## Percentage nonzero weights: 13.47656
## Average number of links: 4.3125
## Link number distribution:
##
## 1 2 3 4 5 6 7 8 9
## 1 6 6 6 5 2 3 2 1
## 1 least connected region:
## 31 with 1 link
## 1 most connected region:
## 8 with 9 links
# Convertir la lista de vecinos a una lista de pesos espaciales (normalizados por fila)
lw_2016 <- nb2listw(swm_2016, style = "W", zero.policy = TRUE)
#2022
# Convertir el objeto sf a Spatial
state_spatial_2022 <- as(state_geodata2022, "Spatial")
# Crear la lista de vecinos
swm_2022 <- poly2nb(state_spatial_2022, queen = TRUE)
# Ver el resumen
summary(swm_2022)
## Neighbour list object:
## Number of regions: 32
## Number of nonzero links: 138
## Percentage nonzero weights: 13.47656
## Average number of links: 4.3125
## Link number distribution:
##
## 1 2 3 4 5 6 7 8 9
## 1 6 6 6 5 2 3 2 1
## 1 least connected region:
## 31 with 1 link
## 1 most connected region:
## 8 with 9 links
# Convertir a lista de pesos espaciales
lw_2022 <- nb2listw(swm_2022, style = "W", zero.policy = TRUE)
#2016
# I de Moran para Gdp de Turismo en 2016
moran_gdp_2016 <- moran.test(state_geodata2016$tourism_gdp, lw_2016)
print("Moran's I para Gdp de Turismo (2016):")
## [1] "Moran's I para Gdp de Turismo (2016):"
print(moran_gdp_2016)
##
## Moran I test under randomisation
##
## data: state_geodata2016$tourism_gdp
## weights: lw_2016
##
## Moran I statistic standard deviate = 0.90588, p-value = 0.1825
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.05557820 -0.03225806 0.00940171
# I de Moran para Llegada de turistas extranjeros en 2016
moran_llegada_ext_2016 <- moran.test(state_geodata2016$`Llegada de turistas extranjeros`, lw_2016)
print("Moran's I para Llegada de turistas extranjeros (2016):")
## [1] "Moran's I para Llegada de turistas extranjeros (2016):"
print(moran_llegada_ext_2016)
##
## Moran I test under randomisation
##
## data: state_geodata2016$`Llegada de turistas extranjeros`
## weights: lw_2016
##
## Moran I statistic standard deviate = 0.68464, p-value = 0.2468
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## -0.002190870 -0.032258065 0.001928686
# I de Moran para Actividad Empresarial en 2016
moran_business_2016 <- moran.test(state_geodata2016$business_activity, lw_2016)
print("Moran's I para Actividad Empresarial (2016):")
## [1] "Moran's I para Actividad Empresarial (2016):"
print(moran_business_2016)
##
## Moran I test under randomisation
##
## data: state_geodata2016$business_activity
## weights: lw_2016
##
## Moran I statistic standard deviate = 2.3263, p-value = 0.01
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.160239071 -0.032258065 0.006847258
# I de Moran para Tasa de Criminalidad en 2016
moran_popdensity_2016 <- moran.test(state_geodata2016$pop_density, lw_2016)
print("Moran's I para Tasa de Criminalidad (2016):")
## [1] "Moran's I para Tasa de Criminalidad (2016):"
print(moran_popdensity_2016)
##
## Moran I test under randomisation
##
## data: state_geodata2016$pop_density
## weights: lw_2016
##
## Moran I statistic standard deviate = 4.4057, p-value = 5.272e-06
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0937056988 -0.0322580645 0.0008174426
Gdp de Turismo: I de Moran positivo (0.0556) pero no significativo (p-value = 0.1825). No hay evidencia clara de agrupamiento espacial.
Llegada de turistas extranjeros: I de Moran cercano a cero (-0.0022) y no significativo (p-value = 0.2468). Distribución espacial aparentemente aleatoria.
Actividad Empresarial: I de Moran positivo y significativo (0.1602, p-value = 0.01). Existe una tendencia a la agrupación espacial de estados con niveles similares de actividad empresarial.
Tasa de Criminalidad: I de Moran positivo (0.0948) pero no significativo (p-value = 0.1339). No hay evidencia clara de agrupamiento espacial.
#2022
# I de Moran para Gdp de Turismo en 2022
moran_gdp_2022 <- moran.test(state_geodata2022$tourism_gdp, lw_2022)
print("Moran's I para Gdp de Turismo (2022):")
## [1] "Moran's I para Gdp de Turismo (2022):"
print(moran_gdp_2022)
##
## Moran I test under randomisation
##
## data: state_geodata2022$tourism_gdp
## weights: lw_2022
##
## Moran I statistic standard deviate = 0.38237, p-value = 0.3511
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.006512234 -0.032258065 0.010281098
# I de Moran para Llegada de turistas extranjeros en 2022
moran_llegada_ext_2022 <- moran.test(state_geodata2022$`Llegada de turistas extranjeros`, lw_2022)
print("Moran's I para Llegada de turistas extranjeros (2022):")
## [1] "Moran's I para Llegada de turistas extranjeros (2022):"
print(moran_llegada_ext_2022)
##
## Moran I test under randomisation
##
## data: state_geodata2022$`Llegada de turistas extranjeros`
## weights: lw_2022
##
## Moran I statistic standard deviate = 0.51872, p-value = 0.302
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## -0.004982638 -0.032258065 0.002764844
# I de Moran para Actividad Empresarial en 2022
moran_business_2022 <- moran.test(state_geodata2022$business_activity, lw_2022)
print("Moran's I para Actividad Empresarial (2022):")
## [1] "Moran's I para Actividad Empresarial (2022):"
print(moran_business_2022)
##
## Moran I test under randomisation
##
## data: state_geodata2022$business_activity
## weights: lw_2022
##
## Moran I statistic standard deviate = -0.76529, p-value = 0.778
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## -0.049098437 -0.032258065 0.000484227
# I de Moran para Tasa de Criminalidad en 2022
moran_popdensity_2022 <- moran.test(state_geodata2022$pop_density, lw_2022)
print("Moran's I para Tasa de Criminalidad (2022):")
## [1] "Moran's I para Tasa de Criminalidad (2022):"
print(moran_popdensity_2022)
##
## Moran I test under randomisation
##
## data: state_geodata2022$pop_density
## weights: lw_2022
##
## Moran I statistic standard deviate = 4.3633, p-value = 6.405e-06
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0989846831 -0.0322580645 0.0009047252
Gdp de Turismo: I de Moran cercano a cero (0.0065) y no significativo (p-value = 0.3511). Distribución espacial aparentemente aleatoria.
Llegada de turistas extranjeros: I de Moran cercano a cero (-0.0050) y no significativo (p-value = 0.302). Distribución espacial aparentemente aleatoria.
Actividad Empresarial: I de Moran negativo (-0.0491) y no significativo (p-value = 0.778). Distribución espacial aparentemente aleatoria.
Tasa de Criminalidad: I de Moran positivo (0.0206) y no significativo (p-value = 0.3298). Distribución espacial aparentemente aleatoria.
#2016
# I de Moran Local para Gdp de Turismo en 2016
local_moran_gdp_2016 <- localmoran(state_geodata2016$tourism_gdp, lw_2016)
state_geodata2016$Ii_gdp_2016 <- local_moran_gdp_2016[, 1]
state_geodata2016$P.Ii_gdp_2016 <- p.adjust(local_moran_gdp_2016[, 5], method = "bonferroni")
# I de Moran Local para Llegada de turistas extranjeros en 2016
local_moran_llegada_ext_2016 <- localmoran(state_geodata2016$`Llegada de turistas extranjeros`, lw_2016)
state_geodata2016$Ii_llegada_ext_2016 <- local_moran_llegada_ext_2016[, 1]
state_geodata2016$P.Ii_llegada_ext_2016 <- p.adjust(local_moran_llegada_ext_2016[, 5], method = "bonferroni")
# I de Moran Local para Actividad Empresarial en 2016
local_moran_business_2016 <- localmoran(state_geodata2016$business_activity, lw_2016)
state_geodata2016$Ii_business_2016 <- local_moran_business_2016[, 1]
state_geodata2016$P.Ii_business_2016 <- p.adjust(local_moran_business_2016[, 5], method = "bonferroni")
# I de Moran Local para Tasa de Criminalidad en 2016
local_moran_popdensity_2016 <- localmoran(state_geodata2016$pop_density, lw_2016)
state_geodata2016$Ii_popdensity_2016 <- local_moran_popdensity_2016[, 1]
state_geodata2016$P.Ii_popdensity_2016 <- p.adjust(local_moran_popdensity_2016[, 5], method = "bonferroni")
#2022
# I de Moran Local para Gdp de Turismo en 2022
local_moran_gdp_2022 <- localmoran(state_geodata2022$tourism_gdp, lw_2022)
state_geodata2022$Ii_gdp_2022 <- local_moran_gdp_2022[, 1]
state_geodata2022$P.Ii_gdp_2022 <- p.adjust(local_moran_gdp_2022[, 5], method = "bonferroni")
# I de Moran Local para Llegada de turistas extranjeros en 2022
local_moran_llegada_ext_2022 <- localmoran(state_geodata2022$`Llegada de turistas extranjeros`, lw_2022)
state_geodata2022$Ii_llegada_ext_2022 <- local_moran_llegada_ext_2022[, 1]
state_geodata2022$P.Ii_llegada_ext_2022 <- p.adjust(local_moran_llegada_ext_2022[, 5], method = "bonferroni")
# I de Moran Local para Actividad Empresarial en 2022
local_moran_business_2022 <- localmoran(state_geodata2022$business_activity, lw_2022)
state_geodata2022$Ii_business_2022 <- local_moran_business_2022[, 1]
state_geodata2022$P.Ii_business_2022 <- p.adjust(local_moran_business_2022[, 5], method = "bonferroni")
# I de Moran Local para Tasa de Criminalidad en 2022
local_moran_popdensity_2022 <- localmoran(state_geodata2022$pop_density, lw_2022)
state_geodata2022$Ii_popdensity_2022 <- local_moran_popdensity_2022[, 1]
state_geodata2022$P.Ii_popdensity_2022 <- p.adjust(local_moran_popdensity_2022[, 5], method = "bonferroni")
#2016
# Clasificación de clústeres para Gdp de Turismo en 2016
state_geodata2016 <- mutate(state_geodata2016,
cluster_gdp_2016 = case_when(
P.Ii_gdp_2016 <= 0.05 & Ii_gdp_2016 > 0 & tourism_gdp > mean(tourism_gdp, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_gdp_2016 <= 0.05 & Ii_gdp_2016 > 0 & tourism_gdp <= mean(tourism_gdp, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_gdp_2016 <= 0.05 & Ii_gdp_2016 < 0 & tourism_gdp > mean(tourism_gdp, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_gdp_2016 <= 0.05 & Ii_gdp_2016 < 0 & tourism_gdp <= mean(tourism_gdp, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Llegada de turistas extranjeros en 2016
state_geodata2016 <- mutate(state_geodata2016,
cluster_llegada_ext_2016 = case_when(
P.Ii_llegada_ext_2016 <= 0.05 & Ii_llegada_ext_2016 > 0 & `Llegada de turistas extranjeros` > mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_llegada_ext_2016 <= 0.05 & Ii_llegada_ext_2016 > 0 & `Llegada de turistas extranjeros` <= mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_llegada_ext_2016 <= 0.05 & Ii_llegada_ext_2016 < 0 & `Llegada de turistas extranjeros` > mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_llegada_ext_2016 <= 0.05 & Ii_llegada_ext_2016 < 0 & `Llegada de turistas extranjeros` <= mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Actividad Empresarial en 2016
state_geodata2016 <- mutate(state_geodata2016,
cluster_business_2016 = case_when(
P.Ii_business_2016 <= 0.05 & Ii_business_2016 > 0 & business_activity > mean(business_activity, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_business_2016 <= 0.05 & Ii_business_2016 > 0 & business_activity <= mean(business_activity, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_business_2016 <= 0.05 & Ii_business_2016 < 0 & business_activity > mean(business_activity, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_business_2016 <= 0.05 & Ii_business_2016 < 0 & business_activity <= mean(business_activity, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Tasa de Criminalidad en 2016
state_geodata2016 <- mutate(state_geodata2016,
cluster_popdensity_2016 = case_when(
P.Ii_popdensity_2016 <= 0.05 & Ii_popdensity_2016> 0 & pop_density > mean(pop_density, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_popdensity_2016 <= 0.05 & Ii_popdensity_2016> 0 & pop_density <= mean(pop_density, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_popdensity_2016<= 0.05 & Ii_popdensity_2016 < 0 & pop_density > mean(pop_density, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_popdensity_2016<= 0.05 &Ii_popdensity_2016< 0 & pop_density <= mean(pop_density, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Mapa de Clústeres de Gdp de Turismo (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "cluster_gdp_2016",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Gdp Turismo") +
tm_layout(main.title = "Clústeres Locales de Gdp de Turismo (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## The visual variable "fill" of the layer "polygons" contains a unique value. Therefore a categorical scale is applied (tm_scale_categorical).
# Mapa de Clústeres de Llegada de turistas extranjeros (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "cluster_llegada_ext_2016",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Llegada Ext.") +
tm_layout(main.title = "Clústeres Locales de Llegada de turistas extranjeros (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Clústeres de Actividad Empresarial (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "cluster_business_2016",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Actividad Empresarial") +
tm_layout(main.title = "Clústeres Locales de Actividad Empresarial (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Clústeres de Tasa de Criminalidad (2016)
tm_shape(state_geodata2016) +
tm_polygons(col = "cluster_popdensity_2016",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Densidad de Población") +
tm_layout(main.title = "Clústeres Locales de Densidad de Población (2016)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
#2022
# Clasificación de clústeres para Gdp de Turismo en 2022
state_geodata2022 <- mutate(state_geodata2022,
cluster_gdp_2022 = case_when(
P.Ii_gdp_2022 <= 0.05 & Ii_gdp_2022 > 0 & tourism_gdp > mean(tourism_gdp, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_gdp_2022 <= 0.05 & Ii_gdp_2022 > 0 & tourism_gdp <= mean(tourism_gdp, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_gdp_2022 <= 0.05 & Ii_gdp_2022 < 0 & tourism_gdp > mean(tourism_gdp, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_gdp_2022 <= 0.05 & Ii_gdp_2022 < 0 & tourism_gdp <= mean(tourism_gdp, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Llegada de turistas extranjeros en 2022
state_geodata2022 <- mutate(state_geodata2022,
cluster_llegada_ext_2022 = case_when(
P.Ii_llegada_ext_2022 <= 0.05 & Ii_llegada_ext_2022 > 0 & `Llegada de turistas extranjeros` > mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_llegada_ext_2022 <= 0.05 & Ii_llegada_ext_2022 > 0 & `Llegada de turistas extranjeros` <= mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_llegada_ext_2022 <= 0.05 & Ii_llegada_ext_2022 < 0 & `Llegada de turistas extranjeros` > mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_llegada_ext_2022 <= 0.05 & Ii_llegada_ext_2022 < 0 & `Llegada de turistas extranjeros` <= mean(`Llegada de turistas extranjeros`, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Actividad Empresarial en 2022
state_geodata2022 <- mutate(state_geodata2022,
cluster_business_2022 = case_when(
P.Ii_business_2022 <= 0.05 & Ii_business_2022 > 0 & business_activity > mean(business_activity, na.rm = TRUE) ~ "Alto-Alto",
P.Ii_business_2022 <= 0.05 & Ii_business_2022 > 0 & business_activity <= mean(business_activity, na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_business_2022 <= 0.05 & Ii_business_2022 < 0 & business_activity > mean(business_activity, na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_business_2022 <= 0.05 & Ii_business_2022 < 0 & business_activity <= mean(business_activity, na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Clasificación de clústeres para Tasa de Criminalidad en 2022
state_geodata2022 <- mutate(state_geodata2022,
cluster_popdensity_2022 = case_when(
P.Ii_popdensity_2022 <= 0.05 & Ii_popdensity_2022 > 0 & pop_density > mean(pop_density , na.rm = TRUE) ~ "Alto-Alto",
P.Ii_popdensity_2022 <= 0.05 & Ii_popdensity_2022 > 0 & pop_density <= mean(pop_density , na.rm = TRUE) ~ "Bajo-Bajo",
P.Ii_popdensity_2022 <= 0.05 & Ii_popdensity_2022 < 0 & pop_density > mean(pop_density , na.rm = TRUE) ~ "Alto-Bajo",
P.Ii_popdensity_2022 <= 0.05 & Ii_popdensity_2022 < 0 & pop_density <= mean(pop_density , na.rm = TRUE) ~ "Bajo-Alto",
TRUE ~ "No Significativo"
)
)
# Mapa de Clústeres de Gdp de Turismo (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "cluster_gdp_2022",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Gdp Turismo") +
tm_layout(main.title = "Clústeres Locales de Gdp de Turismo (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).
## [v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`
## [v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
## The visual variable "fill" of the layer "polygons" contains a unique value. Therefore a categorical scale is applied (tm_scale_categorical).
# Mapa de Clústeres de Llegada de turistas extranjeros (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "cluster_llegada_ext_2022",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Llegada Ext.") +
tm_layout(main.title = "Clústeres Locales de Llegada de turistas extranjeros (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Clústeres de Actividad Empresarial (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "cluster_business_2022",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Actividad Empresarial") +
tm_layout(main.title = "Clústeres Locales de Actividad Empresarial (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
# Mapa de Clústeres de Tasa de Criminalidad (2022)
tm_shape(state_geodata2022) +
tm_polygons(col = "cluster_popdensity_2022",
palette = c("red", "blue", "lightcoral", "skyblue", "lightgray"),
title = "Clústeres Densidad de Población") +
tm_layout(main.title = "Clústeres Locales de Densidad de población (2022)",
title.size = 1.2,
legend.position = c("left", "bottom"))
##
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_tm_polygons()`: migrate the argument(s) related to the scale of
## the visual variable `fill` namely 'palette' (rename to 'values') to fill.scale
## = tm_scale(<HERE>).[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
## visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(main.title = )`
Hallazgos adicionales:
Cambio en la Agrupación Empresarial: En 2016, la actividad empresarial tendía a concentrarse geográficamente en estados con niveles similares. Sin embargo, para 2022, esta tendencia de agrupamiento a nivel nacional desapareció, sugiriendo una distribución más dispersa o aleatoria.
Ausencia de Agrupación Turística Global: Ni el Gdp de Turismo ni la Llegada de turistas extranjeros mostraron una tendencia significativa a agruparse a nivel nacional en 2016 o 2022. Esto indica que la actividad turística a gran escala no sigue un patrón de concentración o dispersión uniforme entre los estados.
Importancia del Análisis Local: La falta de patrones globales claros en el turismo no descarta la existencia de regiones específicas con alta o baja actividad turística. Por lo tanto, es crucial analizar los clústeres locales para identificar estas áreas de concentración.
Diferencias Sectoriales: Los distintos patrones espaciales entre la actividad empresarial (con agrupación en 2016) y el sector turístico sugieren que diferentes factores influyen en su distribución geográfica. Comprender estas diferencias es clave para políticas específicas.
Posible Independencia Espacial del Turismo: La falta de fuerte agrupación turística sugiere que el éxito de un estado en este sector no depende tanto del desempeño de sus vecinos inmediatos. Factores internos y específicos de cada destino parecen jugar un rol más dominante en la atracción turística.
Limitaciones de la Escala Estatal: Analizar solo a nivel estatal podría ocultar dinámicas importantes que ocurren dentro de los estados o entre regiones más pequeñas. Considerar un análisis a nivel municipal o incluyendo factores externos como infraestructura nacional o flujos internacionales podría ofrecer una visión más completa.