Mata Kuliah Spasial

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

Author email :

##Memanggil package yang diperlukan:

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(maps)
## Warning: package 'maps' was built under R version 4.3.3
library(raster)
## Warning: package 'raster' was built under R version 4.3.3
## Loading required package: sp
## Warning: package 'sp' was built under R version 4.3.3
library(sp)
library(spdep)
## Warning: package 'spdep' was built under R version 4.3.3
## Loading required package: spData
## Warning: package 'spData' was built under R version 4.3.3
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## Loading required package: sf
## Warning: package 'sf' was built under R version 4.3.3
## Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
library(gstat)
## Warning: package 'gstat' was built under R version 4.3.3
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:raster':
## 
##     intersect, select, union
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(sf)
library(spatialreg)
## Warning: package 'spatialreg' was built under R version 4.3.3
## Loading required package: Matrix
## 
## Attaching package: 'spatialreg'
## The following objects are masked from 'package:spdep':
## 
##     get.ClusterOption, get.coresOption, get.mcOption,
##     get.VerboseOption, get.ZeroPolicyOption, set.ClusterOption,
##     set.coresOption, set.mcOption, set.VerboseOption,
##     set.ZeroPolicyOption
library(geodata)
## Warning: package 'geodata' was built under R version 4.3.3
## Loading required package: terra
## Warning: package 'terra' was built under R version 4.3.3
## terra 1.7.71
library(tidytable)
## Warning: package 'tidytable' was built under R version 4.3.3
## Warning: tidytable was loaded after dplyr.
## This can lead to most dplyr functions being overwritten by tidytable functions.
## 
## Attaching package: 'tidytable'
## The following objects are masked from 'package:terra':
## 
##     %in%, extract
## The following object is masked from 'package:Matrix':
## 
##     expand
## The following objects are masked from 'package:dplyr':
## 
##     across, add_count, add_tally, anti_join, arrange, between,
##     bind_cols, bind_rows, c_across, case_match, case_when, coalesce,
##     consecutive_id, count, cross_join, cume_dist, cur_column, cur_data,
##     cur_group_id, cur_group_rows, dense_rank, desc, distinct, filter,
##     first, full_join, group_by, group_cols, group_split, group_vars,
##     if_all, if_any, if_else, inner_join, is_grouped_df, lag, last,
##     lead, left_join, min_rank, mutate, n, n_distinct, na_if, nest_by,
##     nest_join, nth, percent_rank, pick, pull, recode, reframe,
##     relocate, rename, rename_with, right_join, row_number, rowwise,
##     select, semi_join, slice, slice_head, slice_max, slice_min,
##     slice_sample, slice_tail, summarise, summarize, tally, top_n,
##     transmute, tribble, ungroup
## The following objects are masked from 'package:raster':
## 
##     %in%, extract, select
## The following object is masked from 'package:maps':
## 
##     map
## The following objects are masked from 'package:stats':
## 
##     dt, filter, lag
## The following object is masked from 'package:base':
## 
##     %in%
library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ✔ readr     2.1.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidytable::across()            masks dplyr::across()
## ✖ tidytable::add_count()         masks dplyr::add_count()
## ✖ tidytable::add_tally()         masks dplyr::add_tally()
## ✖ tidytable::anti_join()         masks dplyr::anti_join()
## ✖ tidytable::arrange()           masks dplyr::arrange()
## ✖ tidytable::between()           masks dplyr::between()
## ✖ tidytable::bind_cols()         masks dplyr::bind_cols()
## ✖ tidytable::bind_rows()         masks dplyr::bind_rows()
## ✖ tidytable::c_across()          masks dplyr::c_across()
## ✖ tidytable::case_match()        masks dplyr::case_match()
## ✖ tidytable::case_when()         masks dplyr::case_when()
## ✖ tidytable::coalesce()          masks dplyr::coalesce()
## ✖ tidyr::complete()              masks tidytable::complete()
## ✖ tidytable::consecutive_id()    masks dplyr::consecutive_id()
## ✖ tidytable::count()             masks dplyr::count()
## ✖ tidytable::cross_join()        masks dplyr::cross_join()
## ✖ tidyr::crossing()              masks tidytable::crossing()
## ✖ tidytable::cume_dist()         masks dplyr::cume_dist()
## ✖ tidytable::cur_column()        masks dplyr::cur_column()
## ✖ tidytable::cur_data()          masks dplyr::cur_data()
## ✖ tidytable::cur_group_id()      masks dplyr::cur_group_id()
## ✖ tidytable::cur_group_rows()    masks dplyr::cur_group_rows()
## ✖ tidytable::dense_rank()        masks dplyr::dense_rank()
## ✖ tidytable::desc()              masks dplyr::desc()
## ✖ tidytable::distinct()          masks dplyr::distinct()
## ✖ tidyr::drop_na()               masks tidytable::drop_na()
## ✖ tibble::enframe()              masks tidytable::enframe()
## ✖ tidyr::expand()                masks tidytable::expand(), Matrix::expand()
## ✖ tidyr::expand_grid()           masks tidytable::expand_grid()
## ✖ tidyr::extract()               masks tidytable::extract(), terra::extract(), raster::extract()
## ✖ tidyr::fill()                  masks tidytable::fill()
## ✖ tidytable::filter()            masks dplyr::filter(), stats::filter()
## ✖ tidytable::first()             masks dplyr::first()
## ✖ tidytable::full_join()         masks dplyr::full_join()
## ✖ tidytable::group_by()          masks dplyr::group_by()
## ✖ tidytable::group_cols()        masks dplyr::group_cols()
## ✖ tidytable::group_split()       masks dplyr::group_split()
## ✖ tidytable::group_vars()        masks dplyr::group_vars()
## ✖ tidytable::if_all()            masks dplyr::if_all()
## ✖ tidytable::if_any()            masks dplyr::if_any()
## ✖ tidytable::if_else()           masks dplyr::if_else()
## ✖ tidytable::inner_join()        masks dplyr::inner_join()
## ✖ tidytable::is_grouped_df()     masks dplyr::is_grouped_df()
## ✖ tidytable::lag()               masks dplyr::lag(), stats::lag()
## ✖ tidytable::last()              masks dplyr::last()
## ✖ tidytable::lead()              masks dplyr::lead()
## ✖ tidytable::left_join()         masks dplyr::left_join()
## ✖ purrr::map()                   masks tidytable::map(), maps::map()
## ✖ purrr::map_chr()               masks tidytable::map_chr()
## ✖ purrr::map_dbl()               masks tidytable::map_dbl()
## ✖ purrr::map_df()                masks tidytable::map_df()
## ✖ purrr::map_dfc()               masks tidytable::map_dfc()
## ✖ purrr::map_dfr()               masks tidytable::map_dfr()
## ✖ purrr::map_int()               masks tidytable::map_int()
## ✖ purrr::map_lgl()               masks tidytable::map_lgl()
## ✖ purrr::map_vec()               masks tidytable::map_vec()
## ✖ purrr::map2()                  masks tidytable::map2()
## ✖ purrr::map2_chr()              masks tidytable::map2_chr()
## ✖ purrr::map2_dbl()              masks tidytable::map2_dbl()
## ✖ purrr::map2_df()               masks tidytable::map2_df()
## ✖ purrr::map2_dfc()              masks tidytable::map2_dfc()
## ✖ purrr::map2_dfr()              masks tidytable::map2_dfr()
## ✖ purrr::map2_int()              masks tidytable::map2_int()
## ✖ purrr::map2_lgl()              masks tidytable::map2_lgl()
## ✖ purrr::map2_vec()              masks tidytable::map2_vec()
## ✖ tidytable::min_rank()          masks dplyr::min_rank()
## ✖ tidytable::mutate()            masks dplyr::mutate()
## ✖ tidytable::n()                 masks dplyr::n()
## ✖ tidytable::n_distinct()        masks dplyr::n_distinct()
## ✖ tidytable::na_if()             masks dplyr::na_if()
## ✖ tidyr::nest()                  masks tidytable::nest()
## ✖ tidytable::nest_by()           masks dplyr::nest_by()
## ✖ tidytable::nest_join()         masks dplyr::nest_join()
## ✖ tidyr::nesting()               masks tidytable::nesting()
## ✖ tidytable::nth()               masks dplyr::nth()
## ✖ tidyr::pack()                  masks Matrix::pack()
## ✖ tidytable::pick()              masks dplyr::pick()
## ✖ tidyr::pivot_longer()          masks tidytable::pivot_longer()
## ✖ tidyr::pivot_wider()           masks tidytable::pivot_wider()
## ✖ purrr::pmap()                  masks tidytable::pmap()
## ✖ purrr::pmap_chr()              masks tidytable::pmap_chr()
## ✖ purrr::pmap_dbl()              masks tidytable::pmap_dbl()
## ✖ purrr::pmap_df()               masks tidytable::pmap_df()
## ✖ purrr::pmap_dfc()              masks tidytable::pmap_dfc()
## ✖ purrr::pmap_dfr()              masks tidytable::pmap_dfr()
## ✖ purrr::pmap_int()              masks tidytable::pmap_int()
## ✖ purrr::pmap_lgl()              masks tidytable::pmap_lgl()
## ✖ purrr::pmap_vec()              masks tidytable::pmap_vec()
## ✖ tidytable::pull()              masks dplyr::pull()
## ✖ tidytable::recode()            masks dplyr::recode()
## ✖ tidytable::reframe()           masks dplyr::reframe()
## ✖ tidytable::relocate()          masks dplyr::relocate()
## ✖ tidytable::rename()            masks dplyr::rename()
## ✖ tidytable::rename_with()       masks dplyr::rename_with()
## ✖ tidyr::replace_na()            masks tidytable::replace_na()
## ✖ tidytable::right_join()        masks dplyr::right_join()
## ✖ tidytable::row_number()        masks dplyr::row_number()
## ✖ tidytable::rowwise()           masks dplyr::rowwise()
## ✖ tidytable::select()            masks dplyr::select(), raster::select()
## ✖ tidytable::semi_join()         masks dplyr::semi_join()
## ✖ tidyr::separate()              masks tidytable::separate()
## ✖ tidyr::separate_longer_delim() masks tidytable::separate_longer_delim()
## ✖ tidyr::separate_rows()         masks tidytable::separate_rows()
## ✖ tidyr::separate_wider_delim()  masks tidytable::separate_wider_delim()
## ✖ tidyr::separate_wider_regex()  masks tidytable::separate_wider_regex()
## ✖ tidytable::slice()             masks dplyr::slice()
## ✖ tidytable::slice_head()        masks dplyr::slice_head()
## ✖ tidytable::slice_max()         masks dplyr::slice_max()
## ✖ tidytable::slice_min()         masks dplyr::slice_min()
## ✖ tidytable::slice_sample()      masks dplyr::slice_sample()
## ✖ tidytable::slice_tail()        masks dplyr::slice_tail()
## ✖ tidytable::summarise()         masks dplyr::summarise()
## ✖ tidytable::summarize()         masks dplyr::summarize()
## ✖ tidytable::tally()             masks dplyr::tally()
## ✖ tidytable::top_n()             masks dplyr::top_n()
## ✖ tidytable::transmute()         masks dplyr::transmute()
## ✖ tidyr::tribble()               masks tibble::tribble(), tidytable::tribble(), dplyr::tribble()
## ✖ tidyr::uncount()               masks tidytable::uncount()
## ✖ tidytable::ungroup()           masks dplyr::ungroup()
## ✖ tidyr::unite()                 masks tidytable::unite()
## ✖ tidyr::unnest()                masks tidytable::unnest()
## ✖ tidyr::unnest_longer()         masks tidytable::unnest_longer()
## ✖ tidyr::unnest_wider()          masks tidytable::unnest_wider()
## ✖ tidyr::unpack()                masks Matrix::unpack()
## ✖ purrr::walk()                  masks tidytable::walk()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(spgwr)
## Warning: package 'spgwr' was built under R version 4.3.3
## NOTE: This package does not constitute approval of GWR
## as a method of spatial analysis; see example(gwr)
library(car)
## Warning: package 'car' was built under R version 4.3.3
## Loading required package: carData
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:purrr':
## 
##     some
## 
## The following object is masked from 'package:tidytable':
## 
##     recode
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
library(lmtest)
## Warning: package 'lmtest' was built under R version 4.3.3
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following object is masked from 'package:terra':
## 
##     time<-
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(ggplot2)

Mempersiapkan file

setwd("C:/Users/nadin/OneDrive/Documents/Semester 5/Spasial/UTS")
Indonesia<-readRDS("C:/Users/nadin/OneDrive/Documents/Semester 5/Spasial/UTS/gadm36_IDN_2_sp.rds")
data <- read_excel("C:/Users/nadin/OneDrive/Documents/Semester 5/Spasial/UTS/Data Ujian Tengah Semester.xlsx")
data
## # A tibble: 35 × 8
##       id Kota           BGK    PUS AirLayak Posyandu Imunisasi Sanitasi
##    <dbl> <chr>        <dbl>  <dbl>    <dbl>    <dbl>     <dbl>    <dbl>
##  1     1 Cilacap       5176 348057     88.8     2205     24770     80.4
##  2     2 Banyumas      4127 303267     93.6     2548     24953     83  
##  3     3 Purbalingga   3267 184376     82.8     1238     14164     77.2
##  4     4 Banjarnegara  2120 190610     87.6     1578     13256     46.1
##  5     5 Kebumen       3227 193660     87.3     2123     16267     93.7
##  6     6 Purworejo      760 108734     91.3     1646      8716     81.4
##  7     7 Wonosobo      1825 148878     94.6     1291     11199     58.1
##  8     8 Magelang      3425 204578     97.5     2479     17862     85.1
##  9     9 Boyolali      2192 172389     94.4     1860     13461     89.3
## 10    10 Klaten        3699 197321     99.5     2297     15343     97.2
## # ℹ 25 more rows

Membuat plot sebagai eksplorasi data

Jawa_Tengah<-Indonesia[Indonesia$NAME_1 == "Jawa Tengah",]
Jawa_Tengah <- Jawa_Tengah[Jawa_Tengah$NAME_2 != 'Waduk Kedungombo',]
plot(Jawa_Tengah)

Jawa_Tengah$id<-c(1:35)
Jawa_Tengah_sf<-st_as_sf(Jawa_Tengah)
Jawa_Tengah_merged <- Jawa_Tengah_sf %>%left_join(data, by = "id")
Jawa_Tengah_merged <- st_as_sf(Jawa_Tengah_merged)

ggplot() + 
  geom_sf(data=Jawa_Tengah_merged, aes(fill = 
                                     BGK),color=NA) +
  theme_bw() + 
  scale_fill_gradient(low = "#ffcf01", high = 
                        "blue") +
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank())+
  theme(legend.position = "right",
        axis.text.x = element_blank(),
        axis.text.y = element_blank())+ 
labs(title = "",
     fill = "Bayi Gizi Kurang")

summary(data)
##        id           Kota                BGK            PUS        
##  Min.   : 1.0   Length:35          Min.   : 225   Min.   : 13937  
##  1st Qu.: 9.5   Class :character   1st Qu.:1411   1st Qu.:143723  
##  Median :18.0   Mode  :character   Median :2163   Median :179799  
##  Mean   :18.0                      Mean   :2316   Mean   :183086  
##  3rd Qu.:26.5                      3rd Qu.:3208   3rd Qu.:213785  
##  Max.   :35.0                      Max.   :5330   Max.   :382016  
##     AirLayak         Posyandu      Imunisasi        Sanitasi    
##  Min.   : 82.18   Min.   : 198   Min.   : 1536   Min.   :46.09  
##  1st Qu.: 92.90   1st Qu.:1232   1st Qu.:10548   1st Qu.:81.08  
##  Median : 95.92   Median :1442   Median :13461   Median :89.31  
##  Mean   : 94.63   Mean   :1428   Mean   :13931   Mean   :85.31  
##  3rd Qu.: 98.33   3rd Qu.:1672   3rd Qu.:17779   3rd Qu.:94.71  
##  Max.   :100.00   Max.   :2548   Max.   :27302   Max.   :98.15
hist(data$BGK)

breaks <- c(-Inf, 1411, 2163, 3208,Inf)

labels <- c("Very Low", "Low", "High", 
            "Very High")

Jawa_Tengah_merged$BGK_Discrete <- 
  cut(Jawa_Tengah_merged$BGK, breaks = 
        breaks, labels = labels, right = TRUE)


ggplot() +
  geom_sf(data=Jawa_Tengah_merged, aes(fill = 
                                     BGK_Discrete),color=NA) +
  theme_bw() +
  scale_fill_manual(values = c("Very Low" = "#ffcf01",
                               "Low" = "#ff8a01",
                               "High" = "#003780",
                               "Very High" = "#011f47"))+
  labs(fill = "Bayi Kurang Gizi")+theme(legend.position = "right",
                             axis.text.x = element_blank(), 
                             axis.text.y = element_blank())+ 
labs(title = "",
     fill = "Bayi Kurang Gizi")

Membuat Koordinat

ID <- c(1:35)
Jawa_Tengah$ID <- c(1:35)
plot(Jawa_Tengah, axes = T, col ="#ffcf01")

Membuat koordinat centroid dari peta

Coordk <- coordinates(Jawa_Tengah)

Membuat Matriks Bobot

##Berdasarkan Contiguity (Persinggungan) #ROOK

