R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

##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('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 × 6
##       id Kota           BGK    PUS Air_Layak Posyandu
##    <dbl> <chr>        <dbl>  <dbl>     <dbl>    <dbl>
##  1     1 Cilacap       5176 348057      88.8     2205
##  2     2 Banyumas      4127 303267      93.6     2548
##  3     3 Purbalingga   3267 184376      82.8     1238
##  4     4 Banjarnegara  2120 190610      87.6     1578
##  5     5 Kebumen       3227 193660      87.3     2123
##  6     6 Purworejo      760 108734      91.3     1646
##  7     7 Wonosobo      1825 148878      94.6     1291
##  8     8 Magelang      3425 204578      97.5     2479
##  9     9 Boyolali      2192 172389      94.4     1860
## 10    10 Klaten        3699 197321      99.5     2297
## # ℹ 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 = "#ff8a01", high = 
                        "#011f47") +
  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$BGK)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     225    1411    2163    2316    3208    5330
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$Air_Layak 
x3 <- data$Posyandu

plot(data)

Optimal Bandwidth

#Optimal Bandwidth Gaussian Fixed
bandwGF <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.Gauss);bandwGF
## Bandwidth: 1.108584 CV score: 44630093 
## Bandwidth: 1.791936 CV score: 45489724 
## Bandwidth: 0.6862495 CV score: 44182898 
## Bandwidth: 0.4252323 CV score: 48117016 
## Bandwidth: 0.847567 CV score: 44185710 
## Bandwidth: 0.764724 CV score: 44119226 
## Bandwidth: 0.7660371 CV score: 44119486 
## Bandwidth: 0.7575499 CV score: 44118404 
## Bandwidth: 0.7303155 CV score: 44125696 
## Bandwidth: 0.7553253 CV score: 44118363 
## Bandwidth: 0.7555275 CV score: 44118362 
## Bandwidth: 0.7555682 CV score: 44118362 
## Bandwidth: 0.7556089 CV score: 44118362 
## Bandwidth: 0.7555682 CV score: 44118362
## [1] 0.7555682
#Optimal Bandwidth Bisquare Fixed
bandwBF <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.bisquare);bandwBF
## Bandwidth: 1.108584 CV score: 47840907 
## Bandwidth: 1.791936 CV score: 43296937 
## Bandwidth: 2.214271 CV score: 43742479 
## Bandwidth: 1.927404 CV score: 43389252 
## Bandwidth: 1.597969 CV score: 43229224 
## Bandwidth: 1.411041 CV score: 43695644 
## Bandwidth: 1.521946 CV score: 43288545 
## Bandwidth: 1.653226 CV score: 43229874 
## Bandwidth: 1.624623 CV score: 43225909 
## Bandwidth: 1.624362 CV score: 43225907 
## Bandwidth: 1.623481 CV score: 43225903 
## Bandwidth: 1.62344 CV score: 43225903 
## Bandwidth: 1.6234 CV score: 43225903 
## Bandwidth: 1.62344 CV score: 43225903
## [1] 1.62344
#Optimal Bandwidth Tricube Fixed
bandwTF <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.tricube);bandwTF
## Bandwidth: 1.108584 CV score: 48809162 
## Bandwidth: 1.791936 CV score: 42712451 
## Bandwidth: 2.214271 CV score: 43319836 
## Bandwidth: 1.926358 CV score: 42897749 
## Bandwidth: 1.530919 CV score: 42691069 
## Bandwidth: 1.648936 CV score: 42561833 
## Bandwidth: 1.656451 CV score: 42564991 
## Bandwidth: 1.635288 CV score: 42558563 
## Bandwidth: 1.595423 CV score: 42571138 
## Bandwidth: 1.628067 CV score: 42558243 
## Bandwidth: 1.629309 CV score: 42558224 
## Bandwidth: 1.629447 CV score: 42558224 
## Bandwidth: 1.629407 CV score: 42558224 
## Bandwidth: 1.629488 CV score: 42558224 
## Bandwidth: 1.629447 CV score: 42558224
## [1] 1.629447
#Optimal Bandwidth Gaussian Adaptive
bandwGA <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.Gauss,adapt = TRUE);bandwGA
## Adaptive q: 0.381966 CV score: 46831750 
## Adaptive q: 0.618034 CV score: 46311579 
## Adaptive q: 0.763932 CV score: 46475091 
## Adaptive q: 0.6265948 CV score: 46387149 
## Adaptive q: 0.527864 CV score: 46321088 
## Adaptive q: 0.5735318 CV score: 46029873 
## Adaptive q: 0.5733232 CV score: 46028876 
## Adaptive q: 0.5559593 CV score: 46175749 
## Adaptive q: 0.5702572 CV score: 46031679 
## Adaptive q: 0.5720532 CV score: 46022795 
## Adaptive q: 0.5713672 CV score: 46020415 
## Adaptive q: 0.5709432 CV score: 46024717 
## Adaptive q: 0.5715688 CV score: 46020467 
## Adaptive q: 0.5714485 CV score: 46019888 
## Adaptive q: 0.5714892 CV score: 46020084 
## Adaptive q: 0.5714485 CV score: 46019888
## [1] 0.5714485
#Optimal Bandwidth Bisquare Adaptive
bandwBA <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.bisquare, adapt = TRUE);bandwBA
## Adaptive q: 0.381966 CV score: 67100980 
## Adaptive q: 0.618034 CV score: 56119282 
## Adaptive q: 0.763932 CV score: 48819595 
## Adaptive q: 0.854102 CV score: 47335061 
## Adaptive q: 0.866906 CV score: 47044086 
## Adaptive q: 0.9177434 CV score: 46358124 
## Adaptive q: 0.9388337 CV score: 46241180 
## Adaptive q: 0.9533775 CV score: 46353233 
## Adaptive q: 0.935745 CV score: 46255903 
## Adaptive q: 0.9406591 CV score: 46232817 
## Adaptive q: 0.9455171 CV score: 46255639 
## Adaptive q: 0.9413962 CV score: 46229509 
## Adaptive q: 0.9429703 CV score: 46224439 
## Adaptive q: 0.9439431 CV score: 46236289 
## Adaptive q: 0.942369 CV score: 46225203 
## Adaptive q: 0.943011 CV score: 46224933 
## Adaptive q: 0.9427001 CV score: 46223753 
## Adaptive q: 0.9425736 CV score: 46224306 
## Adaptive q: 0.9427623 CV score: 46223481 
## Adaptive q: 0.9428417 CV score: 46223134 
## Adaptive q: 0.9428908 CV score: 46223476 
## Adaptive q: 0.9428417 CV score: 46223134
## [1] 0.9428417
#Optimal Bandwidth Tricube Adaptive
bandwTA <- gwr.sel(y ~ x1 + x2 + x3, data = data, coord=Coordk, gweight=gwr.tricube, adapt = TRUE);bandwTA
## Adaptive q: 0.381966 CV score: 70195424 
## Adaptive q: 0.618034 CV score: 58391918 
## Adaptive q: 0.763932 CV score: 49872676 
## Adaptive q: 0.854102 CV score: 47815769 
## Adaptive q: 0.8846916 CV score: 46769183 
## Adaptive q: 0.9287355 CV score: 46128681 
## Adaptive q: 0.9343006 CV score: 46071869 
## Adaptive q: 0.9593955 CV score: 46105805 
## Adaptive q: 0.9450549 CV score: 46002988 
## Adaptive q: 0.9455981 CV score: 46005631 
## Adaptive q: 0.9428878 CV score: 45993763 
## Adaptive q: 0.9396078 CV score: 46022123 
## Adaptive q: 0.941635 CV score: 46004188 
## Adaptive q: 0.9433926 CV score: 45995717 
## Adaptive q: 0.9424093 CV score: 45997487 
## Adaptive q: 0.9429769 CV score: 45994099 
## Adaptive q: 0.942705 CV score: 45994948 
## Adaptive q: 0.9428471 CV score: 45993733 
## Adaptive q: 0.9428064 CV score: 45994081 
## Adaptive q: 0.9428471 CV score: 45993733
## [1] 0.9428471
Coord <- coordinates(Jawa_Tengah)
longitude <- Coord[, 1]
latitude <- Coord[, 2]

