Modulo Geoestadística-Estadística Espacial Big data e inteligencia territorial - 2020

Trabajo Práctico de Autocorrelación espacial (Índice de Moran) en base al Arbolado Publico Lineal en CABA

Área de estudio:

Arbolado Público Lineal de la Ciudad de Buenos Aires y análisis por Barrios

Datos

Para este trabajo se utilizarón las siguientes bases de datos:

  • Barrios CABA
  • Arbolado Público Lineal
barrios <- st_read('../Modulo_5_Estadistica_Espacial/barrios_badata.shp') %>% 
  st_transform(4326)
## Reading layer `barrios_badata' from data source `C:\Users\danie\Documents\Big Data e Inteligencia Territorial 2020\Modulo_5_Estadistica_Espacial\barrios_badata.shp' using driver `ESRI Shapefile'
## Simple feature collection with 48 features and 5 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 93743.42 ymin: 91566.42 xmax: 111751.4 ymax: 111401.7
## projected CRS:  Argentina_GKBsAs
APL <- st_read('../Modulo_5_Estadistica_Espacial/arbolado-publico-lineal-2017-2018.shp')
## Reading layer `arbolado-publico-lineal-2017-2018' from data source `C:\Users\danie\Documents\Big Data e Inteligencia Territorial 2020\Modulo_5_Estadistica_Espacial\arbolado-publico-lineal-2017-2018.shp' using driver `ESRI Shapefile'
## replacing null geometries with empty geometries
## Simple feature collection with 370180 features and 18 fields (with 15342 geometries empty)
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: -58.53046 ymin: -34.69733 xmax: -58.354 ymax: -34.53597
## geographic CRS: WGS 84

Cantidad de arbolado por barrio

APL_barrio <- st_intersection(barrios,APL) %>% 
  group_by(BARRIO) %>% 
    summarise(total=sum(n()))
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries
hist(APL_barrio$total, main="Arbolado Publico Lineal por Barrios - CABA", xlab="")

Ver outliers numéricos

boxplot(APL_barrio$total, horizontal = TRUE)

Cantidad de arbolado por area por barrio

APL_barrio_df <- APL_barrio %>% 
  as.data.frame(.) %>% 
  select(BARRIO, total)
  
APL_barrio_total <- left_join(barrios,APL_barrio_df)
## Joining, by = "BARRIO"

Exploración de datos espaciales

tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(APL_barrio_total) + 
  tm_fill("total", style = "quantile", n = 10, palette = "Greens") +
  tm_borders(alpha = 0.1) +
  tm_layout(main.title = "Cantidad de Arbolado por Barrios - CABA", main.title.size = 0.7 ,
            legend.position = c("right", "bottom"), legend.title.size = 0.8)
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.

Calculo de cantidad de arboles por Hectarea por Barrios en CABA

APL_barrio_total_area <-  APL_barrio_total%>% 
  mutate(Ha=AREA/10000) %>% 
  mutate(APL_area=total/Ha)

Explorar datos espaciales normalizados

tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(APL_barrio_total_area) + 
  tm_fill("APL_area", style = "quantile", n = 10, palette = "Greens") +
  tm_borders(alpha = 0.1) +
  tm_layout(main.title = "Cantidad de Arbolado por Barrios - CABA", main.title.size = 0.7 ,
            legend.position = c("right", "bottom"), legend.title.size = 0.8)
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.

Vecinos

Lista de vecinos (de clase nb) a partir de los poligonos con poly2nb

poly2nb(polis, row.names = NULL, queen=TRUE,)

polis pueden ser sf o SpatialPolygons (sp) row.names = columna con el id o nombre de los poligonos queen = True vecinos por 1 punto de borde, False vecinos por dos o mas puntos de borde

w_APL <- poly2nb(APL_barrio_total_area, row.names = "BARRIO")

Explorar los vecinos