WRook <- poly2nb(Jawa_Tengah, row.names=ID,queen=FALSE);WRook
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 146 
## Percentage nonzero weights: 11.91837 
## Average number of links: 4.171429
WBRook <- nb2mat(WRook, style='B', zero.policy=TRUE);WBRook
##    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1     0    1    1    0    0    0    0    0    0     0     0     1     0     0
## 2     1    0    0    0    0    1    1    0    0     0     0     1     0     0
## 3     1    0    0    0    0    0    0    0    0     0     0     0     1     0
## 4     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 5     0    0    0    0    0    0    0    0    1     0     1     0     0     1
## 6     0    1    0    0    0    0    1    0    0     0     0     0     0     0
## 7     0    1    0    0    0    1    0    0    0     0     0     1     0     0
## 8     0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 9     0    0    0    1    1    0    0    1    0     0     0     0     0     0
## 10    0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 11    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 12    1    1    0    0    0    0    1    0    0     0     0     0     0     0
## 13    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 14    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 15    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 16    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 17    0    0    0    0    0    0    0    1    0     0     0     0     1     0
## 18    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 19    0    0    0    0    0    0    0    1    1     1     0     0     0     0
## 20    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 21    0    0    0    1    0    0    0    0    1     1     0     0     0     0
## 22    1    0    1    0    0    0    0    0    0     0     0     0     0     0
## 23    0    1    0    0    0    0    0    0    0     0     0     0     0     0
## 24    1    1    0    0    0    0    0    0    0     0     0     0     0     0
## 25    0    0    0    0    0    0    0    0    0     0     0     1     0     0
## 26    0    0    0    1    0    0    0    0    0     0     0     0     0     0
## 27    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 28    0    0    0    0    1    0    0    1    1     0     0     0     1     0
## 29    0    0    0    0    1    0    0    0    1     0     1     0     0     0
## 30    0    0    0    0    1    0    0    0    0     0     1     0     0     1
## 31    0    0    0    0    1    0    0    0    0     0     1     0     0     0
## 32    0    1    0    0    0    1    0    0    0     0     0     0     0     0
## 33    0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 34    0    0    0    0    0    0    0    0    0     0     1     0     0     0
## 35    1    0    1    0    0    0    0    0    0     0     0     1     1     0
##    [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## 1      0     0     0     0     0     0     0     1     0     1     0     0
## 2      0     0     0     0     0     0     0     0     1     1     0     0
## 3      0     1     0     0     0     0     0     1     0     0     0     0
## 4      0     0     0     0     0     0     1     0     0     0     0     1
## 5      0     0     0     0     0     1     0     0     0     0     0     0
## 6      0     0     0     1     0     0     0     0     0     0     0     0
## 7      0     0     0     0     0     0     0     0     0     0     0     0
## 8      0     0     1     0     1     0     0     0     0     0     0     0
## 9      0     0     0     0     1     0     1     0     0     0     0     0
## 10     0     0     0     0     1     0     1     0     0     0     0     0
## 11     0     0     0     0     0     0     0     0     0     0     0     0
## 12     0     0     0     0     0     0     0     0     0     0     1     0
## 13     0     0     1     0     0     0     0     0     0     0     0     0
## 14     0     0     0     0     0     0     0     0     0     0     0     0
## 15     0     0     0     0     0     1     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     1     0     0     0     0
## 17     0     0     0     0     0     0     0     0     0     0     0     0
## 18     0     0     0     0     0     0     0     0     0     0     0     0
## 19     0     0     0     0     0     0     1     0     0     0     0     0
## 20     1     0     0     0     0     0     0     0     0     0     1     0
## 21     0     0     0     0     1     0     0     0     0     0     0     1
## 22     0     1     0     0     0     0     0     0     1     1     0     0
## 23     0     0     0     0     0     0     0     1     0     1     0     0
## 24     0     0     0     0     0     0     0     1     1     0     0     0
## 25     0     0     0     0     0     1     0     0     0     0     0     0
## 26     0     0     0     0     0     0     1     0     0     0     0     0
## 27     0     0     0     0     0     0     0     0     0     0     0     0
## 28     0     0     1     0     0     1     0     0     0     0     0     0
## 29     0     0     0     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     0     0     0     0     0     0     0     0
## 31     0     0     0     0     0     0     0     0     0     0     0     0
## 32     0     0     0     1     0     0     0     0     1     0     0     0
## 33     0     0     0     0     0     1     0     0     0     0     0     0
## 34     0     0     0     0     0     0     0     0     0     0     0     0
## 35     0     0     0     0     0     1     0     0     0     0     1     0
##    [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## 1      0     0     0     0     0     0     0     0     1
## 2      0     0     0     0     0     1     0     0     0
## 3      0     0     0     0     0     0     0     0     1
## 4      0     0     0     0     0     0     0     0     0
## 5      0     1     1     1     1     0     0     0     0
## 6      0     0     0     0     0     1     0     0     0
## 7      0     0     0     0     0     0     0     0     0
## 8      0     1     0     0     0     0     0     0     0
## 9      0     1     1     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0
## 11     0     0     1     1     1     0     0     1     0
## 12     0     0     0     0     0     0     0     0     1
## 13     0     1     0     0     0     0     1     0     1
## 14     0     0     0     1     0     0     0     0     0
## 15     0     0     0     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     0     0
## 17     0     1     0     0     0     0     0     0     0
## 18     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     0     0     0
## 20     0     1     0     0     0     0     1     0     1
## 21     0     0     0     0     0     0     0     0     0
## 22     0     0     0     0     0     0     0     0     0
## 23     0     0     0     0     0     1     0     0     0
## 24     0     0     0     0     0     0     0     0     0
## 25     0     0     0     0     0     0     0     0     1
## 26     0     0     0     0     0     0     0     0     0
## 27     0     1     0     0     0     0     0     0     0
## 28     1     0     0     0     0     0     1     0     0
## 29     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     1     0     0     1     0
## 31     0     0     0     1     0     0     0     0     0
## 32     0     0     0     0     0     0     0     0     0
## 33     0     1     0     0     0     0     0     0     1
## 34     0     0     0     1     0     0     0     0     0
## 35     0     0     0     0     0     0     1     0     0
## attr(,"call")
## nb2mat(neighbours = WRook, style = "B", zero.policy = TRUE)
WBRook[c(1:35),c(1:35)]
##    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1     0    1    1    0    0    0    0    0    0     0     0     1     0     0
## 2     1    0    0    0    0    1    1    0    0     0     0     1     0     0
## 3     1    0    0    0    0    0    0    0    0     0     0     0     1     0
## 4     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 5     0    0    0    0    0    0    0    0    1     0     1     0     0     1
## 6     0    1    0    0    0    0    1    0    0     0     0     0     0     0
## 7     0    1    0    0    0    1    0    0    0     0     0     1     0     0
## 8     0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 9     0    0    0    1    1    0    0    1    0     0     0     0     0     0
## 10    0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 11    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 12    1    1    0    0    0    0    1    0    0     0     0     0     0     0
## 13    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 14    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 15    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 16    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 17    0    0    0    0    0    0    0    1    0     0     0     0     1     0
## 18    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 19    0    0    0    0    0    0    0    1    1     1     0     0     0     0
## 20    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 21    0    0    0    1    0    0    0    0    1     1     0     0     0     0
## 22    1    0    1    0    0    0    0    0    0     0     0     0     0     0
## 23    0    1    0    0    0    0    0    0    0     0     0     0     0     0
## 24    1    1    0    0    0    0    0    0    0     0     0     0     0     0
## 25    0    0    0    0    0    0    0    0    0     0     0     1     0     0
## 26    0    0    0    1    0    0    0    0    0     0     0     0     0     0
## 27    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 28    0    0    0    0    1    0    0    1    1     0     0     0     1     0
## 29    0    0    0    0    1    0    0    0    1     0     1     0     0     0
## 30    0    0    0    0    1    0    0    0    0     0     1     0     0     1
## 31    0    0    0    0    1    0    0    0    0     0     1     0     0     0
## 32    0    1    0    0    0    1    0    0    0     0     0     0     0     0
## 33    0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 34    0    0    0    0    0    0    0    0    0     0     1     0     0     0
## 35    1    0    1    0    0    0    0    0    0     0     0     1     1     0
##    [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## 1      0     0     0     0     0     0     0     1     0     1     0     0
## 2      0     0     0     0     0     0     0     0     1     1     0     0
## 3      0     1     0     0     0     0     0     1     0     0     0     0
## 4      0     0     0     0     0     0     1     0     0     0     0     1
## 5      0     0     0     0     0     1     0     0     0     0     0     0
## 6      0     0     0     1     0     0     0     0     0     0     0     0
## 7      0     0     0     0     0     0     0     0     0     0     0     0
## 8      0     0     1     0     1     0     0     0     0     0     0     0
## 9      0     0     0     0     1     0     1     0     0     0     0     0
## 10     0     0     0     0     1     0     1     0     0     0     0     0
## 11     0     0     0     0     0     0     0     0     0     0     0     0
## 12     0     0     0     0     0     0     0     0     0     0     1     0
## 13     0     0     1     0     0     0     0     0     0     0     0     0
## 14     0     0     0     0     0     0     0     0     0     0     0     0
## 15     0     0     0     0     0     1     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     1     0     0     0     0
## 17     0     0     0     0     0     0     0     0     0     0     0     0
## 18     0     0     0     0     0     0     0     0     0     0     0     0
## 19     0     0     0     0     0     0     1     0     0     0     0     0
## 20     1     0     0     0     0     0     0     0     0     0     1     0
## 21     0     0     0     0     1     0     0     0     0     0     0     1
## 22     0     1     0     0     0     0     0     0     1     1     0     0
## 23     0     0     0     0     0     0     0     1     0     1     0     0
## 24     0     0     0     0     0     0     0     1     1     0     0     0
## 25     0     0     0     0     0     1     0     0     0     0     0     0
## 26     0     0     0     0     0     0     1     0     0     0     0     0
## 27     0     0     0     0     0     0     0     0     0     0     0     0
## 28     0     0     1     0     0     1     0     0     0     0     0     0
## 29     0     0     0     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     0     0     0     0     0     0     0     0
## 31     0     0     0     0     0     0     0     0     0     0     0     0
## 32     0     0     0     1     0     0     0     0     1     0     0     0
## 33     0     0     0     0     0     1     0     0     0     0     0     0
## 34     0     0     0     0     0     0     0     0     0     0     0     0
## 35     0     0     0     0     0     1     0     0     0     0     1     0
##    [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## 1      0     0     0     0     0     0     0     0     1
## 2      0     0     0     0     0     1     0     0     0
## 3      0     0     0     0     0     0     0     0     1
## 4      0     0     0     0     0     0     0     0     0
## 5      0     1     1     1     1     0     0     0     0
## 6      0     0     0     0     0     1     0     0     0
## 7      0     0     0     0     0     0     0     0     0
## 8      0     1     0     0     0     0     0     0     0
## 9      0     1     1     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0
## 11     0     0     1     1     1     0     0     1     0
## 12     0     0     0     0     0     0     0     0     1
## 13     0     1     0     0     0     0     1     0     1
## 14     0     0     0     1     0     0     0     0     0
## 15     0     0     0     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     0     0
## 17     0     1     0     0     0     0     0     0     0
## 18     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     0     0     0
## 20     0     1     0     0     0     0     1     0     1
## 21     0     0     0     0     0     0     0     0     0
## 22     0     0     0     0     0     0     0     0     0
## 23     0     0     0     0     0     1     0     0     0
## 24     0     0     0     0     0     0     0     0     0
## 25     0     0     0     0     0     0     0     0     1
## 26     0     0     0     0     0     0     0     0     0
## 27     0     1     0     0     0     0     0     0     0
## 28     1     0     0     0     0     0     1     0     0
## 29     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     1     0     0     1     0
## 31     0     0     0     1     0     0     0     0     0
## 32     0     0     0     0     0     0     0     0     0
## 33     0     1     0     0     0     0     0     0     1
## 34     0     0     0     1     0     0     0     0     0
## 35     0     0     0     0     0     0     1     0     0
WLR<-nb2listw(WRook);WLR #List neighbours / Moran's I
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 146 
## Percentage nonzero weights: 11.91837 
## Average number of links: 4.171429 
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0      S1       S2
## W 35 1225 35 18.9401 150.9739
plot(WLR, coordinates(Jawa_Tengah), col="#ffffff")

plot(Jawa_Tengah, axes=T, col="#ffcf01")
text(Coordk[,1], Coordk[,2],  row.names(Jawa_Tengah), col="black", cex=0.8, pos=1.5)
points(Coordk[,1], Coordk[,2], pch=19, cex=0.7,col="#011f47")
plot(WLR, coordinates(Jawa_Tengah), col="#003780", add=T)

#QUEEN

WQueen <- poly2nb(Jawa_Tengah, row.names=ID, queen=TRUE) #Mendapatkan W
WBQueen <- nb2mat(WQueen, style='B', zero.policy = TRUE) #menyajikan dalam bentuk matrix biner "B"
WBQueen[c(1:35),c(1:35)]
##    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1     0    1    1    0    0    0    0    0    0     0     0     1     0     0
## 2     1    0    0    0    0    1    1    0    0     0     0     1     0     0
## 3     1    0    0    0    0    0    0    0    0     0     0     0     1     0
## 4     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 5     0    0    0    0    0    0    0    0    1     0     1     0     0     1
## 6     0    1    0    0    0    0    1    0    0     0     0     0     0     0
## 7     0    1    0    0    0    1    0    0    0     0     0     1     0     0
## 8     0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 9     0    0    0    1    1    0    0    1    0     0     0     0     0     0
## 10    0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 11    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 12    1    1    0    0    0    0    1    0    0     0     0     0     0     0
## 13    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 14    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 15    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 16    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 17    0    0    0    0    0    0    0    1    0     0     0     0     1     0
## 18    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 19    0    0    0    0    0    0    0    1    1     1     0     0     0     0
## 20    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 21    0    0    0    1    0    0    0    0    1     1     0     0     0     0
## 22    1    0    1    0    0    0    0    0    0     0     0     0     0     0
## 23    0    1    0    0    0    0    0    0    0     0     0     0     0     0
## 24    1    1    0    0    0    0    0    0    0     0     0     0     0     0
## 25    0    0    0    0    0    0    0    0    0     0     0     1     0     0
## 26    0    0    0    1    0    0    0    0    0     0     0     0     0     0
## 27    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 28    0    0    0    0    1    0    0    1    1     0     0     0     1     0
## 29    0    0    0    0    1    0    0    0    1     0     1     0     0     0
## 30    0    0    0    0    1    0    0    0    0     0     1     0     0     1
## 31    0    0    0    0    1    0    0    0    0     0     1     0     0     0
## 32    0    1    0    0    0    1    0    0    0     0     0     0     0     0
## 33    0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 34    0    0    0    0    0    0    0    0    0     0     1     0     0     0
## 35    1    0    1    0    0    0    0    0    0     0     0     1     1     0
##    [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## 1      0     0     0     0     0     0     0     1     0     1     0     0
## 2      0     0     0     0     0     0     0     0     1     1     0     0
## 3      0     1     0     0     0     0     0     1     0     0     0     0
## 4      0     0     0     0     0     0     1     0     0     0     0     1
## 5      0     0     0     0     0     1     0     0     0     0     0     0
## 6      0     0     0     1     0     0     0     0     0     0     0     0
## 7      0     0     0     0     0     0     0     0     0     0     0     0
## 8      0     0     1     0     1     0     0     0     0     0     0     0
## 9      0     0     0     0     1     0     1     0     0     0     0     0
## 10     0     0     0     0     1     0     1     0     0     0     0     0
## 11     0     0     0     0     0     0     0     0     0     0     0     0
## 12     0     0     0     0     0     0     0     0     0     0     1     0
## 13     0     0     1     0     0     0     0     0     0     0     0     0
## 14     0     0     0     0     0     0     0     0     0     0     0     0
## 15     0     0     0     0     0     1     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     1     0     0     0     0
## 17     0     0     0     0     0     0     0     0     0     0     0     0
## 18     0     0     0     0     0     0     0     0     0     0     0     0
## 19     0     0     0     0     0     0     1     0     0     0     0     0
## 20     1     0     0     0     0     0     0     0     0     0     1     0
## 21     0     0     0     0     1     0     0     0     0     0     0     1
## 22     0     1     0     0     0     0     0     0     1     1     0     0
## 23     0     0     0     0     0     0     0     1     0     1     0     0
## 24     0     0     0     0     0     0     0     1     1     0     0     0
## 25     0     0     0     0     0     1     0     0     0     0     0     0
## 26     0     0     0     0     0     0     1     0     0     0     0     0
## 27     0     0     0     0     0     0     0     0     0     0     0     0
## 28     0     0     1     0     0     1     0     0     0     0     0     0
## 29     0     0     0     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     0     0     0     0     0     0     0     0
## 31     0     0     0     0     0     0     0     0     0     0     0     0
## 32     0     0     0     1     0     0     0     0     1     0     0     0
## 33     0     0     0     0     0     1     0     0     0     0     0     0
## 34     0     0     0     0     0     0     0     0     0     0     0     0
## 35     0     0     0     0     0     1     0     0     0     0     1     0
##    [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## 1      0     0     0     0     0     0     0     0     1
## 2      0     0     0     0     0     1     0     0     0
## 3      0     0     0     0     0     0     0     0     1
## 4      0     0     0     0     0     0     0     0     0
## 5      0     1     1     1     1     0     0     0     0
## 6      0     0     0     0     0     1     0     0     0
## 7      0     0     0     0     0     0     0     0     0
## 8      0     1     0     0     0     0     0     0     0
## 9      0     1     1     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0
## 11     0     0     1     1     1     0     0     1     0
## 12     0     0     0     0     0     0     0     0     1
## 13     0     1     0     0     0     0     1     0     1
## 14     0     0     0     1     0     0     0     0     0
## 15     0     0     0     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     0     0
## 17     0     1     0     0     0     0     0     0     0
## 18     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     0     0     0
## 20     0     1     0     0     0     0     1     0     1
## 21     0     0     0     0     0     0     0     0     0
## 22     0     0     0     0     0     0     0     0     0
## 23     0     0     0     0     0     1     0     0     0
## 24     0     0     0     0     0     0     0     0     0
## 25     0     0     0     0     0     0     0     0     1
## 26     0     0     0     0     0     0     0     0     0
## 27     0     1     0     0     0     0     0     0     0
## 28     1     0     0     0     0     0     1     0     0
## 29     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     1     0     0     1     0
## 31     0     0     0     1     0     0     0     0     0
## 32     0     0     0     0     0     0     0     0     0
## 33     0     1     0     0     0     0     0     0     1
## 34     0     0     0     1     0     0     0     0     0
## 35     0     0     0     0     0     0     1     0     0
WLQ<-nb2listw(WQueen);WLQ
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 146 
## Percentage nonzero weights: 11.91837 
## Average number of links: 4.171429 
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0      S1       S2
## W 35 1225 35 18.9401 150.9739
plot(WLQ, coordinates(Jawa_Tengah), col="#ffffff")

plot(Jawa_Tengah, axes=T, col="#ffcf01")
text(Coordk[,1], Coordk[,2],  row.names(Jawa_Tengah), col="black", cex=0.8, pos=1.5)
points(Coordk[,1], Coordk[,2], pch=19, cex=0.7,col="#011f47")
plot(WLQ, coordinates(Jawa_Tengah), col="#003780", add=T)

##PENDEKATAN JARAK

#k=2

WJ2 <- knn2nb(knearneigh(Coordk, k = 
                           2), row.names = ID);WJ2
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 70 
## Percentage nonzero weights: 5.714286 
## Average number of links: 2 
## Non-symmetric neighbours list
WBJ2 <- nb2mat(WJ2, style='B', zero.policy
               = TRUE);WJ2 #menyajikan dalam bentuk matrix biner "B
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 70 
## Percentage nonzero weights: 5.714286 
## Average number of links: 2 
## Non-symmetric neighbours list
WLJ2<-nb2listw(WJ2);WLJ2
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 70 
## Percentage nonzero weights: 5.714286 
## Average number of links: 2 
## Non-symmetric neighbours list
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0   S1    S2
## W 35 1225 35 29.5 153.5
plot(Jawa_Tengah, axes=T, col="#ffcf01")
text(Coordk[,1], Coordk[,2],  row.names(Jawa_Tengah), col="black", cex=0.8, pos=1.5)
points(Coordk[,1], Coordk[,2], pch=19, cex=0.7,col="#011f47")
plot(WJ2, coordinates(Jawa_Tengah), col="#003780", add=T)

#K=3

WJ3 <- knn2nb(knearneigh(Coordk, k = 
                           3), row.names = ID);WJ3
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 105 
## Percentage nonzero weights: 8.571429 
## Average number of links: 3 
## Non-symmetric neighbours list
WBJ3 <- nb2mat(WJ3, style='B', zero.policy
               = TRUE);WBJ3 #menyajikan dalam bentuk matrix biner "B
