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)

I de Moran

#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.

I de Moran Local

#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")

Clasificación de tipos de clusters

#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.

###Parte 2

#1) Relación entre Análisis Espacial de Datos y Location Intelligence:

El análisis espacial de datos proporciona las metodologías y técnicas para comprender patrones, relaciones y dependencias inherentes a datos georreferenciados. Location Intelligence (LI) es una herramienta de inteligencia de negocios que utiliza estos métodos y tecnologías (como GIS, mapas y visualizaciones espaciales) para ofrecer insights basados en la ubicación. En esencia, el análisis espacial de datos es el motor analítico detrás del LI, permitiendo transformar datos geográficos brutos en información estratégica para la toma de decisiones empresariales y organizacionales.

#2) Principales Diferencias entre Regresión Lineal No Espacial y Espacial:

La regresión lineal no espacial asume independencia entre observaciones, ignorando cualquier relación sistemática basada en la ubicación. En cambio, la regresión espacial reconoce y modela la dependencia espacial (autocorrelación), donde valores cercanos tienden a ser similares o diferentes. La regresión espacial utiliza una matriz de pesos espaciales (W) para definir la vecindad y parámetros como ρ (SAR) o λ (SEM) para cuantificar la influencia espacial, lo que afecta la interpretación de los coeficientes de las variables independientes según la ubicación y las características vecinas. La regresión no espacial asume la ausencia de autocorrelación en los residuos, mientras que la espacial la modela explícitamente.

3) Especificar y estimar 1 modelo de regresión no espacial:

# Modelo de Regresión No Espacial (Año 2016)
modelo_no_espacial_2016_act2 <- lm(`Llegada de turistas extranjeros` ~ tourism_gdp + business_activity + crime_rate + pop_density + good_governance, data = state_geodata2016)

# Mostrar el resumen del modelo
summary(modelo_no_espacial_2016_act2)
## 
## Call:
## lm(formula = `Llegada de turistas extranjeros` ~ tourism_gdp + 
##     business_activity + crime_rate + pop_density + good_governance, 
##     data = state_geodata2016)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2226890  -534157  -277610   -63717 10350662 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)
## (Intercept)       -237060.53 1186417.88  -0.200    0.843
## tourism_gdp            14.31      10.33   1.385    0.178
## business_activity -286128.83  463066.70  -0.618    0.542
## crime_rate          -8528.66   20882.28  -0.408    0.686
## pop_density          -633.63     701.58  -0.903    0.375
## good_governance     -4537.06   11935.24  -0.380    0.707
## 
## Residual standard error: 2200000 on 26 degrees of freedom
## Multiple R-squared:  0.1044, Adjusted R-squared:  -0.06787 
## F-statistic: 0.606 on 5 and 26 DF,  p-value: 0.6959

4) De acuerdo al ESDA de la Actividad 1 ¿por qué sí / no se justifica el uso de análisis de regresión espacial?

De acuerdo al ESDA de la Actividad 1, el uso de análisis de regresión espacial se justifica principalmente para la variable Actividad Empresarial en 2016, ya que encontramos una autocorrelación espacial global positiva y estadísticamente significativa (I de Moran significativo). La presencia de autocorrelación espacial viola el supuesto de independencia de la regresión lineal no espacial, lo que hace que los modelos espaciales sean más apropiados para modelar esta variable.

Para la variable principal, Llegada de turistas extranjeros en 2016, el I de Moran global no fue estadísticamente significativo, lo que sugiere que a nivel global no hay una fuerte dependencia espacial lineal. Sin embargo, la existencia de clústeres locales identificados por el análisis LISA podría indicar que los modelos espaciales aún podrían ser útiles para capturar efectos de vecindad a una escala más fina o para modelar patrones no lineales en la dependencia espacial.

En resumen, la justificación para el uso de regresión espacial es más sólida para la Actividad Empresarial en 2016 debido a la autocorrelación global significativa. Para la Llegada de turistas extranjeros en 2016, la justificación es más débil a nivel global, pero la presencia de clústeres locales sugiere que podría haber beneficios al explorar modelos espaciales.

