Mata Kuliah : Spasial

Dosen Pengampu : Dr. I Gede Nyoman Mindra Jaya, M.Si.

Universitas Padjadjaran

library(fields)
## Loading required package: spam
## Spam version 2.10-0 (2023-10-23) is loaded.
## Type 'help( Spam)' or 'demo( spam)' for a short introduction 
## and overview of this package.
## Help for individual functions is also obtained by adding the
## suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
## 
## Attaching package: 'spam'
## The following objects are masked from 'package:base':
## 
##     backsolve, forwardsolve
## Loading required package: viridisLite
## 
## Try help(fields) to get started.
library(tibble)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(ggplot2)
library(viridisLite)
library(gridExtra)
library(knitr)
library(gt)
library(terra) 
## terra 1.7.78
## 
## Attaching package: 'terra'
## The following object is masked from 'package:knitr':
## 
##     spin
## The following object is masked from 'package:zoo':
## 
##     time<-
## The following object is masked from 'package:fields':
## 
##     describe
library(geodata)
## 
## Attaching package: 'geodata'
## The following object is masked from 'package:fields':
## 
##     world
library(leaflet)
## 
## Attaching package: 'leaflet'
## The following object is masked from 'package:fields':
## 
##     addLegend
library(maps)
library(raster)
## Loading required package: sp
library(stars)
## Loading required package: abind
## Loading required package: sf
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(gtools)
library(sp) 
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')`
library(splancs)
## 
## Spatial Point Pattern Analysis Code in S-Plus
##  
##  Version 2 - Spatial and Space-Time analysis
## 
## Attaching package: 'splancs'
## The following object is masked from 'package:raster':
## 
##     zoom
## The following objects are masked from 'package:terra':
## 
##     as.points, is.points, zoom
## The following object is masked from 'package:tibble':
## 
##     tribble
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::combine() masks gridExtra::combine()
## ✖ tidyr::extract() masks raster::extract(), terra::extract()
## ✖ dplyr::filter()  masks stats::filter()
## ✖ dplyr::lag()     masks stats::lag()
## ✖ purrr::map()     masks maps::map()
## ✖ dplyr::select()  masks raster::select()
## ✖ dplyr::tribble() masks tidyr::tribble(), splancs::tribble(), tibble::tribble()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
require(mgcv)
## Loading required package: mgcv
## Loading required package: nlme
## 
## Attaching package: 'nlme'
## 
## The following object is masked from 'package:dplyr':
## 
##     collapse
## 
## The following object is masked from 'package:raster':
## 
##     getData
## 
## This is mgcv 1.9-1. For overview type 'help("mgcv-package")'.
## 
## Attaching package: 'mgcv'
## 
## The following object is masked from 'package:gtools':
## 
##     scat
require(dplyr)
require(DAAG)
## Loading required package: DAAG
## 
## Attaching package: 'DAAG'
## 
## The following object is masked from 'package:maps':
## 
##     ozone
require(reshape2)
## Loading required package: reshape2
## 
## Attaching package: 'reshape2'
## 
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(gstat)
library(oce)  
## Loading required package: gsw
## 
## Attaching package: 'oce'
## 
## The following object is masked from 'package:terra':
## 
##     rescale
library(dplyr)
library(chirps)
library(sf)
library(spgwr)
## NOTE: This package does not constitute approval of GWR
## as a method of spatial analysis; see example(gwr)
library(GWmodel)
## Loading required package: robustbase
## 
## Attaching package: 'robustbase'
## 
## The following object is masked from 'package:DAAG':
## 
##     milk
## 
## Loading required package: Rcpp
## Welcome to GWmodel version 2.4-2.
library(GWmodel)
setwd("/Users/carissaegytiawidiantoro/Library/CloudStorage/GoogleDrive-carissawidiantoro12@gmail.com/Drive Saya/KULIAH/Semester 5/Spasial /Spasial")

Input Data

Data yang digunakan merupakan data Timbulan Sampah serta data mengenai demografi yaitu jumlah penduduk dan Tingkat Pengangguran Terbuka serta data mengenai ekonomi yaitu Produk Domestik Regional Bruto (PDRB) Jawa Timur menurut Kabupaten/Kota Tahun 2023.

data = read.csv("Data UTS Spasial - Sheet1-6.csv")
data
##       Kabupaten.Kota Timbulan.Sampah.Tahunan Jumlah.Penduduk
## 1          Bangkalan               152259.02         1101556
## 2         Banyuwangi               305312.85         1744814
## 3               Batu                52062.68          218802
## 4             Blitar               150990.10         1249497
## 5         Bojonegoro               133639.42         1322474
## 6          Bondowoso                      NA          784192
## 7             Gresik               144238.33         1344648
## 8             Jember               377298.02         2584771
## 9            Jombang               193583.44         1345886
## 10            Kediri               241778.92         1667450
## 11       Kota Blitar                27988.20          153541
## 12       Kota Kediri                63461.92          290836
## 13       Kota Madiun                44750.39          201460
## 14       Kota Malang               284095.41          847182
## 15    Kota Mojokerto                35882.93          135414
## 16     Kota Pasuruan                53830.17          213450
## 17 Kota Probolinggo                 35705.61          245174
## 18          Lamongan               201686.44         1386941
## 19          Lumajang               195275.12         1147261
## 20            Madiun               109147.99          765135
## 21           Magetan               100725.11          682466
## 22            Malang               352927.26         2703175
## 23         Mojokerto               172984.00         1141516
## 24           Nganjuk               163086.82         1124247
## 25             Ngawi               135297.67          881393
## 26           Pacitan               105345.64          196649
## 27          Pasuruan                      NA         1626029
## 28         Pemekasan               101156.10          862009
## 29          Ponorogo               140780.94          972582
## 30       Probolinggo               169354.89         1163859
## 31           Sampang               169511.29          992210
## 32          Sidoarjo               320690.10         2114588
## 33         Situbondo                92130.84          694081
## 34           Sumenep               134116.66         1143295
## 35          Surabaya               657016.64         2893698
## 36        Trenggalek               109657.53          744358
## 37             Tuban               185422.94         1215795
## 38       Tulungagung               204028.80          113973
##    Tingkat.Pengangguran.Terbuka Angka.Kelahiran.Total      PDRB
## 1                          6.18                  2.10  25408.14
## 2                          4.75                  2.05  58085.92
## 3                          4.52                  1.95  93209.32
## 4                          4.91                  2.00  35811.68
## 5                          4.63                  1.81  73901.41
## 6                          4.15                  2.05  31432.05
## 7                          6.82                  1.95 130386.33
## 8                          4.01                  2.03  36836.81
## 9                          4.66                  2.10  36990.72
## 10                         5.79                  2.13  30192.65
## 11                         5.24                  1.92  55523.25
## 12                         4.06                  2.00 541112.50
## 13                         5.85                  1.85  86285.03
## 14                         6.80                  1.82 107541.79
## 15                         4.73                  1.87  59061.31
## 16                         5.64                  2.13  48057.75
## 17                         4.53                  2.05  57885.14
## 18                         5.46                  1.90  35725.69
## 19                         3.67                  1.96  35178.07
## 20                         5.14                  2.03  31587.94
## 21                         4.16                  1.99  33627.24
## 22                         5.70                  2.10  47272.21
## 23                         4.67                  1.95  91112.00
## 24                         4.68                  2.02  29916.56
## 25                         2.41                  1.90  27619.27
## 26                         1.83                  1.78  33148.63
## 27                         5.48                  1.92 113682.69
## 28                         1.74                  2.16  23842.11
## 29                         4.66                  1.92  26313.86
## 30                         3.24                  2.03  36006.17
## 31                         2.72                  2.36  23978.20
## 32                         8.05                  1.84 127381.65
## 33                         3.27                  2.03  36189.55
## 34                         1.71                  2.12  37370.05
## 35                         6.76                  1.70 245684.76
## 36                         4.52                  1.89  30681.00
## 37                         4.40                  1.84  67175.83
## 38                         5.65                  1.97  43296.90
##    Rata.Rata.Lama.Sekolah Rasio.Jenis.Kelamin.Penduduk
## 1                    5.99                         97.6
## 2                    7.76                        100.1
## 3                    9.85                        101.3
## 4                    7.83                        101.2
## 5                    7.45                        100.7
## 6                    6.36                         97.2
## 7                   10.01                        101.4
## 8                    6.52                         99.3
## 9                    8.77                        101.6
## 10                   8.24                        101.9
## 11                  10.78                         98.6
## 12                  10.69                        100.5
## 13                  11.82                         95.9
## 14                  10.94                         98.9
## 15                  11.05                         98.3
## 16                   9.78                        100.1
## 17                   9.56                         98.5
## 18                   8.34                        100.1
## 19                   7.14                         97.8
## 20                   7.95                         98.0
## 21                   8.67                         96.8
## 22                   7.75                        101.2
## 23                   9.11                        101.1
## 24                   8.24                        101.1
## 25                   7.78                         98.3
## 26                   7.88                        100.8
## 27                   7.15                         96.7
## 28                   7.44                        100.1
## 29                   7.78                         99.4
## 30                   6.29                         97.5
## 31                   5.07                         98.9
## 32                  10.78                        101.1
## 33                   6.90                         96.6
## 34                   5.94                         94.0
## 35                  10.70                         98.1
## 36                   7.90                        100.6
## 37                   7.40                         99.7
## 38                   8.66                        100.1
##    Laju.Pertumbuhan.Penduduk.per.Tahun Kepadatan.Penduduk.per.km.persegi..km2.
## 1                                 1.07                                     839
## 2                                 0.76                                     485
## 3                                 3.38                                    1134
## 4                                 0.88                                     718
## 5                                 0.50                                     571
## 6                                 0.56                                     507
## 7                                 1.08                                    1075
## 8                                 0.71                                     781
## 9                                 0.91                                    1218
## 10                                0.92                                    1101
## 11                                2.86                                    4619
## 12                                2.94                                    4391
## 13                                2.45                                    5536
## 14                                2.55                                    7790
## 15                                2.80                                    6732
## 16                                4.04                                    5549
## 17                                3.08                                    4517
## 18                                0.68                                     781
## 19                                0.64                                     634
## 20                                0.49                                     678
## 21                                0.59                                     965
## 22                                0.83                                     782
## 23                                0.85                                    1163
## 24                                0.68                                     872
## 25                                0.44                                     631
## 26                                0.12                                     410
## 27                                1.09                                    1101
## 28                                0.86                                    1101
## 29                                0.39                                     676
## 30                                0.77                                     682
## 31                                1.29                                     818
## 32                                1.14                                    2968
## 33                                0.58                                     421
## 34                                0.71                                     550
## 35                                1.29                                    8667
## 36                                0.50                                     593
## 37                                0.62                                     617
## 38                                0.60                                     968
##    Persentase.Penduduk.Miskin APS.7.12 APS.13.15 APS.16.18
## 1                       19.35    99.75     95.68     53.34
## 2                        7.34    98.45     99.20     74.45
## 3                        3.31    99.23     98.50     79.99
## 4                        8.69    98.12     96.50     69.63
## 5                       12.18    99.56     99.37     82.68
## 6                       13.34    99.51     98.67     68.71
## 7                       10.96    99.47     98.32     82.29
## 8                        9.51    99.61     95.11     73.93
## 9                        9.15    99.71     98.67     85.43
## 10                      10.72    98.42     99.23     84.40
## 11                       7.30    99.01     97.20     91.70
## 12                       7.15    99.54     98.30     87.18
## 13                       4.74    99.42     98.44     74.77
## 14                       4.26    99.50     98.54     80.90
## 15                       5.77    99.50     98.73     82.23
## 16                       6.60    99.70     99.01     78.91
## 17                       6.48    99.68     99.12     82.90
## 18                      12.42    99.67     99.53     74.25
## 19                       8.93    99.65     98.63     59.10
## 20                      11.04    98.86     98.50     85.03
## 21                       9.80    99.71     99.22     85.78
## 22                       9.45    99.71     95.27     65.84
## 23                       9.80    99.82     99.33     81.91
## 24                      10.89    99.75     97.90     85.20
## 25                      14.40    99.70     99.11     78.42
## 26                      13.65    99.98     97.27     79.06
## 27                      13.85    98.82     97.08     75.13
## 28                       9.24    98.71     97.13     62.77
## 29                       9.53    99.28     98.20     79.36
## 30                      17.19    99.67     96.91     63.59
## 31                      21.76    99.01     92.49     64.14
## 32                       5.00    99.83     99.25     82.88
## 33                      11.90    99.16     95.05     63.52
## 34                      18.70    99.40     97.43     79.81
## 35                       4.65    97.88     98.54     65.29
## 36                      10.63    99.43     96.91     83.34
## 37                      14.91    99.51     98.25     64.13
## 38                       6.53    99.59     98.66     78.12

Input Map

Peta yang digunakan merupakan peta Kabupaten/Kota di Jawa Timur yang tediri atas 38 Kabupaten/Kota

Indo_Prov<-readRDS('gadm36_IDN_2_sp.rds')
Jawa_Timur <-Indo_Prov[Indo_Prov$NAME_1 == "Jawa Timur",]
plot(Jawa_Timur)

Menggabungkan Data dengan Map

Menggabungkan data yang ingin dianalisis yakni Timbulan Sampah, Jumlah Penduduk, Tingkat Pengangguran Terbuka, dan PDRB dengan peta Provinsi Jawa Timur berdasarkan Kabupaten/Kota

data$id <- c(1:38)
Jawa_Timur$id<-c(1:38)
Jawa_Timur_sf<-st_as_sf(Jawa_Timur)

Jawa_Timur_merged <- Jawa_Timur_sf %>%
  left_join(data, by = "id") 

Mapping

Dilakukan mapping terhadap Timbulan Sampah untuk mengetahui bagaimana penyebaran Timbulan Sampah Tahunan di Kabupaten/Kota Provinsi Jawa Timur Tahun 2023. Mengingat pada tahun 2023, Provinsi Jawa Timur merupakan peringkat pertama dengan jumlah timbulan sampah terbanyak di Indonesia.

ggplot() +
  geom_sf(data = Jawa_Timur_merged, aes(fill = Timbulan.Sampah.Tahunan), color = NA) +
  geom_sf_text(data = Jawa_Timur_merged, aes(label = NAME_2), size = 1.5) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    legend.position = "right",
    axis.text.x = element_blank(),  # Remove x-axis labels
    axis.text.y = element_blank()   # Remove y-axis labels
  ) +  
  labs(
    title = "Peta Timbulan Sampah di Jawa Timur",
    fill = "Timbulan Sampah"
  )
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Berdasarkan hasil peta tersebut, diketahui terdapat dua wilayah yang tidak ada data mengenai Timbulan Sampah Tahunan 2023, yaitu Bondowoso dan Pamekasan, sehingga akan dilakukan Imputasi Interpolasi dengan Inverse Distance Weight (IDW)

# Cek NA pada Data 
sum(is.na(data$Timbulan.Sampah.Tahunan)) 
## [1] 2
sum(is.na(data$Tingkat.Pengangguran.Terbuka))  
## [1] 0
sum(is.na(data$PDRB))  
## [1] 0
sum(is.na(data$Jumlah.Penduduk))  
## [1] 0

Ekstrak Longnitude dan Latitude

Untuk melakukan interpolasi IDW diperlukan titik-titik yang menyatakan suatu wilayah, di sini titik tersebut merupakan longitude dan latitude dari suatu wilayah. Pada data map Jawa Timur tersedia data geografi untuk masing-masing Kabupaten/Kota di mana data tersebut mengandung longitude dan latitude, sehingga diperlukan ekstraksi longitude dan latitude untuk masing-masing kabupaten/kota untuk melakukan interpolasi IDW

# Menghitung centroid dari setiap polygon
centroids <- st_centroid(Jawa_Timur_merged)
## Warning: st_centroid assumes attributes are constant over geometries
# Ekstrak koordinat dari centroid
centroid_coords <- st_coordinates(centroids)

# Ubah nama kolom X menjadi longitude dan Y menjadi latitude
centroid_coords_renamed <- as.data.frame(centroid_coords) %>%
  rename(longitude = X, latitude = Y)

# Lihat hasilnya (harus ada 38 baris)
head(centroid_coords_renamed)
##   longitude  latitude
## 1  112.9302 -7.043866
## 2  114.2054 -8.364784
## 3  112.5311 -7.833102
## 4  112.2381 -8.130094
## 5  111.8098 -7.255443
## 6  113.9475 -7.944030
nrow(centroid_coords_renamed)  # Harus 38
## [1] 38
Jawa_Timur_merged$longitude <- centroid_coords_renamed$longitude
Jawa_Timur_merged$latitude <- centroid_coords_renamed$latitude

IDW

Dilakukan interpolasi IDW pada data Timbulan Sampah Tahunan 2023, yaitu pada wilayah Bondowoso dan Pamekasan. Interpolasi ini dilakukan untuk mengestimasi nilai timbulan sampah tahunan pada wilayah yang hilang. Di mana setelah interpolasi diharapkan data menjadi lengkap untuk dilakukan analisis lanjutan.

data_relevant <- Jawa_Timur_merged[, c("latitude", "longitude", "Timbulan.Sampah.Tahunan")]

# Data tanpa NA pada z
complete_data <- data_relevant[!is.na(data_relevant$Timbulan.Sampah.Tahunan), ]

# Data dengan NA pada z
na_data <- data_relevant[is.na(data_relevant$Timbulan.Sampah.Tahunan), ]

# Fungsi IDW untuk menghitung estimasi
idw_estimate <- function(complete_data, target_point) {
  # Hitung jarak Euclidean dari setiap titik yang tidak NA
  euclidean_dist <- sqrt((complete_data$longitude - target_point[1])^2 + 
                         (complete_data$latitude - target_point[2])^2)
  
  # Cek jika ada titik yang valid
  if (all(euclidean_dist == 0)) {
    return(0)  # Kembalikan 0 jika semua jarak sama
  }

  # Inverse Distance
  inv_dist <- 1 / euclidean_dist

  # Bobot
  weights <- inv_dist / sum(inv_dist, na.rm = TRUE)

  # Estimasi nilai z di titik target
  estimate_z <- sum(weights * complete_data$Timbulan.Sampah.Tahunan, na.rm = TRUE)

  return(estimate_z)
}

# Estimasi nilai z di titik yang memiliki NA
for (i in 1:nrow(na_data)) {
  target_point <- as.numeric(na_data[i, c("longitude", "latitude")])
  na_data$Timbulan.Sampah.Tahunan[i] <- idw_estimate(complete_data, target_point)
}
na_data$Timbulan.Sampah.Tahunan[1]
## [1] 177160.2
na_data$Timbulan.Sampah.Tahunan[2]
## [1] 177131.6
# Langkah 3: Gabungkan kembali hasil imputasi ke dalam data awal
Jawa_Timur_merged$Timbulan.Sampah.Tahunan[is.na(Jawa_Timur_merged$Timbulan.Sampah.Tahunan)] <- na_data$Timbulan.Sampah.Tahunan