##    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1     0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 2     0    0    0    0    0    0    1    0    0     0     0     0     0     0
## 3     0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 4     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 5     0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 6     0    0    0    0    0    0    1    0    0     0     0     0     0     0
## 7     0    1    0    0    0    1    0    0    0     0     0     0     0     0
## 8     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 9     0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 10    0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 11    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 12    1    0    0    0    0    0    0    0    0     0     0     0     0     0
## 13    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 14    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 15    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 16    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 17    0    0    0    0    0    0    0    1    0     0     0     0     1     0
## 18    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 19    0    0    0    0    0    0    0    1    0     1     0     0     0     0
## 20    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 21    0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 22    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 23    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 24    1    1    0    0    0    0    0    0    0     0     0     0     0     0
## 25    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 26    0    0    0    1    0    0    0    0    0     0     0     0     0     0
## 27    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 28    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 29    0    0    0    0    0    0    0    0    1     0     1     0     0     0
## 30    0    0    0    0    0    0    0    0    0     0     1     0     0     1
## 31    0    0    0    0    1    0    0    0    0     0     1     0     0     0
## 32    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 33    0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 34    0    0    0    0    0    0    0    0    0     0     1     0     0     0
## 35    1    0    0    0    0    0    0    0    0     0     0     0     0     0
##    [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## 1      0     0     0     0     0     0     0     1     0     1     0     0
## 2      0     0     0     0     0     0     0     0     0     1     0     0
## 3      0     1     0     0     0     0     0     1     0     0     0     0
## 4      0     0     0     0     0     0     1     0     0     0     0     1
## 5      0     0     0     0     0     0     0     0     0     0     0     0
## 6      0     0     0     1     0     0     0     0     0     0     0     0
## 7      0     0     0     0     0     0     0     0     0     0     0     0
## 8      0     0     1     0     1     0     0     0     0     0     0     0
## 9      0     0     0     0     1     0     0     0     0     0     0     0
## 10     0     0     0     0     1     0     1     0     0     0     0     0
## 11     0     0     0     0     0     0     0     0     0     0     0     0
## 12     0     0     0     0     0     0     0     0     0     0     1     0
## 13     0     0     1     0     0     0     0     0     0     0     0     0
## 14     0     0     0     0     0     0     0     0     0     0     0     0
## 15     0     0     0     0     0     1     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     1     1     0     0     0
## 17     0     0     0     0     0     0     0     0     0     0     0     0
## 18     0     0     0     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     1     0     0     0     0     0
## 20     1     0     0     0     0     0     0     0     0     0     0     0
## 21     0     0     0     0     1     0     0     0     0     0     0     0
## 22     0     1     0     0     0     0     0     0     1     0     0     0
## 23     0     0     0     0     0     0     0     1     0     1     0     0
## 24     0     0     0     0     0     0     0     0     1     0     0     0
## 25     1     0     0     0     0     1     0     0     0     0     0     0
## 26     0     0     0     0     1     0     1     0     0     0     0     0
## 27     0     0     0     0     0     1     0     0     0     0     0     0
## 28     0     0     1     0     0     0     0     0     0     0     0     0
## 29     0     0     0     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     0     0     0     0     0     0     0     0
## 31     0     0     0     0     0     0     0     0     0     0     0     0
## 32     0     0     0     1     0     0     0     0     1     0     0     0
## 33     1     0     0     0     0     1     0     0     0     0     0     0
## 34     0     0     0     0     0     0     0     0     0     0     0     0
## 35     0     0     0     0     0     0     0     0     0     0     1     0
##    [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## 1      0     0     0     0     0     0     0     0     1
## 2      0     0     0     0     0     1     0     0     0
## 3      0     0     0     0     0     0     0     0     0
## 4      0     0     0     0     0     0     0     0     0
## 5      1     1     0     0     1     0     0     0     0
## 6      0     0     0     0     0     1     0     0     0
## 7      0     0     0     0     0     1     0     0     0
## 8      0     0     0     0     0     0     0     0     0
## 9      0     0     1     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0
## 11     0     0     1     1     1     0     0     0     0
## 12     0     0     0     0     0     0     0     0     1
## 13     0     0     0     0     0     0     1     0     0
## 14     0     0     0     1     1     0     0     0     0
## 15     1     0     0     0     0     0     1     0     0
## 16     0     0     0     0     0     0     0     0     0
## 17     0     1     0     0     0     0     0     0     0
## 18     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     0     0     0
## 20     1     0     0     0     0     0     1     0     0
## 21     0     0     0     0     0     0     0     0     0
## 22     0     0     0     0     0     0     0     0     0
## 23     0     0     0     0     0     1     0     0     0
## 24     0     0     0     0     0     0     0     0     0
## 25     0     0     0     0     0     0     0     0     1
## 26     0     0     0     0     0     0     0     0     0
## 27     0     1     0     0     0     0     0     0     0
## 28     1     0     0     0     0     0     0     0     0
## 29     0     0     0     0     1     0     0     0     0
## 30     0     0     0     0     1     0     0     0     0
## 31     0     0     0     1     0     0     0     0     0
## 32     0     0     0     0     0     0     0     0     0
## 33     0     0     0     0     0     0     0     0     0
## 34     0     0     0     1     1     0     0     0     0
## 35     0     0     0     0     0     0     1     0     0
## attr(,"call")
## nb2mat(neighbours = WJ3, style = "B", zero.policy = TRUE)
WLJ3<-nb2listw(WJ3);WLJ3
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 105 
## Percentage nonzero weights: 8.571429 
## Average number of links: 3 
## Non-symmetric neighbours list
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0       S1       S2
## W 35 1225 35 20.55556 147.5556
plot(Jawa_Tengah, axes=T, col="#ffcf01")
text(Coordk[,1], Coordk[,2],  row.names(Jawa_Tengah), col="black", cex=0.8, pos=1.5)
points(Coordk[,1], Coordk[,2], pch=19, cex=0.7,col="#011f47")
plot(WJ3, coordinates(Jawa_Tengah), col="#003780", add=T)

#K=4

WJ4 <- knn2nb(knearneigh(Coordk, k = 
                           4), row.names = ID);WJ4
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 140 
## Percentage nonzero weights: 11.42857 
## Average number of links: 4 
## Non-symmetric neighbours list
WBJ4 <- nb2mat(WJ4, style='B', zero.policy
               = TRUE);WBJ4 #menyajikan dalam bentuk matrix biner "B
##    [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## 1     0    0    0    0    0    0    0    0    0     0     0     1     0     0
## 2     0    0    0    0    0    1    1    0    0     0     0     0     0     0
## 3     0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 4     0    0    0    0    0    0    0    0    1     0     0     0     0     0
## 5     0    0    0    0    0    0    0    0    0     0     0     0     0     1
## 6     0    1    0    0    0    0    1    0    0     0     0     0     0     0
## 7     0    1    0    0    0    1    0    0    0     0     0     0     0     0
## 8     0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 9     0    0    0    0    0    0    0    1    0     0     0     0     0     0
## 10    0    0    0    0    0    0    0    1    1     0     0     0     0     0
## 11    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 12    1    0    0    0    0    0    0    0    0     0     0     0     0     0
## 13    0    0    1    0    0    0    0    0    0     0     0     0     0     0
## 14    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 15    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 16    1    0    1    0    0    0    0    0    0     0     0     0     0     0
## 17    0    0    0    0    0    0    0    1    0     0     0     0     1     0
## 18    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 19    0    0    0    0    0    0    0    1    1     1     0     0     0     0
## 20    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 21    0    0    0    0    0    0    0    0    1     1     0     0     0     0
## 22    1    0    1    0    0    0    0    0    0     0     0     0     0     0
## 23    0    0    0    0    0    0    0    0    0     0     0     0     0     0
## 24    1    1    0    0    0    0    0    0    0     0     0     0     0     0
## 25    0    0    0    0    0    0    0    0    0     0     0     1     0     0
## 26    0    0    0    1    0    0    0    0    1     0     0     0     0     0
## 27    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 28    0    0    0    0    1    0    0    0    0     0     0     0     0     0
## 29    0    0    0    0    0    0    0    0    1     0     1     0     0     0
## 30    0    0    0    0    0    0    0    0    0     0     1     0     0     1
## 31    0    0    0    0    1    0    0    0    0     0     1     0     0     0
## 32    0    0    0    0    0    1    0    0    0     0     0     0     0     0
## 33    0    0    0    0    0    0    0    0    0     0     0     0     1     0
## 34    0    0    0    0    0    0    0    0    0     0     1     0     0     1
## 35    1    0    0    0    0    0    0    0    0     0     0     0     0     0
##    [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## 1      0     0     0     0     0     0     0     1     0     1     0     0
## 2      0     0     0     0     0     0     0     0     0     1     0     0
## 3      0     1     0     0     0     0     0     1     0     0     0     0
## 4      0     0     0     0     0     0     1     0     0     0     0     1
## 5      0     0     0     0     0     0     0     0     0     0     0     0
## 6      0     0     0     1     0     0     0     0     0     0     0     0
## 7      0     0     0     0     0     0     0     0     0     1     0     0
## 8      0     0     1     0     1     0     0     0     0     0     0     0
## 9      0     0     0     0     1     0     1     0     0     0     0     0
## 10     0     0     0     0     1     0     1     0     0     0     0     0
## 11     0     0     0     0     0     0     0     0     0     0     0     0
## 12     0     0     0     0     0     0     0     0     0     1     1     0
## 13     0     0     1     0     0     0     0     0     0     0     0     0
## 14     0     0     0     0     0     0     0     0     0     0     0     0
## 15     0     0     0     0     0     1     0     0     0     0     0     0
## 16     0     0     0     0     0     0     0     1     1     0     0     0
## 17     0     0     0     0     0     0     0     0     0     0     0     0
## 18     0     0     0     0     0     0     0     1     1     0     0     0
## 19     0     0     0     0     0     0     1     0     0     0     0     0
## 20     1     0     0     0     0     0     0     0     0     0     0     0
## 21     0     0     0     0     1     0     0     0     0     0     0     1
## 22     0     1     0     0     0     0     0     0     1     0     0     0
## 23     0     1     0     0     0     0     0     1     0     1     0     0
## 24     0     0     0     0     0     0     0     1     1     0     0     0
## 25     1     0     0     0     0     1     0     0     0     0     0     0
## 26     0     0     0     0     1     0     1     0     0     0     0     0
## 27     1     0     0     0     0     1     0     0     0     0     0     0
## 28     0     0     1     0     0     1     0     0     0     0     0     0
## 29     0     0     0     0     0     0     0     0     0     0     0     0
## 30     0     0     0     0     0     0     0     0     0     0     0     0
## 31     0     0     0     0     0     0     0     0     0     0     0     0
## 32     0     0     0     1     0     0     0     0     1     1     0     0
## 33     1     0     0     0     0     1     0     0     0     0     0     0
## 34     0     0     0     0     0     0     0     0     0     0     0     0
## 35     1     0     0     0     0     0     0     0     0     0     1     0
##    [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## 1      0     0     0     0     0     0     0     0     1
## 2      0     0     0     0     0     1     0     0     0
## 3      0     0     0     0     0     0     1     0     0
## 4      0     0     1     0     0     0     0     0     0
## 5      1     1     0     0     1     0     0     0     0
## 6      0     0     0     0     0     1     0     0     0
## 7      0     0     0     0     0     1     0     0     0
## 8      0     0     0     0     0     0     0     0     0
## 9      0     0     1     0     0     0     0     0     0
## 10     0     0     0     0     0     0     0     0     0
## 11     0     0     1     1     1     0     0     1     0
## 12     0     0     0     0     0     0     0     0     1
## 13     0     1     0     0     0     0     1     0     0
## 14     1     0     0     1     1     0     0     0     0
## 15     1     0     0     0     0     0     1     0     1
## 16     0     0     0     0     0     0     0     0     0
## 17     1     1     0     0     0     0     0     0     0
## 18     0     0     0     0     0     1     0     0     0
## 19     0     0     0     0     0     0     0     0     0
## 20     1     1     0     0     0     0     1     0     0
## 21     0     0     0     0     0     0     0     0     0
## 22     0     0     0     0     0     0     0     0     0
## 23     0     0     0     0     0     1     0     0     0
## 24     0     0     0     0     0     0     0     0     0
## 25     0     0     0     0     0     0     0     0     1
## 26     0     0     0     0     0     0     0     0     0
## 27     0     1     0     0     0     0     0     0     0
## 28     1     0     0     0     0     0     0     0     0
## 29     0     0     0     1     1     0     0     0     0
## 30     0     0     0     0     1     0     0     1     0
## 31     0     0     1     1     0     0     0     0     0
## 32     0     0     0     0     0     0     0     0     0
## 33     0     0     0     0     0     0     0     0     1
## 34     0     0     0     1     1     0     0     0     0
## 35     0     0     0     0     0     0     1     0     0
## attr(,"call")
## nb2mat(neighbours = WJ4, style = "B", zero.policy = TRUE)
WLJ4<-nb2listw(WJ4);WLJ4
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 140 
## Percentage nonzero weights: 11.42857 
## Average number of links: 4 
## Non-symmetric neighbours list
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0     S1     S2
## W 35 1225 35 15.875 144.75
plot(Jawa_Tengah, axes=T, col="#ffcf01")
text(Coordk[,1], Coordk[,2],  row.names(Jawa_Tengah), col="black", cex=0.8, pos=1.5)
points(Coordk[,1], Coordk[,2], pch=19, cex=0.7,col="#011f47")
plot(WJ4, coordinates(Jawa_Tengah), col="#003780", add=T)

Menghitung Inverse Distance

#Inverse Distance

Dist.mat<-as.matrix(dist(Coordk, 
                         method="euclidean"))