Model GWR Adaptive Gaussian Kernel

GWRAG <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     gweight = gwr.Gauss, adapt = bandwGA, hatmatrix = TRUE, se.fit = TRUE)
## Kernel function: gwr.Gauss 
## Adaptive quantile: 0.5714485 (about 20 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  9.2084e+02  1.5786e+03  2.1195e+03  2.8520e+03  3.3911e+03
## x1            2.6215e-03  3.2962e-03  4.5633e-03  7.3044e-03  7.8315e-03
## x2           -2.9615e+01 -2.5902e+01 -1.7304e+01 -1.2881e+01 -3.9042e+00
## x3            4.2799e-01  4.6885e-01  6.5440e-01  8.0249e-01  8.7992e-01
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 7.29353 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 27.70647 
## Sigma (residual: 2traceS - traceS'S): 1009.876 
## Effective number of parameters (model: traceS): 5.967828 
## Effective degrees of freedom (model: traceS): 29.03217 
## Sigma (model: traceS): 986.5491 
## Sigma (ML): 898.5131 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 593.4208 
## AIC (GWR p. 96, eq. 4.22): 581.3454 
## Residual sum of squares: 28256404 
## Quasi-global R2: 0.5043885

Model GWR Adaptive Bisquare Kernel

GWRAB <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     gweight = gwr.bisquare, adapt = bandwBA, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.bisquare 
## Adaptive quantile: 0.9428417 (about 32 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  1.9060e+02  2.0507e+03  2.6078e+03  3.6366e+03  5.0499e+03
## x1            1.7123e-03  2.6138e-03  4.1172e-03  8.5510e-03  1.1702e-02
## x2           -4.6028e+01 -3.3951e+01 -2.4335e+01 -1.4781e+01  3.6919e+00
## x3            5.2609e-02  2.9494e-01  6.0751e-01  8.1869e-01  9.8190e-01
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 8.961104 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 26.0389 
## Sigma (residual: 2traceS - traceS'S): 1001.806 
## Effective number of parameters (model: traceS): 7.311438 
## Effective degrees of freedom (model: traceS): 27.68856 
## Sigma (model: traceS): 971.5043 
## Sigma (ML): 864.0938 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 595.2916 
## AIC (GWR p. 96, eq. 4.22): 579.9548 
## Residual sum of squares: 26133033 
## Quasi-global R2: 0.5416319