# Lihat hasil akhir
head(Jawa_Timur_merged)
## Simple feature collection with 6 features and 30 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 111.4236 ymin: -8.78036 xmax: 114.605 ymax: -6.879476
## Geodetic CRS:  +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
##   GID_0    NAME_0    GID_1     NAME_1 NL_NAME_1      GID_2     NAME_2 VARNAME_2
## 1   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.1_1  Bangkalan      <NA>
## 2   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.2_1 Banyuwangi      <NA>
## 3   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.3_1       Batu      <NA>
## 4   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.4_1     Blitar      <NA>
## 5   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.5_1 Bojonegoro      <NA>
## 6   IDN Indonesia IDN.11_1 Jawa Timur      <NA> IDN.11.6_1  Bondowoso      <NA>
##   NL_NAME_2    TYPE_2 ENGTYPE_2 CC_2   HASC_2 id Kabupaten.Kota
## 1      <NA> Kabupaten   Regency 3526 ID.JI.BK  1      Bangkalan
## 2      <NA> Kabupaten   Regency 3510 ID.JI.BW  2     Banyuwangi
## 3      <NA>      Kota      City 3579 ID.JI.BA  3           Batu
## 4      <NA> Kabupaten   Regency 3505 ID.JI.BR  4         Blitar
## 5      <NA> Kabupaten   Regency 3522 ID.JI.BJ  5     Bojonegoro
## 6      <NA> Kabupaten   Regency 3511 ID.JI.BD  6      Bondowoso
##   Timbulan.Sampah.Tahunan Jumlah.Penduduk Tingkat.Pengangguran.Terbuka
## 1               152259.02         1101556                         6.18
## 2               305312.85         1744814                         4.75
## 3                52062.68          218802                         4.52
## 4               150990.10         1249497                         4.91
## 5               133639.42         1322474                         4.63
## 6               177160.17          784192                         4.15
##   Angka.Kelahiran.Total     PDRB Rata.Rata.Lama.Sekolah
## 1                  2.10 25408.14                   5.99
## 2                  2.05 58085.92                   7.76
## 3                  1.95 93209.32                   9.85
## 4                  2.00 35811.68                   7.83
## 5                  1.81 73901.41                   7.45
## 6                  2.05 31432.05                   6.36
##   Rasio.Jenis.Kelamin.Penduduk Laju.Pertumbuhan.Penduduk.per.Tahun
## 1                         97.6                                1.07
## 2                        100.1                                0.76
## 3                        101.3                                3.38
## 4                        101.2                                0.88
## 5                        100.7                                0.50
## 6                         97.2                                0.56
##   Kepadatan.Penduduk.per.km.persegi..km2. Persentase.Penduduk.Miskin APS.7.12
## 1                                     839                      19.35    99.75
## 2                                     485                       7.34    98.45
## 3                                    1134                       3.31    99.23
## 4                                     718                       8.69    98.12
## 5                                     571                      12.18    99.56
## 6                                     507                      13.34    99.51
##   APS.13.15 APS.16.18                       geometry longitude  latitude
## 1     95.68     53.34 MULTIPOLYGON (((112.695 -7....  112.9302 -7.043866
## 2     99.20     74.45 MULTIPOLYGON (((114.0247 -8...  114.2054 -8.364784
## 3     98.50     79.99 MULTIPOLYGON (((112.5227 -7...  112.5311 -7.833102
## 4     96.50     69.63 MULTIPOLYGON (((112.237 -8....  112.2381 -8.130094
## 5     99.37     82.68 MULTIPOLYGON (((111.5608 -7...  111.8098 -7.255443
## 6     98.67     68.71 MULTIPOLYGON (((113.7905 -8...  113.9475 -7.944030
nrow(Jawa_Timur_merged)  # Pastikan jumlah baris tetap 38
## [1] 38

Statistika Deskriptif

# Mengambil ringkasan untuk setiap variabel dan mengonversi menjadi vektor
timbulan_sampah_summary <- as.vector(summary(Jawa_Timur_merged$Timbulan.Sampah.Tahunan))
jumlah_penduduk_summary <- as.vector(summary(Jawa_Timur_merged$Jumlah.Penduduk))
pengangguran_summary <- as.vector(summary(Jawa_Timur_merged$Tingkat.Pengangguran.Terbuka))
pdrb_summary <- as.vector(summary(Jawa_Timur_merged$PDRB))

# Membuat data frame untuk menggabungkan ringkasan
summary_df <- data.frame(
  Statistic = c("Min", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max"),
  Timbulan_Sampah = timbulan_sampah_summary,
  Jumlah_Penduduk = jumlah_penduduk_summary,
  Tingkat_Pengangguran_Terbuka = pengangguran_summary,
  PDRB = pdrb_summary
)

# Menampilkan data frame
print(summary_df)
##   Statistic Timbulan_Sampah Jumlah_Penduduk Tingkat_Pengangguran_Terbuka
## 1       Min         27988.2        113973.0                     1.710000
## 2   1st Qu.        102203.5        685369.8                     4.082500
## 3    Median        151624.6       1046883.0                     4.665000
## 4      Mean        170302.9       1053063.3                     4.662895
## 5   3rd Qu.        194852.2       1339104.5                     5.600000
## 6       Max        657016.6       2893698.0                     8.050000
##        PDRB
## 1  23842.11
## 2  31978.11
## 3  37180.39
## 4  70645.06
## 5  72220.01
## 6 541112.50

Cek Outlier Timbulan Sampah Tahunan

# Buat boxplot untuk melihat outlier
boxplot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, main = "Boxplot Timbulan Sampah Tahunan")

# Mendeteksi outlier menggunakan IQR
Q1 <- quantile(Jawa_Timur_merged$Timbulan_Sampah, 0.25)
Q3 <- quantile(Jawa_Timur_merged$Timbulan_Sampah, 0.75)
IQR <- Q3 - Q1

# Nilai outlier jika di luar 1.5*IQR
outlier_lower <- Q1 - 1.5 * IQR
outlier_upper <- Q3 + 1.5 * IQR

# Cari data yang merupakan outlier
outliers <- Jawa_Timur_merged$Timbulan_Sampah[Jawa_Timur_merged$Timbulan_Sampah < outlier_lower | Jawa_Timur_merged$Timbulan_Sampah > outlier_upper]
outliers
## NULL

Pembuatan Map

Setelah dilakukan interpolasi, didapatkan estimasi data timbulan sampah tahunan untuk Bondowoso dan Pamekasa, dilakukan pemetaan kembali untuk mengetahui penyebaran timbulan sampah tahunan di Provinsi Jawa Timur Tahun 2023. Selain itu jga akan dilakukan break pemetaan berdasarkan nilai kuartilnya.

ggplot() +
geom_sf(data=Jawa_Timur_merged, aes(fill = Timbulan.Sampah.Tahunan),color=NA) +
    geom_sf_text(data = Jawa_Timur_merged, aes(label = NAME_2), size = 1.5) + 
theme_bw() +
scale_fill_gradient(low = "yellow", high = "red") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+ 
theme(legend.position = "right",
axis.text.x = element_blank(),  # Remove x-axis labels
axis.text.y = element_blank())+  # Remove y-axis labels   
labs(title = "Peta Timbulan Sampah Setelah Interpolasi",
       fill = "Timbulan Sampah") 
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

summary(Jawa_Timur_merged$Timbulan.Sampah.Tahunan)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   27988  102204  151625  170303  194852  657017
breaks <- c(-Inf, 103000, 152000, 195000,Inf)

# Define labels for each interval
labels <- c("Very Low", "Low", "High", "Very High")

# Create a new column with discretized Diare
Jawa_Timur_merged$Timbulan.Sampah.Tahunan.Discrete <- cut(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, breaks = breaks, labels = labels, right = TRUE)

ggplot() +
geom_sf(data=Jawa_Timur_merged, aes(fill = Timbulan.Sampah.Tahunan.Discrete),color=NA) +
  geom_sf_text(data = Jawa_Timur_merged, aes(label = NAME_2), size = 1.5) + 
theme_bw() +
scale_fill_manual(values = c("Very Low" = "yellow", 
                                "Low" = "orange",
                                "High" = "red",
                                "Very High" = "red3"))+
labs( title = "Peta Timbulan Sampah", fill = "Timbulan Sampah")+theme(legend.position = "right",
axis.text.x = element_blank(),  # Remove x-axis labels
axis.text.y = element_blank())+  # Remove y-axis labels   
labs(title = "Peta Timbulan Sampah",
       fill = "Timbulan Sampah")      
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Moran’S

Ingin dilihat apakah terdapat autokorelasi spasial pada variabel Timbulan Sampah Tahunan, perhitungan Moran’s mempertimbangkan beberapa pembobot yaitu ROOK, Queen, dan KNN. Dengan hipotesis sebagai berikut, H0 : Tidak terdapat autokorelasi spasial H1 : Terdapat autokorelasi spasial

Selain melihat hipotesis, dilihat juga nilai indeks moran’s. Nilai indeks moran berkisar antara -1 hingga 1

Pembobot ROOK

# ROOK 
# Membuat koordinat centroid 
CoordK <- coordinates(Jawa_Timur)
W <- poly2nb(Jawa_Timur, row.names = Jawa_Timur$id, queen = FALSE)
## Warning in poly2nb(Jawa_Timur, row.names = Jawa_Timur$id, queen = FALSE): neighbour object has 2 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
#Menyajikan dalam bentuk matrix biner "B"
#Zero policy mengizinkan ada lokasi yang tidak bersinggungan sama sekali (tidak ada tetangga)
WB <- nb2mat(W, style='B', zero.policy=TRUE)
#List neighbours Digunakan unruk menghitung Moran's I 
WL <- nb2listw(W)

plot(Jawa_Timur, axes=T, col="gray90")
text(CoordK[,1], CoordK[,2], row.names(Jawa_Timur), col="black", cex=0.8, pos=1.5)
points(CoordK[,1], CoordK[,2], pch=19, cex=0.7, col="blue")
plot(W, CoordK, col="red", add=TRUE)

moran.test(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)
## 
##  Moran I test under randomisation
## 
## data:  Jawa_Timur_merged$Timbulan.Sampah.Tahunan  
## weights: WL    
## 
## Moran I statistic standard deviate = 1.8144, p-value = 0.03481
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.18787174       -0.02702703        0.01402832
moran.plot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)

Pembobot Queen

# Queen 
### Queen 
W <- poly2nb(Jawa_Timur, row.names = Jawa_Timur$id, queen = TRUE)
## Warning in poly2nb(Jawa_Timur, row.names = Jawa_Timur$id, queen = TRUE): neighbour object has 2 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
#Zero policy mengizinkan ada lokasi yang tidak bersinggungan sama sekali (tidak ada tetangga)
WB <- nb2mat(W, style="B", zero.policy = TRUE) 
WB[1:5,1:5]
##   [,1] [,2] [,3] [,4] [,5]
## 1    0    0    0    0    0
## 2    0    0    0    0    0
## 3    0    0    0    0    0
## 4    0    0    0    0    0
## 5    0    0    0    0    0
WL <- nb2listw(W)
# Plot peta Jawa Timur 
plot(Jawa_Timur, axes=T, col="gray90")
plot(W, CoordK, col="red", add=TRUE)
text(CoordK[,1], CoordK[,2], row.names(Jawa_Timur), col="black", cex=0.8, pos=1.5)
points(CoordK[,1], CoordK[,2], pch=19, cex=0.7, col="blue")

moran.test(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)
## 
##  Moran I test under randomisation
## 
## data:  Jawa_Timur_merged$Timbulan.Sampah.Tahunan  
## weights: WL    
## 
## Moran I statistic standard deviate = 1.8144, p-value = 0.03481
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.18787174       -0.02702703        0.01402832
moran.plot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)

Pembobot KNN (K=3)

# KNN  K = 3
### Pendekatan Jarak (KNN)
W <- knn2nb(knearneigh(CoordK, k=3), row.names=Jawa_Timur$id)
#Zero policy mengizinkan ada lokasi yang tidak bersinggungan sama sekali (tidak ada tetangga)
WB <- nb2mat(W, style = "B", zero.policy=TRUE) 
WL <- nb2listw(W)
# Plot peta Jawa Timur
plot(Jawa_Timur, axes=T, col="gray90")
plot(W, CoordK, col="red", add=TRUE)
text(CoordK[,1], CoordK[,2], row.names(Jawa_Timur), col="black", cex=0.8, pos=1.5)
points(CoordK[,1], CoordK[,2], pch=19, cex=0.7, col="blue")

moran.test(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)
## 
##  Moran I test under randomisation
## 
## data:  Jawa_Timur_merged$Timbulan.Sampah.Tahunan  
## weights: WL    
## 
## Moran I statistic standard deviate = 0.7886, p-value = 0.2152
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.05687567       -0.02702703        0.01131992
moran.plot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)

Pembobot KNN (K=5)

# KNN  K = 5
### Pendekatan Jarak (KNN)
W <- knn2nb(knearneigh(CoordK, k=5), row.names=Jawa_Timur$id)
#Zero policy mengizinkan ada lokasi yang tidak bersinggungan sama sekali (tidak ada tetangga)
WB <- nb2mat(W, style = "B", zero.policy=TRUE)
WL <- nb2listw(W)
# Plot peta Jawa Timur
plot(Jawa_Timur, axes=T, col="gray90")
plot(W, CoordK, col="red", add=TRUE)
text(CoordK[,1], CoordK[,2], row.names(Jawa_Timur), col="black", cex=0.8, pos=1.5)
points(CoordK[,1], CoordK[,2], pch=19, cex=0.7, col="blue")

moran.test(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)
## 
##  Moran I test under randomisation
## 
## data:  Jawa_Timur_merged$Timbulan.Sampah.Tahunan  
## weights: WL    
## 
## Moran I statistic standard deviate = 0.1767, p-value = 0.4299
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.012849274      -0.027027027       0.006438139
moran.plot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)

Pembobot KNN (K=10)

# KNN  K = 10
### Pendekatan Jarak (KNN)
W <- knn2nb(knearneigh(CoordK, k=10), row.names=Jawa_Timur$id)
#Zero policy mengizinkan ada lokasi yang tidak bersinggungan sama sekali (tidak ada tetangga)
WB <- nb2mat(W, style = "B", zero.policy=TRUE) 
WL <- nb2listw(W)
# Plot peta Jawa Timur
plot(Jawa_Timur, axes=T, col="gray90")
plot(W, CoordK, col="red", add=TRUE)
text(CoordK[,1], CoordK[,2], row.names(Jawa_Timur), col="black", cex=0.8, pos=1.5)
points(CoordK[,1], CoordK[,2], pch=19, cex=0.7, col="blue")

moran.test(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)
## 
##  Moran I test under randomisation
## 
## data:  Jawa_Timur_merged$Timbulan.Sampah.Tahunan  
## weights: WL    
## 
## Moran I statistic standard deviate = -0.54814, p-value = 0.7082
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.054720186      -0.027027027       0.002552452
moran.plot(Jawa_Timur_merged$Timbulan.Sampah.Tahunan, WL)

Regresi OLS

Sebelum dilakukan regresi menggunakan GWR, langkah awal dilakukan pembentukan model dengan regresi OLS

# Variabel 
y <- Jawa_Timur_merged$Timbulan.Sampah.Tahunan
x1 <- Jawa_Timur_merged$Jumlah.Penduduk
x2 <- Jawa_Timur_merged$Tingkat.Pengangguran.Terbuka
x3 <- Jawa_Timur_merged$PDRB

# Regresi OLS
model_ols <- lm(y ~ x1 + x2 + x3, 
  data = Jawa_Timur_merged)
summary(model_ols)
## 
## Call:
## lm(formula = y ~ x1 + x2 + x3, data = Jawa_Timur_merged)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -92620 -20629 -12040   3443 192376 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -2.526e+04  3.434e+04  -0.735    0.467    
## x1           1.386e-01  1.471e-02   9.420 5.26e-11 ***
## x2           8.849e+03  7.450e+03   1.188    0.243    
## x3           1.181e-01  1.138e-01   1.037    0.307    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 60440 on 34 degrees of freedom
## Multiple R-squared:  0.7613, Adjusted R-squared:  0.7403 
## F-statistic: 36.15 on 3 and 34 DF,  p-value: 1.108e-10
AIC(model_ols)
## [1] 950.3242

Uji Asumsi Regresi OLS

Asumsi Multikolinearitas

vif(model_ols)
##     x1     x2     x3 
## 1.0961 1.1479 1.0497

Asumsi Heterogenitas model OLS

bptest(model_ols) 
## 
##  studentized Breusch-Pagan test
## 
## data:  model_ols
## BP = 8.048, df = 3, p-value = 0.04503

Asumsi Normalitas Residual model OLS

shapiro.test(model_ols$residuals) 
## 
##  Shapiro-Wilk normality test
## 
## data:  model_ols$residuals
## W = 0.82565, p-value = 3.639e-05

Asumsi Autokorelasi

dwtest(model_ols)
## 
##  Durbin-Watson test
## 
## data:  model_ols
## DW = 2.0893, p-value = 0.608
## alternative hypothesis: true autocorrelation is greater than 0

Asumsi Autokorelasi Spasial

## Menggunakan pembobot ROOK
moran.test(model_ols$residuals, WL)
## 
##  Moran I test under randomisation
## 
## data:  model_ols$residuals  
## weights: WL    
## 
## Moran I statistic standard deviate = -1.2063, p-value = 0.8862
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.090779056      -0.027027027       0.002792939
moran.plot(model_ols$residuals, WL)

## Pemodelan GWR ### Bandwidth Optimal

bandwidth_optimal <- gwr.sel(y ~ x1+x2+x3,
  data = Jawa_Timur_merged,
  coords = cbind(Jawa_Timur_merged$longitude, Jawa_Timur_merged$latitude),
  adapt = TRUE
)
## Adaptive q: 0.381966 CV score: 3.22302e+11 
## Adaptive q: 0.618034 CV score: 347315691560 
## Adaptive q: 0.236068 CV score: 2.88095e+11 
## Adaptive q: 0.145898 CV score: 206409318091 
## Adaptive q: 0.09016994 CV score: 196705343284 
## Adaptive q: 0.1006753 CV score: 195331433604 
## Adaptive q: 0.105121 CV score: 1.95013e+11 
## Adaptive q: 0.1206964 CV score: 196431192562 
## Adaptive q: 0.1073059 CV score: 193705268767 
## Adaptive q: 0.1124206 CV score: 192687168487 
## Adaptive q: 0.1116819 CV score: 192653913265 
## Adaptive q: 0.1116412 CV score: 192653738158 
## Adaptive q: 0.1116005 CV score: 192653738227 
## Adaptive q: 0.1116412 CV score: 192653738158
hist(Jawa_Timur_merged$Timbulan.Sampah.Tahunan)

GWR Gaussian Kernel Bandwith Optimal