Dist.mat[1:35,1:35]
##           24        35        46        54        55        56        57
## 24 0.0000000 0.4927800 0.3884859 1.7520798 0.9954655 0.7863504 0.7795139
## 35 0.4927800 0.0000000 0.8115827 2.2443202 1.4755221 0.4671286 0.2874077
## 46 0.3884859 0.8115827 0.0000000 1.5271455 0.8835287 0.9347265 1.0786723
## 54 1.7520798 2.2443202 1.5271455 0.0000000 0.8127282 2.4601759 2.5314720
## 55 0.9954655 1.4755221 0.8835287 0.8127282 0.0000000 1.7601808 1.7617240
## 56 0.7863504 0.4671286 0.9347265 2.4601759 1.7601808 0.0000000 0.4332291
## 57 0.7795139 0.2874077 1.0786723 2.5314720 1.7617240 0.4332291 0.0000000
## 58 1.0696316 1.5547253 0.7783837 0.7733933 0.5077895 1.7109299 1.8355925
## 59 1.2912497 1.7838889 1.0699120 0.4623467 0.4091963 2.0004151 2.0707603
## 25 1.3635125 1.8292787 1.0210086 0.7789438 0.8454335 1.9163919 2.0996659
## 26 1.3929783 1.8565062 1.3068823 0.6506399 0.4234072 2.1702380 2.1383440
## 27 0.3060114 0.4850381 0.6793227 1.8626047 1.0600051 0.9116461 0.7453323
## 28 0.5892990 1.0655876 0.2950220 1.2321973 0.6242139 1.2287029 1.3443074
## 29 1.0189528 1.4627136 1.0087447 0.9808416 0.2695901 1.8048189 1.7404922
## 30 0.5764861 1.0447836 0.5800277 1.2345090 0.4344837 1.3584646 1.3297910
## 31 0.4593294 0.7538619 0.2239684 1.7195121 1.1056573 0.7685789 0.9887672
## 32 0.8036558 1.2894477 0.5280667 0.9996452 0.4761307 1.4625363 1.5712353
## 33 0.7257612 0.5893651 0.7611282 2.2812894 1.6303579 0.2678255 0.6616974
## 34 1.3365778 1.8203788 1.0346526 0.5920676 0.6665289 1.9609187 2.1000770
## 36 0.6075356 1.0717295 0.6151532 1.2179617 0.4126870 1.3908609 1.3559454
## 37 1.5118399 1.9969675 1.2122215 0.4800549 0.7800714 2.1373698 2.2771943
## 38 0.2974169 0.5971425 0.2436480 1.7673225 1.0919094 0.6929059 0.8493677
## 39 0.4102621 0.4726161 0.4667392 1.9930471 1.3124969 0.4680174 0.6790334
## 40 0.2517724 0.2668092 0.5451843 1.9956567 1.2470039 0.5474395 0.5435354
## 41 0.4649154 0.8273914 0.6863034 1.5523705 0.7400456 1.2200267 1.0956707
## 42 1.8938070 2.3847061 1.6186958 0.3093250 1.0347829 2.5497263 2.6686684
## 43 0.8411182 1.3280000 0.7114679 0.9270919 0.1720996 1.5954846 1.6152475
## 44 0.8206606 1.3113915 0.6626950 0.9344201 0.2283667 1.5615550 1.5987759
## 45 1.3216443 1.8042534 1.1756865 0.5143590 0.3293681 2.0771927 2.0907101
## 47 1.2223123 1.6743322 1.1756085 0.8195827 0.3203846 2.0058361 1.9534675
## 48 1.1840639 1.6510224 1.1015565 0.7421675 0.2220467 1.9603813 1.9341425
## 49 0.5932360 0.4244009 0.7031407 2.2296909 1.5417359 0.2326000 0.5322554
## 50 0.4873686 0.9801133 0.3621124 1.2651486 0.5395074 1.2243196 1.2668498
## 52 1.4582851 1.8831513 1.4509297 0.9288114 0.6115301 2.2445422 2.1532087
## 53 0.2577862 0.7327144 0.3968815 1.5188592 0.7434318 1.0424538 1.0196039
##           58        59        25        26        27        28        29
## 24 1.0696316 1.2912497 1.3635125 1.3929783 0.3060114 0.5892990 1.0189528
## 35 1.5547253 1.7838889 1.8292787 1.8565062 0.4850381 1.0655876 1.4627136
## 46 0.7783837 1.0699120 1.0210086 1.3068823 0.6793227 0.2950220 1.0087447
## 54 0.7733933 0.4623467 0.7789438 0.6506399 1.8626047 1.2321973 0.9808416
## 55 0.5077895 0.4091963 0.8454335 0.4234072 1.0600051 0.6242139 0.2695901
## 56 1.7109299 2.0004151 1.9163919 2.1702380 0.9116461 1.2287029 1.8048189
## 57 1.8355925 2.0707603 2.0996659 2.1383440 0.7453323 1.3443074 1.7404922
## 58 0.0000000 0.3597432 0.3609460 0.8072713 1.2582462 0.4925495 0.7753728
## 59 0.3597432 0.0000000 0.5520564 0.5088724 1.4160367 0.7751193 0.6470888
## 25 0.3609460 0.5520564 0.0000000 1.0603067 1.5840008 0.7748977 1.1148256
## 26 0.8072713 0.5088724 1.0603067 0.0000000 1.4082161 1.0439623 0.4112169
## 27 1.2582462 1.4160367 1.5840008 1.4082161 0.0000000 0.8193910 1.0029716
## 28 0.4925495 0.7751193 0.7748977 1.0439623 0.8193910 0.0000000 0.7974167
## 29 0.7753728 0.6470888 1.1148256 0.4112169 1.0029716 0.7974167 0.0000000
## 30 0.7000240 0.7934730 1.0564661 0.8168804 0.6284920 0.4440139 0.4512197
## 31 0.9543022 1.2691200 1.1484983 1.5290503 0.7646530 0.4995822 1.2316048
## 32 0.2659761 0.5461541 0.5884560 0.8711564 0.9996053 0.2341493 0.7046928
## 33 1.5168346 1.8282396 1.6923696 2.0503894 0.9328106 1.0538920 1.7119650
## 34 0.2672094 0.3327965 0.2225531 0.8416267 1.5226915 0.7557872 0.9314560
## 36 0.7049530 0.7817732 1.0634100 0.7872145 0.6475063 0.4721324 0.4169631
## 37 0.4424106 0.3905576 0.3029798 0.8729583 1.6909293 0.9330311 1.0328937
## 38 1.0220302 1.3080673 1.2560262 1.5119777 0.5984985 0.5359495 1.1812624
## 39 1.2433783 1.5342294 1.4609241 1.7301106 0.6574932 0.7610526 1.3866280
## 40 1.2920764 1.5336881 1.5625450 1.6441411 0.3931857 0.8011696 1.2658855
## 41 1.0320930 1.1239218 1.3835381 1.0623226 0.3514343 0.6885411 0.6539935
## 42 0.8403928 0.6340138 0.7040966 0.9471514 2.0430844 1.3314491 1.2400598
## 43 0.4475569 0.4824712 0.8067794 0.5955068 0.9363106 0.4555549 0.3687071
## 44 0.3951543 0.4790857 0.7560461 0.6487232 0.9381306 0.3960379 0.4378608
## 45 0.5893370 0.2757542 0.8272997 0.2331290 1.3871980 0.8939150 0.4667082
## 47 0.7959603 0.5715099 1.0983213 0.2011225 1.2174880 0.9349026 0.2148020
## 48 0.6746760 0.4532287 0.9751734 0.2099088 1.2098903 0.8462162 0.2405690
## 49 1.4784942 1.7707859 1.6859945 1.9562484 0.7747813 0.9976562 1.6016888
## 50 0.6054966 0.8039295 0.9353064 0.9589343 0.6530602 0.2210214 0.6466504
## 52 1.0742268 0.8066607 1.3539108 0.3049734 1.4081417 1.2213244 0.4465986
## 53 0.8830411 1.0627098 1.2085486 1.1357344 0.3761157 0.4523313 0.7624112
##           30        31        32        33        34        36        37
## 24 0.5764861 0.4593294 0.8036558 0.7257612 1.3365778 0.6075356 1.5118399
## 35 1.0447836 0.7538619 1.2894477 0.5893651 1.8203788 1.0717295 1.9969675
## 46 0.5800277 0.2239684 0.5280667 0.7611282 1.0346526 0.6151532 1.2122215
## 54 1.2345090 1.7195121 0.9996452 2.2812894 0.5920676 1.2179617 0.4800549
## 55 0.4344837 1.1056573 0.4761307 1.6303579 0.6665289 0.4126870 0.7800714
## 56 1.3584646 0.7685789 1.4625363 0.2678255 1.9609187 1.3908609 2.1373698
## 57 1.3297910 0.9887672 1.5712353 0.6616974 2.1000770 1.3559454 2.2771943
## 58 0.7000240 0.9543022 0.2659761 1.5168346 0.2672094 0.7049530 0.4424106
## 59 0.7934730 1.2691200 0.5461541 1.8282396 0.3327965 0.7817732 0.3905576
## 25 1.0564661 1.1484983 0.5884560 1.6923696 0.2225531 1.0634100 0.3029798
## 26 0.8168804 1.5290503 0.8711564 2.0503894 0.8416267 0.7872145 0.8729583
## 27 0.6284920 0.7646530 0.9996053 0.9328106 1.5226915 0.6475063 1.6909293
## 28 0.4440139 0.4995822 0.2341493 1.0538920 0.7557872 0.4721324 0.9330311
## 29 0.4512197 1.2316048 0.7046928 1.7119650 0.9314560 0.4169631 1.0328937
## 30 0.0000000 0.7970225 0.4871295 1.2608204 0.9462647 0.0355598 1.1012929
## 31 0.7970225 0.0000000 0.7229659 0.5626346 1.1963613 0.8324746 1.3717083
## 32 0.4871295 0.7229659 0.0000000 1.2827543 0.5330131 0.5016587 0.7082865
## 33 1.2608204 0.5626346 1.2827543 0.0000000 1.7557643 1.2953924 1.9297209
## 34 0.9462647 1.1963613 0.5330131 1.7557643 0.0000000 0.9464482 0.1776537
## 36 0.0355598 0.8324746 0.5016587 1.2953924 0.9464482 0.0000000 1.0983611
## 37 1.1012929 1.3717083 0.7082865 1.9297209 0.1776537 1.0983611 0.0000000
## 38 0.7323699 0.1735571 0.7699763 0.5385122 1.2776656 0.7676362 1.4551341
## 39 0.9354185 0.3172334 0.9946869 0.3257096 1.4953630 0.9698910 1.6723219
## 40 0.8273161 0.5079635 1.0277430 0.5396306 1.5567983 0.8577342 1.7338039
## 41 0.3377077 0.8565076 0.8003903 1.1887508 1.2828478 0.3433900 1.4389875
## 42 1.4258230 1.7873815 1.0994798 2.3474864 0.5918354 1.4152664 0.4212188
## 43 0.3110200 0.9335678 0.3359886 1.4601788 0.6629377 0.3001727 0.8054052
## 44 0.3257402 0.8826338 0.2668522 1.4175261 0.6252688 0.3222709 0.7762160
## 45 0.7636893 1.3916183 0.6942102 1.9337441 0.6085349 0.7409867 0.6474195
## 47 0.6473837 1.3995577 0.7964220 1.9010191 0.8924811 0.6151297 0.9599696
## 48 0.6086639 1.3245771 0.6908777 1.8414786 0.7704094 0.5798674 0.8433274
## 49 1.1516260 0.5375265 1.2311847 0.1677749 1.7283549 1.1851482 1.9048625
## 50 0.2350018 0.5853615 0.3476275 1.0915433 0.8710077 0.2673320 1.0416725
## 52 0.8972877 1.6745692 1.0875529 2.1580641 1.1386596 0.8626738 1.1774929
## 53 0.3189163 0.5706397 0.6234922 0.9619207 1.1484196 0.3497497 1.3183777
##           38        39        40        41        42         43         44
## 24 0.2974169 0.4102621 0.2517724 0.4649154 1.8938070 0.84111825 0.82066057
## 35 0.5971425 0.4726161 0.2668092 0.8273914 2.3847061 1.32800001 1.31139147
## 46 0.2436480 0.4667392 0.5451843 0.6863034 1.6186958 0.71146786 0.66269501
## 54 1.7673225 1.9930471 1.9956567 1.5523705 0.3093250 0.92709185 0.93442009
## 55 1.0919094 1.3124969 1.2470039 0.7400456 1.0347829 0.17209958 0.22836666
## 56 0.6929059 0.4680174 0.5474395 1.2200267 2.5497263 1.59548456 1.56155497
## 57 0.8493677 0.6790334 0.5435354 1.0956707 2.6686684 1.61524750 1.59877585
## 58 1.0220302 1.2433783 1.2920764 1.0320930 0.8403928 0.44755687 0.39515426
## 59 1.3080673 1.5342294 1.5336881 1.1239218 0.6340138 0.48247119 0.47908573
## 25 1.2560262 1.4609241 1.5625450 1.3835381 0.7040966 0.80677935 0.75604608
## 26 1.5119777 1.7301106 1.6441411 1.0623226 0.9471514 0.59550679 0.64872322
## 27 0.5984985 0.6574932 0.3931857 0.3514343 2.0430844 0.93631061 0.93813062
## 28 0.5359495 0.7610526 0.8011696 0.6885411 1.3314491 0.45555485 0.39603786
## 29 1.1812624 1.3866280 1.2658855 0.6539935 1.2400598 0.36870707 0.43786081
## 30 0.7323699 0.9354185 0.8273161 0.3377077 1.4258230 0.31102000 0.32574024
## 31 0.1735571 0.3172334 0.5079635 0.8565076 1.7873815 0.93356779 0.88263378
## 32 0.7699763 0.9946869 1.0277430 0.8003903 1.0994798 0.33598861 0.26685219
## 33 0.5385122 0.3257096 0.5396306 1.1887508 2.3474864 1.46017876 1.41752613
## 34 1.2776656 1.4953630 1.5567983 1.2828478 0.5918354 0.66293774 0.62526880
## 36 0.7676362 0.9698910 0.8577342 0.3433900 1.4152664 0.30017270 0.32227089
## 37 1.4551341 1.6723219 1.7338039 1.4389875 0.4212188 0.80540517 0.77621597
## 38 0.0000000 0.2263451 0.3409433 0.7298378 1.8623397 0.92203048 0.88096376
## 39 0.2263451 0.0000000 0.2866417 0.8750671 2.0828393 1.14395773 1.10503585
## 40 0.3409433 0.2866417 0.0000000 0.6738325 2.1257618 1.09121687 1.06815038
## 41 0.7298378 0.8750671 0.6738325 0.0000000 1.7578245 0.64342003 0.66329102
## 42 1.8623397 2.0828393 2.1257618 1.7578245 0.0000000 1.11533223 1.10553804
## 43 0.9220305 1.1439577 1.0912169 0.6434200 1.1153322 0.00000000 0.06916569
## 44 0.8809638 1.1050359 1.0681504 0.6632910 1.1055380 0.06916569 0.00000000
## 45 1.3979128 1.6220824 1.5725958 1.0594594 0.7797063 0.48269474 0.51705503
## 47 1.3652053 1.5772555 1.4715082 0.8687929 1.1010935 0.47999619 0.54388200
## 48 1.3032460 1.5206458 1.4354660 0.8689524 1.0096523 0.39232305 0.45040857
## 49 0.4627343 0.2366449 0.3835663 1.0484143 2.3171394 1.37478729 1.33805572
## 50 0.5530642 0.7730127 0.7312137 0.4731688 1.4107729 0.37159992 0.33904853
## 52 1.6278408 1.8325517 1.7013732 1.0576306 1.2339865 0.76852024 0.83370243
## 53 0.4593097 0.6372053 0.5084121 0.2900799 1.6807864 0.59623146 0.58462976
##           45        47        48        49        50        52        53
## 24 1.3216443 1.2223123 1.1840639 0.5932360 0.4873686 1.4582851 0.2577862
## 35 1.8042534 1.6743322 1.6510224 0.4244009 0.9801133 1.8831513 0.7327144
## 46 1.1756865 1.1756085 1.1015565 0.7031407 0.3621124 1.4509297 0.3968815
## 54 0.5143590 0.8195827 0.7421675 2.2296909 1.2651486 0.9288114 1.5188592
## 55 0.3293681 0.3203846 0.2220467 1.5417359 0.5395074 0.6115301 0.7434318
## 56 2.0771927 2.0058361 1.9603813 0.2326000 1.2243196 2.2445422 1.0424538
## 57 2.0907101 1.9534675 1.9341425 0.5322554 1.2668498 2.1532087 1.0196039
## 58 0.5893370 0.7959603 0.6746760 1.4784942 0.6054966 1.0742268 0.8830411
## 59 0.2757542 0.5715099 0.4532287 1.7707859 0.8039295 0.8066607 1.0627098
## 25 0.8272997 1.0983213 0.9751734 1.6859945 0.9353064 1.3539108 1.2085486
## 26 0.2331290 0.2011225 0.2099088 1.9562484 0.9589343 0.3049734 1.1357344
## 27 1.3871980 1.2174880 1.2098903 0.7747813 0.6530602 1.4081417 0.3761157
## 28 0.8939150 0.9349026 0.8462162 0.9976562 0.2210214 1.2213244 0.4523313
## 29 0.4667082 0.2148020 0.2405690 1.6016888 0.6466504 0.4465986 0.7624112
## 30 0.7636893 0.6473837 0.6086639 1.1516260 0.2350018 0.8972877 0.3189163
## 31 1.3916183 1.3995577 1.3245771 0.5375265 0.5853615 1.6745692 0.5706397
## 32 0.6942102 0.7964220 0.6908777 1.2311847 0.3476275 1.0875529 0.6234922
## 33 1.9337441 1.9010191 1.8414786 0.1677749 1.0915433 2.1580641 0.9619207
## 34 0.6085349 0.8924811 0.7704094 1.7283549 0.8710077 1.1386596 1.1484196
## 36 0.7409867 0.6151297 0.5798674 1.1851482 0.2673320 0.8626738 0.3497497
## 37 0.6474195 0.9599696 0.8433274 1.9048625 1.0416725 1.1774929 1.3183777
## 38 1.3979128 1.3652053 1.3032460 0.4627343 0.5530642 1.6278408 0.4593097
## 39 1.6220824 1.5772555 1.5206458 0.2366449 0.7730127 1.8325517 0.6372053
## 40 1.5725958 1.4715082 1.4354660 0.3835663 0.7312137 1.7013732 0.5084121
## 41 1.0594594 0.8687929 0.8689524 1.0484143 0.4731688 1.0576306 0.2900799
## 42 0.7797063 1.1010935 1.0096523 2.3171394 1.4107729 1.2339865 1.6807864
## 43 0.4826947 0.4799962 0.3923230 1.3747873 0.3715999 0.7685202 0.5962315
## 44 0.5170550 0.5438820 0.4504086 1.3380557 0.3390485 0.8337024 0.5846298
## 45 0.0000000 0.3265138 0.2303971 1.8547994 0.8528979 0.5328630 1.0717119
## 47 0.3265138 0.0000000 0.1232892 1.7977617 0.8170214 0.2911482 0.9646124
## 48 0.2303971 0.1232892 0.0000000 1.7464022 0.7504299 0.4030696 0.9271904
## 49 1.8547994 1.7977617 1.7464022 0.0000000 1.0032006 2.0453617 0.8417461
## 50 0.8528979 0.8170214 0.7504299 1.0032006 0.0000000 1.0892789 0.2775474
## 52 0.5328630 0.2911482 0.4030696 2.0453617 1.0892789 0.0000000 1.2040485
## 53 1.0717119 0.9646124 0.9271904 0.8417461 0.2775474 1.2040485 0.0000000
Dist.mat.inv<-1/Dist.mat
diag(Dist.mat.inv)<-0
Dist.mat.inv[1:35,1:35]
##           24        35        46        54        55        56        57
## 24 0.0000000 2.0293030 2.5740962 0.5707503 1.0045552 1.2716976 1.2828508
## 35 2.0293030 0.0000000 1.2321604 0.4455692 0.6777262 2.1407381 3.4793782
## 46 2.5740962 1.2321604 0.0000000 0.6548165 1.1318251 1.0698317 0.9270656
## 54 0.5707503 0.4455692 0.6548165 0.0000000 1.2304236 0.4064750 0.3950271
## 55 1.0045552 0.6777262 1.1318251 1.2304236 0.0000000 0.5681235 0.5676258
## 56 1.2716976 2.1407381 1.0698317 0.4064750 0.5681235 0.0000000 2.3082476
## 57 1.2828508 3.4793782 0.9270656 0.3950271 0.5676258 2.3082476 0.0000000
## 58 0.9349013 0.6432004 1.2847135 1.2930032 1.9693200 0.5844775 0.5447832
## 59 0.7744436 0.5605730 0.9346563 2.1628791 2.4438150 0.4998962 0.4829144
## 25 0.7333999 0.5466636 0.9794237 1.2837897 1.1828251 0.5218139 0.4762662
## 26 0.7178863 0.5386462 0.7651798 1.5369484 2.3617925 0.4607789 0.4676516
## 27 3.2678522 2.0616937 1.4720545 0.5368826 0.9433917 1.0969168 1.3416834
## 28 1.6969315 0.9384493 3.3895773 0.8115584 1.6020149 0.8138664 0.7438775
## 29 0.9813997 0.6836608 0.9913312 1.0195326 3.7093349 0.5540722 0.5745501
## 30 1.7346473 0.9571360 1.7240557 0.8100386 2.3015826 0.7361252 0.7519979
## 31 2.1770869 1.3265030 4.4649160 0.5815603 0.9044394 1.3011027 1.0113604
## 32 1.2443138 0.7755258 1.8937001 1.0003549 2.1002635 0.6837437 0.6364419
## 33 1.3778636 1.6967412 1.3138390 0.4383486 0.6133623 3.7337743 1.5112648
## 34 0.7481794 0.5493362 0.9665080 1.6889962 1.5003101 0.5099651 0.4761730
## 36 1.6459940 0.9330712 1.6256113 0.8210439 2.4231441 0.7189792 0.7374928
## 37 0.6614457 0.5007593 0.8249318 2.0830951 1.2819339 0.4678648 0.4391369
## 38 3.3622838 1.6746421 4.1042810 0.5658277 0.9158269 1.4431973 1.1773464
## 39 2.4374664 2.1158821 2.1425242 0.5017443 0.7619066 2.1366728 1.4726817
## 40 3.9718405 3.7479972 1.8342421 0.5010882 0.8019221 1.8266857 1.8398067
## 41 2.1509291 1.2086178 1.4570816 0.6441761 1.3512681 0.8196542 0.9126829
## 42 0.5280369 0.4193389 0.6177813 3.2328462 0.9663862 0.3921990 0.3747187
## 43 1.1888935 0.7530120 1.4055449 1.0786418 5.8105896 0.6267688 0.6191002
## 44 1.2185306 0.7625488 1.5089898 1.0701825 4.3789229 0.6403873 0.6254785
## 45 0.7566332 0.5542459 0.8505669 1.9441675 3.0361165 0.4814190 0.4783064
## 47 0.8181216 0.5972530 0.8506233 1.2201331 3.1212483 0.4985452 0.5119102
## 48 0.8445490 0.6056853 0.9078064 1.3474048 4.5035570 0.5101048 0.5170250
## 49 1.6856697 2.3562626 1.4221905 0.4484927 0.6486195 4.2992256 1.8787973
## 50 2.0518351 1.0202902 2.7615735 0.7904210 1.8535426 0.8167802 0.7893596
## 52 0.6857370 0.5310248 0.6892133 1.0766449 1.6352424 0.4455252 0.4644232
## 53 3.8791835 1.3647882 2.5196437 0.6583889 1.3451133 0.9592751 0.9807730
##           58        59        25        26        27        28        29
## 24 0.9349013 0.7744436 0.7333999 0.7178863 3.2678522 1.6969315 0.9813997
## 35 0.6432004 0.5605730 0.5466636 0.5386462 2.0616937 0.9384493 0.6836608
## 46 1.2847135 0.9346563 0.9794237 0.7651798 1.4720545 3.3895773 0.9913312
## 54 1.2930032 2.1628791 1.2837897 1.5369484 0.5368826 0.8115584 1.0195326
## 55 1.9693200 2.4438150 1.1828251 2.3617925 0.9433917 1.6020149 3.7093349
## 56 0.5844775 0.4998962 0.5218139 0.4607789 1.0969168 0.8138664 0.5540722
## 57 0.5447832 0.4829144 0.4762662 0.4676516 1.3416834 0.7438775 0.5745501
## 58 0.0000000 2.7797608 2.7704972 1.2387409 0.7947570 2.0302529 1.2897022
## 59 2.7797608 0.0000000 1.8114091 1.9651292 0.7061964 1.2901239 1.5453829
## 25 2.7704972 1.8114091 0.0000000 0.9431234 0.6313128 1.2904930 0.8970013
## 26 1.2387409 1.9651292 0.9431234 0.0000000 0.7101183 0.9578890 2.4318068
## 27 0.7947570 0.7061964 0.6313128 0.7101183 0.0000000 1.2204186 0.9970372
## 28 2.0302529 1.2901239 1.2904930 0.9578890 1.2204186 0.0000000 1.2540495
## 29 1.2897022 1.5453829 0.8970013 2.4318068 0.9970372 1.2540495 0.0000000
## 30 1.4285225 1.2602823 0.9465519 1.2241694 1.5911102 2.2521820 2.2162151
## 31 1.0478861 0.7879476 0.8707022 0.6540007 1.3077827 2.0016725 0.8119487
## 32 3.7597369 1.8309850 1.6993625 1.1478995 1.0003949 4.2707798 1.4190580
## 33 0.6592676 0.5469743 0.5908875 0.4877122 1.0720290 0.9488638 0.5841241
## 34 3.7423830 3.0048395 4.4933107 1.1881752 0.6567318 1.3231238 1.0735880
## 36 1.4185344 1.2791433 0.9403711 1.2703017 1.5443866 2.1180497 2.3982936
## 37 2.2603435 2.5604418 3.3005501 1.1455301 0.5913908 1.0717756 0.9681539
## 38 0.9784447 0.7644867 0.7961617 0.6613854 1.6708481 1.8658474 0.8465520
## 39 0.8042605 0.6517930 0.6844983 0.5779977 1.5209282 1.3139696 0.7211740
## 40 0.7739480 0.6520231 0.6399816 0.6082203 2.5433276 1.2481752 0.7899608
## 41 0.9689049 0.8897416 0.7227846 0.9413337 2.8454819 1.4523461 1.5290672
## 42 1.1899198 1.5772526 1.4202597 1.0557974 0.4894560 0.7510614 0.8064127
## 43 2.2343529 2.0726626 1.2394963 1.6792420 1.0680216 2.1951253 2.7121802
## 44 2.5306573 2.0873091 1.3226707 1.5414894 1.0659496 2.5250111 2.2838308
## 45 1.6968222 3.6264184 1.2087519 4.2894700 0.7208776 1.1186745 2.1426665
## 47 1.2563441 1.7497510 0.9104804 4.9720937 0.8213634 1.0696302 4.6554511
## 48 1.4821930 2.2063915 1.0254586 4.7639735 0.8265212 1.1817312 4.1568109
## 49 0.6763638 0.5647210 0.5931218 0.5111825 1.2906868 1.0023493 0.6243410
## 50 1.6515369 1.2438902 1.0691684 1.0428243 1.5312525 4.5244490 1.5464306
## 52 0.9309021 1.2396786 0.7386011 3.2789749 0.7101558 0.8187833 2.2391473
## 53 1.1324502 0.9409906 0.8274388 0.8804876 2.6587563 2.2107687 1.3116282
##            30        31        32        33        34         36        37
## 24  1.7346473 2.1770869 1.2443138 1.3778636 0.7481794  1.6459940 0.6614457
## 35  0.9571360 1.3265030 0.7755258 1.6967412 0.5493362  0.9330712 0.5007593
## 46  1.7240557 4.4649160 1.8937001 1.3138390 0.9665080  1.6256113 0.8249318
## 54  0.8100386 0.5815603 1.0003549 0.4383486 1.6889962  0.8210439 2.0830951
## 55  2.3015826 0.9044394 2.1002635 0.6133623 1.5003101  2.4231441 1.2819339
## 56  0.7361252 1.3011027 0.6837437 3.7337743 0.5099651  0.7189792 0.4678648
## 57  0.7519979 1.0113604 0.6364419 1.5112648 0.4761730  0.7374928 0.4391369
## 58  1.4285225 1.0478861 3.7597369 0.6592676 3.7423830  1.4185344 2.2603435
## 59  1.2602823 0.7879476 1.8309850 0.5469743 3.0048395  1.2791433 2.5604418
## 25  0.9465519 0.8707022 1.6993625 0.5908875 4.4933107  0.9403711 3.3005501
## 26  1.2241694 0.6540007 1.1478995 0.4877122 1.1881752  1.2703017 1.1455301
## 27  1.5911102 1.3077827 1.0003949 1.0720290 0.6567318  1.5443866 0.5913908
## 28  2.2521820 2.0016725 4.2707798 0.9488638 1.3231238  2.1180497 1.0717756
## 29  2.2162151 0.8119487 1.4190580 0.5841241 1.0735880  2.3982936 0.9681539
## 30  0.0000000 1.2546698 2.0528421 0.7931344 1.0567868 28.1216463 0.9080237
## 31  1.2546698 0.0000000 1.3831911 1.7773526 0.8358679  1.2012379 0.7290180
## 32  2.0528421 1.3831911 0.0000000 0.7795725 1.8761265  1.9933873 1.4118580
## 33  0.7931344 1.7773526 0.7795725 0.0000000 0.5695525  0.7719668 0.5182096
## 34  1.0567868 0.8358679 1.8761265 0.5695525 0.0000000  1.0565819 5.6289273
## 36 28.1216463 1.2012379 1.9933873 0.7719668 1.0565819  0.0000000 0.9104474
## 37  0.9080237 0.7290180 1.4118580 0.5182096 5.6289273  0.9104474 0.0000000
## 38  1.3654303 5.7617935 1.2987412 1.8569680 0.7826774  1.3027005 0.6872219
## 39  1.0690402 3.1522535 1.0053414 3.0702199 0.6687339  1.0310437 0.5979710
## 40  1.2087279 1.9686455 0.9730059 1.8531196 0.6423440  1.1658624 0.5767665
## 41  2.9611405 1.1675320 1.2493905 0.8412192 0.7795157  2.9121404 0.6949331
## 42  0.7013493 0.5594776 0.9095210 0.4259876 1.6896590  0.7065808 2.3740633
## 43  3.2152273 1.0711595 2.9762914 0.6848477 1.5084373  3.3314155 1.2416111
## 44  3.0699308 1.1329727 3.7473930 0.7054544 1.5993122  3.1029796 1.2883012
## 45  1.3094331 0.7185879 1.4404859 0.5171315 1.6432913  1.3495518 1.5445936
## 47  1.5446790 0.7145115 1.2556157 0.5260336 1.1204719  1.6256735 1.0416996
## 48  1.6429429 0.7549579 1.4474343 0.5430419 1.2980112  1.7245321 1.1857792
## 49  0.8683375 1.8603733 0.8122258 5.9603668 0.5785849  0.8437763 0.5249723
## 50  4.2552861 1.7083462 2.8766422 0.9161340 1.1480955  3.7406664 0.9599946
## 52  1.1144698 0.5971685 0.9194955 0.4633783 0.8782256  1.1591868 0.8492620
## 53  3.1356194 1.7524193 1.6038692 1.0395868 0.8707619  2.8591873 0.7585080
##           38        39        40        41        42         43         44
## 24 3.3622838 2.4374664 3.9718405 2.1509291 0.5280369  1.1888935  1.2185306
## 35 1.6746421 2.1158821 3.7479972 1.2086178 0.4193389  0.7530120  0.7625488
## 46 4.1042810 2.1425242 1.8342421 1.4570816 0.6177813  1.4055449  1.5089898
## 54 0.5658277 0.5017443 0.5010882 0.6441761 3.2328462  1.0786418  1.0701825
## 55 0.9158269 0.7619066 0.8019221 1.3512681 0.9663862  5.8105896  4.3789229
## 56 1.4431973 2.1366728 1.8266857 0.8196542 0.3921990  0.6267688  0.6403873
## 57 1.1773464 1.4726817 1.8398067 0.9126829 0.3747187  0.6191002  0.6254785
## 58 0.9784447 0.8042605 0.7739480 0.9689049 1.1899198  2.2343529  2.5306573
## 59 0.7644867 0.6517930 0.6520231 0.8897416 1.5772526  2.0726626  2.0873091
## 25 0.7961617 0.6844983 0.6399816 0.7227846 1.4202597  1.2394963  1.3226707
## 26 0.6613854 0.5779977 0.6082203 0.9413337 1.0557974  1.6792420  1.5414894
## 27 1.6708481 1.5209282 2.5433276 2.8454819 0.4894560  1.0680216  1.0659496
## 28 1.8658474 1.3139696 1.2481752 1.4523461 0.7510614  2.1951253  2.5250111
## 29 0.8465520 0.7211740 0.7899608 1.5290672 0.8064127  2.7121802  2.2838308
## 30 1.3654303 1.0690402 1.2087279 2.9611405 0.7013493  3.2152273  3.0699308
## 31 5.7617935 3.1522535 1.9686455 1.1675320 0.5594776  1.0711595  1.1329727
## 32 1.2987412 1.0053414 0.9730059 1.2493905 0.9095210  2.9762914  3.7473930
## 33 1.8569680 3.0702199 1.8531196 0.8412192 0.4259876  0.6848477  0.7054544
## 34 0.7826774 0.6687339 0.6423440 0.7795157 1.6896590  1.5084373  1.5993122
## 36 1.3027005 1.0310437 1.1658624 2.9121404 0.7065808  3.3314155  3.1029796
## 37 0.6872219 0.5979710 0.5767665 0.6949331 2.3740633  1.2416111  1.2883012
## 38 0.0000000 4.4180317 2.9330388 1.3701675 0.5369590  1.0845628  1.1351205
## 39 4.4180317 0.0000000 3.4886764 1.1427695 0.4801138  0.8741582  0.9049480
## 40 2.9330388 3.4886764 0.0000000 1.4840483 0.4704196  0.9164081  0.9361978
## 41 1.3701675 1.1427695 1.4840483 0.0000000 0.5688850  1.5541947  1.5076339
## 42 0.5369590 0.4801138 0.4704196 0.5688850 0.0000000  0.8965938  0.9045369
## 43 1.0845628 0.8741582 0.9164081 1.5541947 0.8965938  0.0000000 14.4580362
## 44 1.1351205 0.9049480 0.9361978 1.5076339 0.9045369 14.4580362  0.0000000
## 45 0.7153522 0.6164915 0.6358913 0.9438776 1.2825342  2.0717027  1.9340301
## 47 0.7324906 0.6340127 0.6795749 1.1510223 0.9081881  2.0833499  1.8386341
## 48 0.7673149 0.6576153 0.6966379 1.1508111 0.9904400  2.5489198  2.2202064
## 49 2.1610674 4.2257407 2.6071111 0.9538214 0.4315666  0.7273853  0.7473530
## 50 1.8081083 1.2936398 1.3675892 2.1134105 0.7088313  2.6910663  2.9494303
## 52 0.6143107 0.5456872 0.5877605 0.9455097 0.8103817  1.3012019  1.1994687
## 53 2.1771804 1.5693529 1.9669083 3.4473255 0.5949596  1.6772010  1.7104843
##           45        47        48        49        50        52        53
## 24 0.7566332 0.8181216 0.8445490 1.6856697 2.0518351 0.6857370 3.8791835
## 35 0.5542459 0.5972530 0.6056853 2.3562626 1.0202902 0.5310248 1.3647882
## 46 0.8505669 0.8506233 0.9078064 1.4221905 2.7615735 0.6892133 2.5196437
## 54 1.9441675 1.2201331 1.3474048 0.4484927 0.7904210 1.0766449 0.6583889
## 55 3.0361165 3.1212483 4.5035570 0.6486195 1.8535426 1.6352424 1.3451133
## 56 0.4814190 0.4985452 0.5101048 4.2992256 0.8167802 0.4455252 0.9592751
## 57 0.4783064 0.5119102 0.5170250 1.8787973 0.7893596 0.4644232 0.9807730
## 58 1.6968222 1.2563441 1.4821930 0.6763638 1.6515369 0.9309021 1.1324502
## 59 3.6264184 1.7497510 2.2063915 0.5647210 1.2438902 1.2396786 0.9409906
## 25 1.2087519 0.9104804 1.0254586 0.5931218 1.0691684 0.7386011 0.8274388
## 26 4.2894700 4.9720937 4.7639735 0.5111825 1.0428243 3.2789749 0.8804876
## 27 0.7208776 0.8213634 0.8265212 1.2906868 1.5312525 0.7101558 2.6587563
## 28 1.1186745 1.0696302 1.1817312 1.0023493 4.5244490 0.8187833 2.2107687
## 29 2.1426665 4.6554511 4.1568109 0.6243410 1.5464306 2.2391473 1.3116282
## 30 1.3094331 1.5446790 1.6429429 0.8683375 4.2552861 1.1144698 3.1356194
## 31 0.7185879 0.7145115 0.7549579 1.8603733 1.7083462 0.5971685 1.7524193
## 32 1.4404859 1.2556157 1.4474343 0.8122258 2.8766422 0.9194955 1.6038692
## 33 0.5171315 0.5260336 0.5430419 5.9603668 0.9161340 0.4633783 1.0395868
## 34 1.6432913 1.1204719 1.2980112 0.5785849 1.1480955 0.8782256 0.8707619
## 36 1.3495518 1.6256735 1.7245321 0.8437763 3.7406664 1.1591868 2.8591873
## 37 1.5445936 1.0416996 1.1857792 0.5249723 0.9599946 0.8492620 0.7585080
## 38 0.7153522 0.7324906 0.7673149 2.1610674 1.8081083 0.6143107 2.1771804
## 39 0.6164915 0.6340127 0.6576153 4.2257407 1.2936398 0.5456872 1.5693529
## 40 0.6358913 0.6795749 0.6966379 2.6071111 1.3675892 0.5877605 1.9669083
## 41 0.9438776 1.1510223 1.1508111 0.9538214 2.1134105 0.9455097 3.4473255
## 42 1.2825342 0.9081881 0.9904400 0.4315666 0.7088313 0.8103817 0.5949596
## 43 2.0717027 2.0833499 2.5489198 0.7273853 2.6910663 1.3012019 1.6772010
## 44 1.9340301 1.8386341 2.2202064 0.7473530 2.9494303 1.1994687 1.7104843
## 45 0.0000000 3.0626574 4.3403326 0.5391419 1.1724732 1.8766550 0.9330866
## 47 3.0626574 0.0000000 8.1110081 0.5562472 1.2239581 3.4346770 1.0366858
## 48 4.3403326 8.1110081 0.0000000 0.5726058 1.3325694 2.4809609 1.0785271
## 49 0.5391419 0.5562472 0.5726058 0.0000000 0.9968096 0.4889111 1.1880066
## 50 1.1724732 1.2239581 1.3325694 0.9968096 0.0000000 0.9180385 3.6029885
## 52 1.8766550 3.4346770 2.4809609 0.4889111 0.9180385 0.0000000 0.8305313
## 53 0.9330866 1.0366858 1.0785271 1.1880066 3.6029885 0.8305313 0.0000000
Dist.mat.invs<-mat2listw(Dist.mat.inv, 
                         style="W")