w_APL
## Neighbour list object:
## Number of regions: 48 
## Number of nonzero links: 250 
## Percentage nonzero weights: 10.85069 
## Average number of links: 5.208333
summary(w_APL)
## Neighbour list object:
## Number of regions: 48 
## Number of nonzero links: 250 
## Percentage nonzero weights: 10.85069 
## Average number of links: 5.208333 
## Link number distribution:
## 
##  2  3  4  5  6  7  8 
##  1  5  8 13 13  6  2 
## 1 least connected region:
## 35 with 2 links
## 2 most connected regions:
## 8 10 with 8 links
str(w_APL)
## List of 48
##  $ : int [1:5] 2 3 24 29 34
##  $ : int [1:7] 1 3 4 26 27 28 29
##  $ : int [1:6] 1 2 5 6 26 34
##  $ : int [1:6] 2 7 8 26 28 38
##  $ : int [1:7] 3 6 13 14 25 34 45
##  $ : int [1:6] 3 5 10 14 26 32
##  $ : int [1:5] 4 8 10 11 26
##  $ : int [1:8] 4 7 9 11 15 16 38 40
##  $ : int [1:3] 8 38 40
##  $ : int [1:8] 6 7 11 26 31 32 33 36
##  $ : int [1:5] 7 8 10 15 31
##  $ : int [1:6] 13 17 20 25 30 42
##  $ : int [1:6] 5 12 14 17 25 42
##  $ : int [1:7] 5 6 13 17 25 32 33
##  $ : int [1:4] 8 11 16 31
##  $ : int [1:6] 8 15 18 31 39 40
##  $ : int [1:5] 12 13 14 30 33
##  $ : int [1:4] 16 19 31 39
##  $ : int [1:4] 18 31 35 36
##  $ : int [1:5] 12 30 41 42 48
##  $ : int [1:4] 22 23 37 47
##  $ : int [1:4] 21 23 44 47
##  $ : int [1:7] 21 22 27 28 29 37 44
##  $ : int [1:4] 1 29 34 44
##  $ : int [1:7] 5 12 13 14 42 43 45
##  $ : int [1:6] 2 3 4 6 7 10
##  $ : int [1:5] 2 23 28 29 37
##  $ : int [1:6] 2 4 23 27 37 38
##  $ : int [1:6] 1 2 23 24 27 44
##  $ : int [1:5] 12 17 20 33 48
##  $ : int [1:7] 10 11 15 16 18 19 36
##  $ : int [1:4] 6 10 14 33
##  $ : int [1:6] 10 14 17 30 32 36
##  $ : int [1:6] 1 3 5 24 44 45
##  $ : int [1:2] 19 36
##  $ : int [1:5] 10 19 31 33 35
##  $ : int [1:5] 21 23 27 28 38
##  $ : int [1:5] 4 8 9 28 37
##  $ : int [1:3] 16 18 40
##  $ : int [1:4] 8 9 16 39
##  $ : int [1:5] 20 42 43 46 48
##  $ : int [1:6] 12 13 20 25 41 43
##  $ : int [1:5] 25 41 42 45 46
##  $ : int [1:6] 22 23 24 29 34 47
##  $ : int [1:5] 5 25 34 43 46
##  $ : int [1:3] 41 43 45
##  $ : int [1:3] 21 22 44
##  $ : int [1:3] 20 30 41
##  - attr(*, "class")= chr "nb"
##  - attr(*, "region.id")= chr [1:48] "1" "2" "3" "4" ...
##  - attr(*, "call")= language poly2nb(pl = APL_barrio_total_area, row.names = "BARRIO")
##  - attr(*, "type")= chr "queen"
##  - attr(*, "sym")= logi TRUE
card(w_APL)
##  [1] 5 7 6 6 7 6 5 8 3 8 5 6 6 7 4 6 5 4 4 5 4 4 7 4 7 6 5 6 6 5 7 4 6 6 2 5 5 5
## [39] 3 4 5 6 5 6 5 3 3 3

Mapear los vecinos

plot(st_geometry(APL_barrio_total_area), border="grey")
plot(w_APL, coordinates(as(APL_barrio_total_area, "Spatial")), add=TRUE, col="blue")

Matrices de pesos vecinos

pesos binarios style=‘B’ pesos estandarizados por fila style=‘W’, la suma de los pesos por fila es 1

wmatb <- nb2mat(w_APL, style='B')
head(wmatb)
##   [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1    0    1    1    0    0    0    0    0    0     0     0     0     0     0
## 2    1    0    1    1    0    0    0    0    0     0     0     0     0     0
## 3    1    1    0    0    1    1    0    0    0     0     0     0     0     0
## 4    0    1    0    0    0    0    1    1    0     0     0     0     0     0
## 5    0    0    1    0    0    1    0    0    0     0     0     0     1     1
## 6    0    0    1    0    1    0    0    0    0     1     0     0     0     1
##   [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27]
## 1     0     0     0     0     0     0     0     0     0     1     0     0     0
## 2     0     0     0     0     0     0     0     0     0     0     0     1     1
## 3     0     0     0     0     0     0     0     0     0     0     0     1     0
## 4     0     0     0     0     0     0     0     0     0     0     0     1     0
## 5     0     0     0     0     0     0     0     0     0     0     1     0     0
## 6     0     0     0     0     0     0     0     0     0     0     0     1     0
##   [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## 1     0     1     0     0     0     0     1     0     0     0     0     0     0
## 2     1     1     0     0     0     0     0     0     0     0     0     0     0
## 3     0     0     0     0     0     0     1     0     0     0     0     0     0
## 4     1     0     0     0     0     0     0     0     0     0     1     0     0
## 5     0     0     0     0     0     0     1     0     0     0     0     0     0
## 6     0     0     0     0     1     0     0     0     0     0     0     0     0
##   [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## 1     0     0     0     0     0     0     0     0
## 2     0     0     0     0     0     0     0     0
## 3     0     0     0     0     0     0     0     0
## 4     0     0     0     0     0     0     0     0
## 5     0     0     0     0     1     0     0     0
## 6     0     0     0     0     0     0     0     0