Model GWR Adaptive Tricube Kernel

GWRAT <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     gweight = gwr.tricube, adapt = bandwTA, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.tricube 
## Adaptive quantile: 0.9428471 (about 32 of 35 data points)
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept.  2.5589e+02  2.2490e+03  2.8862e+03  3.6597e+03  4.9266e+03
## x1            1.8081e-03  2.5888e-03  4.1658e-03  8.7399e-03  1.1416e-02
## x2           -4.4587e+01 -3.2488e+01 -2.7250e+01 -1.6622e+01  3.0637e+00
## x3            5.6889e-02  2.7397e-01  5.9845e-01  8.1304e-01  9.6970e-01
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 7.96253 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 27.03747 
## Sigma (residual: 2traceS - traceS'S): 1002.672 
## Effective number of parameters (model: traceS): 6.785939 
## Effective degrees of freedom (model: traceS): 28.21406 
## Sigma (model: traceS): 981.5427 
## Sigma (ML): 881.2679 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 594.812 
## AIC (GWR p. 96, eq. 4.22): 580.807 
## Residual sum of squares: 27182161 
## Quasi-global R2: 0.5232305

Model GWR Fixed Gaussian Kernel

GWRFG <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     bandwidth = bandwGF, gweight = gwr.Gauss, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.Gauss 
## Fixed bandwidth: 0.7555682 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept. -2.3053e+03  1.2159e+03  2.2441e+03  3.3717e+03  3.7797e+03
## x1            1.0219e-03  2.8195e-03  4.5297e-03  7.7222e-03  1.3623e-02
## x2           -3.3649e+01 -2.9669e+01 -2.0581e+01 -1.0479e+01  2.8988e+01
## x3           -1.1890e-01  3.9485e-01  6.5135e-01  8.1963e-01  1.0996e+00
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 9.282711 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 25.71729 
## Sigma (residual: 2traceS - traceS'S): 1000.272 
## Effective number of parameters (model: traceS): 7.381722 
## Effective degrees of freedom (model: traceS): 27.61828 
## Sigma (model: traceS): 965.2337 
## Sigma (ML): 857.4262 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 595.0036 
## AIC (GWR p. 96, eq. 4.22): 579.4829 
## Residual sum of squares: 25731289 
## Quasi-global R2: 0.5486785

Model GWR Fixed Bisquare Kernel