summary(Dist.mat.invs)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 35 
## Number of nonzero links: 1190 
## Percentage nonzero weights: 97.14286 
## Average number of links: 34 
## Link number distribution:
## 
## 34 
## 35 
## 35 least connected regions:
## 24 35 46 54 55 56 57 58 59 25 26 27 28 29 30 31 32 33 34 36 37 38 39 40 41 42 43 44 45 47 48 49 50 52 53 with 34 links
## 35 most connected regions:
## 24 35 46 54 55 56 57 58 59 25 26 27 28 29 30 31 32 33 34 36 37 38 39 40 41 42 43 44 45 47 48 49 50 52 53 with 34 links
## 
## Weights style: W 
## Weights constants summary:
##    n   nn S0      S1       S2
## W 35 1225 35 3.50751 141.1293

Asumsi Autokorelasi Spasial

#MORAN’S INDEX and LOCAL MORAN’s INDEX

Kasus<-data$BGK

#Berdasarkan contiguity #Rook

moran.test(Kasus,WLR)
## 
##  Moran I test under randomisation
## 
## data:  Kasus  
## weights: WLR    
## 
## Moran I statistic standard deviate = 0.9792, p-value = 0.1637
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.08487630       -0.02941176        0.01362247
moran.plot(Kasus,WLR)

locm<-localmoran(Kasus,WLR)
locm
##              Ii          E.Ii      Var.Ii        Z.Ii Pr(z != E(Ii))
## 1   0.638002835 -0.1476468625 0.622880410  0.99546641     0.31950947
## 2  -0.206074763 -0.0591914090 0.227813670 -0.30773911     0.75828086
## 3   0.157913102 -0.0163158335 0.098729524  0.55449389     0.57924089
## 4   0.056635068 -0.0006964607 0.007627612  0.65644634     0.51153698
## 5  -0.068912058 -0.0149716249 0.050834101 -0.23924169     0.81091818
## 6  -0.191426973 -0.0437377150 0.332696694 -0.25604993     0.79791228
## 7  -0.014057679 -0.0043599745 0.047575224 -0.04446093     0.96453699
## 8   0.596171957 -0.0221903113 0.133474969  1.69255608     0.09054000
## 9  -0.022258077 -0.0002794180 0.001142754 -0.65016676     0.51558451
## 10 -0.203478037 -0.0345149104 0.365213536 -0.27958799     0.77979363
## 11  0.150264857 -0.0010962133 0.006735980  1.84422449     0.06515043
## 12 -0.037038954 -0.0002363011 0.001453266 -0.96539834     0.33434533
## 13 -0.167657865 -0.0128129863 0.077809369 -0.55511236     0.57881781
## 14  0.299159898 -0.0123010611 0.206177490  0.68593504     0.49275407
## 15 -0.378505718 -0.0022295497 0.077860259 -1.34849330     0.17749977
## 16  0.191725030 -0.0056743985 0.095746419  0.63794703     0.52350816
## 17  0.366178660 -0.0053748008 0.058589038  1.53501677     0.12477971
## 18 -1.572495601 -0.0380983112 0.621885599 -1.94572999     0.05168718
## 19 -0.065544933 -0.0034543887 0.027383172 -0.37521793     0.70749839
## 20  0.095254759 -0.0555865725 0.259832178  0.29591971     0.76729140
## 21 -0.124619263 -0.0349054438 0.207226422 -0.19707738     0.84376698
## 22  0.087296248 -0.0004832593 0.002971340  1.61033760     0.10732418
## 23 -0.091664047 -0.0110810466 0.087167953 -0.27293863     0.78490039
## 24  0.471566912 -0.0103905688 0.081793448  1.68519230     0.09195148
## 25 -0.007904099 -0.0004248781 0.004654514 -0.10962742     0.91270486
## 26 -0.051433808 -0.0002013453 0.003416081 -0.87655904     0.38072620
## 27  1.614333944 -0.0137481437 0.474569629  2.36334066     0.01811101
## 28  0.630119346 -0.1639777263 0.472541738  1.15519023     0.24801253
## 29 -0.106969255 -0.0169325828 0.182432014 -0.21079917     0.83304398
## 30  0.764944921 -0.0789746761 0.447446920  1.26162507     0.20708373
## 31  0.437606646 -0.0405386400 0.426276320  0.73234256     0.46395951
## 32 -0.279239493 -0.0701007143 0.518529806 -0.29043417     0.77148411
## 33 -0.584290147 -0.0406469307 0.310185573 -0.97611992     0.32900504
## 34  0.946774171 -0.0314316084 0.516619726  1.36095803     0.17352695
## 35 -0.359707110 -0.0348050976 0.137428784 -0.87642256     0.38080036
## attr(,"call")
## localmoran(x = Kasus, listw = WLR)
## attr(,"class")
## [1] "localmoran" "matrix"     "array"     
## attr(,"quadr")
##         mean    median     pysal
## 1  High-High High-High High-High
## 2   High-Low  High-Low  High-Low
## 3  High-High High-High High-High
## 4    Low-Low   Low-Low   Low-Low
## 5   High-Low  High-Low  High-Low
## 6   Low-High   Low-Low  Low-High
## 7    Low-Low   Low-Low  Low-High
## 8  High-High High-High High-High
## 9   Low-High High-High  Low-High
## 10  High-Low  High-Low  High-Low
## 11   Low-Low   Low-Low   Low-Low
## 12  Low-High High-High  Low-High
## 13  Low-High  Low-High  Low-High
## 14   Low-Low   Low-Low   Low-Low
## 15  Low-High  Low-High  Low-High
## 16 High-High High-High High-High
## 17 High-High High-High High-High
## 18  High-Low  High-Low  High-Low
## 19  Low-High  Low-High  Low-High
## 20  High-Low  High-Low High-High
## 21   Low-Low   Low-Low  Low-High
## 22 High-High High-High High-High
## 23  Low-High   Low-Low  Low-High
## 24 High-High High-High High-High
## 25   Low-Low   Low-Low  Low-High
## 26  High-Low  High-Low  High-Low
## 27 High-High High-High High-High
## 28 High-High High-High High-High
## 29   Low-Low   Low-Low  Low-High
## 30   Low-Low   Low-Low   Low-Low
## 31   Low-Low   Low-Low   Low-Low
## 32  Low-High  Low-High  Low-High
## 33  Low-High  Low-High  Low-High
## 34   Low-Low   Low-Low   Low-Low
## 35  Low-High  Low-High  Low-High

#Queen

moran.test(Kasus,WLQ)
## 
##  Moran I test under randomisation
## 
## data:  Kasus  
## weights: WLQ    
## 
## Moran I statistic standard deviate = 0.9792, p-value = 0.1637
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.08487630       -0.02941176        0.01362247
moran.plot(Kasus,WLQ)

locm<-localmoran(Kasus,WLQ)
locm
##              Ii          E.Ii      Var.Ii        Z.Ii Pr(z != E(Ii))
## 1   0.638002835 -0.1476468625 0.622880410  0.99546641     0.31950947
## 2  -0.206074763 -0.0591914090 0.227813670 -0.30773911     0.75828086
## 3   0.157913102 -0.0163158335 0.098729524  0.55449389     0.57924089
## 4   0.056635068 -0.0006964607 0.007627612  0.65644634     0.51153698
## 5  -0.068912058 -0.0149716249 0.050834101 -0.23924169     0.81091818
## 6  -0.191426973 -0.0437377150 0.332696694 -0.25604993     0.79791228
## 7  -0.014057679 -0.0043599745 0.047575224 -0.04446093     0.96453699
## 8   0.596171957 -0.0221903113 0.133474969  1.69255608     0.09054000
## 9  -0.022258077 -0.0002794180 0.001142754 -0.65016676     0.51558451
## 10 -0.203478037 -0.0345149104 0.365213536 -0.27958799     0.77979363
## 11  0.150264857 -0.0010962133 0.006735980  1.84422449     0.06515043
## 12 -0.037038954 -0.0002363011 0.001453266 -0.96539834     0.33434533
## 13 -0.167657865 -0.0128129863 0.077809369 -0.55511236     0.57881781
## 14  0.299159898 -0.0123010611 0.206177490  0.68593504     0.49275407
## 15 -0.378505718 -0.0022295497 0.077860259 -1.34849330     0.17749977
## 16  0.191725030 -0.0056743985 0.095746419  0.63794703     0.52350816
## 17  0.366178660 -0.0053748008 0.058589038  1.53501677     0.12477971
## 18 -1.572495601 -0.0380983112 0.621885599 -1.94572999     0.05168718
## 19 -0.065544933 -0.0034543887 0.027383172 -0.37521793     0.70749839
## 20  0.095254759 -0.0555865725 0.259832178  0.29591971     0.76729140
## 21 -0.124619263 -0.0349054438 0.207226422 -0.19707738     0.84376698
## 22  0.087296248 -0.0004832593 0.002971340  1.61033760     0.10732418
## 23 -0.091664047 -0.0110810466 0.087167953 -0.27293863     0.78490039
## 24  0.471566912 -0.0103905688 0.081793448  1.68519230     0.09195148
## 25 -0.007904099 -0.0004248781 0.004654514 -0.10962742     0.91270486
## 26 -0.051433808 -0.0002013453 0.003416081 -0.87655904     0.38072620
## 27  1.614333944 -0.0137481437 0.474569629  2.36334066     0.01811101
## 28  0.630119346 -0.1639777263 0.472541738  1.15519023     0.24801253
## 29 -0.106969255 -0.0169325828 0.182432014 -0.21079917     0.83304398
## 30  0.764944921 -0.0789746761 0.447446920  1.26162507     0.20708373
## 31  0.437606646 -0.0405386400 0.426276320  0.73234256     0.46395951
## 32 -0.279239493 -0.0701007143 0.518529806 -0.29043417     0.77148411
## 33 -0.584290147 -0.0406469307 0.310185573 -0.97611992     0.32900504
## 34  0.946774171 -0.0314316084 0.516619726  1.36095803     0.17352695
## 35 -0.359707110 -0.0348050976 0.137428784 -0.87642256     0.38080036
## attr(,"call")
## localmoran(x = Kasus, listw = WLQ)
## attr(,"class")
## [1] "localmoran" "matrix"     "array"     
## attr(,"quadr")
##         mean    median     pysal
## 1  High-High High-High High-High
## 2   High-Low  High-Low  High-Low
## 3  High-High High-High High-High
## 4    Low-Low   Low-Low   Low-Low
## 5   High-Low  High-Low  High-Low
## 6   Low-High   Low-Low  Low-High
## 7    Low-Low   Low-Low  Low-High
## 8  High-High High-High High-High
## 9   Low-High High-High  Low-High
## 10  High-Low  High-Low  High-Low
## 11   Low-Low   Low-Low   Low-Low
## 12  Low-High High-High  Low-High
## 13  Low-High  Low-High  Low-High
## 14   Low-Low   Low-Low   Low-Low
## 15  Low-High  Low-High  Low-High
## 16 High-High High-High High-High
## 17 High-High High-High High-High
## 18  High-Low  High-Low  High-Low
## 19  Low-High  Low-High  Low-High
## 20  High-Low  High-Low High-High
## 21   Low-Low   Low-Low  Low-High
## 22 High-High High-High High-High
## 23  Low-High   Low-Low  Low-High
## 24 High-High High-High High-High
## 25   Low-Low   Low-Low  Low-High
## 26  High-Low  High-Low  High-Low
## 27 High-High High-High High-High
## 28 High-High High-High High-High
## 29   Low-Low   Low-Low  Low-High
## 30   Low-Low   Low-Low   Low-Low
## 31   Low-Low   Low-Low   Low-Low
## 32  Low-High  Low-High  Low-High
## 33  Low-High  Low-High  Low-High
## 34   Low-Low   Low-Low   Low-Low
## 35  Low-High  Low-High  Low-High