¿Cómo seria con los pesos estandarizados por fila (style=‘W’)

wmatw <- nb2mat(w_APL, glist=NULL, style="W", zero.policy=NULL)
head(wmatw)
##        [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
## 1 0.0000000 0.2000000 0.2000000 0.0000000 0.0000000 0.0000000 0.0000000
## 2 0.1428571 0.0000000 0.1428571 0.1428571 0.0000000 0.0000000 0.0000000
## 3 0.1666667 0.1666667 0.0000000 0.0000000 0.1666667 0.1666667 0.0000000
## 4 0.0000000 0.1666667 0.0000000 0.0000000 0.0000000 0.0000000 0.1666667
## 5 0.0000000 0.0000000 0.1428571 0.0000000 0.0000000 0.1428571 0.0000000
## 6 0.0000000 0.0000000 0.1666667 0.0000000 0.1666667 0.0000000 0.0000000
##        [,8] [,9]     [,10] [,11] [,12]     [,13]     [,14] [,15] [,16] [,17]
## 1 0.0000000    0 0.0000000     0     0 0.0000000 0.0000000     0     0     0
## 2 0.0000000    0 0.0000000     0     0 0.0000000 0.0000000     0     0     0
## 3 0.0000000    0 0.0000000     0     0 0.0000000 0.0000000     0     0     0
## 4 0.1666667    0 0.0000000     0     0 0.0000000 0.0000000     0     0     0
## 5 0.0000000    0 0.0000000     0     0 0.1428571 0.1428571     0     0     0
## 6 0.0000000    0 0.1666667     0     0 0.0000000 0.1666667     0     0     0
##   [,18] [,19] [,20] [,21] [,22] [,23] [,24]     [,25]     [,26]     [,27]
## 1     0     0     0     0     0     0   0.2 0.0000000 0.0000000 0.0000000
## 2     0     0     0     0     0     0   0.0 0.0000000 0.1428571 0.1428571
## 3     0     0     0     0     0     0   0.0 0.0000000 0.1666667 0.0000000
## 4     0     0     0     0     0     0   0.0 0.0000000 0.1666667 0.0000000
## 5     0     0     0     0     0     0   0.0 0.1428571 0.0000000 0.0000000
## 6     0     0     0     0     0     0   0.0 0.0000000 0.1666667 0.0000000
##       [,28]     [,29] [,30] [,31]     [,32] [,33]     [,34] [,35] [,36] [,37]
## 1 0.0000000 0.2000000     0     0 0.0000000     0 0.2000000     0     0     0
## 2 0.1428571 0.1428571     0     0 0.0000000     0 0.0000000     0     0     0
## 3 0.0000000 0.0000000     0     0 0.0000000     0 0.1666667     0     0     0
## 4 0.1666667 0.0000000     0     0 0.0000000     0 0.0000000     0     0     0
## 5 0.0000000 0.0000000     0     0 0.0000000     0 0.1428571     0     0     0
## 6 0.0000000 0.0000000     0     0 0.1666667     0 0.0000000     0     0     0
##       [,38] [,39] [,40] [,41] [,42] [,43] [,44]     [,45] [,46] [,47] [,48]
## 1 0.0000000     0     0     0     0     0     0 0.0000000     0     0     0
## 2 0.0000000     0     0     0     0     0     0 0.0000000     0     0     0
## 3 0.0000000     0     0     0     0     0     0 0.0000000     0     0     0
## 4 0.1666667     0     0     0     0     0     0 0.0000000     0     0     0
## 5 0.0000000     0     0     0     0     0     0 0.1428571     0     0     0
## 6 0.0000000     0     0     0     0     0     0 0.0000000     0     0     0

Matrix de pesos en formato listw