model_gwr <- gwr(Jawa_Timur_merged$Timbulan.Sampah.Tahunan ~ Jawa_Timur_merged$Jumlah.Penduduk + Jawa_Timur_merged$Tingkat.Pengangguran.Terbuka + Jawa_Timur_merged$PDRB,
  data = Jawa_Timur_merged,
  coords = cbind(Jawa_Timur_merged$longitude, Jawa_Timur_merged$latitude),
  adapt = bandwidth_optimal,
  hatmatrix = TRUE,
  se.fit = TRUE
)
summary(model_gwr)
##           Length Class                  Mode     
## SDF         38   SpatialPointsDataFrame S4       
## lhat      1444   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth   38   -none-                 numeric  
## adapt        1   -none-                 numeric  
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    7   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric

UTM (Universal Tranverse Mercator)

# Menetapkan CRS WGS 84
Jawa_Timur_merged <- st_set_crs(Jawa_Timur_merged, 4326)

# Memverifikasi CRS
print(st_crs(Jawa_Timur_merged))
## Coordinate Reference System:
##   User input: EPSG:4326 
##   wkt:
## GEOGCRS["WGS 84",
##     ENSEMBLE["World Geodetic System 1984 ensemble",
##         MEMBER["World Geodetic System 1984 (Transit)"],
##         MEMBER["World Geodetic System 1984 (G730)"],
##         MEMBER["World Geodetic System 1984 (G873)"],
##         MEMBER["World Geodetic System 1984 (G1150)"],
##         MEMBER["World Geodetic System 1984 (G1674)"],
##         MEMBER["World Geodetic System 1984 (G1762)"],
##         MEMBER["World Geodetic System 1984 (G2139)"],
##         ELLIPSOID["WGS 84",6378137,298.257223563,
##             LENGTHUNIT["metre",1]],
##         ENSEMBLEACCURACY[2.0]],
##     PRIMEM["Greenwich",0,
##         ANGLEUNIT["degree",0.0174532925199433]],
##     CS[ellipsoidal,2],
##         AXIS["geodetic latitude (Lat)",north,
##             ORDER[1],
##             ANGLEUNIT["degree",0.0174532925199433]],
##         AXIS["geodetic longitude (Lon)",east,
##             ORDER[2],
##             ANGLEUNIT["degree",0.0174532925199433]],
##     USAGE[
##         SCOPE["Horizontal component of 3D system."],
##         AREA["World."],
##         BBOX[-90,-180,90,180]],
##     ID["EPSG",4326]]
# Mengubah ke sistem koordinat UTM Zone 33
Jawa_Timur_utm <- st_transform(Jawa_Timur_merged, crs = 32733)

# Memverifikasi CRS setelah transformasi
print(st_crs(Jawa_Timur_utm))
## Coordinate Reference System:
##   User input: EPSG:32733 
##   wkt:
## PROJCRS["WGS 84 / UTM zone 33S",
##     BASEGEOGCRS["WGS 84",
##         ENSEMBLE["World Geodetic System 1984 ensemble",
##             MEMBER["World Geodetic System 1984 (Transit)"],
##             MEMBER["World Geodetic System 1984 (G730)"],
##             MEMBER["World Geodetic System 1984 (G873)"],
##             MEMBER["World Geodetic System 1984 (G1150)"],
##             MEMBER["World Geodetic System 1984 (G1674)"],
##             MEMBER["World Geodetic System 1984 (G1762)"],
##             MEMBER["World Geodetic System 1984 (G2139)"],
##             ELLIPSOID["WGS 84",6378137,298.257223563,
##                 LENGTHUNIT["metre",1]],
##             ENSEMBLEACCURACY[2.0]],
##         PRIMEM["Greenwich",0,
##             ANGLEUNIT["degree",0.0174532925199433]],
##         ID["EPSG",4326]],
##     CONVERSION["UTM zone 33S",
##         METHOD["Transverse Mercator",
##             ID["EPSG",9807]],
##         PARAMETER["Latitude of natural origin",0,
##             ANGLEUNIT["degree",0.0174532925199433],
##             ID["EPSG",8801]],
##         PARAMETER["Longitude of natural origin",15,
##             ANGLEUNIT["degree",0.0174532925199433],
##             ID["EPSG",8802]],
##         PARAMETER["Scale factor at natural origin",0.9996,
##             SCALEUNIT["unity",1],
##             ID["EPSG",8805]],
##         PARAMETER["False easting",500000,
##             LENGTHUNIT["metre",1],
##             ID["EPSG",8806]],
##         PARAMETER["False northing",10000000,
##             LENGTHUNIT["metre",1],
##             ID["EPSG",8807]]],
##     CS[Cartesian,2],
##         AXIS["(E)",east,
##             ORDER[1],
##             LENGTHUNIT["metre",1]],
##         AXIS["(N)",north,
##             ORDER[2],
##             LENGTHUNIT["metre",1]],
##     USAGE[
##         SCOPE["Engineering survey, topographic mapping."],
##         AREA["Between 12°E and 18°E, southern hemisphere between 80°S and equator, onshore and offshore. Angola. Congo. Democratic Republic of the Congo (Zaire). Gabon. Namibia. South Africa."],
##         BBOX[-80,12,0,18]],
##     ID["EPSG",32733]]

Pemodelan GWR (UTM)

Bandwidth Kernel

# Bandwidth untuk Fixed Gaussian Kernel
bwd_fixed_gaussian <- bw.gwr(y ~ x1 + x2 + x3,
                             data = Jawa_Timur_utm, 
                             kernel = "gaussian", 
                             adaptive = FALSE)
## Fixed bandwidth: 1199033 CV score: 328576867475 
## Fixed bandwidth: 741191.4 CV score: 345034134461 
## Fixed bandwidth: 1481995 CV score: 323422088338 
## Fixed bandwidth: 1656875 CV score: 321305298134 
## Fixed bandwidth: 1764956 CV score: 3.20268e+11 
## Fixed bandwidth: 1831755 CV score: 319708279493 
## Fixed bandwidth: 1873038 CV score: 319389343378 
## Fixed bandwidth: 1898553 CV score: 319201686987 
## Fixed bandwidth: 1914322 CV score: 319089137902 
## Fixed bandwidth: 1924067 CV score: 319020847407 
## Fixed bandwidth: 1930091 CV score: 318979116756 
## Fixed bandwidth: 1933813 CV score: 318953505129 
## Fixed bandwidth: 1936114 CV score: 318937744267 
## Fixed bandwidth: 1937536 CV score: 3.18928e+11 
## Fixed bandwidth: 1938415 CV score: 3.18922e+11 
## Fixed bandwidth: 1938958 CV score: 318918334160 
## Fixed bandwidth: 1939293 CV score: 3.18916e+11 
## Fixed bandwidth: 1939501 CV score: 318914636105 
## Fixed bandwidth: 1939629 CV score: 318913763530 
## Fixed bandwidth: 1939708 CV score: 318913224329 
## Fixed bandwidth: 1939757 CV score: 318912891115 
## Fixed bandwidth: 1939787 CV score: 318912685189 
## Fixed bandwidth: 1939806 CV score: 318912557924 
## Fixed bandwidth: 1939818 CV score: 318912479271 
## Fixed bandwidth: 1939825 CV score: 318912430662 
## Fixed bandwidth: 1939829 CV score: 318912400620 
## Fixed bandwidth: 1939832 CV score: 318912382054 
## Fixed bandwidth: 1939834 CV score: 318912370579 
## Fixed bandwidth: 1939835 CV score: 318912363487 
## Fixed bandwidth: 1939835 CV score: 318912359104 
## Fixed bandwidth: 1939836 CV score: 318912356395 
## Fixed bandwidth: 1939836 CV score: 318912354721 
## Fixed bandwidth: 1939836 CV score: 318912353686 
## Fixed bandwidth: 1939836 CV score: 318912353047 
## Fixed bandwidth: 1939836 CV score: 318912352651 
## Fixed bandwidth: 1939836 CV score: 318912352407 
## Fixed bandwidth: 1939836 CV score: 318912352256 
## Fixed bandwidth: 1939836 CV score: 318912352163 
## Fixed bandwidth: 1939836 CV score: 318912352105 
## Fixed bandwidth: 1939836 CV score: 318912352070 
## Fixed bandwidth: 1939836 CV score: 318912352048 
## Fixed bandwidth: 1939836 CV score: 318912352034 
## Fixed bandwidth: 1939836 CV score: 318912352026 
## Fixed bandwidth: 1939836 CV score: 318912352020 
## Fixed bandwidth: 1939836 CV score: 318912352017 
## Fixed bandwidth: 1939836 CV score: 318912352015 
## Fixed bandwidth: 1939836 CV score: 318912352014 
## Fixed bandwidth: 1939836 CV score: 318912352013 
## Fixed bandwidth: 1939836 CV score: 318912352013 
## Fixed bandwidth: 1939836 CV score: 318912352012 
## Fixed bandwidth: 1939836 CV score: 318912352012
# Bandwidth untuk Adaptive Gaussian Kernel
bwd_adaptive_gaussian <- bw.gwr(y ~ x1 + x2 + x3,
                                data = Jawa_Timur_utm,
                                kernel = "gaussian", 
                                adaptive = TRUE)
## Adaptive bandwidth: 31 CV score: 342350835534 
## Adaptive bandwidth: 27 CV score: 345904073736 
## Adaptive bandwidth: 34 CV score: 333796278180 
## Adaptive bandwidth: 35 CV score: 330953895060 
## Adaptive bandwidth: 37 CV score: 327311512991 
## Adaptive bandwidth: 37 CV score: 327311512991
# Bandwidth untuk Adaptive Bisquare Kernel
bwd_fixed_bisquare <- bw.gwr(y ~ x1 + x2 + x3,
                                data = Jawa_Timur_utm,  
                                kernel = "bisquare", 
                                adaptive = FALSE)
## Fixed bandwidth: 1199033 CV score: 365683275914 
## Fixed bandwidth: 741191.4 CV score: 291839324397 
## Fixed bandwidth: 458229.6 CV score: Inf 
## Fixed bandwidth: 916071.3 CV score: 342967831989 
## Fixed bandwidth: 633109.6 CV score: 229801584577 
## Fixed bandwidth: 566311.4 CV score: 385098199900 
## Fixed bandwidth: 674393.2 CV score: 255881065813 
## Fixed bandwidth: 607595 CV score: 362382263886 
## Fixed bandwidth: 648878.5 CV score: 2.37628e+11 
## Fixed bandwidth: 623363.9 CV score: 266045542604 
## Fixed bandwidth: 639132.8 CV score: 231730571977 
## Fixed bandwidth: 629387.1 CV score: 231217929779 
## Fixed bandwidth: 635410.3 CV score: 230214448408 
## Fixed bandwidth: 631687.7 CV score: 229915711467 
## Fixed bandwidth: 633988.4 CV score: 2.2989e+11 
## Fixed bandwidth: 632566.5 CV score: 229802291456 
## Fixed bandwidth: 633445.3 CV score: 229823349004 
## Fixed bandwidth: 632902.1 CV score: 229796334961 
## Fixed bandwidth: 632773.9 CV score: 229796431901 
## Fixed bandwidth: 632981.4 CV score: 229797567220 
## Fixed bandwidth: 632853.2 CV score: 229796063111 
## Fixed bandwidth: 632822.9 CV score: 229796085076 
## Fixed bandwidth: 632871.9 CV score: 229796122316 
## Fixed bandwidth: 632841.6 CV score: 229796054269 
## Fixed bandwidth: 632834.5 CV score: 229796059442 
## Fixed bandwidth: 632846 CV score: 229796055138 
## Fixed bandwidth: 632838.9 CV score: 229796055284 
## Fixed bandwidth: 632843.3 CV score: 229796054234 
## Fixed bandwidth: 632844.3 CV score: 229796054440 
## Fixed bandwidth: 632842.7 CV score: 229796054194 
## Fixed bandwidth: 632842.3 CV score: 229796054202 
## Fixed bandwidth: 632842.9 CV score: 229796054202 
## Fixed bandwidth: 632842.5 CV score: 229796054194 
## Fixed bandwidth: 632842.8 CV score: 229796054196 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194 
## Fixed bandwidth: 632842.6 CV score: 229796054194
# Bandwidth untuk Adaptive Bisquare Kernel
bwd_adaptive_bisquare <- bw.gwr(y ~ x1 + x2 + x3,
                                data = Jawa_Timur_utm,  
                                kernel = "bisquare", 
                                adaptive = TRUE)
## Adaptive bandwidth: 31 CV score: 297561719860 
## Adaptive bandwidth: 27 CV score: 243524856392 
## Adaptive bandwidth: 24 CV score: 221293801549 
## Adaptive bandwidth: 22 CV score: 237423474563 
## Adaptive bandwidth: 25 CV score: 220597226998 
## Adaptive bandwidth: 26 CV score: 215036453006 
## Adaptive bandwidth: 26 CV score: 215036453006

Model GWR dengan Fixed Gaussian Kernel

# Model GWR dengan Fixed Gaussian Kernel
gwr_fixed_gaussian <- gwr.basic(y ~ x1 + x2 + x3,
                                data = Jawa_Timur_utm,  
                                bw = bwd_fixed_gaussian, 
                                kernel = "gaussian", 
                                adaptive = FALSE)
gwr_fixed_gaussian
##    ***********************************************************************
##    *                       Package   GWmodel                             *
##    ***********************************************************************
##    Program starts at: 2024-11-07 10:36:28.270136 
##    Call:
##    gwr.basic(formula = y ~ x1 + x2 + x3, data = Jawa_Timur_utm, 
##     bw = bwd_fixed_gaussian, kernel = "gaussian", adaptive = FALSE)
## 
##    Dependent (y) variable:  y
##    Independent variables:  x1 x2 x3
##    Number of data points: 38
##    ***********************************************************************
##    *                    Results of Global Regression                     *
##    ***********************************************************************
## 
##    Call:
##     lm(formula = formula, data = data)
## 
##    Residuals:
##    Min     1Q Median     3Q    Max 
## -92620 -20629 -12040   3443 192376 
## 
##    Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
##    (Intercept) -2.526e+04  3.434e+04  -0.735    0.467    
##    x1           1.386e-01  1.471e-02   9.420 5.26e-11 ***
##    x2           8.849e+03  7.450e+03   1.188    0.243    
##    x3           1.181e-01  1.138e-01   1.037    0.307    
## 
##    ---Significance stars
##    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
##    Residual standard error: 60440 on 34 degrees of freedom
##    Multiple R-squared: 0.7613
##    Adjusted R-squared: 0.7403 
##    F-statistic: 36.15 on 3 and 34 DF,  p-value: 1.108e-10 
##    ***Extra Diagnostic information
##    Residual sum of squares: 124190614352
##    Sigma(hat): 58734.48
##    AIC:  950.3242
##    AICc:  952.1992
##    BIC:  938.7001
##    ***********************************************************************
##    *          Results of Geographically Weighted Regression              *
##    ***********************************************************************
## 
##    *********************Model calibration information*********************
##    Kernel function: gaussian 
##    Fixed bandwidth: 1939836 
##    Regression points: the same locations as observations are used.
##    Distance metric: Euclidean distance metric is used.
## 
##    ****************Summary of GWR coefficient estimates:******************
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
##    Intercept -3.0102e+04 -2.7975e+04 -2.6953e+04 -2.5890e+04 -23982.4657
##    x1         1.3699e-01  1.3813e-01  1.3894e-01  1.3933e-01      0.1410
##    x2         8.7437e+03  8.9776e+03  9.0787e+03  9.2179e+03   9525.3235
##    x3         1.1086e-01  1.1648e-01  1.2041e-01  1.2252e-01      0.1309
##    ************************Diagnostic information*************************
##    Number of data points: 38 
##    Effective number of parameters (2trace(S) - trace(S'S)): 4.41405 
##    Effective degrees of freedom (n-2trace(S) + trace(S'S)): 33.58595 
##    AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 952.3221 
##    AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 944.0677 
##    BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 917.1851 
##    Residual sum of squares: 122659254003 
##    R-square value:  0.7642638 
##    Adjusted R-square value:  0.7323312 
## 
##    ***********************************************************************
##    Program stops at: 2024-11-07 10:36:28.310219

Model gwr dengan Adaptive Gaussian Kernel

# Model GWR dengan Adaptive Gaussian Kernel
gwr_adaptive_gaussian <- gwr.basic(y ~ x1 + x2 + x3,
                                   data = Jawa_Timur_utm,  
                                   bw = bwd_adaptive_gaussian, 
                                   kernel = "gaussian", 
                                   adaptive = TRUE)
gwr_adaptive_gaussian
##    ***********************************************************************
##    *                       Package   GWmodel                             *
##    ***********************************************************************
##    Program starts at: 2024-11-07 10:36:28.320451 
##    Call:
##    gwr.basic(formula = y ~ x1 + x2 + x3, data = Jawa_Timur_utm, 
##     bw = bwd_adaptive_gaussian, kernel = "gaussian", adaptive = TRUE)
## 
##    Dependent (y) variable:  y
##    Independent variables:  x1 x2 x3
##    Number of data points: 38
##    ***********************************************************************
##    *                    Results of Global Regression                     *
##    ***********************************************************************
## 
##    Call:
##     lm(formula = formula, data = data)
## 
##    Residuals:
##    Min     1Q Median     3Q    Max 
## -92620 -20629 -12040   3443 192376 
## 
##    Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
##    (Intercept) -2.526e+04  3.434e+04  -0.735    0.467    
##    x1           1.386e-01  1.471e-02   9.420 5.26e-11 ***
##    x2           8.849e+03  7.450e+03   1.188    0.243    
##    x3           1.181e-01  1.138e-01   1.037    0.307    
## 
##    ---Significance stars
##    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
##    Residual standard error: 60440 on 34 degrees of freedom
##    Multiple R-squared: 0.7613
##    Adjusted R-squared: 0.7403 
##    F-statistic: 36.15 on 3 and 34 DF,  p-value: 1.108e-10 
##    ***Extra Diagnostic information
##    Residual sum of squares: 124190614352
##    Sigma(hat): 58734.48
##    AIC:  950.3242
##    AICc:  952.1992
##    BIC:  938.7001
##    ***********************************************************************
##    *          Results of Geographically Weighted Regression              *
##    ***********************************************************************
## 
##    *********************Model calibration information*********************
##    Kernel function: gaussian 
##    Adaptive bandwidth: 37 (number of nearest neighbours)
##    Regression points: the same locations as observations are used.
##    Distance metric: Euclidean distance metric is used.
## 
##    ****************Summary of GWR coefficient estimates:******************
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
##    Intercept -3.4588e+04 -3.2562e+04 -3.0737e+04 -2.6771e+04 -23557.2138
##    x1         1.3637e-01  1.3768e-01  1.3947e-01  1.4055e-01      0.1434
##    x2         8.6620e+03  9.0509e+03  9.4780e+03  9.8406e+03  11074.9872
##    x3         1.0837e-01  1.1400e-01  1.2389e-01  1.3045e-01      0.1437
##    ************************Diagnostic information*************************
##    Number of data points: 38 
##    Effective number of parameters (2trace(S) - trace(S'S)): 4.913624 
##    Effective degrees of freedom (n-2trace(S) + trace(S'S)): 33.08638 
##    AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 952.0061 
##    AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 943.2593 
##    BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 917.0953 
##    Residual sum of squares: 119219683046 
##    R-square value:  0.7708742 
##    Adjusted R-square value:  0.7357865 
## 
##    ***********************************************************************
##    Program stops at: 2024-11-07 10:36:28.35939