5) Especificar y estimar 3 modelos diferentes de regresión espacial:

library(spatialreg)
## Loading required package: Matrix
## 
## Attaching package: 'spatialreg'
## The following objects are masked from 'package:spdep':
## 
##     get.ClusterOption, get.coresOption, get.mcOption,
##     get.VerboseOption, get.ZeroPolicyOption, set.ClusterOption,
##     set.coresOption, set.mcOption, set.VerboseOption,
##     set.ZeroPolicyOption
# Modelo Autorregresivo Espacial (SAR)
modelo_sar_2016_act2 <- lagsarlm(`Llegada de turistas extranjeros` ~ tourism_gdp + business_activity + crime_rate + pop_density + good_governance, data = state_geodata2016, listw = lw_2016, type = "lag")
## Warning in lagsarlm(`Llegada de turistas extranjeros` ~ tourism_gdp + business_activity + : inversion of asymptotic covariance matrix failed for tol.solve = 2.22044604925031e-16 
##   reciprocal condition number = 4.15193e-26 - using numerical Hessian.
summary(modelo_sar_2016_act2)
## 
## Call:lagsarlm(formula = `Llegada de turistas extranjeros` ~ tourism_gdp + 
##     business_activity + crime_rate + pop_density + good_governance, 
##     data = state_geodata2016, listw = lw_2016, type = "lag")
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2226768  -533452  -276632   -66595 10351008 
## 
## Type: lag 
## Coefficients: (numerical Hessian approximate standard errors) 
##                      Estimate  Std. Error z value Pr(>|z|)
## (Intercept)       -2.3838e+05  1.0729e+06 -0.2222   0.8242
## tourism_gdp        1.4318e+01  9.3227e+00  1.5358   0.1246
## business_activity -2.8599e+05  4.1965e+05 -0.6815   0.4956
## crime_rate        -8.5094e+03  1.8779e+04 -0.4531   0.6505
## pop_density       -6.3394e+02  6.3304e+02 -1.0014   0.3166
## good_governance   -4.5356e+03  1.0732e+04 -0.4226   0.6726
## 
## Rho: 0.0012709, LR test value: 3.1606e-05, p-value: 0.99551
## Approximate (numerical Hessian) standard error: 0.032458
##     z-value: 0.039156, p-value: 0.96877
## Wald statistic: 0.0015332, p-value: 0.96877
## 
## Log likelihood: -509.4045 for lag model
## ML residual variance (sigma squared): 3.9309e+12, (sigma: 1982700)
## Number of observations: 32 
## Number of parameters estimated: 8 
## AIC: 1034.8, (AIC for lm: 1032.8)
# Modelo de Error Espacial (SEM)
modelo_sem_2016_act2 <- errorsarlm(`Llegada de turistas extranjeros` ~ tourism_gdp + business_activity + crime_rate + pop_density + good_governance, data = state_geodata2016, listw = lw_2016, etype = "error")
## Warning in errorsarlm(`Llegada de turistas extranjeros` ~ tourism_gdp + : inversion of asymptotic covariance matrix failed for tol.solve = 2.22044604925031e-16 
##   reciprocal condition number = 5.7113e-26 - using numerical Hessian.
summary(modelo_sem_2016_act2)
## 
## Call:errorsarlm(formula = `Llegada de turistas extranjeros` ~ tourism_gdp + 
##     business_activity + crime_rate + pop_density + good_governance, 
##     data = state_geodata2016, listw = lw_2016, etype = "error")
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2239472  -512406  -222547   -84096 10349628 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                      Estimate  Std. Error z value Pr(>|z|)
## (Intercept)       -2.9073e+05  1.0773e+06 -0.2699   0.7873
## tourism_gdp        1.4709e+01  9.2373e+00  1.5923   0.1113
## business_activity -2.9154e+05  4.1905e+05 -0.6957   0.4866
## crime_rate        -7.1463e+03  1.8894e+04 -0.3782   0.7053
## pop_density       -6.4690e+02  6.2751e+02 -1.0309   0.3026
## good_governance   -4.5194e+03  1.0730e+04 -0.4212   0.6736
## 
## Lambda: 0.044776, LR test value: 0.034993, p-value: 0.85161
## Approximate (numerical Hessian) standard error: 0.23613
##     z-value: 0.18962, p-value: 0.8496
## Wald statistic: 0.035957, p-value: 0.8496
## 
## Log likelihood: -509.387 for error model
## ML residual variance (sigma squared): 3.9246e+12, (sigma: 1981100)
## Number of observations: 32 
## Number of parameters estimated: 8 
## AIC: 1034.8, (AIC for lm: 1032.8)
# Modelo Durbin Espacial (SDM)
modelo_sdm_2016_act2 <- lagsarlm(tourism_gdp ~ business_activity + crime_rate + pop_density + good_governance , data = state_geodata2016, listw =lw_2016, type = "mixed")
## Warning in lagsarlm(tourism_gdp ~ business_activity + crime_rate + pop_density + : inversion of asymptotic covariance matrix failed for tol.solve = 2.22044604925031e-16 
##   reciprocal condition number = 8.80178e-20 - using numerical Hessian.
summary(modelo_sdm_2016_act2)
## 
## Call:lagsarlm(formula = tourism_gdp ~ business_activity + crime_rate + 
##     pop_density + good_governance, data = state_geodata2016, 
##     listw = lw_2016, type = "mixed")
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -45305.2 -18824.6  -9529.8   9401.4 112571.9 
## 
## Type: mixed 
## Coefficients: (numerical Hessian approximate standard errors) 
##                         Estimate Std. Error z value Pr(>|z|)
## (Intercept)           51340.5828 48092.1359  1.0675   0.2857
## business_activity      -178.1929 11957.7022 -0.0149   0.9881
## crime_rate             -202.6775   345.2538 -0.5870   0.5572
## pop_density              58.0444     6.3005  9.2126   <2e-16
## good_governance         264.1539   191.2349  1.3813   0.1672
## lag.business_activity -4935.2967  8662.5512 -0.5697   0.5689
## lag.crime_rate          332.6638  1117.8535  0.2976   0.7660
## lag.pop_density          29.8222    26.5561  1.1230   0.2614
## lag.good_governance    -127.9810   542.5880 -0.2359   0.8135
## 
## Rho: -0.42795, LR test value: 2.4641, p-value: 0.11647
## Approximate (numerical Hessian) standard error: 0.26621
##     z-value: -1.6076, p-value: 0.10793
## Wald statistic: 2.5843, p-value: 0.10793
## 
## Log likelihood: -380.9338 for mixed model
## ML residual variance (sigma squared): 1224300000, (sigma: 34990)
## Number of observations: 32 
## Number of parameters estimated: 11 
## AIC: 783.87, (AIC for lm: 784.33)