lwb_APL <-  nb2listw(w_APL, style='B')
lwb_APL
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 48 
## Number of nonzero links: 250 
## Percentage nonzero weights: 10.85069 
## Average number of links: 5.208333 
## 
## Weights style: B 
## Weights constants summary:
##    n   nn  S0  S1   S2
## B 48 2304 250 500 5568
head(lwb_APL)
## $style
## [1] "B"
## 
## $neighbours
## Neighbour list object:
## Number of regions: 48 
## Number of nonzero links: 250 
## Percentage nonzero weights: 10.85069 
## Average number of links: 5.208333 
## 
## $weights
## $weights[[1]]
## [1] 1 1 1 1 1
## 
## $weights[[2]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[3]]
## [1] 1 1 1 1 1 1
## 
## $weights[[4]]
## [1] 1 1 1 1 1 1
## 
## $weights[[5]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[6]]
## [1] 1 1 1 1 1 1
## 
## $weights[[7]]
## [1] 1 1 1 1 1
## 
## $weights[[8]]
## [1] 1 1 1 1 1 1 1 1
## 
## $weights[[9]]
## [1] 1 1 1
## 
## $weights[[10]]
## [1] 1 1 1 1 1 1 1 1
## 
## $weights[[11]]
## [1] 1 1 1 1 1
## 
## $weights[[12]]
## [1] 1 1 1 1 1 1
## 
## $weights[[13]]
## [1] 1 1 1 1 1 1
## 
## $weights[[14]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[15]]
## [1] 1 1 1 1
## 
## $weights[[16]]
## [1] 1 1 1 1 1 1
## 
## $weights[[17]]
## [1] 1 1 1 1 1
## 
## $weights[[18]]
## [1] 1 1 1 1
## 
## $weights[[19]]
## [1] 1 1 1 1
## 
## $weights[[20]]
## [1] 1 1 1 1 1
## 
## $weights[[21]]
## [1] 1 1 1 1
## 
## $weights[[22]]
## [1] 1 1 1 1
## 
## $weights[[23]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[24]]
## [1] 1 1 1 1
## 
## $weights[[25]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[26]]
## [1] 1 1 1 1 1 1
## 
## $weights[[27]]
## [1] 1 1 1 1 1
## 
## $weights[[28]]
## [1] 1 1 1 1 1 1
## 
## $weights[[29]]
## [1] 1 1 1 1 1 1
## 
## $weights[[30]]
## [1] 1 1 1 1 1
## 
## $weights[[31]]
## [1] 1 1 1 1 1 1 1
## 
## $weights[[32]]
## [1] 1 1 1 1
## 
## $weights[[33]]
## [1] 1 1 1 1 1 1
## 
## $weights[[34]]
## [1] 1 1 1 1 1 1
## 
## $weights[[35]]
## [1] 1 1
## 
## $weights[[36]]
## [1] 1 1 1 1 1
## 
## $weights[[37]]
## [1] 1 1 1 1 1
## 
## $weights[[38]]
## [1] 1 1 1 1 1
## 
## $weights[[39]]
## [1] 1 1 1
## 
## $weights[[40]]
## [1] 1 1 1 1
## 
## $weights[[41]]
## [1] 1 1 1 1 1
## 
## $weights[[42]]
## [1] 1 1 1 1 1 1
## 
## $weights[[43]]
## [1] 1 1 1 1 1
## 
## $weights[[44]]
## [1] 1 1 1 1 1 1
## 
## $weights[[45]]
## [1] 1 1 1 1 1
## 
## $weights[[46]]
## [1] 1 1 1
## 
## $weights[[47]]
## [1] 1 1 1
## 
## $weights[[48]]
## [1] 1 1 1
## 
## attr(,"mode")
## [1] "binary"
## attr(,"B")
## [1] TRUE

Moran’s I

Moran I Global

moran.test(APL_barrio_total_area$total, lwb_APL)
## 
##  Moran I test under randomisation
## 
## data:  APL_barrio_total_area$total  
## weights: lwb_APL    
## 
## Moran I statistic standard deviate = 1.9677, p-value = 0.02455
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.142072392      -0.021276596       0.006891794
moran.test(APL_barrio_total_area$APL_area, lwb_APL)
## 
##  Moran I test under randomisation
## 
## data:  APL_barrio_total_area$APL_area  
## weights: lwb_APL    
## 
## Moran I statistic standard deviate = 5.9808, p-value = 1.11e-09
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##         0.4817972        -0.0212766         0.0070752

Cómo se interpretan el valor de Moran I? ¿Alguno es sinificativo??

Para el cálculo del I Moran (APL por Barrio) se puede concluir que:

Se puede observar en los resultados que el valor p-value de 0.02455. Estimando un nivel de confianza de 95% se verifica un p < a 0.05, por lo cual se puede rechazar al hipotesis nula. [https://pro.arcgis.com/es/pro-app/tool-reference/spatial-statistics/what-is-a-z-score-what-is-a-p-value.htm]

Por otra parte, el I de Moran es de 0.142072392, positivo, lo cual indica que los valores tienden a agruparse espacialmente (los valores altos se agrupan cerca de otros valores altos; los valores bajos se agrupan cerca de otros valores bajos. [https://rpubs.com/VMO/IntroSpatial#:~:text=El%20gr%C3%A1fico%20de%20Moran%20es,un%20conjunto%20de%20datos%20georreferenciados.&text=el%20cual%20se%20refiere%20a,cijzj)]

Para el cálculo del I Moran normalizado (APL por Barrio /Ha) se puede concluir que:

Se puede observar en los resultados que el valor p-value de 1.11e-09 menor que el calculado anteriormente (0.02455). Estimando un nivel de confianza de 95% se verifica un p < a 0.05, por lo cual se puede rechazar al hipotesis nula. [https://pro.arcgis.com/es/pro-app/tool-reference/spatial-statistics/what-is-a-z-score-what-is-a-p-value.htm]

Por otra parte, el I de Moran es de 0.4817972 , positivo y mayor al calculado sin normalizar (0.142072392), lo cual indica que los valores tienden a agruparse espacialmente (los valores altos se agrupan cerca de otros valores altos; los valores bajos se agrupan cerca de otros valores bajos. [https://rpubs.com/VMO/IntroSpatial#:~:text=El%20gr%C3%A1fico%20de%20Moran%20es,un%20conjunto%20de%20datos%20georreferenciados.&text=el%20cual%20se%20refiere%20a,cijzj)]

En general, se puede concluir que valor de I > 0,35, evidencia la presencia de patrones tipo clustes. [http://www.scielo.org.co/pdf/rcdg/v28n1/2256-5442-rcdg-28-01-1.pdf - pág. 11]

Correlograma de Moran

Importante para que si algun poli no tiene vecinos no de error! zero.policy por defecto NULL, TRUE asigna cero al valor lagged al poli sin vecinos, FALSE asigna NA Ante la duda usar zero.policy = TRUE Para ver numero de vecinos esta la función spdep::card

Icorr3 <-sp.correlogram(neighbours=w_APL,var=APL_barrio_total_area$APL_area,order=3,method="I",zero.policy=TRUE)
plot(Icorr3)

Diagrama de dispersión de Morán

mp <- moran.plot(APL_barrio_total_area$APL_area, lwb_APL, zero.policy=TRUE, labels=as.character(APL_barrio_total_area$'BARRIO'))

mp
##            x        wx is_inf            labels        dfb.1_         dfb.x
## 1  16.619020 100.78737  FALSE         CHACARITA  0.0218443684 -1.128874e-02
## 2  16.938518 152.02208  FALSE          PATERNAL  0.1645526436 -7.904077e-02
## 3  21.288849 111.87066  FALSE      VILLA CRESPO  0.0011762676  5.757629e-03
## 4  24.479382 132.67632  FALSE  VILLA DEL PARQUE -0.0242909521  5.125131e-02
## 5  20.907228 136.85454  FALSE           ALMAGRO  0.0150469103  3.368419e-02
## 6  22.205424 133.09372  FALSE         CABALLITO -0.0057895297  4.329927e-02
## 7  26.466195 118.04583  FALSE  VILLA SANTA RITA  0.0142847739 -2.384601e-02
## 8  27.227596 206.03527   TRUE      MONTE CASTRO -0.2766345176  4.385810e-01
## 9  28.789951  79.24040  FALSE        VILLA REAL  0.2189106248 -3.218375e-01
## 10 18.048411 164.61570  FALSE            FLORES  0.1485408217 -4.531004e-02
## 11 26.285844 116.25548  FALSE          FLORESTA  0.0170017887 -2.878992e-02
## 12 15.542378  92.00254  FALSE      CONSTITUCION  0.0067897514 -4.155512e-03
## 13 25.150326 106.32257  FALSE     SAN CRISTOBAL  0.0254132489 -4.836921e-02
## 14 25.193010 148.62003  FALSE             BOEDO -0.0585832688  1.108922e-01
## 15 24.611351  96.80511  FALSE   VELEZ SARSFIELD  0.0343911933 -7.089979e-02
## 16 23.389745 142.25669  FALSE        VILLA LURO -0.0267020475  7.499747e-02
## 17 17.425149  95.76054  FALSE  PARQUE PATRICIOS -0.0001299464  5.386505e-05
## 18 22.423086  78.64247  FALSE         MATADEROS  0.0123444741 -6.619223e-02
## 19 13.231295  56.29301  FALSE      VILLA LUGANO -0.1332692497  9.799351e-02
## 20 10.728167  49.21038  FALSE         SAN TELMO -0.1716428004  1.391300e-01
## 21 19.432439  97.46333  FALSE          SAAVEDRA -0.0059069089 -8.707522e-04
## 22 28.774531  81.14950  FALSE           COGHLAN  0.2095926091 -3.083241e-01
## 23 27.325819 156.62464  FALSE     VILLA URQUIZA -0.1014238475  1.598708e-01
## 24 26.627081  69.45980  FALSE        COLEGIALES  0.1589962252 -2.622500e-01
## 25 18.849543 113.43488  FALSE         BALVANERA  0.0221454800 -2.115392e-03
## 26 22.004600 129.42678  FALSE VILLA GRAL. MITRE -0.0027281189  3.499086e-02
## 27 30.893348 104.88081  FALSE       PARQUE CHAS  0.1777364668 -2.448011e-01
## 28 13.999825 149.55624  FALSE         AGRONOMIA  0.2996619360 -2.104989e-01
## 29 22.737055 135.31164  FALSE     VILLA ORTUZAR -0.0131211442  5.217718e-02
## 30 11.444085  72.57073  FALSE          BARRACAS -0.0307367164  2.436739e-02
## 31 19.901924 131.65909  FALSE PARQUE AVELLANEDA  0.0303331342  1.376149e-02
## 32 25.651620  83.87758  FALSE  PARQUE CHACABUCO  0.0844791324 -1.516819e-01
## 33 18.430738 101.43164  FALSE     NUEVA POMPEYA  0.0048814321 -1.062256e-03
## 34 13.195866 113.32156  FALSE           PALERMO  0.1518917917 -1.118952e-01
## 35 10.298644  16.90065  FALSE   VILLA RIACHUELO -0.4008018236  3.287341e-01
## 36  3.669360  79.91101   TRUE     VILLA SOLDATI  0.2985349177 -2.718686e-01
## 37 23.879588 117.69101  FALSE  VILLA PUEYRREDON -0.0027916217  6.715215e-03
## 38 26.039581 118.37634  FALSE      VILLA DEVOTO  0.0089076858 -1.540505e-02
## 39 22.119510  71.78605  FALSE           LINIERS  0.0079097806 -7.140527e-02
## 40 25.973221 101.52680  FALSE         VERSALLES  0.0497462665 -8.655110e-02
## 41  3.374350  41.09089   TRUE     PUERTO MADERO -0.1416565526  1.293589e-01
## 42  8.405265  80.90992  FALSE         MONSERRAT  0.0999665044 -8.549100e-02
## 43  7.265157  45.84868  FALSE       SAN NICOLAS -0.1687599644  1.471359e-01
## 44 16.907857 136.14374  FALSE          BELGRANO  0.1183494605 -5.728619e-02
## 45 10.971521  64.46580  FALSE          RECOLETA -0.0745810558  6.002229e-02
## 46  4.248001  21.61103  FALSE            RETIRO -0.3815948474  3.455366e-01
## 47 17.483390  65.11483  FALSE             NUÑEZ -0.0761794652  3.090122e-02
## 48 10.444299  25.54660  FALSE              BOCA -0.3354908684  2.741005e-01
##            dffit     cov.r       cook.d        hat
## 1   0.0341835182 1.0676406 5.965929e-04 0.02338349
## 2   0.2709356031 0.9339489 3.506403e-02 0.02277136
## 3   0.0196815292 1.0685111 1.979123e-04 0.02278310
## 4   0.0851309960 1.0700097 3.686593e-03 0.03267659
## 5   0.1376761582 1.0299748 9.511187e-03 0.02215981
## 6   0.1086242671 1.0496921 5.969094e-03 0.02476897
## 7  -0.0331893018 1.0907752 5.626980e-04 0.04306370
## 8   0.5834265169 0.8293905 1.512385e-01 0.04790403
## 9  -0.3995459074 0.9956831 7.724726e-02 0.05932775
## 10  0.3071760012 0.8882445 4.398822e-02 0.02129670
## 11 -0.0405606788 1.0889175 8.401631e-04 0.04198696
## 12  0.0092762513 1.0727489 4.397737e-05 0.02606382
## 13 -0.0747766591 1.0765472 2.848376e-03 0.03582157
## 14  0.1707358191 1.0473836 1.464546e-02 0.03603417
## 15 -0.1159747575 1.0623598 6.815320e-03 0.03326596
## 16  0.1455986520 1.0415391 1.066291e-02 0.02835722
## 17 -0.0002338904 1.0684441 2.796018e-08 0.02200019
## 18 -0.1569290802 1.0283626 1.232753e-02 0.02534200
## 19 -0.1539173470 1.0521413 1.193543e-02 0.03503403
## 20 -0.1825570023 1.0690960 1.679599e-02 0.04970066
## 21 -0.0192736472 1.0663915 1.897907e-04 0.02087594
## 22 -0.3829843054 1.0040003 7.127650e-02 0.05920520
## 23  0.2115676285 1.0566879 2.244046e-02 0.04856314
## 24 -0.3612457283 0.9674707 6.274985e-02 0.04404678
## 25  0.0577853456 1.0598065 1.700751e-03 0.02086129
## 26  0.0929309011 1.0546019 4.380244e-03 0.02427481
## 27 -0.2860328267 1.0859261 4.093518e-02 0.07787540
## 28  0.3610211493 0.9100630 6.117958e-02 0.03156400
## 29  0.1149711433 1.0500728 6.683193e-03 0.02623714
## 30 -0.0332574892 1.0930124 5.650250e-04 0.04498018
## 31  0.1245669672 1.0340865 7.805944e-03 0.02109074
## 32 -0.2242173155 1.0283572 2.499624e-02 0.03841277
## 33  0.0111800099 1.0671018 6.387686e-05 0.02102312
## 34  0.1751272842 1.0437165 1.538814e-02 0.03520569
## 35 -0.4226568006 0.9611488 8.522692e-02 0.05273490
## 36  0.2993859954 1.1515211 4.514486e-02 0.11879141
## 37  0.0120675435 1.0772299 7.442313e-05 0.03017827
## 38 -0.0220894991 1.0885541 2.493307e-04 0.04055989
## 39 -0.1834447103 1.0103182 1.670364e-02 0.02455351
## 40 -0.1247245703 1.0709273 7.885842e-03 0.04018386
## 41 -0.1419872837 1.1833061 1.027126e-02 0.12257026
## 42  0.1026772787 1.1139043 5.371182e-03 0.06791713
## 43 -0.1716765218 1.1166874 1.494893e-02 0.07848012
## 44  0.1938658933 0.9967949 1.854648e-02 0.02282646
## 45 -0.0797527853 1.0915585 3.241847e-03 0.04804883
## 46 -0.3831498466 1.1173874 7.313354e-02 0.11158717
## 47 -0.1387303557 1.0287210 9.652699e-03 0.02192093
## 48 -0.3547655626 0.9969564 6.118802e-02 0.05168898

Guía para interpretar Eje x Arbolado Publico Lineal por Barrio Eje y lag espacial de x = promedio de valores de vecinos a x Pendiente de recta de regresion es Moran I si fuera correlacion positiva, mas Arbolado Público Líneal (APL) en areas vecinas si fuera correlacion negativa, menos Arbolado Público Líneal (APL) en las areas vecinas Valores con alta influencia Outliers

¿Qué decía el Moran I sobre s podemos rechazar la hipotesis nula?

Cuando el I de moran es positivo podemos rechazar la hipotesis Nula

Moran local Ii

  propc_lm_lwb <- localmoran(APL_barrio_total_area$APL_area, lwb_APL)
head(propc_lm_lwb)
##           Ii       E.Ii   Var.Ii         Z.Ii Pr(z > 0)
## 1 -0.2572267 -0.1063830 4.441505 -0.071575125 0.5285300
## 2 -0.7816464 -0.1489362 5.931824 -0.259783008 0.6024844
## 3 -0.1199362 -0.1276596 5.207113  0.003384593 0.4986497
## 4  1.9073430 -0.1276596 5.207113  0.891797929 0.1862506
## 5  0.1092024 -0.1489362 5.931824  0.105988512 0.4577957
## 6  1.1249913 -0.1276596 5.207113  0.548948424 0.2915204

Ii: Moran local E.Ii: experanza del Moran local Var.Ii: varianza del local Moran statistic Z.Ii: desvío estándar del Moran local Pr(): p-value del Moran local

¿Cuál es el dominio de Ii?

La suma del Ii corresponde al I global. El dominio de Ii es de -3.516794056 a 16.900930678.

LISA clusters y exploracion de Moran Ii con mapas

Agrego la salida del Moran local a los datos por depto (comuna) para poder mapearlos

moran_map_APL <- cbind(APL_barrio_total_area, propc_lm_lwb)
head(moran_map_APL)
## Simple feature collection with 6 features and 13 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -58.50617 ymin: -34.63064 xmax: -58.41192 ymax: -34.57829
## geographic CRS: WGS 84
##             BARRIO COMUNA PERIMETRO    AREA OBJETO total       Ha APL_area
## 1        CHACARITA     15  7724.853 3115707 BARRIO  5178 311.5707 16.61902
## 2         PATERNAL     15  7087.513 2229829 BARRIO  3777 222.9829 16.93852
## 3     VILLA CRESPO     15  8131.857 3615978 BARRIO  7698 361.5978 21.28885
## 4 VILLA DEL PARQUE     11  7705.390 3399596 BARRIO  8322 339.9596 24.47938
## 5          ALMAGRO      5  8537.901 4050752 BARRIO  8469 405.0752 20.90723
## 6        CABALLITO      6 10990.964 6851029 BARRIO 15213 685.1029 22.20542
##           Ii       E.Ii   Var.Ii         Z.Ii Pr.z...0.
## 1 -0.2572267 -0.1063830 4.441505 -0.071575125 0.5285300
## 2 -0.7816464 -0.1489362 5.931824 -0.259783008 0.6024844
## 3 -0.1199362 -0.1276596 5.207113  0.003384593 0.4986497
## 4  1.9073430 -0.1276596 5.207113  0.891797929 0.1862506
## 5  0.1092024 -0.1489362 5.931824  0.105988512 0.4577957
## 6  1.1249913 -0.1276596 5.207113  0.548948424 0.2915204
##                         geometry
## 1 POLYGON ((-58.45282 -34.595...
## 2 POLYGON ((-58.46558 -34.596...
## 3 POLYGON ((-58.42375 -34.597...
## 4 POLYGON ((-58.49461 -34.614...
## 5 POLYGON ((-58.41287 -34.614...
## 6 POLYGON ((-58.43061 -34.607...

Copia las p-values en la variable $p para que sea mas facil de llamar

APL_barrio_total_area$p <- APL_barrio_total_area$Pr.z...0.

Cuadrante para los LISA clusters (con autocorrelación positiva) (hotspots del scatterplor de Moran en el mapa) Hay que hacerlo con valores estadarizados o escalados (valor - media)

z_APL <- moran_map_APL$APL_area - mean(moran_map_APL$APL_area) # Z bus_pob
#zi<-moran_map_propcasos$Z.Ii
lag_APL <- lag.listw(lwb_APL, moran_map_APL$APL_area)#lag de bus_pob
z_lag_APL<-lag_APL - mean(lag_APL) # Z de lag de bus_pob
quad <- vector(mode="numeric",length=nrow(moran_map_APL))
quad[z_APL > 0 & z_lag_APL > 0] <- 1 #alto-alto HH blue
quad[z_APL > 0 & z_lag_APL < 0] <- 2 #alto-bajo HL *
quad[z_APL < 0 & z_lag_APL > 0] <- 3 #bajo-alto LH *
quad[z_APL < 0 & z_lag_APL < 0] <- 4 #bajo-bajo LL red
quad[moran_map_APL$p > 0.05] <- 5 #No Signif blanco
moran_map_APL$quad <- quad
LISA <- c("blue", "skyblue2","lightpink","red", "white")
tm_shape(moran_map_APL) + 
tm_fill(col="quad", palette = LISA,  style = "fixed", breaks = c(1,2,3,4,5,6),
              labels = c("HH", "LH", "HL","LL", "no signif"),title="Agrupamientos LISA") +
tm_legend(outside=TRUE)+
tm_borders(col = "Grey")
alto_alto <-moran_map_APL %>% 
  filter(quad==1) %>% 
   as.data.frame(.) %>% 
   select(BARRIO)
bajo_bajo <-moran_map_APL %>% 
  filter(quad==4) %>% 
   as.data.frame(.) %>% 
   select(BARRIO)

Conclusiones:

Se puede observar en la Ciudad de Buenos Aires que se presentan agrupaciones o clústeres del APL en los barrios de color azul, los cuales presentan valores por encima de la media global y están rodeados por vencimos que también están por encima de la media. Presenta un comportamiento Alto-Alto

Estos barrios son:

knitr::kable(
  alto_alto, caption = 'Barrios con clusters APL Alto-Alto'
)
Barrios con clusters APL Alto-Alto
BARRIO
VILLA CRESPO
VILLA DEL PARQUE
ALMAGRO
CABALLITO
VILLA SANTA RITA
MONTE CASTRO
FLORESTA
SAN CRISTOBAL
BOEDO
VILLA LURO
VILLA URQUIZA
VILLA GRAL. MITRE
PARQUE CHAS
VILLA ORTUZAR
PARQUE AVELLANEDA
VILLA PUEYRREDON
VILLA DEVOTO
VERSALLES

Por el contrario, se observa en los barrios de color rojo, valores que están por debajo de la media global y están rodeados por vecinos que también están por debajo de la media. Presenta un comportamiento Bajo-Bajo

Estos barrios son:

knitr::kable(
  bajo_bajo, caption = 'Barrios con clusters APL Bajo-Bajo'
)
Barrios con clusters APL Bajo-Bajo
BARRIO
CHACARITA
CONSTITUCION
PARQUE PATRICIOS
VILLA LUGANO
SAN TELMO
BARRACAS
VILLA RIACHUELO
VILLA SOLDATI
PUERTO MADERO
MONSERRAT
SAN NICOLAS
RECOLETA
RETIRO
NUÑEZ
BOCA