Model GWR dengan Fixed Bisquare Kernel

# Model GWR dengan Fixed Bisquare Kernel
gwr_fixed_bisquare <- gwr.basic(y ~ x1 + x2 + x3,
                                data = Jawa_Timur_utm, 
                                bw = bwd_fixed_bisquare, 
                                kernel = "bisquare", 
                                adaptive = FALSE)
gwr_fixed_bisquare
##    ***********************************************************************
##    *                       Package   GWmodel                             *
##    ***********************************************************************
##    Program starts at: 2024-11-07 10:36:28.367284 
##    Call:
##    gwr.basic(formula = y ~ x1 + x2 + x3, data = Jawa_Timur_utm, 
##     bw = bwd_fixed_bisquare, kernel = "bisquare", adaptive = FALSE)
## 
##    Dependent (y) variable:  y
##    Independent variables:  x1 x2 x3
##    Number of data points: 38
##    ***********************************************************************
##    *                    Results of Global Regression                     *
##    ***********************************************************************
## 
##    Call:
##     lm(formula = formula, data = data)
## 
##    Residuals:
##    Min     1Q Median     3Q    Max 
## -92620 -20629 -12040   3443 192376 
## 
##    Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
##    (Intercept) -2.526e+04  3.434e+04  -0.735    0.467    
##    x1           1.386e-01  1.471e-02   9.420 5.26e-11 ***
##    x2           8.849e+03  7.450e+03   1.188    0.243    
##    x3           1.181e-01  1.138e-01   1.037    0.307    
## 
##    ---Significance stars
##    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
##    Residual standard error: 60440 on 34 degrees of freedom
##    Multiple R-squared: 0.7613
##    Adjusted R-squared: 0.7403 
##    F-statistic: 36.15 on 3 and 34 DF,  p-value: 1.108e-10 
##    ***Extra Diagnostic information
##    Residual sum of squares: 124190614352
##    Sigma(hat): 58734.48
##    AIC:  950.3242
##    AICc:  952.1992
##    BIC:  938.7001
##    ***********************************************************************
##    *          Results of Geographically Weighted Regression              *
##    ***********************************************************************
## 
##    *********************Model calibration information*********************
##    Kernel function: bisquare 
##    Fixed bandwidth: 632842.6 
##    Regression points: the same locations as observations are used.
##    Distance metric: Euclidean distance metric is used.
## 
##    ****************Summary of GWR coefficient estimates:******************
##                     Min.     1st Qu.      Median     3rd Qu.       Max.
##    Intercept -1.8768e+05 -8.4328e+04 -4.7919e+04  4.6100e+02 1.0237e+05
##    x1         2.6990e-02  9.7818e-02  1.3437e-01  1.5335e-01 2.6880e-01
##    x2        -2.7019e+04 -1.0889e+03  7.3385e+03  2.4544e+04 7.4261e+04
##    x3        -3.5065e+00 -6.5954e-02  6.6752e-02  3.5444e-01 1.0087e+00
##    ************************Diagnostic information*************************
##    Number of data points: 38 
##    Effective number of parameters (2trace(S) - trace(S'S)): 18.10263 
##    Effective degrees of freedom (n-2trace(S) + trace(S'S)): 19.89737 
##    AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 967.8553 
##    AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 924.9895 
##    BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 926.5342 
##    Residual sum of squares: 55909118338 
##    R-square value:  0.8925494 
##    Adjusted R-square value:  0.7896177 
## 
##    ***********************************************************************
##    Program stops at: 2024-11-07 10:36:28.405985

Model GWR dengan Adaptive Bisquare Kernel

# Model GWR dengan Adaptive Bisquare Kernel
gwr_adaptive_bisquare <- gwr.basic(y ~ x1 + x2 + x3,
                                   data = Jawa_Timur_utm, 
                                   bw = bwd_adaptive_bisquare, 
                                   kernel = "bisquare", 
                                   adaptive = TRUE)
gwr_adaptive_bisquare
##    ***********************************************************************
##    *                       Package   GWmodel                             *
##    ***********************************************************************
##    Program starts at: 2024-11-07 10:36:28.413913 
##    Call:
##    gwr.basic(formula = y ~ x1 + x2 + x3, data = Jawa_Timur_utm, 
##     bw = bwd_adaptive_bisquare, kernel = "bisquare", adaptive = TRUE)
## 
##    Dependent (y) variable:  y
##    Independent variables:  x1 x2 x3
##    Number of data points: 38
##    ***********************************************************************
##    *                    Results of Global Regression                     *
##    ***********************************************************************
## 
##    Call:
##     lm(formula = formula, data = data)
## 
##    Residuals:
##    Min     1Q Median     3Q    Max 
## -92620 -20629 -12040   3443 192376 
## 
##    Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
##    (Intercept) -2.526e+04  3.434e+04  -0.735    0.467    
##    x1           1.386e-01  1.471e-02   9.420 5.26e-11 ***
##    x2           8.849e+03  7.450e+03   1.188    0.243    
##    x3           1.181e-01  1.138e-01   1.037    0.307    
## 
##    ---Significance stars
##    Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
##    Residual standard error: 60440 on 34 degrees of freedom
##    Multiple R-squared: 0.7613
##    Adjusted R-squared: 0.7403 
##    F-statistic: 36.15 on 3 and 34 DF,  p-value: 1.108e-10 
##    ***Extra Diagnostic information
##    Residual sum of squares: 124190614352
##    Sigma(hat): 58734.48
##    AIC:  950.3242
##    AICc:  952.1992
##    BIC:  938.7001
##    ***********************************************************************
##    *          Results of Geographically Weighted Regression              *
##    ***********************************************************************
## 
##    *********************Model calibration information*********************
##    Kernel function: bisquare 
##    Adaptive bandwidth: 26 (number of nearest neighbours)
##    Regression points: the same locations as observations are used.
##    Distance metric: Euclidean distance metric is used.
## 
##    ****************Summary of GWR coefficient estimates:******************
##                     Min.     1st Qu.      Median     3rd Qu.       Max.
##    Intercept -1.3703e+05 -7.9181e+04 -3.6093e+04 -1.2890e+04 54813.3458
##    x1         7.7112e-02  9.3095e-02  1.3649e-01  1.4768e-01     0.1954
##    x2        -1.0606e+04  1.5166e+03  6.5492e+03  1.9435e+04 39843.9341
##    x3        -6.8639e-02  1.4978e-02  1.9184e-01  4.6664e-01     0.9855
##    ************************Diagnostic information*************************
##    Number of data points: 38 
##    Effective number of parameters (2trace(S) - trace(S'S)): 13.41031 
##    Effective degrees of freedom (n-2trace(S) + trace(S'S)): 24.58969 
##    AICc (GWR book, Fotheringham, et al. 2002, p. 61, eq 2.33): 954.8652 
##    AIC (GWR book, Fotheringham, et al. 2002,GWR p. 96, eq. 4.22): 930.6621 
##    BIC (GWR book, Fotheringham, et al. 2002,GWR p. 61, eq. 2.34): 920.6946 
##    Residual sum of squares: 72810927861 
##    R-square value:  0.8600662 
##    Adjusted R-square value:  0.7805164 
## 
##    ***********************************************************************
##    Program stops at: 2024-11-07 10:36:28.452723

Perbandingan Model GWR

# Membuat data frame untuk menyimpan hasil AIC dan R-squared dari setiap model
results <- data.frame(
  Model = c("Fixed Gaussian", "Adaptive Gaussian", "Fixed Bisquare", "Adaptive Bisquare"),
  AIC = c(gwr_fixed_gaussian$GW.diagnostic$AIC, gwr_adaptive_gaussian$GW.diagnostic$AIC, 
          gwr_fixed_bisquare$GW.diagnostic$AIC, gwr_adaptive_bisquare$GW.diagnostic$AIC),
  R_squared = c(gwr_fixed_gaussian$GW.diagnostic$gw.R2, gwr_adaptive_gaussian$GW.diagnostic$gw.R2, 
                gwr_fixed_bisquare$GW.diagnostic$gw.R2, gwr_adaptive_bisquare$GW.diagnostic$gw.R2)
)
results
##               Model      AIC R_squared
## 1    Fixed Gaussian 944.0677 0.7642638
## 2 Adaptive Gaussian 943.2593 0.7708742
## 3    Fixed Bisquare 924.9895 0.8925494
## 4 Adaptive Bisquare 930.6621 0.8600662

Uji Asumsi

Uji Spasial Autokorelasi

Dilakukan uji spasial autokorelasi untuk masing-masing model GWR dengan menggunakan pembobot ROOK

# ROOK
nb_rook <- poly2nb(Jawa_Timur_utm, snap = 2)  
## Warning in poly2nb(Jawa_Timur_utm, snap = 2): neighbour object has 2 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
summary(nb_rook)
## Neighbour list object:
## Number of regions: 38 
## Number of nonzero links: 138 
## Percentage nonzero weights: 9.556787 
## Average number of links: 3.631579 
## 2 disjoint connected subgraphs
## Link number distribution:
## 
## 1 2 3 4 5 6 7 8 9 
## 8 6 6 6 2 7 1 1 1 
## 8 least connected regions:
## 1 11 12 14 15 16 17 34 with 1 link
## 1 most connected region:
## 22 with 9 links
listw_rook <- nb2listw(nb_rook, style = "W")
## Residual Model Fixed Gaussian Kernel
residual_gwr_FG <- gwr_fixed_gaussian$SDF$residual

# Perform Moran's I test on residuals with rook contiguity weights
moran.test(residual_gwr_FG, listw_rook)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr_FG  
## weights: listw_rook    
## 
## Moran I statistic standard deviate = -1.43, p-value = 0.9236
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.20463324       -0.02702703        0.01542595
## Residual Model Adaptive Gaussian Kernel
residual_gwr_AG <- gwr_adaptive_gaussian$SDF$residual

# Perform Moran's I test on residuals with rook contiguity weights
moran.test(residual_gwr_AG, listw_rook)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr_AG  
## weights: listw_rook    
## 
## Moran I statistic standard deviate = -1.4745, p-value = 0.9298
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.21078962       -0.02702703        0.01553227
## Residual Model Fixed Bisquare Kernel
residual_gwr_FB <- gwr_fixed_bisquare$SDF$residual

# Perform Moran's I test on residuals with rook contiguity weights
moran.test(residual_gwr_FB, listw_rook)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr_FB  
## weights: listw_rook    
## 
## Moran I statistic standard deviate = -1.3531, p-value = 0.912
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.19966557       -0.02702703        0.01627860
## Residual Model Adaptive Bisquare Kernel
residual_gwr_AB <- gwr_adaptive_bisquare$SDF$residual

# Perform Moran's I test on residuals with rook contiguity weights
moran.test(residual_gwr_AB, listw_rook)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr_AB  
## weights: listw_rook    
## 
## Moran I statistic standard deviate = -0.8416, p-value = 0.8
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.13531004       -0.02702703        0.01655406

Uji Normalitas Residual GWR

Dilakukan uji normalitas residual untuk maisng-masing model GWR

Hipotesis H0 : Residual mengikuti distribusi normal H1 : Residual tidak mengikuti distribusi normal

## Uji Normalitas Residual GWR 
norm_FG <- shapiro.test(residual_gwr_FG)
norm_AG <- shapiro.test(residual_gwr_AG)
norm_FB <- shapiro.test(residual_gwr_FB)
norm_AB <- shapiro.test(residual_gwr_AB)

# Hasil dari uji normalitas (p-value)
pvalue_FG <- norm_FG$p.value
pvalue_AG <- norm_AG$p.value
pvalue_FB <- norm_FB$p.value
pvalue_AB <- norm_AB$p.value

tabel_pvalue <- data.frame(
  Model = c("Residual GWR FG", "Residual GWR AG", "Residual GWR FB", "Residual GWR AB"),
  P_Value = c(pvalue_FG, pvalue_AG, pvalue_FB, pvalue_AB)
)

tabel_pvalue
##             Model      P_Value
## 1 Residual GWR FG 4.695244e-05
## 2 Residual GWR AG 8.369315e-05
## 3 Residual GWR FB 8.446299e-03
## 4 Residual GWR AB 1.764772e-01

Uji Heterogenitas

# Uji Heteroskedastisitas untuk berbagai kernel GWR
# Fixed Gaussian Kernel
gwr_residuals_fixed_gaussian <- gwr_fixed_gaussian$SDF$residual
bp_test_fixed_gaussian <- bptest(gwr_residuals_fixed_gaussian ~ gwr_fixed_gaussian$SDF$x1 + gwr_fixed_gaussian$SDF$x2 + gwr_fixed_gaussian$SDF$x3, 
                                 data = Jawa_Timur_merged)

# Adaptive Gaussian Kernel
gwr_residuals_adaptive_gaussian <- gwr_adaptive_gaussian$SDF$residual
bp_test_adaptive_gaussian <- bptest(gwr_residuals_adaptive_gaussian ~ gwr_adaptive_gaussian$SDF$x1 + gwr_adaptive_gaussian$SDF$x2 + gwr_adaptive_gaussian$SDF$x3, 
                                    data = Jawa_Timur_merged)

# Fixed Bisquare Kernel
gwr_residuals_fixed_bisquare <- gwr_fixed_bisquare$SDF$residual
bp_test_fixed_bisquare <- bptest(gwr_residuals_fixed_bisquare ~ gwr_fixed_bisquare$SDF$x1 + gwr_fixed_bisquare$SDF$x2 + gwr_fixed_bisquare$SDF$x3, 
                                 data = Jawa_Timur_merged)

# Adaptive Bisquare Kernel
gwr_residuals_adaptive_bisquare <- gwr_adaptive_bisquare$SDF$residual
bp_test_adaptive_bisquare <- bptest(gwr_residuals_adaptive_bisquare ~ gwr_adaptive_bisquare$SDF$x1 + gwr_adaptive_bisquare$SDF$x2 + gwr_adaptive_bisquare$SDF$x3, 
                                    data = Jawa_Timur_merged)

# Membuat tabel perbandingan hasil uji Breusch-Pagan
bp_results <- tibble::tibble(
  Kernel = c("Fixed Gaussian", "Adaptive Gaussian", "Fixed Bisquare", "Adaptive Bisquare"),
  BP_Statistic = c(bp_test_fixed_gaussian$statistic, bp_test_adaptive_gaussian$statistic, bp_test_fixed_bisquare$statistic, bp_test_adaptive_bisquare$statistic),
  df = c(bp_test_fixed_gaussian$parameter, bp_test_adaptive_gaussian$parameter, bp_test_fixed_bisquare$parameter, bp_test_adaptive_bisquare$parameter),
  p_value = c(bp_test_fixed_gaussian$p.value, bp_test_adaptive_gaussian$p.value, bp_test_fixed_bisquare$p.value, bp_test_adaptive_bisquare$p.value)
)

# Melihat tabel hasil
print(bp_results)
## # A tibble: 4 × 4
##   Kernel            BP_Statistic    df p_value
##   <chr>                    <dbl> <dbl>   <dbl>
## 1 Fixed Gaussian           0.173     3   0.982
## 2 Adaptive Gaussian        0.362     3   0.948
## 3 Fixed Bisquare           1.79      3   0.617
## 4 Adaptive Bisquare        0.410     3   0.938

Ekstrak Koefisien Model GWR

Koefisien Model GWR Kernel Fixed Gaussian

## Ekstraksi koefisien lokal untuk setiap variabel dari model GWR
koefisien_gwr <- as.data.frame(gwr_fixed_gaussian$SDF)

# Hitung t-statistic untuk masing-masing variabel
t_stat_variable1 <- koefisien_gwr$x1 / koefisien_gwr$x1_SE
t_stat_variable2 <- koefisien_gwr$x2 / koefisien_gwr$x2_SE
t_stat_variable3 <- koefisien_gwr$x3 / koefisien_gwr$x3_SE

# Asumsi bahwa kita memiliki derajat kebebasan n-k (n adalah jumlah observasi dan k adalah jumlah variabel dalam model)
n <- nrow(koefisien_gwr)  # jumlah observasi
k <- 3  # jumlah variabel
df <- n - k  # derajat kebebasan

# Hitung p-value berdasarkan t-statistic
p_value_variable1 <- 2 * pt(-abs(t_stat_variable1), df)
p_value_variable2 <- 2 * pt(-abs(t_stat_variable2), df)
p_value_variable3 <- 2 * pt(-abs(t_stat_variable3), df)

# Buat data frame untuk menyimpan t-statistic dan p-value, per kabupaten/kota
koefisien_gwr$t_stat_variable1 <- t_stat_variable1
koefisien_gwr$p_value_variable1 <- p_value_variable1

koefisien_gwr$t_stat_variable2 <- t_stat_variable2
koefisien_gwr$p_value_variable2 <- p_value_variable2

koefisien_gwr$t_stat_variable3 <- t_stat_variable3
koefisien_gwr$p_value_variable3 <- p_value_variable3