#Berdasarkan jarak #k=2

moran.test(Kasus,WLJ2)
## 
##  Moran I test under randomisation
## 
## data:  Kasus  
## weights: WLJ2    
## 
## Moran I statistic standard deviate = 1.2819, p-value = 0.09994
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.16178383       -0.02941176        0.02224650
moran.plot(Kasus,WLJ2)

locm<-localmoran(Kasus,WLJ2)
locm
##              Ii          E.Ii      Var.Ii        Z.Ii Pr(z != E(Ii))
## 1  -0.552803154 -0.1476468625 2.135589977 -0.27724495    0.781592024
## 2   0.148498319 -0.0591914090 0.945004855  0.21364759    0.830821885
## 3   0.211309439 -0.0163158335 0.272357309  0.43616515    0.662716911
## 4   0.001133344 -0.0006964607 0.011810496  0.01683723    0.986566465
## 5  -0.174914484 -0.0149716249 0.250260188 -0.31971939    0.749181062
## 6   0.247369320 -0.0437377150 0.709752948  0.34554061    0.729687984
## 7  -0.038341868 -0.0043599745 0.073664863 -0.12520376    0.900362239
## 8   0.036818382 -0.0221903113 0.368206811  0.09724563    0.922531333
## 9   0.053679256 -0.0002794180 0.004740314  0.78371418    0.433207841
## 10 -0.775689286 -0.0345149104 0.565491927 -0.98561474    0.324322200
## 11  0.271502307 -0.0010962133 0.018582015  1.99975639    0.045526575
## 12 -0.095027320 -0.0002363011 0.004009010 -1.49709245    0.134369205
## 13  0.246884222 -0.0128129863 0.214646535  0.56053836    0.575112281
## 14  0.909488653 -0.0123010611 0.206177490  2.03007103    0.042349320
## 15 -0.027418259 -0.0022295497 0.037750428 -0.12964177    0.896849851
## 16  0.191725030 -0.0056743985 0.095746419  0.63794703    0.523508161
## 17  0.044580505 -0.0053748008 0.090718511  0.16585694    0.868269531
## 18 -1.572495601 -0.0380983112 0.621885599 -1.94572999    0.051687182
## 19  0.001047215 -0.0034543887 0.058417433  0.01862499    0.985140267
## 20 -0.997320559 -0.0555865725 0.890853183 -0.99775790    0.318396768
## 21 -0.403390847 -0.0349054438 0.571659095 -0.48736207    0.626001765
## 22 -0.011188221 -0.0004832593 0.008196801 -0.11823959    0.905877818
## 23  0.434466421 -0.0110810466 0.185958300  1.03320428    0.301508312
## 24  1.087453975 -0.0103905688 0.174492689  2.62816260    0.008584747
## 25  0.081919493 -0.0004248781 0.007206990  0.96996702    0.332062930
## 26 -0.051433808 -0.0002013453 0.003416081 -0.87655904    0.380726196
## 27  1.051063390 -0.0137481437 0.230094366  2.21983020    0.026430296
## 28  1.649484466 -0.1639777263 2.326359324  1.18896784    0.234452322
## 29  0.518636408 -0.0169325828 0.282475377  1.00768577    0.313605339
## 30  1.120070408 -0.0789746761 1.234336330  1.07924180    0.280479951
## 31  1.075220871 -0.0405386400 0.660040753  1.37336262    0.169639645
## 32  0.062778989 -0.0701007143 1.106196919  0.12634045    0.899462436
## 33  0.549795521 -0.0406469307 0.661729222  0.72583418    0.467940428
## 34  0.946774171 -0.0314316084 0.516619726  1.36095803    0.173526954
## 35 -0.579242658 -0.0348050976 0.570074956 -0.72107776    0.470861676
## attr(,"call")
## localmoran(x = Kasus, listw = WLJ2)
## attr(,"class")
## [1] "localmoran" "matrix"     "array"     
## attr(,"quadr")
##         mean    median     pysal
## 1   High-Low  High-Low  High-Low
## 2  High-High High-High High-High
## 3  High-High High-High High-High
## 4   Low-High  Low-High   Low-Low
## 5   High-Low  High-Low  High-Low
## 6    Low-Low   Low-Low   Low-Low
## 7   Low-High  Low-High  Low-High
## 8  High-High High-High High-High
## 9    Low-Low  High-Low   Low-Low
## 10  High-Low  High-Low  High-Low
## 11   Low-Low   Low-Low   Low-Low
## 12  Low-High High-High  Low-High
## 13   Low-Low   Low-Low   Low-Low
## 14   Low-Low   Low-Low   Low-Low
## 15  Low-High  Low-High  Low-High
## 16 High-High High-High High-High
## 17 High-High High-High High-High
## 18  High-Low  High-Low  High-Low
## 19  Low-High  Low-High   Low-Low
## 20  High-Low  High-Low  High-Low
## 21  Low-High  Low-High  Low-High
## 22 High-High High-High  High-Low
## 23   Low-Low   Low-Low   Low-Low
## 24 High-High High-High High-High
## 25   Low-Low   Low-Low   Low-Low
## 26  High-Low  High-Low  High-Low
## 27 High-High High-High High-High
## 28 High-High High-High High-High
## 29   Low-Low   Low-Low   Low-Low
## 30   Low-Low   Low-Low   Low-Low
## 31   Low-Low   Low-Low   Low-Low
## 32  Low-High  Low-High   Low-Low
## 33   Low-Low   Low-Low   Low-Low
## 34   Low-Low   Low-Low   Low-Low
## 35  Low-High  Low-High  Low-High

#k=3

moran.test(Kasus,WLJ3)
## 
##  Moran I test under randomisation
## 
## data:  Kasus  
## weights: WLJ3    
## 
## Moran I statistic standard deviate = 1.3743, p-value = 0.08467
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.13908523       -0.02941176        0.01503179
moran.plot(Kasus,WLJ3)

locm<-localmoran(Kasus,WLJ3)
locm
##               Ii          E.Ii      Var.Ii          Z.Ii Pr(z != E(Ii))
## 1  -0.2728028265 -0.1476468625 1.379235193 -0.1065693666     0.91513062
## 2  -0.6310437542 -0.0591914090 0.610315635 -0.7319925459     0.46417312
## 3  -0.0229925212 -0.0163158335 0.175897428 -0.0159195692     0.98729856
## 4   0.0566350680 -0.0006964607 0.007627612  0.6564463394     0.51153698
## 5   0.4449353400 -0.0149716249 0.161626371  1.1439679980     0.25263691
## 6   0.3214176875 -0.0437377150 0.458382112  0.5393415759     0.58965119
## 7   0.1725735996 -0.0043599745 0.047575224  0.8111848482     0.41725953
## 8  -0.0036750326 -0.0221903113 0.237800232  0.0379685591     0.96971275
## 9   0.0075655498 -0.0002794180 0.003061453  0.1417840488     0.88725058
## 10 -0.2034780371 -0.0345149104 0.365213536 -0.2795879853     0.77979363
## 11  0.2298292969 -0.0010962133 0.012000884  2.1079741643     0.03503322
## 12 -0.0308494081 -0.0002363011 0.002589152 -0.6016287877     0.54742126
## 13  0.0007240007 -0.0128129863 0.138625887  0.0363579879     0.97099691
## 14  0.4525232601 -0.0123010611 0.133156296  1.2738197873     0.20272729
## 15 -0.0810251612 -0.0022295497 0.024380485 -0.5046390561     0.61381237
## 16  0.0379480883 -0.0056743985 0.061836229  0.1754239643     0.86074651
## 17  0.3661786602 -0.0053748008 0.058589038  1.5350167741     0.12477971
## 18 -1.2811936295 -0.0380983112 0.401634449 -1.9615028916     0.04982039
## 19 -0.0985277370 -0.0034543887 0.037727926 -0.4894714048     0.62450799
## 20 -0.3515773092 -0.0555865725 0.575342681 -0.3902247611     0.69637035
## 21 -0.2335330842 -0.0349054438 0.369196499 -0.3268969712     0.74374581
## 22  0.0243650136 -0.0004832593 0.005293767  0.3415181419     0.73271355
## 23  0.1680347216 -0.0110810466 0.120098069  0.5168515318     0.60525980
## 24  0.6033597576 -0.0103905688 0.112693195  1.8282807653     0.06750743
## 25 -0.0004645777 -0.0004248781 0.004654514 -0.0005819009     0.99953571
## 26 -0.0437409939 -0.0002013453 0.002206219 -0.9269592287     0.35394770
## 27  1.0140119905 -0.0137481437 0.148602611  2.6661129700     0.00767339
## 28  1.4361146343 -0.1639777263 1.502440397  1.3054084684     0.19175380
## 29  0.3704092822 -0.0169325828 0.182432014  0.9068676559     0.36447679
## 30  1.0999560457 -0.0789746761 0.797175547  1.3204175896     0.18669563
## 31  0.4376066465 -0.0405386400 0.426276320  0.7323425622     0.46395951
## 32  0.3577233096 -0.0701007143 0.714418844  0.5061610445     0.61274360
## 33 -0.1721814531 -0.0406469307 0.427366789 -0.2012052773     0.84053807
## 34  1.0357358980 -0.0314316084 0.333650240  1.8475103186     0.06467321
## 35 -0.3425793592 -0.0348050976 0.368173409 -0.5072313510     0.61199250
## attr(,"call")
## localmoran(x = Kasus, listw = WLJ3)
## attr(,"class")
## [1] "localmoran" "matrix"     "array"     
## attr(,"quadr")
##         mean    median     pysal
## 1   High-Low  High-Low  High-Low
## 2   High-Low  High-Low  High-Low
## 3  High-High High-High  High-Low
## 4    Low-Low   Low-Low   Low-Low
## 5  High-High High-High High-High
## 6    Low-Low   Low-Low   Low-Low
## 7    Low-Low   Low-Low   Low-Low
## 8  High-High High-High  High-Low
## 9    Low-Low  High-Low   Low-Low
## 10  High-Low  High-Low  High-Low
## 11   Low-Low   Low-Low   Low-Low
## 12  Low-High High-High  Low-High
## 13  Low-High  Low-High   Low-Low
## 14   Low-Low   Low-Low   Low-Low
## 15  Low-High  Low-High  Low-High
## 16 High-High High-High High-High
## 17 High-High High-High High-High
## 18  High-Low  High-Low  High-Low
## 19  Low-High  Low-High  Low-High
## 20  High-Low  High-Low  High-Low
## 21  Low-High  Low-High  Low-High
## 22 High-High High-High High-High
## 23   Low-Low   Low-Low   Low-Low
## 24 High-High High-High High-High
## 25  Low-High  Low-High  Low-High
## 26  High-Low  High-Low  High-Low
## 27 High-High High-High High-High
## 28 High-High High-High High-High
## 29   Low-Low   Low-Low   Low-Low
## 30   Low-Low   Low-Low   Low-Low
## 31   Low-Low   Low-Low   Low-Low
## 32   Low-Low   Low-Low   Low-Low
## 33  Low-High  Low-High  Low-High
## 34   Low-Low   Low-Low   Low-Low
## 35  Low-High  Low-High  Low-High

#k=4

moran.test(Kasus,WLJ4)
## 
##  Moran I test under randomisation
## 
## data:  Kasus  
## weights: WLJ4    
## 
## Moran I statistic standard deviate = 1.7457, p-value = 0.04043
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.15574384       -0.02941176        0.01124917
moran.plot(Kasus,WLJ4)

locm<-localmoran(Kasus,WLJ4)
locm
##              Ii          E.Ii      Var.Ii        Z.Ii Pr(z != E(Ii))
## 1  -0.254809075 -0.1476468625 1.001057802 -0.10710558     0.91470522
## 2  -0.905773054 -0.0591914090 0.442971026 -1.27198265     0.20337928
## 3  -0.236140195 -0.0163158335 0.127667488 -0.61522739     0.53840456
## 4   0.071665947 -0.0006964607 0.005536170  0.97254187     0.33078104
## 5   0.218349624 -0.0149716249 0.117309463  0.68122059     0.49573192
## 6  -0.191426973 -0.0437377150 0.332696694 -0.25604993     0.79791228
## 7   0.072219065 -0.0043599745 0.034530404  0.41210614     0.68026163
## 8   0.232479841 -0.0221903113 0.172596943  0.61300144     0.53987538
## 9   0.032219772 -0.0002794180 0.002222022  0.68944296     0.49054456
## 10 -0.179005220 -0.0345149104 0.265074341 -0.28064343     0.77898390
## 11  0.222266137 -0.0010962133 0.008710319  2.39327680     0.01669864
## 12 -0.036456050 -0.0002363011 0.001879223 -0.83551880     0.40342567
## 13 -0.389072778 -0.0128129863 0.100615563 -1.18619265     0.23554623
## 14  0.228854282 -0.0123010611 0.096645699  0.77572113     0.43791366
## 15  0.014108215 -0.0022295497 0.017695513  0.12281773     0.90225144
## 16  0.274492702 -0.0056743985 0.044881134  1.32246816     0.18601231
## 17  0.347701141 -0.0053748008 0.042524302  1.71218043     0.08686342
## 18 -0.924423026 -0.0380983112 0.291508874 -1.64159859     0.10067322
## 19 -0.065544933 -0.0034543887 0.027383172 -0.37521793     0.70749839
## 20  0.547831555 -0.0555865725 0.417587430  0.93378016     0.35041730
## 21 -0.197683707 -0.0349054438 0.267965201 -0.31445406     0.75317620
## 22  0.090073217 -0.0004832593 0.003842251  1.46092080     0.14403718
## 23  0.058624592 -0.0110810466 0.087167953  0.23609647     0.81335782
## 24  0.471566912 -0.0103905688 0.081793448  1.68519230     0.09195148
## 25  0.002344862 -0.0004248781 0.003378276  0.04765313     0.96199269
## 26 -0.034821868 -0.0002013453 0.001601288 -0.86516495     0.38694826
## 27  0.713449251 -0.0137481437 0.107856734  2.21426034     0.02681087
## 28  1.888600512 -0.1639777263 1.090480933  1.96557981     0.04934717
## 29  0.588638055 -0.0169325828 0.132410333  1.66419369     0.09607373
## 30  1.248459955 -0.0789746761 0.578595155  1.74512181     0.08096367
## 31  0.550902369 -0.0405386400 0.309394103  1.06329903     0.28764636
## 32  0.038889104 -0.0701007143 0.518529806  0.15135580     0.87969505
## 33  0.190572446 -0.0406469307 0.310185573  0.41515802     0.67802623
## 34  0.943939275 -0.0314316084 0.242165496  1.98204566     0.04747413
## 35 -0.182057434 -0.0348050976 0.267222636 -0.28485613     0.77575437
## attr(,"call")
## localmoran(x = Kasus, listw = WLJ4)
## attr(,"class")
## [1] "localmoran" "matrix"     "array"     
## attr(,"quadr")
##         mean    median     pysal
## 1   High-Low  High-Low  High-Low
## 2   High-Low  High-Low  High-Low
## 3   High-Low  High-Low  High-Low
## 4    Low-Low   Low-Low   Low-Low
## 5  High-High High-High High-High
## 6   Low-High  Low-High  Low-High
## 7    Low-Low   Low-Low   Low-Low
## 8  High-High High-High High-High
## 9    Low-Low  High-Low   Low-Low
## 10  High-Low  High-Low  High-Low
## 11   Low-Low   Low-Low   Low-Low
## 12  Low-High High-High  Low-High
## 13  Low-High  Low-High  Low-High
## 14   Low-Low   Low-Low   Low-Low
## 15   Low-Low   Low-Low   Low-Low
## 16 High-High High-High High-High
## 17 High-High High-High High-High
## 18  High-Low  High-Low  High-Low
## 19  Low-High  Low-High  Low-High
## 20 High-High High-High High-High
## 21  Low-High  Low-High  Low-High
## 22 High-High High-High High-High
## 23   Low-Low   Low-Low   Low-Low
## 24 High-High High-High High-High
## 25  Low-High  Low-High   Low-Low
## 26  High-Low  High-Low  High-Low
## 27 High-High High-High High-High
## 28 High-High High-High High-High
## 29   Low-Low   Low-Low   Low-Low
## 30   Low-Low   Low-Low   Low-Low
## 31   Low-Low   Low-Low   Low-Low
## 32   Low-Low  Low-High   Low-Low
## 33   Low-Low   Low-Low   Low-Low
## 34   Low-Low   Low-Low   Low-Low
## 35  Low-High  Low-High  Low-High
locm <- localmoran(Kasus, WLJ4)
plot(locm)

Jawa_Tengah_merged$locm <- locm[, 1]  # Nilai Local Moran's I
Jawa_Tengah_merged$p_value <- locm[, 5]      # P-value dari Local Moran

ggplot(Jawa_Tengah_merged) +
  geom_sf(aes(fill = locm)) + 
  scale_fill_gradient2(low = "#ff8a01", mid = "#78B7D0", high = "#16325B", midpoint = 0) +
  labs(title = "Local Moran's I - BGK", fill = "Moran's I") +
  theme_minimal()

Variables

y <- data$BGK
x1 <- data$PUS
x2 <- data$AirLayak
x3 <- data$Posyandu
x4 <- data$Imunisasi
x5 <- data$Sanitasi

plot(data)

Model OLS

model_ols <- lm(y ~ x1 + x2 + x3 + x4 + x5)
summary(model_ols)
## 
## Call:
## lm(formula = y ~ x1 + x2 + x3 + x4 + x5)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2394.9  -492.6   166.0   533.9  2418.9 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  9.302e+02  4.118e+03   0.226    0.823
## x1           6.088e-03  5.321e-03   1.144    0.262
## x2           7.174e-01  4.391e+01   0.016    0.987
## x3           6.751e-01  4.248e-01   1.589    0.123
## x4          -6.727e-03  7.079e-02  -0.095    0.925
## x5          -7.812e+00  1.624e+01  -0.481    0.634
## 
## Residual standard error: 1066 on 29 degrees of freedom
## Multiple R-squared:  0.422,  Adjusted R-squared:  0.3223 
## F-statistic: 4.234 on 5 and 29 DF,  p-value: 0.005183
AICOLS = AIC(model_ols);AICOLS
## [1] 594.7626

Asumsi OLS

