Dalam analisis spasial, penting untuk mengetahui apakah suatu variabel memiliki ketergantungan spasial antar wilayah. Salah satu metode yang digunakan adalah Geary’s C, yang berfungsi untuk mengukur tingkat kesamaan nilai antar wilayah yang bertetangga.

Berbeda dengan Moran’s I yang berbasis kovarians, Geary’s C lebih sensitif terhadap perbedaan lokal antar wilayah.

Persiapan Data

data <- read.csv("D:/Youtube/Spasial/LISA.csv")
data
##              wilayah Kemiskinan
## 1           Bantaeng        7.2
## 2              Barru        7.5
## 3               Bone        9.5
## 4          Bulukumba       11.1
## 5           Enrekang       10.5
## 6               Gowa        7.8
## 7          Jeneponto       12.5
## 8  Kepulauan Selayar       10.8
## 9               Luwu       11.0
## 10        Luwu Timur       11.8
## 11        Luwu Utara       12.2
## 12          Makassar        4.5
## 13             Maros        6.9
## 14            Palopo        9.3
## 15           Pangkep        8.2
## 16          Parepare        6.5
## 17           Pinrang        8.3
## 18            Sidrap        7.9
## 19            Sinjai        9.8
## 20           Soppeng        8.7
## 21           Takalar        9.0
## 22       Tana Toraja       12.7
## 23      Toraja Utara       13.0
## 24              Wajo       10.2

Persiapan Peta

library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.4, PROJ 9.7.0; sf_use_s2() is TRUE
library(dplyr)
## 
## 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
shp <- st_read("D:/Youtube/Spasial/SHP/sulsel.shp")
## Reading layer `sulsel' from data source `D:\Youtube\Spasial\SHP\sulsel.shp' using driver `ESRI Shapefile'
## Simple feature collection with 24 features and 13 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 117.0385 ymin: -7.758941 xmax: 121.8402 ymax: -1.895236
## Geodetic CRS:  WGS 84
shp$kemiskinan <- data$Kemiskinan
shp$wilayah <- shp$NAME_2

Matriks Pemobobot

library(spdep)
## 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')`
nb <- poly2nb(shp, queen = TRUE)
## Warning in poly2nb(shp, queen = TRUE): some observations have no neighbours;
## if this seems unexpected, try increasing the snap argument.
## Warning in poly2nb(shp, queen = TRUE): neighbour object has 2 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
lw <- nb2listw(nb, style = "W", zero.policy = TRUE)

Uji Geary’s C

geary.test(shp$kemiskinan, lw, zero.policy = TRUE)
## 
##  Geary C test under randomisation
## 
## data:  shp$kemiskinan 
## weights: lw  
## n reduced by no-neighbour observations 
## 
## Geary C statistic standard deviate = 3.1864, p-value = 0.0007203
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic       Expectation          Variance 
##        0.54512664        1.00000000        0.02037913

Hasil uji menunjukkan nilai Geary’s C sebesar 0,545 dengan nilai p-value 0,0007203. Karena nilai p-value jauh lebih kecil dari taraf signifikansi alpha = 0,05, maka terdapat autokorelasi spasial positif yang signifikan pada data kemiskinan tersebut.

Visualisasi Plot

library(ggplot2)

ggplot(shp) +
  geom_sf(aes(fill = kemiskinan), color = "black", size = 0.2) +
  scale_fill_gradient(low = "blue", high = "red") +
  labs(
    title = "Peta Sebaran Kemiskinan",
    subtitle = "Sulawesi Selatan"
  ) +
  theme_minimal()