# Tampilkan hasil
print(koefisien_gwr)
##    Intercept        x1       x2        x3         y      yhat   residual
## 1  -28020.32 0.1399572 8928.271 0.1250932 152259.02 184505.50 -32246.483
## 2  -29277.10 0.1394216 9525.324 0.1235306 305312.85 266408.30  38904.549
## 3  -26930.32 0.1387030 9159.567 0.1192163  52062.68  55931.47  -3868.790
## 4  -26248.25 0.1381068 9223.119 0.1164088 150990.10 195770.11 -44780.007
## 5  -25749.04 0.1386753 8848.635 0.1184162 133639.42 207365.71 -73726.291
## 6  -29124.40 0.1396756 9365.660 0.1245936 177160.17 123191.80  53968.361
## 7  -27472.85 0.1398702 8815.390 0.1243409 144238.33 236936.65 -92698.318
## 8  -28578.41 0.1391743 9426.884 0.1220908 377298.02 373454.54   3843.482
## 9  -26556.37 0.1387861 9021.004 0.1193438 193583.44 206686.45 -13103.012
## 10 -26081.86 0.1382910 9099.160 0.1170740 241778.92 260730.37 -18951.448
## 11 -26125.70 0.1380753 9202.394 0.1162198  27988.20  49747.98 -21759.775
## 12 -25932.04 0.1382194 9088.140 0.1167055  63461.92 114315.80 -50853.878
## 13 -24972.27 0.1379349 8946.214 0.1150628  44750.39  65079.64 -20329.252
## 14 -27055.06 0.1386358 9223.198 0.1190046 284095.41 165910.40 118185.007
## 15 -26923.41 0.1390299 9019.025 0.1205544  35882.93  41683.26  -5800.333
## 16 -27684.45 0.1392325 9144.283 0.1218509  53830.17  59464.35  -5634.183
## 17 -28112.04 0.1393287 9223.891 0.1225088  35705.61  54923.39 -19217.778
## 18 -26827.59 0.1393149 8873.170 0.1216481 201686.44 219187.41 -17500.966
## 19 -27839.22 0.1388986 9332.676 0.1205219 195275.12 170004.39  25270.731
## 20 -25237.03 0.1380686 8962.154 0.1157313 109147.99 130125.24 -20977.251
## 21 -24567.26 0.1377041 8932.751 0.1139469 100725.11 110403.06  -9677.945
## 22 -26994.42 0.1384835 9271.453 0.1183379 352927.26 405792.09 -52864.834
## 23 -26974.89 0.1389839 9052.629 0.1203975 172984.00 184922.89 -11938.892
## 24 -25876.42 0.1384052 8995.139 0.1174206 163086.82 175335.34 -12248.516
## 25 -24615.31 0.1379453 8846.461 0.1149087 135297.67 121462.41  13835.260
## 26 -23982.47 0.1369860 9071.884 0.1108626 105345.64  23232.18  82113.457
## 27 -28930.19 0.1403540 9011.946 0.1274242 177131.60 263160.79 -86029.195
## 28 -27503.13 0.1390629 9166.056 0.1210347 101156.10 111205.03 -10048.926
## 29 -24788.89 0.1375618 9051.323 0.1135018 140780.94 154167.06 -13386.122
## 30 -28244.17 0.1393135 9268.357 0.1225193 169354.89 168337.98   1016.909
## 31 -28553.93 0.1401950 8974.797 0.1264734 169511.29 137993.02  31518.270
## 32 -27413.26 0.1392836 9046.735 0.1218984 320690.10 355468.05 -34777.952
## 33 -29325.24 0.1398875 9330.840 0.1256502  92130.84 102827.06 -10696.216
## 34 -30101.68 0.1409533 9085.452 0.1309274 134116.66 151478.38 -17361.724
## 35 -27541.09 0.1395101 8985.924 0.1229151 657016.64 467102.18 189914.461
## 36 -24984.98 0.1374517 9150.661 0.1131583 109657.53 122161.09 -12503.561
## 37 -26066.23 0.1391347 8743.714 0.1204250 185422.94 189655.03  -4232.092
## 38 -25553.61 0.1377777 9169.912 0.1147340 204028.80  46926.96 157101.839
##    CV_Score Stud_residual Intercept_SE      x1_SE    x2_SE     x3_SE
## 1         0   -0.55751423     34407.14 0.01472365 7460.160 0.1138152
## 2         0    0.66836538     34581.76 0.01476174 7488.542 0.1138568
## 3         0   -0.06631709     34382.24 0.01471895 7458.519 0.1137924
## 4         0   -0.75468242     34409.12 0.01472298 7465.372 0.1138041
## 5         0   -1.24354349     34452.76 0.01474474 7472.793 0.1138088
## 6         0    0.91581039     34539.57 0.01474611 7481.404 0.1138501
## 7         0   -1.61646167     34390.67 0.01472781 7458.211 0.1138063
## 8         0    0.07174178     34468.10 0.01473572 7470.322 0.1138185
## 9         0   -0.22096605     34393.72 0.01472490 7460.937 0.1137950
## 10        0   -0.32506062     34418.57 0.01472747 7466.815 0.1138042
## 11        0   -0.37831810     34416.21 0.01472452 7466.832 0.1138063
## 12        0   -2.25391907     34429.40 0.01472977 7469.061 0.1138076
## 13        0   -0.35985965     34529.28 0.01475349 7488.553 0.1138354
## 14        0    2.06919098     34381.92 0.01471808 7458.425 0.1137924
## 15        0   -0.10010184     34382.84 0.01472209 7458.155 0.1137929
## 16        0   -0.09867870     34388.67 0.01471869 7457.785 0.1137967
## 17        0   -0.33013442     34413.22 0.01472198 7461.319 0.1138050
## 18        0   -0.29683332     34389.96 0.01472886 7459.331 0.1137961
## 19        0    0.42840841     34401.93 0.01472155 7460.360 0.1137977
## 20        0   -0.35593385     34497.66 0.01474714 7482.346 0.1138258
## 21        0   -0.16402822     34583.19 0.01476342 7499.086 0.1138525
## 22        0   -0.96843042     34384.12 0.01471827 7459.214 0.1137936
## 23        0   -0.20049391     34381.49 0.01472082 7457.894 0.1137924
## 24        0   -0.20633304     34435.55 0.01473434 7469.886 0.1138070
## 25        0    0.24587484     34581.57 0.01476859 7498.382 0.1138468
## 26        0    1.52238192     34666.43 0.01476899 7516.034 0.1138921
## 27        0   -1.46883273     34498.17 0.01473288 7474.785 0.1138585
## 28        0   -0.17987205     34383.70 0.01471812 7457.395 0.1137938
## 29        0   -0.22602334     34548.83 0.01475143 7492.972 0.1138483
## 30        0    0.01738380     34425.08 0.01472430 7463.199 0.1138082
## 31        0    0.54669214     34451.03 0.01472720 7467.043 0.1138370
## 32        0   -0.64317203     34381.59 0.01471960 7456.913 0.1137950
## 33        0   -0.18376861     34572.99 0.01475053 7486.848 0.1138669
## 34        0   -0.32641901     34747.08 0.01477070 7517.381 0.1139758
## 35        0    3.81571832     34385.12 0.01472102 7457.169 0.1137989
## 36        0   -0.21139134     34522.91 0.01474319 7488.441 0.1138452
## 37        0   -0.07137736     34435.23 0.01474682 7468.811 0.1138042
## 38        0    2.78146075     34461.52 0.01473275 7476.179 0.1138228
##    Intercept_TV    x1_TV    x2_TV     x3_TV  Local_R2
## 1    -0.8143751 9.505610 1.196794 1.0990897 0.7677763
## 2    -0.8466053 9.444794 1.271986 1.0849646 0.7733190
## 3    -0.7832626 9.423429 1.228068 1.0476645 0.7654454
## 4    -0.7628282 9.380359 1.235453 1.0228880 0.7638047
## 5    -0.7473724 9.405070 1.184113 1.0404842 0.7616932
## 6    -0.8432182 9.472029 1.251859 1.0943655 0.7722793
## 7    -0.7988458 9.497012 1.181971 1.0925657 0.7660238
## 8    -0.8291265 9.444689 1.261911 1.0726797 0.7708534
## 9    -0.7721284 9.425271 1.209098 1.0487618 0.7641198
## 10   -0.7577845 9.390002 1.218613 1.0287323 0.7630759
## 11   -0.7591102 9.377235 1.232436 1.0212069 0.7634340
## 12   -0.7531947 9.383674 1.216771 1.0254629 0.7626662
## 13   -0.7232200 9.349302 1.194652 1.0107819 0.7599621
## 14   -0.7868978 9.419421 1.236615 1.0458045 0.7659474
## 15   -0.7830480 9.443625 1.209284 1.0594194 0.7650736
## 16   -0.8050457 9.459567 1.226139 1.0707765 0.7674443
## 17   -0.8168966 9.463988 1.236228 1.0764799 0.7688641
## 18   -0.7800996 9.458633 1.189540 1.0690010 0.7644784
## 19   -0.8092343 9.435052 1.250969 1.0590890 0.7684204
## 20   -0.7315579 9.362393 1.197773 1.0167400 0.7606475
## 21   -0.7103814 9.327384 1.191179 1.0008296 0.7589451
## 22   -0.7850839 9.408951 1.242953 1.0399347 0.7659142
## 23   -0.7845760 9.441316 1.213832 1.0580453 0.7652923
## 24   -0.7514450 9.393380 1.204187 1.0317518 0.7623186
## 25   -0.7118041 9.340454 1.179783 1.0093272 0.7589079
## 26   -0.6918066 9.275244 1.207004 0.9734004 0.7577728
## 27   -0.8386005 9.526581 1.205646 1.1191451 0.7705626
## 28   -0.7998886 9.448418 1.229123 1.0636315 0.7670079
## 29   -0.7175030 9.325322 1.207975 0.9969563 0.7597136
## 30   -0.8204533 9.461469 1.241875 1.0765414 0.7693738
## 31   -0.8288266 9.519461 1.201921 1.1110041 0.7693822
## 32   -0.7973238 9.462463 1.213201 1.0712105 0.7664454
## 33   -0.8482124 9.483555 1.246298 1.1034836 0.7727699
## 34   -0.8663082 9.542759 1.208593 1.1487298 0.7743150
## 35   -0.8009595 9.476933 1.205005 1.0801074 0.7666311
## 36   -0.7237218 9.323066 1.221971 0.9939667 0.7604047
## 37   -0.7569639 9.434893 1.170697 1.0581769 0.7622721
## 38   -0.7415113 9.351796 1.226551 1.0080052 0.7618844
##                          geometry t_stat_variable1 p_value_variable1
## 1  MULTIPOLYGON (((15706156 -4...         9.505610      3.141030e-11
## 2  MULTIPOLYGON (((14602040 -4...         9.444794      3.698226e-11
## 3  MULTIPOLYGON (((15426453 -4...         9.423429      3.917052e-11
## 4  MULTIPOLYGON (((15334983 -4...         9.380359      4.399112e-11
## 5  MULTIPOLYGON (((16047956 -4...         9.405070      4.115584e-11
## 6  MULTIPOLYGON (((14913039 -5...         9.472029      3.437223e-11
## 7  MULTIPOLYGON (((15756655 -4...         9.497012      3.214296e-11
## 8  MULTIPOLYGON (((14881516 -4...         9.444689      3.699271e-11
## 9  MULTIPOLYGON (((15535174 -4...         9.425271      3.897672e-11
## 10 MULTIPOLYGON (((15581004 -4...         9.390002      4.286178e-11
## 11 MULTIPOLYGON (((15459019 -4...         9.377235      4.436337e-11
## 12 MULTIPOLYGON (((15624671 -4...         9.383674      4.359945e-11
## 13 MULTIPOLYGON (((15909582 -4...         9.349302      4.783834e-11
## 14 MULTIPOLYGON (((15329740 -4...         9.419421      3.959540e-11
## 15 MULTIPOLYGON (((15660042 -4...         9.443625      3.709877e-11
## 16 MULTIPOLYGON (((15390607 -4...         9.459567      3.554236e-11
## 17 MULTIPOLYGON (((15222037 -4...         9.463988      3.512268e-11
## 18 MULTIPOLYGON (((15770125 -4...         9.458633      3.563172e-11
## 19 MULTIPOLYGON (((14988999 -4...         9.435052      3.796416e-11
## 20 MULTIPOLYGON (((15829759 -4...         9.362393      4.617654e-11
## 21 MULTIPOLYGON (((15876026 -4...         9.327384      5.075817e-11
## 22 MULTIPOLYGON (((15139993 -4...         9.408951      4.072785e-11
## 23 MULTIPOLYGON (((15494289 -4...         9.441316      3.732980e-11
## 24 MULTIPOLYGON (((15695383 -4...         9.393380      4.247320e-11
## 25 MULTIPOLYGON (((15997252 -4...         9.340454      4.899590e-11
## 26 MULTIPOLYGON (((15785772 -3...         9.275244      5.845499e-11
## 27 MULTIPOLYGON (((15335201 -5...         9.526581      2.969368e-11
## 28 MULTIPOLYGON (((15279844 -4...         9.448418      3.662367e-11
## 29 MULTIPOLYGON (((15687183 -3...         9.325322      5.104201e-11
## 30 MULTIPOLYGON (((15041209 -4...         9.461469      3.536123e-11
## 31 MULTIPOLYGON (((15436861 -5...         9.519461      3.026550e-11
## 32 MULTIPOLYGON (((15532695 -4...         9.462463      3.526688e-11
## 33 MULTIPOLYGON (((14725379 -5...         9.483555      3.332479e-11
## 34 MULTIPOLYGON (((15248766 -5...         9.542759      2.843492e-11
## 35 MULTIPOLYGON (((15628962 -4...         9.476933      3.392256e-11
## 36 MULTIPOLYGON (((15575336 -3...         9.323066      5.135439e-11
## 37 MULTIPOLYGON (((16133472 -4...         9.434893      3.798040e-11
## 38 MULTIPOLYGON (((15492441 -4...         9.351796      4.751711e-11
##    t_stat_variable2 p_value_variable2 t_stat_variable3 p_value_variable3
## 1          1.196794         0.2394309        1.0990897         0.2792320
## 2          1.271986         0.2117648        1.0849646         0.2853543
## 3          1.228068         0.2276163        1.0476645         0.3019744
## 4          1.235453         0.2248906        1.0228880         0.3133792
## 5          1.184113         0.2443476        1.0404842         0.3052495
## 6          1.251859         0.2189232        1.0943655         0.2812692
## 7          1.181971         0.2451856        1.0925657         0.2820481
## 8          1.261911         0.2153256        1.0726797         0.2907555
## 9          1.209098         0.2347299        1.0487618         0.3014761
## 10         1.218613         0.2311415        1.0287323         0.3106627
## 11         1.232436         0.2260012        1.0212069         0.3141636
## 12         1.216771         0.2318328        1.0254629         0.3121803
## 13         1.194652         0.2402562        1.0107819         0.3190579
## 14         1.236615         0.2244642        1.0458045         0.3028205
## 15         1.209284         0.2346595        1.0594194         0.2966656
## 16         1.226139         0.2283321        1.0707765         0.2915986
## 17         1.236228         0.2246062        1.0764799         0.2890771
## 18         1.189540         0.2422347        1.0690010         0.2923867
## 19         1.250969         0.2192439        1.0590890         0.2968139
## 20         1.197773         0.2390541        1.0167400         0.3162544
## 21         1.191179         0.2415991        1.0008296         0.3237787
## 22         1.242953         0.2221477        1.0399347         0.3055012
## 23         1.213832         0.2329395        1.0580453         0.2972828
## 24         1.204187         0.2365980        1.0317518         0.3092656
## 25         1.179783         0.2460437        1.0093272         0.3197450
## 26         1.207004         0.2355250        0.9734004         0.3370341
## 27         1.205646         0.2360418        1.1191451         0.2707003
## 28         1.229123         0.2272254        1.0636315         0.2947793
## 29         1.207975         0.2351560        0.9969563         0.3256287
## 30         1.241875         0.2225406        1.0765414         0.2890500
## 31         1.201921         0.2374635        1.1110041         0.2741408
## 32         1.213201         0.2331775        1.0712105         0.2914062
## 33         1.246298         0.2209326        1.1034836         0.2773467
## 34         1.208593         0.2349215        1.1487298         0.2584577
## 35         1.205005         0.2362861        1.0801074         0.2874813
## 36         1.221971         0.2298848        0.9939667         0.3270616
## 37         1.170697         0.2496300        1.0581769         0.2972237
## 38         1.226551         0.2281794        1.0080052         0.3203703
library(classInt)

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x1), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X1",
       fill = "Koefisien X1")  

# Membuat kuantil untuk koefisien X1
koefisien_merged$X1_quantile <- cut(koefisien_merged$x1, 
                                    breaks = classIntervals(koefisien_merged$x1, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X1_quantile), color = NA) +  # Menggunakan X1_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X1") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X1 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x2), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X2",
       fill = "Koefisien X2")  

# Membuat kuantil untuk koefisien X2
koefisien_merged$X2_quantile <- cut(koefisien_merged$x2, 
                                    breaks = classIntervals(koefisien_merged$x2, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X2_quantile), color = NA) +  # Menggunakan X2_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X2") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X2 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x3), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X3",
       fill = "Koefisien X3")  

# Membuat kuantil untuk koefisien X3
koefisien_merged$X1_quantile <- cut(koefisien_merged$x3, 
                                    breaks = classIntervals(koefisien_merged$x3, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X1_quantile), color = NA) +  # Menggunakan X3_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X3") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X3 Berdasarkan Kuantil")

Koefisien Model GWR Kernel Adaptive Gaussian

## Ekstraksi koefisien lokal untuk setiap variabel dari model GWR
koefisien_gwr <- as.data.frame(gwr_adaptive_gaussian$SDF)

# Hitung t-statistic untuk masing-masing variabel
t_stat_variable1 <- koefisien_gwr$x1 / koefisien_gwr$x1_SE
t_stat_variable2 <- koefisien_gwr$x2 / koefisien_gwr$x2_SE
t_stat_variable3 <- koefisien_gwr$x3 / koefisien_gwr$x3_SE

# Asumsi bahwa kita memiliki derajat kebebasan n-k (n adalah jumlah observasi dan k adalah jumlah variabel dalam model)
n <- nrow(koefisien_gwr)  # jumlah observasi
k <- 3  # jumlah variabel
df <- n - k  # derajat kebebasan

# Hitung p-value berdasarkan t-statistic
p_value_variable1 <- 2 * pt(-abs(t_stat_variable1), df)
p_value_variable2 <- 2 * pt(-abs(t_stat_variable2), df)
p_value_variable3 <- 2 * pt(-abs(t_stat_variable3), df)

# Buat data frame untuk menyimpan t-statistic dan p-value, per kabupaten/kota
koefisien_gwr$t_stat_variable1 <- t_stat_variable1
koefisien_gwr$p_value_variable1 <- p_value_variable1

koefisien_gwr$t_stat_variable2 <- t_stat_variable2
koefisien_gwr$p_value_variable2 <- p_value_variable2

koefisien_gwr$t_stat_variable3 <- t_stat_variable3
koefisien_gwr$p_value_variable3 <- p_value_variable3