#Heterogenitas Spasial
bptest(model_ols)
## 
##  studentized Breusch-Pagan test
## 
## data:  model_ols
## BP = 17.361, df = 5, p-value = 0.003863
#Multikolinearitas
vif(model_ols)
##       x1       x2       x3       x4       x5 
## 6.766835 1.490332 1.917312 6.276981 1.148656
#Normalitas Residual
shapiro.test(model_ols$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  model_ols$residuals
## W = 0.98402, p-value = 0.8795

Optimal Bandwidth

#Optimal Bandwidth Gaussian Fixed
bandwGF <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.Gauss);bandwGF
## Bandwidth: 1.108584 CV score: 63624917 
## Bandwidth: 1.791936 CV score: 62230306 
## Bandwidth: 2.214271 CV score: 62012117 
## Bandwidth: 2.190487 CV score: 62020031 
## Bandwidth: 2.475288 CV score: 61944805 
## Bandwidth: 2.636605 CV score: 61916208 
## Bandwidth: 2.736305 CV score: 61901939 
## Bandwidth: 2.797923 CV score: 61894165 
## Bandwidth: 2.836005 CV score: 61889712 
## Bandwidth: 2.859541 CV score: 61887084 
## Bandwidth: 2.874087 CV score: 61885505 
## Bandwidth: 2.883077 CV score: 61884545 
## Bandwidth: 2.888633 CV score: 61883959 
## Bandwidth: 2.892066 CV score: 61883599 
## Bandwidth: 2.894189 CV score: 61883377 
## Bandwidth: 2.8955 CV score: 61883240 
## Bandwidth: 2.896311 CV score: 61883156 
## Bandwidth: 2.896812 CV score: 61883104 
## Bandwidth: 2.897122 CV score: 61883072 
## Bandwidth: 2.897313 CV score: 61883052 
## Bandwidth: 2.897431 CV score: 61883039 
## Bandwidth: 2.897504 CV score: 61883032 
## Bandwidth: 2.897549 CV score: 61883027 
## Bandwidth: 2.897549 CV score: 61883027
## Warning in gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord = Coordk, :
## Bandwidth converged to upper bound:2.89762251611451
## [1] 2.897549
#Optimal Bandwidth Bisquare Fixed
bandwBF <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.bisquare);bandwBF
## Bandwidth: 1.108584 CV score: 76119623 
## Bandwidth: 1.791936 CV score: 64514411 
## Bandwidth: 2.214271 CV score: 65097002 
## Bandwidth: 1.961571 CV score: 65081091 
## Bandwidth: 1.530919 CV score: 61976861 
## Bandwidth: 1.369601 CV score: 62046918 
## Bandwidth: 1.45929 CV score: 61407026 
## Bandwidth: 1.452581 CV score: 61389164 
## Bandwidth: 1.43623 CV score: 61381862 
## Bandwidth: 1.41078 CV score: 61489114 
## Bandwidth: 1.442082 CV score: 61378214 
## Bandwidth: 1.442215 CV score: 61378215 
## Bandwidth: 1.442123 CV score: 61378214 
## Bandwidth: 1.442164 CV score: 61378214 
## Bandwidth: 1.442123 CV score: 61378214
## [1] 1.442123
#Optimal Bandwidth Tricube Fixed
bandwTF <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.tricube);bandwTF
## Bandwidth: 1.108584 CV score: 77815498 
## Bandwidth: 1.791936 CV score: 62622019 
## Bandwidth: 2.214271 CV score: 64398465 
## Bandwidth: 1.915153 CV score: 63641170 
## Bandwidth: 1.530919 CV score: 58751204 
## Bandwidth: 1.369601 CV score: 60993795 
## Bandwidth: 1.552433 CV score: 58943381 
## Bandwidth: 1.505915 CV score: 58635728 
## Bandwidth: 1.453848 CV score: 58869624 
## Bandwidth: 1.498882 CV score: 58627068 
## Bandwidth: 1.496576 CV score: 58626710 
## Bandwidth: 1.497056 CV score: 58626681 
## Bandwidth: 1.497096 CV score: 58626681 
## Bandwidth: 1.497015 CV score: 58626682 
## Bandwidth: 1.497056 CV score: 58626681
## [1] 1.497056
#Optimal Bandwidth Gaussian Adaptive
bandwGA <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.Gauss,adapt = TRUE);bandwGA
## Adaptive q: 0.381966 CV score: 69601832 
## Adaptive q: 0.618034 CV score: 65126523 
## Adaptive q: 0.763932 CV score: 64248645 
## Adaptive q: 0.7797852 CV score: 64068826 
## Adaptive q: 0.8638997 CV score: 63384107 
## Adaptive q: 0.9488944 CV score: 62829300 
## Adaptive q: 0.9164293 CV score: 62876136 
## Adaptive q: 0.9401136 CV score: 62836174 
## Adaptive q: 0.9585542 CV score: 62826524 
## Adaptive q: 0.959071 CV score: 62826396 
## Adaptive q: 0.9747045 CV score: 62791228 
## Adaptive q: 0.9843665 CV score: 62701902 
## Adaptive q: 0.990338 CV score: 62651439 
## Adaptive q: 0.9940285 CV score: 62621884 
## Adaptive q: 0.9963094 CV score: 62604203 
## Adaptive q: 0.9977191 CV score: 62593491 
## Adaptive q: 0.9985903 CV score: 62586951 
## Adaptive q: 0.9991288 CV score: 62582940 
## Adaptive q: 0.9994616 CV score: 62580472 
## Adaptive q: 0.9996672 CV score: 62578951 
## Adaptive q: 0.9997943 CV score: 62578013 
## Adaptive q: 0.9998729 CV score: 62577434 
## Adaptive q: 0.9999214 CV score: 62577076 
## Adaptive q: 0.9999214 CV score: 62577076
## Warning in gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord = Coordk, :
## Bandwidth converged to upper bound:1
## [1] 0.9999214
#Optimal Bandwidth Bisquare Adaptive
bandwBA <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.bisquare, adapt = TRUE);bandwBA
## Adaptive q: 0.381966 CV score: 180970336 
## Adaptive q: 0.618034 CV score: 104141509 
## Adaptive q: 0.763932 CV score: 87229125 
## Adaptive q: 0.7966399 CV score: 85575231 
## Adaptive q: 0.8493819 CV score: 79834729 
## Adaptive q: 0.9069129 CV score: 73083877 
## Adaptive q: 0.942469 CV score: 70729865 
## Adaptive q: 0.9849492 CV score: 68654202 
## Adaptive q: 0.9687232 CV score: 70092473 
## Adaptive q: 0.9787514 CV score: 69228449 
## Adaptive q: 0.9906981 CV score: 68203707 
## Adaptive q: 0.9942511 CV score: 67958741 
## Adaptive q: 0.996447 CV score: 67818517 
## Adaptive q: 0.9978041 CV score: 67735774 
## Adaptive q: 0.9986429 CV score: 67686054 
## Adaptive q: 0.9991612 CV score: 67655851 
## Adaptive q: 0.9994816 CV score: 67637380 
## Adaptive q: 0.9996796 CV score: 67626038 
## Adaptive q: 0.999802 CV score: 67619057 
## Adaptive q: 0.9998776 CV score: 67614753 
## Adaptive q: 0.9999244 CV score: 67612097 
## Adaptive q: 0.9999244 CV score: 67612097
## Warning in gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord = Coordk, :
## Bandwidth converged to upper bound:1
## [1] 0.9999244
#Optimal Bandwidth Tricube Adaptive
bandwTA <- gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord=Coordk, gweight=gwr.tricube, adapt = TRUE);bandwTA
## Adaptive q: 0.381966 CV score: 192533317 
## Adaptive q: 0.618034 CV score: 109301712 
## Adaptive q: 0.763932 CV score: 89480937 
## Adaptive q: 0.8107024 CV score: 86055271 
## Adaptive q: 0.8830077 CV score: 77971492 
## Adaptive q: 0.9276948 CV score: 71544057 
## Adaptive q: 0.9553129 CV score: 70130831 
## Adaptive q: 0.9614682 CV score: 69922617 
## Adaptive q: 0.9761861 CV score: 68938771 
## Adaptive q: 0.9852822 CV score: 67783754 
## Adaptive q: 0.9909039 CV score: 67190272 
## Adaptive q: 0.9943783 CV score: 66866035 
## Adaptive q: 0.9965256 CV score: 66680812 
## Adaptive q: 0.9978527 CV score: 66571848 
## Adaptive q: 0.9986729 CV score: 66506539 
## Adaptive q: 0.9991798 CV score: 66466936 
## Adaptive q: 0.9994931 CV score: 66442747 
## Adaptive q: 0.9996867 CV score: 66427906 
## Adaptive q: 0.9998064 CV score: 66418774 
## Adaptive q: 0.9998803 CV score: 66413147 
## Adaptive q: 0.999926 CV score: 66409675 
## Adaptive q: 0.999926 CV score: 66409675
## Warning in gwr.sel(y ~ x1 + x2 + x3 + x4 + x5, data = data, coord = Coordk, :
## Bandwidth converged to upper bound:1
## [1] 0.999926
Coord <- coordinates(Jawa_Tengah)
longitude <- Coord[, 1]
latitude <- Coord[, 2]

Model GWR Adaptive Gaussian Kernel

GWRAG <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  adapt = bandwGA,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.Gauss
)
summary(GWRAG)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth   35   -none-                 numeric  
## adapt        1   -none-                 numeric  
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRAG
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     gweight = gwr.Gauss, adapt = bandwGA, hatmatrix = TRUE, se.fit = TRUE)
## Kernel function: gwr.Gauss 
## Adaptive quantile: 0.9999214 (about 34 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  1.0401e+03  1.2697e+03  1.4441e+03  1.6300e+03  2.0350e+03
## x1            4.7988e-03  5.1092e-03  5.5524e-03  6.6472e-03  7.1194e-03
## x2           -6.4907e+00 -4.1174e+00 -3.0754e+00 -1.4797e+00  9.6358e-01
## x3            6.0450e-01  6.2311e-01  6.8695e-01  7.2770e-01  7.4599e-01
## x4           -1.1926e-02 -8.9032e-03 -6.5605e-03 -2.3171e-03  7.8395e-04
## x5           -1.1656e+01 -1.0245e+01 -9.5943e+00 -8.8998e+00 -7.9759e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 7.374169 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 27.62583 
## Sigma (residual: 2traceS - traceS'S): 1057.08 
## Effective number of parameters (model: traceS): 6.732155 
## Effective degrees of freedom (model: traceS): 28.26785 
## Sigma (model: traceS): 1045.007 
## Sigma (ML): 939.1426 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 599.0785 
## AIC (GWR p. 96, eq. 4.22): 585.2056 
## Residual sum of squares: 30869609 
## Quasi-global R2: 0.4585534

Model GWR Adaptive Bisquare Kernel

GWRAB <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  adapt = bandwBA,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.bisquare
)
summary(GWRAB)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth   35   -none-                 numeric  
## adapt        1   -none-                 numeric  
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRAB
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     gweight = gwr.bisquare, adapt = bandwBA, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.bisquare 
## Adaptive quantile: 0.9999244 (about 34 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  6.4715e+02  2.2135e+03  2.8020e+03  3.7885e+03  6.1860e+03
## x1            8.1597e-04  2.4262e-03  3.9481e-03  8.7973e-03  1.1881e-02
## x2           -2.5280e+01 -1.9636e+01 -1.3136e+01 -2.9446e+00  9.1241e+00
## x3            2.5005e-01  4.2461e-01  7.8036e-01  8.5303e-01  9.6496e-01
## x4           -3.0687e-02 -1.8700e-02 -6.9226e-03  1.0769e-02  2.9885e-02
## x5           -3.7919e+01 -2.2360e+01 -1.5849e+01 -1.2635e+01 -7.9186e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 11.51139 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 23.48861 
## Sigma (residual: 2traceS - traceS'S): 1010.114 
## Effective number of parameters (model: traceS): 9.643204 
## Effective degrees of freedom (model: traceS): 25.3568 
## Sigma (model: traceS): 972.1911 
## Sigma (ML): 827.4939 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 601.5114 
## AIC (GWR p. 96, eq. 4.22): 579.257 
## Residual sum of squares: 23966116 
## Quasi-global R2: 0.5796392

Model GWR Adaptive Tricube Kernel

GWRAT <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  adapt = bandwTA,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.tricube
)
summary(GWRAT)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth   35   -none-                 numeric  
## adapt        1   -none-                 numeric  
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRAT
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     gweight = gwr.tricube, adapt = bandwTA, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.tricube 
## Adaptive quantile: 0.999926 (about 34 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  1.0259e+03  2.5145e+03  2.9220e+03  3.9393e+03  6.3527e+03
## x1            9.9890e-04  2.3462e-03  3.4737e-03  8.5698e-03  1.1531e-02
## x2           -2.5506e+01 -1.8027e+01 -1.6148e+01 -4.6792e+00  6.5769e+00
## x3            2.5433e-01  4.0959e-01  7.7707e-01  8.6117e-01  9.5483e-01
## x4           -2.6369e-02 -1.3926e-02 -4.8489e-03  8.0554e-03  2.7157e-02
## x5           -3.7756e+01 -2.1337e+01 -1.6304e+01 -1.3699e+01 -9.1834e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 10.34204 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 24.65796 
## Sigma (residual: 2traceS - traceS'S): 1009.93 
## Effective number of parameters (model: traceS): 9.010387 
## Effective degrees of freedom (model: traceS): 25.98961 
## Sigma (model: traceS): 983.7165 
## Sigma (ML): 847.6876 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 600.5112 
## AIC (GWR p. 96, eq. 4.22): 580.3119 
## Residual sum of squares: 25150100 
## Quasi-global R2: 0.5588724

Model GWR Fixed Gaussian Kernel

GWRFG <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  bandwidth = bandwGF,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.Gauss
)
summary(GWRFG)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth    1   -none-                 numeric  
## adapt        0   -none-                 NULL     
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRFG
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     bandwidth = bandwGF, gweight = gwr.Gauss, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.Gauss 
## Fixed bandwidth: 2.897549 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  1.0328e+03  1.1405e+03  1.1678e+03  1.2035e+03  1.2406e+03
## x1            5.2896e-03  5.5970e-03  5.8828e-03  6.3252e-03  6.8280e-03
## x2           -2.0923e+00 -1.4166e+00 -1.0248e+00 -5.6427e-01  8.5212e-01
## x3            6.1522e-01  6.5276e-01  6.7769e-01  7.0159e-01  7.3590e-01
## x4           -9.6754e-03 -7.3713e-03 -6.5758e-03 -5.2452e-03 -2.1755e-03
## x5           -9.0235e+00 -8.6872e+00 -8.5457e+00 -8.3087e+00 -7.9599e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 6.693524 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 28.30648 
## Sigma (residual: 2traceS - traceS'S): 1063.682 
## Effective number of parameters (model: traceS): 6.360341 
## Effective degrees of freedom (model: traceS): 28.63966 
## Sigma (model: traceS): 1057.477 
## Sigma (ML): 956.5789 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 599.1016 
## AIC (GWR p. 96, eq. 4.22): 586.1215 
## Residual sum of squares: 32026511 
## Quasi-global R2: 0.4382616

Model GWR Fixed Bisquare Kernel

GWRFB <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  bandwidth = bandwBF,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.bisquare
)
summary(GWRFB)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth    1   -none-                 numeric  
## adapt        0   -none-                 NULL     
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRFB
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     bandwidth = bandwBF, gweight = gwr.bisquare, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.bisquare 
## Fixed bandwidth: 1.442123 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept. -1.0958e+04  3.8050e+02  2.9746e+03  4.4589e+03  6.4651e+03
## x1           -3.2487e-03  1.6266e-03  3.8174e-03  1.0855e-02  2.2453e-02
## x2           -3.3314e+01 -2.3275e+01 -8.8210e+00  9.9479e+00  1.3551e+02
## x3           -4.8599e-01  2.7046e-01  7.4589e-01  8.5237e-01  1.2140e+00
## x4           -9.3078e-02 -3.5775e-02 -6.6957e-03  1.8794e-02  1.0029e-01
## x5           -3.6376e+01 -2.7761e+01 -1.7828e+01 -1.4928e+01  1.9864e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 15.27084 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 19.72916 
## Sigma (residual: 2traceS - traceS'S): 1010.602 
## Effective number of parameters (model: traceS): 12.70298 
## Effective degrees of freedom (model: traceS): 22.29702 
## Sigma (model: traceS): 950.6284 
## Sigma (ML): 758.7526 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 610.8016 
## AIC (GWR p. 96, eq. 4.22): 576.246 
## Residual sum of squares: 20149695 
## Quasi-global R2: 0.6465785

Model GWR Fixed Tricube Kernel

GWRFT <- gwr(
  y ~ x1 + x2 + x3 + x4 + x5,
  data = data,
  coords = Coordk,
  bandwidth = bandwTF,
  hatmatrix = TRUE,
  se.fit = TRUE,
  gweight=gwr.tricube
)
summary(GWRFT)
##           Length Class                  Mode     
## SDF         35   SpatialPointsDataFrame S4       
## lhat      1225   -none-                 numeric  
## lm          11   -none-                 list     
## results     14   -none-                 list     
## bandwidth    1   -none-                 numeric  
## adapt        0   -none-                 NULL     
## hatmatrix    1   -none-                 logical  
## gweight      1   -none-                 character
## gTSS         1   -none-                 numeric  
## this.call    8   -none-                 call     
## fp.given     1   -none-                 logical  
## timings     12   -none-                 numeric
GWRFT
## Call:
## gwr(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data, coords = Coordk, 
##     bandwidth = bandwTF, gweight = gwr.tricube, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.tricube 
## Fixed bandwidth: 1.497056 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept. -1.0535e+04  5.3765e+02  3.2107e+03  4.2905e+03  6.2823e+03
## x1           -3.0995e-03  1.7288e-03  3.9394e-03  1.0438e-02  2.2661e-02
## x2           -3.2048e+01 -2.2886e+01 -1.3102e+01  7.8847e+00  1.2982e+02
## x3           -4.5529e-01  2.6490e-01  7.5332e-01  8.6873e-01  1.2209e+00
## x4           -9.9035e-02 -3.1754e-02 -3.0543e-03  1.3884e-02  1.0162e-01
## x5           -3.3864e+01 -2.5136e+01 -1.7941e+01 -1.5111e+01  1.8074e+00
##                Global
## X.Intercept. 930.1634
## x1             0.0061
## x2             0.7174
## x3             0.6751
## x4            -0.0067
## x5            -7.8117
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 13.45519 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 21.54481 
## Sigma (residual: 2traceS - traceS'S): 1001.162 
## Effective number of parameters (model: traceS): 11.57405 
## Effective degrees of freedom (model: traceS): 23.42595 
## Sigma (model: traceS): 960.1236 
## Sigma (ML): 785.4919 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 607.0477 
## AIC (GWR p. 96, eq. 4.22): 577.5415 
## Residual sum of squares: 21594914 
## Quasi-global R2: 0.6212296
aicc_results = data.frame(Bobot = c("Adaptive Gaussian",
                                    "Adaptive Bisquare",
                                    "Adaptive Tricube",
                                    "Fixed Gaussian",
                                    "Fixed Bisquare",
                                    "Fixed Tricube"),
                          AICc = c(GWRAG$results$AICc,
                                   GWRAB$results$AICc,
                                   GWRAT$results$AICc,
                                   GWRFG$results$AICc,
                                   GWRFB$results$AICc,
                                   GWRFT$results$AICc),
                          CV = c(0.9999214,
                                 0.9999244,
                                 0.999926,
                                 2.897549,
                                 1.442123,
                                 1.497056))

aicc_results
##               Bobot     AICc        CV
## 1 Adaptive Gaussian 599.4138 0.9999214
## 2 Adaptive Bisquare 603.5932 0.9999244
## 3  Adaptive Tricube 601.8240 0.9999260
## 4    Fixed Gaussian 599.2577 2.8975490
## 5    Fixed Bisquare 616.2404 1.4421230
## 6     Fixed Tricube 610.3318 1.4970560

Identifikasi Variabel yang Signifikan

## Ekstrak koefisien lokal untuk variabel xi
coef_x1 = GWRFB$SDF$x1
coef_x2 = GWRFB$SDF$x2
coef_x3 = GWRFB$SDF$x3
coef_x4 = GWRFB$SDF$x4
coef_x5 = GWRFB$SDF$x5


## Ekstrak standar error untuk variabel xi (untuk tiap provinsi)
se_x1 = GWRFB$SDF$x1_se
se_x2 = GWRFB$SDF$x2_se
se_x3 = GWRFB$SDF$x3_se
se_x4 = GWRFB$SDF$x4_se
se_x5 = GWRFB$SDF$x5_se


## t-value untuk variabel xi (untuk tiap provinsi)
t_x1 = coef_x1/se_x1
t_x2 = coef_x2/se_x2
t_x3 = coef_x3/se_x3
t_x4 = coef_x4/se_x4
t_x5 = coef_x5/se_x5

## p-values untuk variabel xi (untuk tiap provinsi)

n = nrow(data)
k = length(coef(GWRFB$lm))
df = n-k-1 

# p-values for each variable at each location
p_values1 <- 2 * (1 - pt(abs(t_x1), df))
p_values2 <- 2 * (1 - pt(abs(t_x2), df))
p_values3 <- 2 * (1 - pt(abs(t_x3), df))
p_values4 <- 2 * (1 - pt(abs(t_x4), df))
p_values5 <- 2 * (1 - pt(abs(t_x5), df))