#6) Especificar y estimar 1 modelo de regresión mediante el uso de machine learning (Random Forest):

library(randomForest)
## randomForest 4.7-1.2
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## The following object is masked from 'package:ggplot2':
## 
##     margin
## The following object is masked from 'package:dplyr':
## 
##     combine
# Asegúrate de que no haya valores NA en las variables predictoras
state_geodata2016_rf <- na.omit(state_geodata2016[, c("Llegada de turistas extranjeros", "tourism_gdp", "business_activity", "crime_rate", "pop_density", "good_governance")])

modelo_rf_2016_act2 <- randomForest(`Llegada de turistas extranjeros` ~ tourism_gdp + business_activity + crime_rate + pop_density + good_governance,
                                     data = state_geodata2016_rf,
                                     ntree = 100) # Puedes ajustar el número de árboles
modelo_rf_2016_act2
## 
## Call:
##  randomForest(formula = `Llegada de turistas extranjeros` ~ tourism_gdp +      business_activity + crime_rate + pop_density + good_governance,      data = state_geodata2016_rf, ntree = 100) 
##                Type of random forest: regression
##                      Number of trees: 100
## No. of variables tried at each split: 1
## 
##           Mean of squared residuals: 4.714192e+12
##                     % Var explained: -7.41

#7) Mediante el uso de Root Mean Square Error (RMSE) seleccionar 1-2 modelos de regresión estimados en 3) - 6) y describir los principales resultados estimados.