GWRFB <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     bandwidth = bandwBF, gweight = gwr.bisquare, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.bisquare 
## Fixed bandwidth: 1.62344 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept. -6.3728e+03  9.0237e+02  2.8886e+03  3.6229e+03  4.3451e+03
## x1            8.9288e-04  2.5797e-03  4.2015e-03  8.5383e-03  1.6147e-02
## x2           -3.9034e+01 -3.3576e+01 -2.5607e+01 -6.3015e+00  7.0184e+01
## x3           -4.2271e-01  3.0306e-01  6.6384e-01  8.2475e-01  1.2002e+00
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 9.669269 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 25.33073 
## Sigma (residual: 2traceS - traceS'S): 991.6601 
## Effective number of parameters (model: traceS): 7.915238 
## Effective degrees of freedom (model: traceS): 27.08476 
## Sigma (model: traceS): 959.0123 
## Sigma (ML): 843.6313 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 595.8441 
## AIC (GWR p. 96, eq. 4.22): 578.881 
## Residual sum of squares: 24909980 
## Quasi-global R2: 0.563084

Model GWR Fixed Tricube Kernel

GWRFT <- gwr(
  y ~ x1 + x2 + x3,
  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, data = data, coords = Coordk, 
##     bandwidth = bandwTF, gweight = gwr.tricube, hatmatrix = TRUE, 
##     se.fit = TRUE)
## Kernel function: gwr.tricube 
## Fixed bandwidth: 1.629447 
## Summary of GWR coefficient estimates at data points:
##                     Min.     1st Qu.      Median     3rd Qu.        Max.
## X.Intercept. -7.2330e+03  9.5373e+02  3.1925e+03  3.4166e+03  4.3514e+03
## x1            9.4165e-04  2.5711e-03  4.0800e-03  8.7062e-03  1.6321e-02
## x2           -3.9225e+01 -3.1680e+01 -2.8414e+01 -6.2940e+00  7.8895e+01
## x3           -4.4444e-01  2.8041e-01  6.8212e-01  8.1227e-01  1.2147e+00
##                Global
## X.Intercept. 988.5957
## x1             0.0056
## x2            -6.8433
## x3             0.6632
## Number of data points: 35 
## Effective number of parameters (residual: 2traceS - traceS'S): 8.576264 
## Effective degrees of freedom (residual: 2traceS - traceS'S): 26.42374 
## Sigma (residual: 2traceS - traceS'S): 984.9654 
## Effective number of parameters (model: traceS): 7.325329 
## Effective degrees of freedom (model: traceS): 27.67467 
## Sigma (model: traceS): 962.4471 
## Sigma (ML): 855.8233 
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 594.6685 
## AIC (GWR p. 96, eq. 4.22): 579.2955 
## Residual sum of squares: 25635170 
## Quasi-global R2: 0.5503644
aicc_results = data.frame(Bobot = c("Adaptive Gaussian",
                                    "Adaptive Bisquare",
                                    "Adaptive Tricube",
                                    "Fixed Gaussian",
                                    "Fixed Bisquare",
                                    "Fixed Tricube"),
                          Bandwidth = c( 0.5714485,
                                         0.9428417,
                                         0.9428471,
                                         0.7555682,
                                         1.62344,
                                         1.629447),
                          AICc = c(GWRAG$results$AICc,
                                   GWRAB$results$AICc,
                                   GWRAT$results$AICc,
                                   GWRFG$results$AICc,
                                   GWRFB$results$AICc,
                                   GWRFT$results$AICc))

aicc_results
##               Bobot Bandwidth     AICc
## 1 Adaptive Gaussian 0.5714485 594.0497
## 2 Adaptive Bisquare 0.9428417 596.4373
## 3  Adaptive Tricube 0.9428471 595.5518
## 4    Fixed Gaussian 0.7555682 596.3802
## 5    Fixed Bisquare 1.6234400 597.3013
## 6     Fixed Tricube 1.6294470 595.6327

Identifikasi Variabel yang Signifikan

## Ekstrak koefisien lokal untuk variabel xi
coef_x1 = GWRAG$SDF$x1
coef_x2 = GWRAG$SDF$x2
coef_x3 = GWRAG$SDF$x3

## Ekstrak standar error untuk variabel xi (untuk tiap provinsi)
se_x1 = GWRAG$SDF$x1_se
se_x2 = GWRAG$SDF$x2_se
se_x3 = GWRAG$SDF$x3_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

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

n = nrow(data)
k = length(coef(GWRAG$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))

# Display p-values
prov_id = rep(1:35, times=3)
var_id = rep(1:3, each = 35)
p_values = data.frame(ID = prov_id,
                      Variabel_X_ke = var_id,
                      p_value = c(p_values1, p_values2, p_values3))
p_values
##     ID Variabel_X_ke    p_value
## 1    1             1 0.01879132
## 2    2             1 0.01320018
## 3    3             1 0.03543897
## 4    4             1 0.34341557
## 5    5             1 0.28660211
## 6    6             1 0.01332495
## 7    7             1 0.01408004
## 8    8             1 0.29379727
## 9    9             1 0.41296796
## 10  10             1 0.23535507
## 11  11             1 0.31280981
## 12  12             1 0.02148016
## 13  13             1 0.10224352
## 14  14             1 0.20843472
## 15  15             1 0.12567472
## 16  16             1 0.01946220
## 17  17             1 0.19586962
## 18  18             1 0.01330219
## 19  19             1 0.33220285
## 20  20             1 0.13622631
## 21  21             1 0.31481692
## 22  22             1 0.01551838
## 23  23             1 0.01265547
## 24  24             1 0.01301058
## 25  25             1 0.06143919
## 26  26             1 0.28601989
## 27  27             1 0.23187961
## 28  28             1 0.22774043
## 29  29             1 0.39198712
## 30  30             1 0.28353385
## 31  31             1 0.31723744
## 32  32             1 0.01259970
## 33  33             1 0.10074003
## 34  34             1 0.24358594
## 35  35             1 0.04723621
## 36   1             2 0.47452668
## 37   2             2 0.68236907
## 38   3             2 0.46586570
## 39   4             2 0.90620136
## 40   5             2 0.67111089
## 41   6             2 0.74636512
## 42   7             2 0.73589846
## 43   8             2 0.74592789
## 44   9             2 0.92440980
## 45  10             2 0.81339420
## 46  11             2 0.77260371
## 47  12             2 0.52288189
## 48  13             2 0.49480632
## 49  14             2 0.63075656
## 50  15             2 0.48013033
## 51  16             2 0.55074259
## 52  17             2 0.57690426
## 53  18             2 0.72732677
## 54  19             2 0.86258630
## 55  20             2 0.48060104
## 56  21             2 0.88367114
## 57  22             2 0.52277470
## 58  23             2 0.63635171
## 59  24             2 0.61073044
## 60  25             2 0.47076660
## 61  26             2 0.90143827
## 62  27             2 0.59542264
## 63  28             2 0.58945482
## 64  29             2 0.85750503
## 65  30             2 0.70248943
## 66  31             2 0.72767443
## 67  32             2 0.70645525
## 68  33             2 0.46194668
## 69  34             2 0.72195269
## 70  35             2 0.46607816
## 71   1             3 0.31348381
## 72   2             3 0.28080312
## 73   3             3 0.18903000
## 74   4             3 0.04309517
## 75   5             3 0.07754978
## 76   6             3 0.25119766
## 77   7             3 0.25283349
## 78   8             3 0.05943783
## 79   9             3 0.05076006
## 80  10             3 0.05050523
## 81  11             3 0.05816182
## 82  12             3 0.28519993
## 83  13             3 0.10900549
## 84  14             3 0.08050340
## 85  15             3 0.12678727
## 86  16             3 0.22764887
## 87  17             3 0.08039979
## 88  18             3 0.25024698
## 89  19             3 0.04785605
## 90  20             3 0.12612893
## 91  21             3 0.04492408
## 92  22             3 0.28929156
## 93  23             3 0.28603556
## 94  24             3 0.30551698
## 95  25             3 0.18535632
## 96  26             3 0.04345396
## 97  27             3 0.08622219
## 98  28             3 0.08593987
## 99  29             3 0.05535053
## 100 30             3 0.06921528
## 101 31             3 0.06837658
## 102 32             3 0.26901305
## 103 33             3 0.12961973
## 104 34             3 0.06538414
## 105 35             3 0.19024481

Koefisien pada setiap lokasi

coef_gwr <- GWRAG$SDF@data[, c("x1", "x2","x3")];coef_gwr
##             x1         x2        x3
## 1  0.007406865 -29.204124 0.4290889
## 2  0.007725457 -16.302535 0.4460441
## 3  0.006410219 -29.537523 0.5341629
## 4  0.002931703  -4.767722 0.8761285
## 5  0.003352616 -17.303568 0.7626348
## 6  0.007692987 -12.827682 0.4685135
## 7  0.007593062 -13.333918 0.4679854
## 8  0.003257039 -12.935229 0.8246538
## 9  0.002621462  -3.904184 0.8799210
## 10 0.003569998  -9.286367 0.8361565
## 11 0.003140831 -11.694550 0.8134728
## 12 0.007141145 -25.717978 0.4527899
## 13 0.004928103 -27.284173 0.6543998
## 14 0.003838239 -19.245663 0.7293665
## 15 0.004671351 -28.540051 0.6306726
## 16 0.007201980 -24.111162 0.4911904
## 17 0.003964593 -22.274112 0.7373002
## 18 0.007709391 -13.879236 0.4691833
## 19 0.003000245  -6.932507 0.8719187
## 20 0.004563281 -28.608464 0.6345918
## 21 0.003082702  -5.849423 0.8725504
## 22 0.007599986 -26.086814 0.4403258
## 23 0.007831456 -19.046184 0.4406289
## 24 0.007803671 -20.491144 0.4279896
## 25 0.005680168 -29.055689 0.5504226
## 26 0.003240348  -4.942444 0.8624602
## 27 0.003714657 -21.469390 0.7274777
## 28 0.003744972 -21.778668 0.7278972
## 29 0.002736962  -7.406110 0.8515329
## 30 0.003335270 -15.478300 0.7773099
## 31 0.003150493 -14.223436 0.7914999
## 32 0.007803139 -15.036733 0.4537546
## 33 0.004983564 -29.614797 0.6205960
## 34 0.003558993 -14.230913 0.7734853
## 35 0.006018163 -29.281748 0.5380056

Pengujian Asumsi GWR

residual_gwr <- GWRAG$SDF$gwr.e

#Normalitas Residual
shapiro.test(residual_gwr)
## 
##  Shapiro-Wilk normality test
## 
## data:  residual_gwr
## W = 0.9578, p-value = 0.1963
#Autokorelasi Spasial
moran.test(residual_gwr, WLJ4)
## 
##  Moran I test under randomisation
## 
## data:  residual_gwr  
## weights: WLJ4    
## 
## Moran I statistic standard deviate = 1.207, p-value = 0.1137
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.09569515       -0.02941176        0.01074404

Model OLS

model_ols <- lm(y ~ x1 + x2 + x3)
summary(model_ols)
## 
## Call:
## lm(formula = y ~ x1 + x2 + x3)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2405.5  -415.9   142.6   516.4  2432.5 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  9.886e+02  3.981e+03   0.248   0.8055  
## x1           5.618e-03  2.937e-03   1.913   0.0651 .
## x2          -6.843e+00  3.987e+01  -0.172   0.8648  
## x3           6.632e-01  4.024e-01   1.648   0.1094  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1035 on 31 degrees of freedom
## Multiple R-squared:  0.4172, Adjusted R-squared:  0.3608 
## F-statistic: 7.397 on 3 and 31 DF,  p-value: 0.0007096
AICOLS = AIC(model_ols);AICOLS
## [1] 591.0495

Asumsi OLS

#Heterogenitas Spasial
bptest(model_ols)
## 
##  studentized Breusch-Pagan test
## 
## data:  model_ols
## BP = 13.001, df = 3, p-value = 0.004635
#Multikolinearitas
vif(model_ols)
##       x1       x2       x3 
## 2.186237 1.302589 1.823495
#Normalitas Residual
shapiro.test(model_ols$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  model_ols$residuals
## W = 0.97606, p-value = 0.6288

Membuat PLot Splot

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

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

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

Membuat plot -gglot2

gwr_df <- as.data.frame(GWRFG$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 = GWRAG$SDF$gwr.e
library(dplyr)
library(broom)
## Warning: package 'broom' was built under R version 4.3.3
names(GWRAG$SDF)
##  [1] "sum.w"              "(Intercept)"        "x1"                
##  [4] "x2"                 "x3"                 "(Intercept)_se"    
##  [7] "x1_se"              "x2_se"              "x3_se"             
## [10] "gwr.e"              "pred"               "pred.se"           
## [13] "localR2"            "(Intercept)_se_EDF" "x1_se_EDF"         
## [16] "x2_se_EDF"          "x3_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"          "Air_Layak"    "Posyandu"     "geometry"    
## [21] "BGK_Discrete" "locm"         "p_value"
gwr_results <- data.frame(
  id = Jawa_Tengah_merged$id,
  intercept = GWRAG$SDF$`(Intercept)`,          
  x1 = GWRAG$SDF$x1,                             
  x2 = GWRAG$SDF$x2,
  x3 = GWRAG$SDF$x3,                             
  intercept_se = GWRAG$SDF$`(Intercept)_se`,    
  x1_se = GWRAG$SDF$x1_se,                       
  x2_se = GWRAG$SDF$x2_se,
  x3_se = GWRAG$SDF$x3_se                    
)

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

## 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$x2 / 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$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")

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()