# Tampilkan hasil
print(koefisien_gwr)
##    Intercept        x1        x2        x3         y      yhat   residual
## 1  -33815.24 0.1433797  8871.151 0.1437486 152259.02 182601.62 -30342.600
## 2  -30410.62 0.1396587  9718.016 0.1252977 305312.85 266706.40  38606.451
## 3  -32588.63 0.1388936 10240.319 0.1224860  52062.68  55504.65  -3441.974
## 4  -29056.57 0.1368368 10206.227 0.1121458 150990.10 196049.32 -45059.222
## 5  -26174.63 0.1387318  8871.032 0.1184620 133639.42 207121.94 -73482.519
## 6  -31055.18 0.1402444  9613.680 0.1284645 177160.17 122858.02  54302.145
## 7  -31301.39 0.1423698  8662.011 0.1363432 144238.33 236988.15 -92749.816
## 8  -31239.90 0.1396278  9895.018 0.1258214 377298.02 373979.87   3318.148
## 9  -29132.37 0.1391046  9390.329 0.1213042 193583.44 206332.67 -12749.226
## 10 -27753.87 0.1377239  9588.358 0.1150607 241778.92 260884.47 -19105.547
## 11 -28365.30 0.1368829 10034.806 0.1120052  27988.20  51453.11 -23464.914
## 12 -27196.48 0.1376069  9507.550 0.1143519  63461.92 113302.45 -49840.531
## 13 -24870.71 0.1375394  9020.075 0.1131984  44750.39  65372.73 -20622.344
## 14 -34588.06 0.1385276 10824.371 0.1223858 284095.41 169537.29 114558.118
## 15 -30687.24 0.1399560  9426.750 0.1257205  35882.93  40278.51  -4395.580
## 16 -34532.03 0.1410432  9942.657 0.1341092  53830.17  58095.23  -4265.059
## 17 -32961.77 0.1406059  9833.047 0.1314892  35705.61  53666.11 -17960.504
## 18 -29528.83 0.1405714  8927.937 0.1274205 201686.44 218734.09 -17047.654
## 19 -32483.42 0.1393552 10217.608 0.1254720 195275.12 169305.90  25969.224
## 20 -25311.76 0.1376699  9068.594 0.1138680 109147.99 130233.74 -21085.749
## 21 -24324.12 0.1373346  8976.553 0.1122103 100725.11 110517.87  -9792.764
## 22 -34365.25 0.1377457 11074.987 0.1190236 352927.26 406739.51 -53812.251
## 23 -31348.68 0.1398953  9596.777 0.1258756 172984.00 184629.81 -11645.809
## 24 -26768.71 0.1381600  9210.194 0.1163796 163086.82 175142.59 -12055.772
## 25 -24445.57 0.1377428  8853.962 0.1138774 135297.67 121443.26  13854.414
## 26 -23557.21 0.1364175  9150.846 0.1083667 105345.64  23607.41  81738.227
## 27 -32199.99 0.1421800  9044.967 0.1381093 177131.60 264255.80 -87124.202
## 28 -34187.15 0.1403639 10110.240 0.1306114 101156.10 107513.68  -6357.578
## 29 -24550.44 0.1368575  9201.108 0.1103988 140780.94 154336.87 -13555.925
## 30 -32460.09 0.1403442  9843.176 0.1299774 169354.89 167452.65   1902.241
## 31 -32785.57 0.1426214  8978.604 0.1403733 169511.29 136512.56  32998.733
## 32 -33521.84 0.1412824  9578.526 0.1335246 320690.10 359347.86 -38657.760
## 33 -31022.41 0.1404660  9517.480 0.1294437  92130.84 102279.03 -10148.189
## 34 -30787.76 0.1413306  9100.493 0.1331770 134116.66 151333.43 -17216.771
## 35 -33098.05 0.1419244  9246.219 0.1360654 657016.64 473521.89 183494.749
## 36 -24850.33 0.1363687  9448.400 0.1085874 109657.53 122695.11 -13037.582
## 37 -26776.79 0.1395888  8678.283 0.1220709 185422.94 189319.23  -3896.288
## 38 -26195.75 0.1365912  9661.294 0.1099462 204028.80  48718.60 155310.204
##    CV_Score Stud_residual Intercept_SE      x1_SE    x2_SE     x3_SE
## 1         0   -0.53465039     34811.27 0.01474746 7513.123 0.1133818
## 2         0    0.67273812     34516.15 0.01469888 7464.756 0.1131470
## 3         0   -0.05958752     34728.46 0.01471207 7524.653 0.1130906
## 4         0   -0.76689767     34689.72 0.01471423 7529.573 0.1131731
## 5         0   -1.25132013     34403.94 0.01470087 7460.134 0.1130791
## 6         0    0.93184770     34575.19 0.01469582 7473.406 0.1131839
## 7         0   -1.64290684     34500.29 0.01473431 7466.698 0.1131800
## 8         0    0.06355958     34542.61 0.01469566 7469.177 0.1131379
## 9         0   -0.21690063     34463.31 0.01470038 7472.725 0.1130713
## 10        0   -0.33101629     34552.14 0.01470687 7495.567 0.1131214
## 11        0   -0.41249811     34660.33 0.01471267 7522.379 0.1131701
## 12        0   -2.27261606     34552.82 0.01470790 7495.353 0.1131279
## 13        0   -0.37127377     34530.07 0.01470839 7486.124 0.1131316
## 14        0    2.04359957     35003.75 0.01473448 7578.528 0.1131211
## 15        0   -0.07658023     34487.96 0.01470087 7473.008 0.1130684
## 16        0   -0.07589497     34843.82 0.01471121 7523.599 0.1131712
## 17        0   -0.31277695     34669.32 0.01469037 7489.483 0.1131732
## 18        0   -0.29200311     34430.15 0.01472014 7461.076 0.1130777
## 19        0    0.44499897     34614.48 0.01468790 7487.121 0.1131082
## 20        0   -0.36104246     34519.26 0.01470816 7484.636 0.1131250
## 21        0   -0.16760181     34548.83 0.01470827 7488.987 0.1131421
## 22        0   -1.01497399     35037.55 0.01473767 7591.293 0.1131451
## 23        0   -0.19720384     34542.58 0.01470300 7483.373 0.1130718
## 24        0   -0.20478524     34483.35 0.01470522 7478.601 0.1131013
## 25        0    0.25052785     34493.83 0.01470467 7477.272 0.1131186
## 26        0    1.56281490     34656.23 0.01471089 7510.627 0.1132003
## 27        0   -1.50766378     34712.64 0.01469942 7496.442 0.1133484
## 28        0   -0.11679619     34796.12 0.01470342 7520.814 0.1131219
## 29        0   -0.23105134     34613.62 0.01471239 7504.047 0.1131734
## 30        0    0.03284715     34628.23 0.01468956 7482.471 0.1131645
## 31        0    0.58151347     34730.83 0.01470733 7498.629 0.1133662
## 32        0   -0.72441509     34706.57 0.01471847 7503.491 0.1131335
## 33        0   -0.17642092     34594.70 0.01469640 7476.867 0.1132044
## 34        0   -0.33189565     34650.29 0.01469259 7489.804 0.1132855
## 35        0    3.78631547     34650.86 0.01472080 7490.730 0.1131711
## 36        0   -0.22258439     34673.03 0.01471528 7518.638 0.1132077
## 37        0   -0.06640106     34388.42 0.01471638 7455.874 0.1130718
## 38        0    2.79222499     34653.91 0.01471435 7517.858 0.1131915
##    Intercept_TV    x1_TV    x2_TV     x3_TV  Local_R2
## 1    -0.9713879 9.722329 1.180754 1.2678272 0.7780017
## 2    -0.8810550 9.501317 1.301853 1.1073883 0.7820869
## 3    -0.9383840 9.440794 1.360903 1.0830784 0.7729180
## 4    -0.8376132 9.299626 1.355486 0.9909227 0.7676593
## 5    -0.7608030 9.436980 1.189125 1.0476035 0.7636866
## 6    -0.8981926 9.543145 1.286385 1.1350066 0.7824841
## 7    -0.9072790 9.662469 1.160086 1.2046576 0.7744262
## 8    -0.9043872 9.501296 1.324780 1.1121068 0.7801226
## 9    -0.8453156 9.462657 1.256614 1.0728115 0.7705748
## 10   -0.8032461 9.364595 1.279204 1.0171430 0.7670231
## 11   -0.8183794 9.303744 1.333994 0.9897071 0.7668356
## 12   -0.7870986 9.355986 1.268459 1.0108195 0.7658475
## 13   -0.7202624 9.351084 1.204906 1.0005901 0.7572555
## 14   -0.9881245 9.401593 1.428295 1.0819008 0.7734280
## 15   -0.8897957 9.520256 1.261440 1.1118982 0.7729545
## 16   -0.9910516 9.587466 1.321529 1.1850121 0.7772829
## 17   -0.9507474 9.571297 1.312914 1.1618402 0.7791635
## 18   -0.8576446 9.549593 1.196602 1.1268396 0.7715464
## 19   -0.9384344 9.487755 1.364691 1.1093090 0.7772890
## 20   -0.7332649 9.360102 1.211628 1.0065676 0.7598311
## 21   -0.7040506 9.337239 1.198634 0.9917637 0.7530563
## 22   -0.9808118 9.346506 1.458907 1.0519550 0.7727120
## 23   -0.9075374 9.514747 1.282413 1.1132363 0.7733288
## 24   -0.7762791 9.395298 1.231540 1.0289853 0.7654591
## 25   -0.7086941 9.367285 1.184117 1.0067075 0.7531666
## 26   -0.6797396 9.273236 1.218386 0.9572998 0.7459123
## 27   -0.9276158 9.672489 1.206568 1.2184491 0.7815057
## 28   -0.9824989 9.546344 1.344301 1.1546074 0.7762988
## 29   -0.7092711 9.302195 1.226153 0.9754840 0.7552952
## 30   -0.9373881 9.554007 1.315498 1.1485707 0.7795999
## 31   -0.9439905 9.697305 1.197366 1.2382293 0.7802287
## 32   -0.9658642 9.598984 1.276543 1.1802391 0.7758246
## 33   -0.8967388 9.557852 1.272924 1.1434511 0.7831529
## 34   -0.8885281 9.619170 1.215051 1.1755879 0.7834012
## 35   -0.9551869 9.641079 1.234355 1.2022975 0.7762592
## 36   -0.7167051 9.267146 1.256664 0.9591868 0.7567242
## 37   -0.7786573 9.485266 1.163953 1.0795874 0.7649008
## 38   -0.7559249 9.282858 1.285113 0.9713287 0.7621323
##                          geometry t_stat_variable1 p_value_variable1
## 1  MULTIPOLYGON (((15706156 -4...         9.722329      1.762142e-11
## 2  MULTIPOLYGON (((14602040 -4...         9.501317      3.177393e-11
## 3  MULTIPOLYGON (((15426453 -4...         9.440794      3.738233e-11
## 4  MULTIPOLYGON (((15334983 -4...         9.299626      5.471784e-11
## 5  MULTIPOLYGON (((16047956 -4...         9.436980      3.776782e-11
## 6  MULTIPOLYGON (((14913039 -5...         9.543145      2.840557e-11
## 7  MULTIPOLYGON (((15756655 -4...         9.662469      2.065913e-11
## 8  MULTIPOLYGON (((14881516 -4...         9.501296      3.177573e-11
## 9  MULTIPOLYGON (((15535174 -4...         9.462657      3.524852e-11
## 10 MULTIPOLYGON (((15581004 -4...         9.364595      4.590286e-11
## 11 MULTIPOLYGON (((15459019 -4...         9.303744      5.411120e-11
## 12 MULTIPOLYGON (((15624671 -4...         9.355986      4.698239e-11
## 13 MULTIPOLYGON (((15909582 -4...         9.351084      4.760857e-11
## 14 MULTIPOLYGON (((15329740 -4...         9.401593      4.154325e-11
## 15 MULTIPOLYGON (((15660042 -4...         9.520256      3.020112e-11
## 16 MULTIPOLYGON (((15390607 -4...         9.587466      2.523149e-11
## 17 MULTIPOLYGON (((15222037 -4...         9.571297      2.634530e-11
## 18 MULTIPOLYGON (((15770125 -4...         9.549593      2.791964e-11
## 19 MULTIPOLYGON (((14988999 -4...         9.487755      3.295124e-11
## 20 MULTIPOLYGON (((15829759 -4...         9.360102      4.646304e-11
## 21 MULTIPOLYGON (((15876026 -4...         9.337239      4.942350e-11
## 22 MULTIPOLYGON (((15139993 -4...         9.346506      4.820105e-11
## 23 MULTIPOLYGON (((15494289 -4...         9.514747      3.065026e-11
## 24 MULTIPOLYGON (((15695383 -4...         9.395298      4.225410e-11
## 25 MULTIPOLYGON (((15997252 -4...         9.367285      4.557069e-11
## 26 MULTIPOLYGON (((15785772 -3...         9.273236      5.877406e-11
## 27 MULTIPOLYGON (((15335201 -5...         9.672489      2.011570e-11
## 28 MULTIPOLYGON (((15279844 -4...         9.546344      2.816345e-11
## 29 MULTIPOLYGON (((15687183 -3...         9.302195      5.433858e-11
## 30 MULTIPOLYGON (((15041209 -4...         9.554007      2.759191e-11
## 31 MULTIPOLYGON (((15436861 -5...         9.697305      1.883175e-11
## 32 MULTIPOLYGON (((15532695 -4...         9.598984      2.446744e-11
## 33 MULTIPOLYGON (((14725379 -5...         9.557852      2.730959e-11
## 34 MULTIPOLYGON (((15248766 -5...         9.619170      2.318465e-11
## 35 MULTIPOLYGON (((15628962 -4...         9.641079      2.186966e-11
## 36 MULTIPOLYGON (((15575336 -3...         9.267146      5.975271e-11
## 37 MULTIPOLYGON (((16133472 -4...         9.485266      3.317215e-11
## 38 MULTIPOLYGON (((15492441 -4...         9.282858      5.726086e-11
##    t_stat_variable2 p_value_variable2 t_stat_variable3 p_value_variable3
## 1          1.180754         0.2456625        1.2678272         0.2132293
## 2          1.301853         0.2014701        1.1073883         0.2756788
## 3          1.360903         0.1822436        1.0830784         0.2861790
## 4          1.355486         0.1839460        0.9909227         0.3285249
## 5          1.189125         0.2423956        1.0476035         0.3020022
## 6          1.286385         0.2067531        1.1350066         0.2640859
## 7          1.160086         0.2538663        1.2046576         0.2364185
## 8          1.324780         0.1938290        1.1121068         0.2736729
## 9          1.256614         0.2172159        1.0728115         0.2906972
## 10         1.279204         0.2092414        1.0171430         0.3160653
## 11         1.333994         0.1908217        0.9897071         0.3291105
## 12         1.268459         0.2130063        1.0108195         0.3190402
## 13         1.204906         0.2363238        1.0005901         0.3238929
## 14         1.428295         0.1620706        1.0819008         0.2866947
## 15         1.261440         0.2154934        1.1118982         0.2737614
## 16         1.321529         0.1948987        1.1850121         0.2439968
## 17         1.312914         0.1977556        1.1618402         0.2531624
## 18         1.196602         0.2395048        1.1268396         0.2674770
## 19         1.364691         0.1810602        1.1093090         0.2748611
## 20         1.211628         0.2337718        1.0065676         0.3210512
## 21         1.198634         0.2387235        0.9917637         0.3281201
## 22         1.458907         0.1535078        1.0519550         0.3000291
## 23         1.282413         0.2081265        1.1132363         0.2731943
## 24         1.231540         0.2263320        1.0289853         0.3105454
## 25         1.184117         0.2443464        1.0067075         0.3209848
## 26         1.218386         0.2312265        0.9572998         0.3449822
## 27         1.206568         0.2356908        1.2184491         0.2312030
## 28         1.344301         0.1874998        1.1546074         0.2560739
## 29         1.226153         0.2283271        0.9754840         0.3360146
## 30         1.315498         0.1968954        1.1485707         0.2585225
## 31         1.197366         0.2392107        1.2382293         0.2238724
## 32         1.276543         0.2101691        1.1802391         0.2458646
## 33         1.272924         0.2114358        1.1434511         0.2606123
## 34         1.215051         0.2324801        1.1755879         0.2476947
## 35         1.234355         0.2252945        1.2022975         0.2373196
## 36         1.256664         0.2171980        0.9591868         0.3440443
## 37         1.163953         0.2523166        1.0795874         0.2877097
## 38         1.285113         0.2071925        0.9713287         0.3380499
koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x1), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X1",
       fill = "Koefisien X1")  

# Membuat kuantil untuk koefisien X1
koefisien_merged$X1_quantile <- cut(koefisien_merged$x1, 
                                    breaks = classIntervals(koefisien_merged$x1, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X1_quantile), color = NA) +  # Menggunakan X1_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X1") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X1 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x2), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X2",
       fill = "Koefisien X2")  

# Membuat kuantil untuk koefisien X2
koefisien_merged$X2_quantile <- cut(koefisien_merged$x2, 
                                    breaks = classIntervals(koefisien_merged$x2, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X2_quantile), color = NA) +  # Menggunakan X2_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X2") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X2 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x3), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X3",
       fill = "Koefisien X3")  

# Membuat kuantil untuk koefisien X3
koefisien_merged$X3_quantile <- cut(koefisien_merged$x3, 
                                    breaks = classIntervals(koefisien_merged$x3, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X3_quantile), color = NA) +  # Menggunakan X3_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X3") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X3 Berdasarkan Kuantil")

Koefisien Model GWR Kernel Fixed Bisquare

## Ekstraksi koefisien lokal untuk setiap variabel dari model GWR
koefisien_gwr <- as.data.frame(gwr_fixed_bisquare$SDF)

# Hitung t-statistic untuk masing-masing variabel
t_stat_variable1 <- koefisien_gwr$x1 / koefisien_gwr$x1_SE
t_stat_variable2 <- koefisien_gwr$x2 / koefisien_gwr$x2_SE
t_stat_variable3 <- koefisien_gwr$x3 / koefisien_gwr$x3_SE

# Asumsi bahwa kita memiliki derajat kebebasan n-k (n adalah jumlah observasi dan k adalah jumlah variabel dalam model)
n <- nrow(koefisien_gwr)  # jumlah observasi
k <- 3 # jumlah variabel
df <- n - k  # derajat kebebasan

# Hitung p-value berdasarkan t-statistic
p_value_variable1 <- 2 * pt(-abs(t_stat_variable1), df)
p_value_variable2 <- 2 * pt(-abs(t_stat_variable2), df)
p_value_variable3 <- 2 * pt(-abs(t_stat_variable3), df)

# Buat data frame untuk menyimpan t-statistic dan p-value, per kabupaten/kota
koefisien_gwr$t_stat_variable1 <- t_stat_variable1
koefisien_gwr$p_value_variable1 <- p_value_variable1

koefisien_gwr$t_stat_variable2 <- t_stat_variable2
koefisien_gwr$p_value_variable2 <- p_value_variable2

koefisien_gwr$t_stat_variable3 <- t_stat_variable3
koefisien_gwr$p_value_variable3 <- p_value_variable3