# Modelo OLS: Residual standard error = 2200000
rmse_ols_2016 <- 2200000
cat("RMSE del modelo no espacial (2016):", rmse_ols_2016, "\n")
## RMSE del modelo no espacial (2016): 2200000
# Modelo SAR: ML residual variance (sigma squared) = 3.9308e+12, RMSE ≈ sqrt(sigma squared)
rmse_sar_2016 <- sqrt(3.9308e+12)
cat("RMSE del modelo SAR (2016):", rmse_sar_2016, "\n")
## RMSE del modelo SAR (2016): 1982625
# Modelo SEM: ML residual variance (sigma squared) = 3.9246e+12, RMSE ≈ sqrt(sigma squared)
rmse_sem_2016 <- sqrt(3.9246e+12)
cat("RMSE del modelo SEM (2016):", rmse_sem_2016, "\n")
## RMSE del modelo SEM (2016): 1981060
# Modelo SDM: ML residual variance (sigma squared) = 1.2243e+10, RMSE ≈ sqrt(sigma squared)
rmse_sdm_2016 <- sqrt(1.2243e+10)
cat("RMSE del modelo SDM (2016):", rmse_sdm_2016, "\n")
## RMSE del modelo SDM (2016): 110648.1
# Modelo Random Forest: Mean of squared residuals = 4.751612e+12, RMSE ≈ sqrt(mean squared residuals)
rmse_rf_2016 <- sqrt(4.751612e+12)
cat("RMSE del modelo Random Forest (2016):", rmse_rf_2016, "\n")
## RMSE del modelo Random Forest (2016): 2179819

El Modelo Durbin Espacial (SDM) tuvo el menor error (RMSE), indicando el mejor ajuste lineal para predecir la llegada de turistas en 2016. La densidad de población del estado fue la única variable significativa, mostrando una relación positiva con la llegada de turistas. No se encontró una autocorrelación espacial significativa en la llegada de turistas ni efectos significativos de las variables de los estados vecinos. El modelo Random Forest tuvo un mal desempeño.

8) Describir los principales 5 – 7 hallazgos del análisis de regresión no espacial y espacial. Principalmente, ¿cómo es el impacto de las variables que incluyen una especificación espacial de estados vecinos (W) sobre la variable dependiente Y?

El modelo OLS explicó muy poca varianza en la llegada de turistas.

La mayoría de las variables no fueron significativas en los modelos OLS, SAR y SEM.

No se encontró una fuerte autocorrelación espacial en los modelos SAR y SEM.

La densidad de población del estado fue un predictor positivo significativo en el modelo SDM.

Las variables de los estados vecinos no tuvieron un efecto significativo en el modelo SDM.

El modelo Random Forest mostró un rendimiento de predicción muy pobre.

El modelo SDM tuvo el mejor ajuste general entre los modelos lineales.

Las características de los estados vecinos no impactaron significativamente la llegada de turistas en el estado focal según el SDM.

9) A partir de los modelos de regresión seleccionados y los hallazgos identificados describir 2 – 3 sugerencias relacionadas con la toma de decisiones para:

  1. Identificar variables para aumentar/disminuir el turismo estatal:

Densidad de Población: Enfocarse en cómo la densidad de población dentro del estado se relaciona positivamente con la llegada de turistas.

Investigación Adicional: Explorar otras variables no incluidas en los modelos actuales que podrían ser más relevantes (infraestructura, promoción, atractivos, conectividad, seguridad).

Análisis No Lineal: Considerar que las relaciones podrían no ser lineales y explorar modelos de machine learning más complejos.

  1. Incrementar el turismo a nivel regional:

Análisis a Escala Fina: Realizar estudios a nivel más detallado (municipal, regiones turísticas) para identificar factores regionales específicos.

Estudios de Caso Regionales: Analizar en profundidad regiones con alto y bajo rendimiento turístico para entender sus dinámicas.

Colaboración Regional Estratégica: Fomentar la cooperación entre estados vecinos en promoción, infraestructura y seguridad para un beneficio mutuo.