# Display p-values
prov_id = rep(1:35, times=5)
var_id = rep(1:5, each = 35)
p_values = data.frame(ID = prov_id,
                      Variabel_X_ke = var_id,
                      p_value = c(p_values1, p_values2, p_values3, p_values4, p_values5))
p_values
##     ID Variabel_X_ke    p_value
## 1    1             1 0.06966540
## 2    2             1 0.02318257
## 3    3             1 0.08981377
## 4    4             1 0.89103230
## 5    5             1 0.79280548
## 6    6             1 0.03606566
## 7    7             1 0.05095055
## 8    8             1 0.50750983
## 9    9             1 0.73557199
## 10  10             1 0.34910300
## 11  11             1 0.84903767
## 12  12             1 0.12635819
## 13  13             1 0.30393330
## 14  14             1 0.94218582
## 15  15             1 0.59823644
## 16  16             1 0.02527693
## 17  17             1 0.46440597
## 18  18             1 0.01460818
## 19  19             1 0.50371411
## 20  20             1 0.63440548
## 21  21             1 0.51951933
## 22  22             1 0.02914747
## 23  23             1 0.01452000
## 24  24             1 0.02609004
## 25  25             1 0.47626583
## 26  26             1 0.96613762
## 27  27             1 0.68258404
## 28  28             1 0.63888932
## 29  29             1 0.94272710
## 30  30             1 0.93798840
## 31  31             1 0.96831683
## 32  32             1 0.01406440
## 33  33             1 0.39272589
## 34  34             1 0.56673359
## 35  35             1 0.24529182
## 36   1             2 0.50778571
## 37   2             2 0.84107878
## 38   3             2 0.53911245
## 39   4             2 0.13983390
## 40   5             2 0.97477703
## 41   6             2 0.78899985
## 42   7             2 0.99088453
## 43   8             2 0.83246592
## 44   9             2 0.57231131
## 45  10             2 0.36438496
## 46  11             2 0.67105412
## 47  12             2 0.49094801
## 48  13             2 0.64714612
## 49  14             2 0.86630678
## 50  15             2 0.57772590
## 51  16             2 0.55459754
## 52  17             2 0.83385207
## 53  18             2 0.70928542
## 54  19             2 0.43946303
## 55  20             2 0.58991542
## 56  21             2 0.22536236
## 57  22             2 0.55055056
## 58  23             2 0.65543213
## 59  24             2 0.64089791
## 60  25             2 0.43821156
## 61  26             2 0.08912888
## 62  27             2 0.84130076
## 63  28             2 0.83558302
## 64  29             2 0.63215485
## 65  30             2 0.91763440
## 66  31             2 0.88658044
## 67  32             2 0.75614936
## 68  33             2 0.58055853
## 69  34             2 0.83817065
## 70  35             2 0.47590072
## 71   1             3 0.58103328
## 72   2             3 0.86386461
## 73   3             3 0.25911808
## 74   4             3 0.03099479
## 75   5             3 0.06859521
## 76   6             3 0.52451289
## 77   7             3 0.59790835
## 78   8             3 0.04856819
## 79   9             3 0.04970052
## 80  10             3 0.05736719
## 81  11             3 0.10623546
## 82  12             3 0.58736388
## 83  13             3 0.07473834
## 84  14             3 0.10572561
## 85  15             3 0.09367652
## 86  16             3 0.55806996
## 87  17             3 0.05204609
## 88  18             3 0.57819526
## 89  19             3 0.04689105
## 90  20             3 0.09142936
## 91  21             3 0.04348020
## 92  22             3 0.66292470
## 93  23             3 0.95593521
## 94  24             3 0.91607665
## 95  25             3 0.24501624
## 96  26             3 0.05245728
## 97  27             3 0.06286372
## 98  28             3 0.05937223
## 99  29             3 0.06731973
## 100 30             3 0.12048465
## 101 31             3 0.09164498
## 102 32             3 0.68201875
## 103 33             3 0.09471136
## 104 34             3 0.24939470
## 105 35             3 0.26136335
## 106  1             4 0.83661531
## 107  2             4 0.55720067
## 108  3             4 0.66657596
## 109  4             4 0.70514192
## 110  5             4 0.79356183
## 111  6             4 0.58828972
## 112  7             4 0.70309745
## 113  8             4 0.74426599
## 114  9             4 0.96040500
## 115 10             4 0.42448427
## 116 11             4 0.44290445
## 117 12             4 0.96003054
## 118 13             4 0.73756974
## 119 14             4 0.59459015
## 120 15             4 0.88800990
## 121 16             4 0.49774765
## 122 17             4 0.79010744
## 123 18             4 0.33847367
## 124 19             4 0.67243695
## 125 20             4 0.86300703
## 126 21             4 0.67118073
## 127 22             4 0.59427319
## 128 23             4 0.43094278
## 129 24             4 0.62948557
## 130 25             4 0.77493270
## 131 26             4 0.91899291
## 132 27             4 0.90913980
## 133 28             4 0.96718584
## 134 29             4 0.67451814
## 135 30             4 0.49171603
## 136 31             4 0.59932181
## 137 32             4 0.35050658
## 138 33             4 0.91983910
## 139 34             4 0.21384632
## 140 35             4 0.99750521
## 141  1             5 0.35485255
## 142  2             5 0.77263047
## 143  3             5 0.25524498
## 144  4             5 0.50250441
## 145  5             5 0.16925305
## 146  6             5 0.96582509
## 147  7             5 0.93620686
## 148  8             5 0.23566199
## 149  9             5 0.43040614
## 150 10             5 0.45232646
## 151 11             5 0.40959688
## 152 12             5 0.34756014
## 153 13             5 0.10446436
## 154 14             5 0.13634745
## 155 15             5 0.09114950
## 156 16             5 0.44685143
## 157 17             5 0.10465778
## 158 18             5 0.81721102
## 159 19             5 0.47086455
## 160 20             5 0.08932978
## 161 21             5 0.56615837
## 162 22             5 0.44319853
## 163 23             5 0.61288817
## 164 24             5 0.56594484
## 165 25             5 0.14911298
## 166 26             5 0.44497782
## 167 27             5 0.11643301
## 168 28             5 0.11318486
## 169 29             5 0.41056552
## 170 30             5 0.25235222
## 171 31             5 0.26116558
## 172 32             5 0.78667205
## 173 33             5 0.10512363
## 174 34             5 0.36549842
## 175 35             5 0.18696422

Koefisien pada setiap lokasi

coef_gwr <- GWRFB$SDF@data[, c("x1", "x2","x3","x4","x5")];coef_gwr
##               x1          x2          x3            x4         x5
## 1   0.0096343905 -28.4968207  0.27042297 -0.0136791667 -17.549296
## 2   0.0168595175 -11.0519435 -0.10901566 -0.0461729899  -6.132143
## 3   0.0087399717 -25.9458255  0.48846301 -0.0285287500 -22.407462
## 4  -0.0010187137  93.3829801  1.18180462  0.0420050176 -15.381128
## 5   0.0013988235  -1.3919626  0.83163713  0.0182234673 -25.436413
## 6   0.0220361738 -19.2858237 -0.48599216 -0.0686713393  -1.085918
## 7   0.0206955772  -0.8570436 -0.38115172 -0.0516422718   1.986378
## 8   0.0035359009   9.2379892  0.94782211 -0.0230070910 -22.477880
## 9   0.0018544629  26.5613588  0.96288553  0.0036504928 -15.801663
## 10  0.0053970477  44.1805424  1.02895092 -0.0626863638 -16.501893
## 11 -0.0010562590  21.0113545  0.83005881  0.0582006254 -16.209199
## 12  0.0082858668 -29.8956647  0.28681377  0.0033694869 -18.157848
## 13  0.0052596883 -18.9699003  0.76676530 -0.0223124335 -32.611194
## 14  0.0003902200  -7.6380677  0.76119075  0.0375015662 -29.283099
## 15  0.0027531897 -23.5746108  0.73779216  0.0094980485 -36.049000
## 16  0.0124247809 -26.7307815  0.27049269 -0.0460827075 -15.088427
## 17  0.0038173577  -8.7895416  0.86974546 -0.0180693453 -29.918755
## 18  0.0224533100 -24.4257647 -0.40563654 -0.0930775894  -5.534786
## 19  0.0037523933  37.0991266  1.02096047 -0.0319778536 -15.233735
## 20  0.0024932073 -22.9087254  0.74588699  0.0116714019 -36.376380
## 21  0.0039247192  65.6639054  1.08451329 -0.0357133688 -12.741762
## 22  0.0120762574 -26.7087353  0.21029501 -0.0358363664 -14.766712
## 23  0.0160069195 -22.6422854 -0.03125749 -0.0564296382 -10.242261
## 24  0.0135338611 -22.1490322  0.05886385 -0.0333070298 -11.223577
## 25  0.0037485696 -33.3140519  0.55590333  0.0193641444 -30.950516
## 26 -0.0005682506 135.5097724  1.21395049  0.0219171955 -19.847216
## 27  0.0021562444  -8.5655117  0.82601401  0.0078041536 -29.245003
## 28  0.0024687348  -8.8210405  0.83499326  0.0028054307 -29.348077
## 29  0.0003950092  22.8573638  0.89872249  0.0310764539 -16.173845
## 30 -0.0004245156   4.8877260  0.76801243  0.0502062348 -21.510847
## 31  0.0002153670   6.5979852  0.81047634  0.0378909331 -21.017597
## 32  0.0204403934 -18.7382031 -0.27537703 -0.0798245577  -6.057230
## 33  0.0043831798 -22.9747724  0.71656784 -0.0066957196 -33.120011
## 34 -0.0032486589  10.6577831  0.68273333  0.1002867970 -17.827706
## 35  0.0059490561 -29.8752393  0.50540876 -0.0002073464 -26.277920

Pengujian Asumsi GWR

residual_gwr <- GWRFB$SDF$gwr.e

#Normalitas Residual
shapiro.test(residual_gwr)
## 
##  Shapiro-Wilk normality test
## 
## data:  residual_gwr
## W = 0.93092, p-value = 0.02979
#Autokorelasi Spasial
moran.test(residual_gwr, WLJ4)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr  
## weights: WLJ4    
## 
## Moran I statistic standard deviate = 1.9721, p-value = 0.0243
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.16943682       -0.02941176        0.01016703
#Breusch Pagan
bptest(residual_gwr ~ GWRFB$SDF$x1+GWRFB$SDF$x2+GWRFB$SDF$x3+GWRFB$SDF$x4++GWRFB$SDF$x5)
## 
##  studentized Breusch-Pagan test
## 
## data:  residual_gwr ~ GWRFB$SDF$x1 + GWRFB$SDF$x2 + GWRFB$SDF$x3 + GWRFB$SDF$x4 +     +GWRFB$SDF$x5
## BP = 4.8211, df = 5, p-value = 0.4381

Membuat PLot Splot

coef_x1 <- GWRFB$SDF$x1
coef_x2 <- GWRFB$SDF$x2
coef_x3 <- GWRFB$SDF$x3
coef_x4 <- GWRFB$SDF$x4
coef_x5 <- GWRFB$SDF$x5
spplot(GWRFB$SDF, "x1", main = "Koefisien GWR untuk x1", col.regions = terrain.colors(100))

spplot(GWRFB$SDF, "x2", main = "Koefisien GWR untuk x2", col.regions = terrain.colors(100))

spplot(GWRFB$SDF, "x3", main = "Koefisien GWR untuk x1", col.regions = terrain.colors(100))

Membuat plot -gglot2

gwr_df <- as.data.frame(GWRFB$SDF)
ggplot(gwr_df, aes(x = longitude, y = latitude)) +
  geom_point(aes(color = x1), size = 2) +
  scale_color_viridis_c() +
  labs(title = "Koefisien GWR untuk x1", color = "Koefisien") +
  theme_minimal()

ggplot(gwr_df, aes(x = longitude, y = latitude)) +
  geom_point(aes(color = x2), size = 2) +
  scale_color_viridis_c() +
  labs(title = "Koefisien GWR untuk x2", color = "Koefisien") +
  theme_minimal()

ggplot(gwr_df, aes(x = longitude, y = latitude)) +
  geom_point(aes(color = x3), size = 2) +
  scale_color_viridis_c() +
  labs(title = "Koefisien GWR untuk x3", color = "Koefisien") +
  theme_minimal()

Membuat Surface Plot

x.range <- range(longitude)
y.range <- range(latitude)
grd <- expand.grid(
  longitude = seq(from = x.range[1], to = x.range[2], length.out = 100),
  latitude = seq(from = y.range[1], to = y.range[2], length.out = 100)
)

coordinates(grd) <- ~longitude + latitude
proj4string(grd) <- CRS("+proj=longlat +datum=WGS84 +no_defs")
residual_gwr = GWRFB$SDF$gwr.e
library(dplyr)
library(broom)
## Warning: package 'broom' was built under R version 4.3.3
names(GWRFB$SDF)
##  [1] "sum.w"              "(Intercept)"        "x1"                
##  [4] "x2"                 "x3"                 "x4"                
##  [7] "x5"                 "(Intercept)_se"     "x1_se"             
## [10] "x2_se"              "x3_se"              "x4_se"             
## [13] "x5_se"              "gwr.e"              "pred"              
## [16] "pred.se"            "localR2"            "(Intercept)_se_EDF"
## [19] "x1_se_EDF"          "x2_se_EDF"          "x3_se_EDF"         
## [22] "x4_se_EDF"          "x5_se_EDF"          "pred.se"
names(Jawa_Tengah_merged)
##  [1] "GID_0"        "NAME_0"       "GID_1"        "NAME_1"       "NL_NAME_1"   
##  [6] "GID_2"        "NAME_2"       "VARNAME_2"    "NL_NAME_2"    "TYPE_2"      
## [11] "ENGTYPE_2"    "CC_2"         "HASC_2"       "id"           "Kota"        
## [16] "BGK"          "PUS"          "AirLayak"     "Posyandu"     "Imunisasi"   
## [21] "Sanitasi"     "geometry"     "BGK_Discrete" "locm"         "p_value"
gwr_results <- data.frame(
  id = Jawa_Tengah_merged$id,
  intercept = GWRFB$SDF$`(Intercept)`,          
  x1 = GWRFB$SDF$x1,                             
  x2 = GWRFB$SDF$x2,
  x3 = GWRFB$SDF$x3,
  x4 = GWRFB$SDF$x4,
  x5 = GWRFB$SDF$x5,
  intercept_se = GWRFB$SDF$`(Intercept)_se`,    
  x1_se = GWRFB$SDF$x1_se,                       
  x2_se = GWRFB$SDF$x2_se,
  x3_se = GWRFB$SDF$x3_se,
  x4_se = GWRFB$SDF$x4_se,
  x5_se = GWRFB$SDF$x5_se 
)

length(Jawa_Tengah_merged$id)
## [1] 35
length(GWRFB$SDF$Intercept)
## [1] 0
num_params <- length(coef(GWRFB))

## Pemetaan GWR
gwr_results$t_intercept <- gwr_results$intercept / gwr_results$intercept_se
gwr_results$p_intercept <- 2 * (1 - pt(abs(gwr_results$t_intercept), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$t_x1 <- gwr_results$x1 / gwr_results$x1_se
gwr_results$p_x1 <- 2 * (1 - pt(abs(gwr_results$t_x1), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$t_x2 <- gwr_results$x2 / gwr_results$x2_se
gwr_results$p_x2 <- 2 * (1 - pt(abs(gwr_results$t_x2), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$t_x3 <- gwr_results$x3 / gwr_results$x3_se
gwr_results$p_x3 <- 2 * (1 - pt(abs(gwr_results$t_x3), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$t_x4 <- gwr_results$x4 / gwr_results$x4_se
gwr_results$p_x4 <- 2 * (1 - pt(abs(gwr_results$t_x4), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$t_x5 <- gwr_results$x5 / gwr_results$x5_se
gwr_results$p_x6 <- 2 * (1 - pt(abs(gwr_results$t_x5), df = nrow(Jawa_Tengah_merged) - num_params))

gwr_results$significant_intercept <- ifelse(gwr_results$p_intercept < 0.05, "Significant", "Not Significant")
gwr_results$significant_x1 <- ifelse(gwr_results$p_x1 < 0.05, "Significant", "Not Significant")
gwr_results$significant_x2 <- ifelse(gwr_results$p_x2 < 0.05, "Significant", "Not Significant")
gwr_results$significant_x3 <- ifelse(gwr_results$p_x3 < 0.05, "Significant", "Not Significant")
gwr_results$significant_x4 <- ifelse(gwr_results$p_x2 < 0.05, "Significant", "Not Significant")
gwr_results$significant_x5 <- ifelse(gwr_results$p_x3 < 0.05, "Significant", "Not Significant")

Jawa_Tengah_combined <- Jawa_Tengah_merged %>% left_join(gwr_results, by = "id")

#Membuat peta untuk intercept
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_intercept)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of Intercept in GWR Model for Jawa_Tengah") +
  theme_minimal()

#Membuat peta untuk variabel x1
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_x1)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of x1 in GWR Model for Jawa_Tengah") +
  theme_minimal()

#Membuat peta untuk variabel x2
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_x2)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of x2 in GWR Model for Jawa_Tengah") +
  theme_minimal()

#Membuat peta untuk variabel x3
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_x3)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of x3 in GWR Model for Jawa_Tengah") +
  theme_minimal()

#Membuat peta untuk variabel x4
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_x4)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of x in GWR Model for Jawa_Tengah") +
  theme_minimal()

#Membuat peta untuk variabel x4
ggplot(data = Jawa_Tengah_combined) +
  geom_sf(aes(fill = significant_x5)) +
  scale_fill_manual(values = c("Significant" = "green", "Not Significant" = "red")) +
  labs(title = "Significance of x5 in GWR Model for Jawa_Tengah") +
  theme_minimal()

# Menggabungkan variabel signifikan menjadi satu kolom
gwr_results <- gwr_results %>%
  mutate(
    variabel_signifikan = paste(
      significant_x1, significant_x2, significant_x3,significant_x4, significant_x5, sep = ", "
    )
  ) %>%
  # Hapus NA dalam hasil variabel_signifikan
  mutate(variabel_signifikan = gsub("NA, |, NA", "", variabel_signifikan)) %>%
  mutate(variabel_signifikan = ifelse(variabel_signifikan == "NA", "Tidak ada", variabel_signifikan))

gwr_results <- cbind(gwr_results, data$Kota)

# Membuat tabel akhir
tabel_hasil <- gwr_results %>%
  dplyr::select(V2, variabel_signifikan)
tabel_hasil
##                  V2
##              <char>
##  1:         Cilacap
##  2:        Banyumas
##  3:     Purbalingga
##  4:    Banjarnegara
##  5:         Kebumen
##  6:       Purworejo
##  7:        Wonosobo
##  8:        Magelang
##  9:        Boyolali
## 10:          Klaten
## 11:       Sukoharjo
## 12:        Wonogiri
## 13:     Karanganyar
## 14:          Sragen
## 15:        Grobogan
## 16:           Blora
## 17:         Rembang
## 18:            Pati
## 19:           Kudus
## 20:          Jepara
## 21:           Demak
## 22:        Semarang
## 23:      Temanggung
## 24:          Kendal
## 25:          Batang
## 26:      Pekalongan
## 27:        Pemalang
## 28:           Tegal
## 29:          Brebes
## 30:   Kota Magelang
## 31:  Kota Surakarta
## 32:   Kota Salatiga
## 33:   Kota Semarang
## 34: Kota Pekalongan
## 35:      Kota Tegal
##                  V2
##                                                                     variabel_signifikan
##                                                                                  <char>
##  1: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  2:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  3: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  4:         Not Significant, Not Significant, Significant, Not Significant, Significant
##  5: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  6:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  7:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
##  8:         Not Significant, Not Significant, Significant, Not Significant, Significant
##  9:         Not Significant, Not Significant, Significant, Not Significant, Significant
## 10: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 11: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 12: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 13: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 14: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 15: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 16:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 17: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 18:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 19:         Not Significant, Not Significant, Significant, Not Significant, Significant
## 20: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 21:         Not Significant, Not Significant, Significant, Not Significant, Significant
## 22:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 23:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 24:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 25: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 26: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 27: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 28: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 29: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 30: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 31: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 32:     Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 33: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 34: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
## 35: Not Significant, Not Significant, Not Significant, Not Significant, Not Significant
##                                                                     variabel_signifikan