# Tampilkan hasil
print(koefisien_gwr)
##      Intercept         x1          x2          x3         y      yhat
## 1     7627.360 0.17123698 -16127.1020  0.80119580 152259.02 116945.88
## 2  -187680.347 0.12134767  74261.0747 -1.23422805 305312.85 305097.60
## 3   -93379.468 0.13325845  23492.1026  0.14250979  52062.68  55245.29
## 4  -120311.926 0.09610822  37248.8246  0.01691118 150990.10 183272.36
## 5   -15993.728 0.12721156   6697.6680  0.03227642 133639.42 185635.73
## 6  -105920.344 0.13547996  55730.8197 -1.96465002 177160.17 169851.88
## 7    33898.801 0.20583760 -27019.3702  0.64419439 144238.33 210399.95
## 8   -62289.110 0.13655280  32681.0487 -0.89059034 377298.02 388913.10
## 9  -106302.973 0.14182911  22700.0761  0.13923380 193583.44 195515.55
## 10 -116263.137 0.10806388  33090.6384  0.04487932 241778.92 256877.80
## 11 -123636.726 0.09425299  37998.9084  0.01499400  27988.20  90781.77
## 12  -95256.174 0.10294843  30062.5594  0.02284139  63461.92  69098.69
## 13   67600.068 0.07561897    670.1552 -0.06789192  44750.39  80896.62
## 14  -83976.733 0.12827933  23143.4134  0.13578254 284095.41 196676.71
## 15  -83104.934 0.15769516  13926.6204  0.20575447  35882.93  16274.24
## 16  -50351.532 0.14882065   6394.1987  0.54017023  53830.17  43436.88
## 17  -19041.346 0.13548480  -2085.3245  0.99057362  35705.61  62068.98
## 18  -45486.964 0.19780678  -5408.9424  0.26305506 201686.44 208724.37
## 19  -32263.486 0.13321209   2353.3142  1.00872343 195275.12 164687.16
## 20   52433.504 0.08131642   3137.0235 -0.06013953 109147.99 128876.16
## 21   84854.313 0.06778810  -2397.6662 -0.07628065 100725.11 118577.99
## 22  -78449.297 0.11874117  24703.9891  0.08862423 352927.26 387531.07
## 23  -84444.432 0.15272940  15765.7452  0.20130650 172984.00 181866.08
## 24  -79623.572 0.11567564  23784.3061  0.03906461 163086.82 162903.65
## 25   82500.507 0.08142074  -5709.0860 -0.05494047 135297.67 138987.87
## 26  102373.660 0.02698968    903.0355 -0.13675094 105345.64 104800.60
## 27   -1334.798 0.15355787  -8427.3360  0.44976890 177131.60 253303.89
## 28  -65188.281 0.14763536  12264.8132  0.35433752 101156.10  91863.65
## 29   73318.689 0.06082378   2916.3347 -0.08704174 140780.94 143774.52
## 30  -20725.525 0.13668313    834.5984  0.83163342 169354.89 171002.40
## 31    1059.604 0.16625354 -13682.8101  0.70927260 169511.29 145807.87
## 32  -55049.660 0.16467252   5511.4073  0.35447137 320690.10 382684.85
## 33  -72282.321 0.13705320  45327.2163 -1.79337534  92130.84 106162.25
## 34 -124278.449 0.26879375  47995.0068 -3.50650733 134116.66 134065.21
## 35  -31373.306 0.17223207  -3495.3214  0.51341223 657016.64 569523.49
## 36   55785.927 0.05895636   7979.3593 -0.08820645 109657.53 133031.01
## 37  -15988.678 0.15445783  -1675.1949  0.10128929 185422.94 171233.71
## 38  -40246.981 0.08190527  24065.3285 -0.03635733 204028.80 103482.96
##        residual CV_Score Stud_residual Intercept_SE      x1_SE     x2_SE
## 1   35313.13571        0   1.199936169     53689.14 0.02970751 12083.925
## 2     215.25436        0   0.019974296    195389.82 0.03766663 67180.798
## 3   -3182.61291        0  -0.066161678     49007.16 0.01662355 10151.474
## 4  -32282.25814        0  -0.683425089     57248.47 0.01989650 11458.420
## 5  -51996.30659        0  -1.148196987     69652.98 0.02737496 14711.722
## 6    7308.28243        0   0.380041442    129741.31 0.02960184 43729.639
## 7  -66161.62254        0  -2.165515182     60091.15 0.03770279 13680.905
## 8  -11615.08194        0  -0.688811682     88557.39 0.02737075 33409.438
## 9   -1932.11075        0  -0.040024377     50389.98 0.01647091 10063.080
## 10 -15098.88208        0  -0.328942998     48683.91 0.01779645 10112.652
## 11 -62793.56776        0  -1.403066374     57037.51 0.01997792 11469.052
## 12  -5636.76733        0  -0.508510087     47116.08 0.01879025  9976.794
## 13 -36146.22759        0  -1.086667233     65238.16 0.03166301 13519.613
## 14  87418.69570        0   2.050863657     48817.66 0.01705454 10154.366
## 15  19608.68868        0   0.431720765     49430.99 0.01734012 10041.363
## 16  10393.28580        0   0.239351553     44731.75 0.01696448  9689.752
## 17 -26363.36647        0  -0.610818911     46328.58 0.01784481 11371.975
## 18  -7037.92787        0  -0.152721588     58422.71 0.02361307 12580.207
## 19  30587.96229        0   0.671796520     52934.38 0.01793229 13838.833
## 20 -19728.16831        0  -0.407523674     66348.39 0.02892646 13546.310
## 21 -17852.87644        0  -0.376388632     64875.78 0.03714132 13670.334
## 22 -34603.80627        0  -1.128091912     50211.31 0.01797544 10310.744
## 23  -8882.08435        0  -0.177632225     48606.69 0.01693851  9937.909
## 24    183.16825        0   0.003720492     49576.08 0.01944705 10628.636
## 25  -3690.19593        0  -0.137015043     74729.64 0.04191426 15424.850
## 26    545.03844        0   0.035966445     76685.69 0.05424966 14294.659
## 27 -76172.28943        0  -2.464361104     60747.77 0.04226166 13490.144
## 28   9292.44541        0   0.247997773     45650.40 0.01674817  9692.151
## 29  -2993.57772        0  -0.065115319     63614.34 0.03261560 12951.243
## 30  -1647.51155        0  -0.035971115     47981.59 0.01880214 12227.521
## 31  23703.42385        0   1.086204043     61859.94 0.03753988 13462.369
## 32 -61994.74599        0  -1.445073758     45186.22 0.01781388  9619.868
## 33 -14031.40967        0  -0.485932956     93124.43 0.03035021 30305.449
## 34     51.44869        0   0.006603670    210793.22 0.24493499 41572.938
## 35  87493.14735        0   2.972461542     45790.06 0.01930568 10016.288
## 36 -23373.47876        0  -0.500371113     66640.96 0.03131603 13727.553
## 37  14189.22947        0   0.368609640     75040.91 0.02918621 16393.967
## 38 100545.84442        0   2.576081954     60786.88 0.02305426 12714.530
##        x3_SE Intercept_TV     x1_TV       x2_TV      x3_TV  Local_R2
## 1  0.4069268   0.14206522 5.7640967 -1.33459140  1.9688942 0.9257031
## 2  3.4920565  -0.96054314 3.2216224  1.10539137 -0.3534387 0.9945487
## 3  0.1037456  -1.90542489 8.0162462  2.31415690  1.3736473 0.9051878
## 4  0.1110859  -2.10157443 4.8304081  3.25078190  0.1522352 0.7980811
## 5  0.1114848  -0.22962015 4.6470046  0.45526064  0.2895140 0.8543168
## 6  1.7803975  -0.81639644 4.5767413  1.27444044 -1.1034895 0.9796166
## 7  0.4260258   0.56412302 5.4594796 -1.97496952  1.5121018 0.9288564
## 8  2.2964930  -0.70337565 4.9890044  0.97819809 -0.3878045 0.9782910
## 9  0.1034677  -2.10960541 8.6108841  2.25577818  1.3456745 0.9082723
## 10 0.1066706  -2.38812262 6.0722140  3.27220191  0.4207280 0.8384787
## 11 0.1110176  -2.16763907 4.7178585  3.31316913  0.1350597 0.7893174
## 12 0.1076903  -2.02173382 5.4788204  3.01324844  0.2121025 0.8177470
## 13 0.1152162   1.03620435 2.3882430  0.04956911 -0.5892568 0.7843712
## 14 0.1049193  -1.72021207 7.5217108  2.27915888  1.2941611 0.8972920
## 15 0.1039937  -1.68123150 9.0942384  1.38692533  1.9785280 0.9249857
## 16 0.1530342  -1.12563294 8.7724852  0.65989295  3.5297362 0.9297672
## 17 0.3279943  -0.41100650 7.5923926 -0.18337399  3.0200939 0.9288946
## 18 0.1144798  -0.77858363 8.3770029 -0.42995654  2.2978289 0.9302526
## 19 0.4593110  -0.60949964 7.4286162  0.17005149  2.1961667 0.9208096
## 20 0.1144952   0.79027540 2.8111434  0.23157772 -0.5252580 0.7799498
## 21 0.1162575   1.30795059 1.8251399 -0.17539192 -0.6561353 0.8105544
## 22 0.1068233  -1.56238288 6.6057446  2.39594633  0.8296341 0.8754523
## 23 0.1036217  -1.73730060 9.0166942  1.58642481  1.9427067 0.9232901
## 24 0.1065023  -1.60608838 5.9482356  2.23775716  0.3667959 0.8457222
## 25 0.1226725   1.10398635 1.9425549 -0.37012263 -0.4478630 0.8427913
## 26 0.1200834   1.33497745 0.4975087  0.06317293 -1.1387993 0.7789525
## 27 0.5851399  -0.02197279 3.6335028 -0.62470319  0.7686519 0.8359186
## 28 0.1178099  -1.42798930 8.8150134  1.26543763  3.0077046 0.9271557
## 29 0.1147970   1.15254970 1.8648676  0.22517799 -0.7582232 0.7433145
## 30 0.3594944  -0.43194741 7.2695523  0.06825574  2.3133419 0.9307351
## 31 0.5082428   0.01712908 4.4287183 -1.01637463  1.3955389 0.9027032
## 32 0.1172331  -1.21828433 9.2440545  0.57291925  3.0236452 0.9329020
## 33 1.2753276  -0.77619078 4.5157246  1.49567873 -1.4062076 0.9715867
## 34 3.4117651  -0.58957517 1.0974086  1.15447715 -1.0277693 0.5048319
## 35 0.1625050  -0.68515542 8.9213179 -0.34896373  3.1593621 0.9340049
## 36 0.1149293   0.83711166 1.8826259  0.58126594 -0.7674846 0.6914624
## 37 0.1287484  -0.21306615 5.2921501 -0.10218362  0.7867226 0.8180990
## 38 0.1126245  -0.66209974 3.5527181  1.89274227 -0.3228189 0.7317458
##                          geometry t_stat_variable1 p_value_variable1
## 1  MULTIPOLYGON (((15706156 -4...        5.7640967      1.579852e-06
## 2  MULTIPOLYGON (((14602040 -4...        3.2216224      2.754522e-03
## 3  MULTIPOLYGON (((15426453 -4...        8.0162462      1.961828e-09
## 4  MULTIPOLYGON (((15334983 -4...        4.8304081      2.674939e-05
## 5  MULTIPOLYGON (((16047956 -4...        4.6470046      4.637361e-05
## 6  MULTIPOLYGON (((14913039 -5...        4.5767413      5.720435e-05
## 7  MULTIPOLYGON (((15756655 -4...        5.4594796      3.985813e-06
## 8  MULTIPOLYGON (((14881516 -4...        4.9890044      1.658451e-05
## 9  MULTIPOLYGON (((15535174 -4...        8.6108841      3.642012e-10
## 10 MULTIPOLYGON (((15581004 -4...        6.0722140      6.203231e-07
## 11 MULTIPOLYGON (((15459019 -4...        4.7178585      3.750751e-05
## 12 MULTIPOLYGON (((15624671 -4...        5.4788204      3.758409e-06
## 13 MULTIPOLYGON (((15909582 -4...        2.3882430      2.245738e-02
## 14 MULTIPOLYGON (((15329740 -4...        7.5217108      8.210768e-09
## 15 MULTIPOLYGON (((15660042 -4...        9.0942384      9.568950e-11
## 16 MULTIPOLYGON (((15390607 -4...        8.7724852      2.321893e-10
## 17 MULTIPOLYGON (((15222037 -4...        7.5923926      6.680641e-09
## 18 MULTIPOLYGON (((15770125 -4...        8.3770029      7.027033e-10
## 19 MULTIPOLYGON (((14988999 -4...        7.4286162      1.078183e-08
## 20 MULTIPOLYGON (((15829759 -4...        2.8111434      8.033171e-03
## 21 MULTIPOLYGON (((15876026 -4...        1.8251399      7.652405e-02
## 22 MULTIPOLYGON (((15139993 -4...        6.6057446      1.240355e-07
## 23 MULTIPOLYGON (((15494289 -4...        9.0166942      1.183373e-10
## 24 MULTIPOLYGON (((15695383 -4...        5.9482356      9.033470e-07
## 25 MULTIPOLYGON (((15997252 -4...        1.9425549      6.015000e-02
## 26 MULTIPOLYGON (((15785772 -3...        0.4975087      6.219417e-01
## 27 MULTIPOLYGON (((15335201 -5...        3.6335028      8.880807e-04
## 28 MULTIPOLYGON (((15279844 -4...        8.8150134      2.063621e-10
## 29 MULTIPOLYGON (((15687183 -3...        1.8648676      7.060250e-02
## 30 MULTIPOLYGON (((15041209 -4...        7.2695523      1.720720e-08
## 31 MULTIPOLYGON (((15436861 -5...        4.4287183      8.884677e-05
## 32 MULTIPOLYGON (((15532695 -4...        9.2440545      6.361692e-11
## 33 MULTIPOLYGON (((14725379 -5...        4.5157246      6.861075e-05
## 34 MULTIPOLYGON (((15248766 -5...        1.0974086      2.799557e-01
## 35 MULTIPOLYGON (((15628962 -4...        8.9213179      1.538341e-10
## 36 MULTIPOLYGON (((15575336 -3...        1.8826259      6.808502e-02
## 37 MULTIPOLYGON (((16133472 -4...        5.2921501      6.623998e-06
## 38 MULTIPOLYGON (((15492441 -4...        3.5527181      1.113229e-03
##    t_stat_variable2 p_value_variable2 t_stat_variable3 p_value_variable3
## 1       -1.33459140       0.190627834        1.9688942       0.056923573
## 2        1.10539137       0.276530888       -0.3534387       0.725879640
## 3        2.31415690       0.026650604        1.3736473       0.178286272
## 4        3.25078190       0.002546853        0.1522352       0.879875661
## 5        0.45526064       0.651733454        0.2895140       0.773896218
## 6        1.27444044       0.210904208       -1.1034895       0.277344107
## 7       -1.97496952       0.056201054        1.5121018       0.139485657
## 8        0.97819809       0.334689669       -0.3878045       0.700509310
## 9        2.25577818       0.030438240        1.3456745       0.187060644
## 10       3.27220191       0.002403907        0.4207280       0.676525908
## 11       3.31316913       0.002151569        0.1350597       0.893338438
## 12       3.01324844       0.004780940        0.2121025       0.833257452
## 13       0.04956911       0.960747564       -0.5892568       0.559473637
## 14       2.27915888       0.028866839        1.2941611       0.204084266
## 15       1.38692533       0.174234669        1.9785280       0.055781561
## 16       0.65989295       0.513641909        3.5297362       0.001186748
## 17      -0.18337399       0.855562778        3.0200939       0.004696310
## 18      -0.42995654       0.669862996        2.2978289       0.027664769
## 19       0.17005149       0.865948804        2.1961667       0.034796741
## 20       0.23157772       0.818214612       -0.5252580       0.602715735
## 21      -0.17539192       0.861782470       -0.6561353       0.516027720
## 22       2.39594633       0.022057615        0.8296341       0.412368639
## 23       1.58642481       0.121637610        1.9427067       0.060130953
## 24       2.23775716       0.031701273        0.3667959       0.715979610
## 25      -0.37012263       0.713521522       -0.4478630       0.657012068
## 26       0.06317293       0.949988215       -1.1387993       0.262521687
## 27      -0.62470319       0.536217435        0.7686519       0.447255882
## 28       1.26543763       0.214074219        3.0077046       0.004850530
## 29       0.22517799       0.823150427       -0.7582232       0.453392923
## 30       0.06825574       0.945970516        2.3133419       0.026700423
## 31      -1.01637463       0.316425790        1.3955389       0.171644974
## 32       0.57291925       0.570362061        3.0236452       0.004652966
## 33       1.49567873       0.143700667       -1.4062076       0.168479166
## 34       1.15447715       0.256126553       -1.0277693       0.311109194
## 35      -0.34896373       0.729207246        3.1593621       0.003253172
## 36       0.58126594       0.564786099       -0.7674846       0.447940337
## 37      -0.10218362       0.919194131        0.7867226       0.436739087
## 38       1.89274227       0.066685602       -0.3228189       0.748753118
koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x1), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X1",
       fill = "Koefisien X1")  

# Membuat kuantil untuk koefisien X1
koefisien_merged$X1_quantile <- cut(koefisien_merged$x1, 
                                    breaks = classIntervals(koefisien_merged$x3, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X1_quantile), color = NA) +  # Menggunakan X1_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X1") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X1 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x2), color = NA) + 
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X2",
       fill = "Koefisien X2") 

# Membuat kuantil untuk koefisien X2
koefisien_merged$X2_quantile <- cut(koefisien_merged$x2, 
                                    breaks = classIntervals(koefisien_merged$x2, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X2_quantile), color = NA) +  # Menggunakan X2_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X2") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X2 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x3), color = NA) + 
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +  
  labs(title = "Peta Koefisien Variabel X3",
       fill = "Koefisien X3") 

# Membuat kuantil untuk koefisien X3
koefisien_merged$X3_quantile <- cut(koefisien_merged$x3, 
                                    breaks = classIntervals(koefisien_merged$x3, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X3_quantile), color = NA) +  # Menggunakan X3_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X3") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X3 Berdasarkan Kuantil")

Koefisien Model GWR Kernel Adaptive Bisquare

## Ekstraksi koefisien lokal untuk setiap variabel dari model GWR
koefisien_gwr <- as.data.frame(gwr_adaptive_bisquare$SDF)

# Hitung t-statistic untuk masing-masing variabel
t_stat_variable1 <- koefisien_gwr$x1 / koefisien_gwr$x1_SE
t_stat_variable2 <- koefisien_gwr$x2 / koefisien_gwr$x2_SE
t_stat_variable3 <- koefisien_gwr$x3 / koefisien_gwr$x3_SE

# Asumsi bahwa kita memiliki derajat kebebasan n-k (n adalah jumlah observasi dan k adalah jumlah variabel dalam model)
n <- nrow(koefisien_gwr)  # jumlah observasi
k <- 3  # jumlah variabel
df <- n - k  # derajat kebebasan

# Hitung p-value berdasarkan t-statistic
p_value_variable1 <- 2 * pt(-abs(t_stat_variable1), df)
p_value_variable2 <- 2 * pt(-abs(t_stat_variable2), df)
p_value_variable3 <- 2 * pt(-abs(t_stat_variable3), df)

# Buat data frame untuk menyimpan t-statistic dan p-value, per kabupaten/kota
koefisien_gwr$t_stat_variable1 <- t_stat_variable1
koefisien_gwr$p_value_variable1 <- p_value_variable1

koefisien_gwr$t_stat_variable2 <- t_stat_variable2
koefisien_gwr$p_value_variable2 <- p_value_variable2

koefisien_gwr$t_stat_variable3 <- t_stat_variable3
koefisien_gwr$p_value_variable3 <- p_value_variable3

# Tampilkan hasil
print(koefisien_gwr)
##      Intercept         x1          x2          x3         y      yhat
## 1    -6828.136 0.16401143 -10606.4211  0.73242041 152259.02 126901.40
## 2   -31967.635 0.13745334   9087.0081  0.42739926 305312.85 275852.05
## 3   -93664.298 0.13266902  23690.1761  0.14176500  52062.68  55657.36
## 4  -122899.635 0.09467291  38048.8344  0.01427508 150990.10 182724.87
## 5   -40232.821 0.13636222  10152.9560  0.06195065 133639.42 191689.10
## 6   -26907.161 0.13905195   5866.9667  0.50485296 177160.17 122352.74
## 7   -22533.782 0.19540399 -10553.5450  0.38337660 144238.33 218227.69
## 8   -27424.031 0.13728974   5938.0010  0.58177529 377298.02 372680.63
## 9  -110711.540 0.14348646  23197.2806  0.13604799 193583.44 195536.71
## 10 -134496.489 0.09935824  38119.2010  0.03162157 241778.92 252843.32
## 11 -130683.773 0.09256944  39663.5886  0.01392325  27988.20  92139.70
## 12 -137029.010 0.09179609  39843.9341  0.01708653  63461.92  60680.71
## 13   43761.454 0.08643148   4520.2247 -0.05098154  44750.39  83218.31
## 14  -84604.490 0.12937411  23074.7984  0.13690019 284095.41 196630.04
## 15  -80992.409 0.16423947  11788.8550  0.22736551  35882.93  10437.70
## 16  -50445.358 0.14889303   6435.9942  0.53701903  53830.17  43442.79
## 17  -17912.656 0.13555643  -2383.5298  0.98553777  35705.61  61572.86
## 18  -49756.331 0.19440829  -3545.0544  0.25409826 201686.44 209598.33
## 19  -46436.567 0.13661970  11289.7736  0.42391114 195275.12 166647.73
## 20   27502.696 0.09122474   7047.3539 -0.03984665 109147.99 132266.66
## 21   54813.346 0.08226521   2994.8123 -0.05928400 100725.11 121421.42
## 22  -82191.039 0.12441130  24278.0646  0.10441098 352927.26 397435.19
## 23  -85031.612 0.15747168  14576.3401  0.22730514 172984.00 183506.57
## 24  -73747.308 0.10736894  23869.9192  0.01831197 163086.82 159220.96
## 25   51563.038 0.08994239   1808.9319 -0.04503604 135297.67 133953.29
## 26   53947.155 0.07711177   4936.9019 -0.06863887 105345.64  75870.35
## 27  -11430.781 0.14487075  -5604.7100  0.75732174 177131.60 279513.83
## 28  -65018.752 0.14745897  12136.1180  0.36612039 101156.10  91938.14
## 29   42335.881 0.08058157   6662.3360 -0.06149302 140780.94 150136.44
## 30  -17265.722 0.13634364  -1028.7452  0.89869650 169354.89 170444.53
## 31   -4772.296 0.14774829  -9062.1459  0.84120959 169511.29 137346.69
## 32  -53684.936 0.16488177   4918.6115  0.38206710 320690.10 383235.23
## 33  -26978.313 0.14024985   5493.5588  0.47971624  92130.84 105691.10
## 34  -24643.420 0.14563367   1419.1924  0.49054392 134116.66 162617.30
## 35  -40219.329 0.17250888   -499.7258  0.40230917 657016.64 554432.35
## 36   23798.940 0.08166286  11076.1219 -0.05746812 109657.53 132886.23
## 37  -42873.297 0.17471052   -119.7189  0.15637017 185422.94 179516.42
## 38  -28470.434 0.08595308  21054.8745 -0.03597470 204028.80  98728.34
##       residual CV_Score Stud_residual Intercept_SE      x1_SE     x2_SE
## 1    25357.624        0    0.67583361     48579.99 0.02230538 11069.370
## 2    29460.800        0    0.64523316     44370.12 0.02033483 11118.583
## 3    -3594.684        0   -0.07230895     50944.78 0.01724190 10555.170
## 4   -31734.772        0   -0.65808851     60193.88 0.02077007 11990.863
## 5   -58049.677        0   -1.21643654     61251.67 0.02358173 13388.456
## 6    54807.423        0    1.18814339     42728.99 0.02001424 10553.095
## 7   -73989.363        0   -1.77942991     49297.80 0.02269851 11168.170
## 8     4617.388        0    0.13691663     44103.89 0.01848815 10430.510
## 9    -1953.274        0   -0.04034022     55739.27 0.01823413 11134.006
## 10  -11064.403        0   -0.24796514     59454.19 0.02007457 11974.440
## 11  -64151.500        0   -1.40760599     61344.39 0.02094421 12228.599
## 12    2781.214        0    0.23205281     75257.86 0.02303366 14787.553
## 13  -38467.922        0   -0.99854736     59390.86 0.02585435 12553.956
## 14   87465.366        0    1.95705532     49648.93 0.01714650 10305.520
## 15   25445.226        0    0.58150804     55001.21 0.01955555 11241.315
## 16   10387.376        0    0.22874975     45895.15 0.01740119  9938.190
## 17  -25867.248        0   -0.56935994     46299.67 0.01770032 11285.588
## 18   -7911.894        0   -0.16547009     57585.82 0.02319787 12266.960
## 19   28627.388        0    0.58117869     46904.19 0.01668605 10191.789
## 20  -23118.670        0   -0.46160816     58190.03 0.02485522 12370.059
## 21  -20696.309        0   -0.40919726     60200.03 0.02645956 12639.505
## 22  -44507.934        0   -1.18184986     49475.93 0.01681374 10166.848
## 23  -10522.566        0   -0.20904616     54963.38 0.01887746 11246.822
## 24    3865.861        0    0.07845981     63811.56 0.02309250 13092.013
## 25    1344.377        0    0.03548275     60562.39 0.02736486 12945.128
## 26   29475.286        0    1.04533070     60595.02 0.02462780 12479.395
## 27 -102382.228        0   -2.22216881     40937.59 0.01874351  9947.866
## 28    9217.962        0    0.23235645     47065.57 0.01730147 10010.597
## 29   -9355.497        0   -0.18717826     58148.52 0.02414379 12128.018
## 30   -1089.645        0   -0.02217843     46129.58 0.01778946 11363.913
## 31   32164.597        0    0.78962746     43596.67 0.02091842 10436.732
## 32  -62545.131        0   -1.41436762     47037.72 0.01848187 10019.286
## 33  -13560.258        0   -0.29105312     43126.58 0.02021217 10656.445
## 34  -28500.636        0   -0.91396532     45619.33 0.01992992 11126.222
## 35  102584.290        0    3.13062568     45445.99 0.01899249  9867.746
## 36  -23228.704        0   -0.46107696     56461.57 0.02259422 11783.196
## 37    5906.522        0    0.13273445     61087.08 0.02419323 13540.776
## 38  105300.456        0    2.46551573     51839.61 0.02173439 11003.440
##        x3_SE Intercept_TV    x1_TV        x2_TV      x3_TV  Local_R2
## 1  0.2908601   -0.1405545 7.353000 -0.958177491  2.5181195 0.8881638
## 2  0.3842387   -0.7204767 6.759504  0.817281123  1.1123276 0.9110713
## 3  0.1068876   -1.8385456 7.694570  2.244414521  1.3262997 0.8824924
## 4  0.1147945   -2.0417296 4.558142  3.173152353  0.1243534 0.8065279
## 5  0.1092834   -0.6568444 5.782536  0.758336566  0.5668807 0.8131295
## 6  0.3620902   -0.6297168 6.947651  0.555947477  1.3942742 0.8527132
## 7  0.1604878   -0.4570950 8.608669 -0.944966362  2.3888206 0.8883628
## 8  0.2901027   -0.6218053 7.425823  0.569291508  2.0054118 0.8906188
## 9  0.1080410   -1.9862394 7.869114  2.083462238  1.2592260 0.8819376
## 10 0.1124953   -2.2621868 4.949459  3.183380725  0.2810924 0.8308693
## 11 0.1149116   -2.1303295 4.419811  3.243510406  0.1211649 0.7963909
## 12 0.1162349   -1.8207933 3.985302  2.694423685  0.1470000 0.8128125
## 13 0.1149336    0.7368382 3.343015  0.360063757 -0.4435739 0.7092795
## 14 0.1072698   -1.7040547 7.545221  2.239071792  1.2762233 0.8793928
## 15 0.1089910   -1.4725568 8.398613  1.048707867  2.0860948 0.8947219
## 16 0.1563845   -1.0991436 8.556485  0.647602234  3.4339651 0.8995681
## 17 0.3261215   -0.3868852 7.658415 -0.211201219  3.0219956 0.8914211
## 18 0.1150656   -0.8640378 8.380436 -0.288992080  2.2082912 0.8981620
## 19 0.1566452   -0.9900302 8.187660  1.107732220  2.7061869 0.8888984
## 20 0.1141745    0.4726358 3.670244  0.569710614 -0.3489977 0.7154796
## 21 0.1154171    0.9105202 3.109093  0.236940625 -0.5136499 0.7206234
## 22 0.1076368   -1.6612329 7.399385  2.387963806  0.9700303 0.8672609
## 23 0.1087243   -1.5470595 8.341785  1.296040815  2.0906554 0.8937380
## 24 0.1127654   -1.1557046 4.649517  1.823242814  0.1623899 0.8294076
## 25 0.1149504    0.8514036 3.286785  0.139738436 -0.3917868 0.7542948
## 26 0.1156048    0.8902902 3.131086  0.395604281 -0.5937370 0.6896027
## 27 0.3310711   -0.2792246 7.729117 -0.563408301  2.2874901 0.8042318
## 28 0.1227329   -1.3814505 8.522917  1.212327067  2.9830667 0.8972419
## 29 0.1151035    0.7280646 3.337569  0.549334296 -0.5342412 0.6808330
## 30 0.3312421   -0.3742874 7.664293 -0.090527367  2.7131109 0.8853049
## 31 0.3466043   -0.1094647 7.063072 -0.868293397  2.4270027 0.8606931
## 32 0.1246889   -1.1413166 8.921272  0.490914392  3.0641624 0.9014778
## 33 0.3639574   -0.6255612 6.938883  0.515515157  1.3180559 0.8305841
## 34 0.3544140   -0.5401969 7.307288  0.127553847  1.3840988 0.5131166
## 35 0.1355701   -0.8849919 9.083003 -0.050642342  2.9675352 0.9018950
## 36 0.1148892    0.4215069 3.614326  0.939992995 -0.5002048 0.6658693
## 37 0.1094789   -0.7018390 7.221465 -0.008841364  1.4283131 0.8139704
## 38 0.1141939   -0.5492024 3.954704  1.913481132 -0.3150317 0.7148120
##                          geometry t_stat_variable1 p_value_variable1
## 1  MULTIPOLYGON (((15706156 -4...         7.353000      1.346074e-08
## 2  MULTIPOLYGON (((14602040 -4...         6.759504      7.824812e-08
## 3  MULTIPOLYGON (((15426453 -4...         7.694570      4.963036e-09
## 4  MULTIPOLYGON (((15334983 -4...         4.558142      6.046715e-05
## 5  MULTIPOLYGON (((16047956 -4...         5.782536      1.493807e-06
## 6  MULTIPOLYGON (((14913039 -5...         6.947651      4.463896e-08
## 7  MULTIPOLYGON (((15756655 -4...         8.608669      3.664636e-10
## 8  MULTIPOLYGON (((14881516 -4...         7.425823      1.087046e-08
## 9  MULTIPOLYGON (((15535174 -4...         7.869114      2.995059e-09
## 10 MULTIPOLYGON (((15581004 -4...         4.949459      1.868710e-05
## 11 MULTIPOLYGON (((15459019 -4...         4.419811      9.122386e-05
## 12 MULTIPOLYGON (((15624671 -4...         3.985302      3.257563e-04
## 13 MULTIPOLYGON (((15909582 -4...         3.343015      1.983893e-03
## 14 MULTIPOLYGON (((15329740 -4...         7.545221      7.665971e-09
## 15 MULTIPOLYGON (((15660042 -4...         8.398613      6.611146e-10
## 16 MULTIPOLYGON (((15390607 -4...         8.556485      4.241009e-10
## 17 MULTIPOLYGON (((15222037 -4...         7.658415      5.512686e-09
## 18 MULTIPOLYGON (((15770125 -4...         8.380436      6.959235e-10
## 19 MULTIPOLYGON (((14988999 -4...         8.187660      1.202157e-09
## 20 MULTIPOLYGON (((15829759 -4...         3.670244      8.008865e-04
## 21 MULTIPOLYGON (((15876026 -4...         3.109093      3.717211e-03
## 22 MULTIPOLYGON (((15139993 -4...         7.399385      1.174682e-08
## 23 MULTIPOLYGON (((15494289 -4...         8.341785      7.762541e-10
## 24 MULTIPOLYGON (((15695383 -4...         4.649517      4.602647e-05
## 25 MULTIPOLYGON (((15997252 -4...         3.286785      2.311006e-03
## 26 MULTIPOLYGON (((15785772 -3...         3.131086      3.506946e-03
## 27 MULTIPOLYGON (((15335201 -5...         7.729117      4.489719e-09
## 28 MULTIPOLYGON (((15279844 -4...         8.522917      4.659668e-10
## 29 MULTIPOLYGON (((15687183 -3...         3.337569      2.013526e-03
## 30 MULTIPOLYGON (((15041209 -4...         7.664293      5.419291e-09
## 31 MULTIPOLYGON (((15436861 -5...         7.063072      3.168152e-08
## 32 MULTIPOLYGON (((15532695 -4...         8.921272      1.538536e-10
## 33 MULTIPOLYGON (((14725379 -5...         6.938883      4.581907e-08
## 34 MULTIPOLYGON (((15248766 -5...         7.307288      1.539746e-08
## 35 MULTIPOLYGON (((15628962 -4...         9.083003      9.867574e-11
## 36 MULTIPOLYGON (((15575336 -3...         3.614326      9.371667e-04
## 37 MULTIPOLYGON (((16133472 -4...         7.221465      1.982877e-08
## 38 MULTIPOLYGON (((15492441 -4...         3.954704      3.558420e-04
##    t_stat_variable2 p_value_variable2 t_stat_variable3 p_value_variable3
## 1      -0.958177491       0.344545726        2.5181195       0.016524592
## 2       0.817281123       0.419296604        1.1123276       0.273579357
## 3       2.244414521       0.031229319        1.3262997       0.193330584
## 4       3.173152353       0.003135830        0.1243534       0.901746963
## 5       0.758336566       0.453325971        0.5668807       0.574413070
## 6       0.555947477       0.581783676        1.3942742       0.172023321
## 7      -0.944966362       0.351154299        2.3888206       0.022427175
## 8       0.569291508       0.572794058        2.0054118       0.052699414
## 9       2.083462238       0.044577784        1.2592260       0.216282232
## 10      3.183380725       0.003051406        0.2810924       0.780294680
## 11      3.243510406       0.002597196        0.1211649       0.904253361
## 12      2.694423685       0.010756538        0.1470000       0.883975498
## 13      0.360063757       0.720963210       -0.4435739       0.660080802
## 14      2.239071792       0.031607573        1.2762233       0.210280651
## 15      1.048707867       0.301500581        2.0860948       0.044324169
## 16      0.647602234       0.521467819        3.4339651       0.001546638
## 17     -0.211201219       0.833955205        3.0219956       0.004673052
## 18     -0.288992080       0.774292304        2.2082912       0.033867638
## 19      1.107732220       0.275532274        2.7061869       0.010447496
## 20      0.569710614       0.572512832       -0.3489977       0.729181944
## 21      0.236940625       0.814084224       -0.5136499       0.610724449
## 22      2.387963806       0.022471987        0.9700303       0.338687551
## 23      1.296040815       0.203443060        2.0906554       0.043887820
## 24      1.823242814       0.076817092        0.1623899       0.871932711
## 25      0.139738436       0.889667702       -0.3917868       0.697591162
## 26      0.395604281       0.694798137       -0.5937370       0.556506200
## 27     -0.563408301       0.576748980        2.2874901       0.028324754
## 28      1.212327067       0.233507519        2.9830667       0.005171524
## 29      0.549334296       0.586264211       -0.5342412       0.596552126
## 30     -0.090527367       0.928384254        2.7131109       0.010269462
## 31     -0.868293397       0.391148743        2.4270027       0.020510634
## 32      0.490914392       0.626551103        3.0641624       0.004184453
## 33      0.515515157       0.609434236        1.3180559       0.196046707
## 34      0.127553847       0.899232113        1.3840988       0.175091088
## 35     -0.050642342       0.959898441        2.9675352       0.005384052
## 36      0.939992995       0.353663692       -0.5002048       0.620061545
## 37     -0.008841364       0.992995908        1.4283131       0.162065311
## 38      1.913481132       0.063893864       -0.3150317       0.754608192
koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x1), color = NA) +  
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +
  labs(title = "Peta Koefisien Variabel X1",
       fill = "Koefisien X1")  

# Membuat kuantil untuk koefisien X1
koefisien_merged$X1_quantile <- cut(koefisien_merged$x1, 
                                    breaks = classIntervals(koefisien_merged$x1, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X1_quantile), color = NA) +  # Menggunakan X1_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X1") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X1 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x2), color = NA) + 
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +
  labs(title = "Peta Koefisien Variabel X2",
       fill = "Koefisien X2") 

# Membuat kuantil untuk koefisien X2
koefisien_merged$X2_quantile <- cut(koefisien_merged$x2, 
                                    breaks = classIntervals(koefisien_merged$x2, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X2_quantile), color = NA) +  # Menggunakan X2_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X2") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X2 Berdasarkan Kuantil")

koefisien_gwr$id <- c(1:38)  

koefisien_merged <- Jawa_Timur_sf %>%
  left_join(koefisien_gwr, by = "id")

# Membuat peta
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = x3), color = NA) + 
  theme_bw() +
  scale_fill_gradient(low = "yellow", high = "red") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  
        axis.text.y = element_blank()) +
  labs(title = "Peta Koefisien Variabel X3",
       fill = "Koefisien X3") 

# Membuat kuantil untuk koefisien X3
koefisien_merged$X3_quantile <- cut(koefisien_merged$x3, 
                                    breaks = classIntervals(koefisien_merged$x3, n = 4, style = "quantile")$brks, 
                                    include.lowest = TRUE)

# Membuat peta dengan pewarnaan kuantil
ggplot(data = koefisien_merged) +
  geom_sf(aes(fill = X3_quantile), color = NA) +  # Menggunakan X3_quantile
  theme_bw() +
  scale_fill_brewer(palette = "OrRd", name = "Koefisien X3") +  # Menggunakan palet warna yang cocok untuk kuantil
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        legend.position = "right",
        axis.text.x = element_blank(),  # Hapus label sumbu x
        axis.text.y = element_blank()) +  # Hapus label sumbu y
  labs(title = "Peta Koefisien Variabel X3 Berdasarkan Kuantil")

Kesimpulan

Berdasarkan perbandingan nilai R-squared, AIC, serta asumsi model, diperoleh model terbaik GWR adalah model dengan kernel Adaptive Bisquare, walaupun model ini bukan model dengan R-Squared tertinggi dan nilai AIC terendah, namun model ini merupakan model yang memenuhi asumsi normalitas residual. Dan nilai R-Sqared dari model ini merupakan terbesar kedua dengan nilai AIC terkecil kedua dibandingkan dengan model lainnya.