Package
library(rgdal)
## Loading required package: sp
## rgdal: version: 1.5-16, (SVN revision 1050)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
## Path to GDAL shared files: C:/Users/Ny 07/Documents/R/win-library/4.0/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
## Path to PROJ shared files: C:/Users/Ny 07/Documents/R/win-library/4.0/rgdal/proj
## Linking to sp version:1.4-2
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
library(raster)
library(spdep)
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## Loading required package: sf
## Warning: package 'sf' was built under R version 4.0.5
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(spatialreg)
## Loading required package: Matrix
## Registered S3 methods overwritten by 'spatialreg':
## method from
## residuals.stsls spdep
## deviance.stsls spdep
## coef.stsls spdep
## print.stsls spdep
## summary.stsls spdep
## print.summary.stsls spdep
## residuals.gmsar spdep
## deviance.gmsar spdep
## coef.gmsar spdep
## fitted.gmsar spdep
## print.gmsar spdep
## summary.gmsar spdep
## print.summary.gmsar spdep
## print.lagmess spdep
## summary.lagmess spdep
## print.summary.lagmess spdep
## residuals.lagmess spdep
## deviance.lagmess spdep
## coef.lagmess spdep
## fitted.lagmess spdep
## logLik.lagmess spdep
## fitted.SFResult spdep
## print.SFResult spdep
## fitted.ME_res spdep
## print.ME_res spdep
## print.lagImpact spdep
## plot.lagImpact spdep
## summary.lagImpact spdep
## HPDinterval.lagImpact spdep
## print.summary.lagImpact spdep
## print.sarlm spdep
## summary.sarlm spdep
## residuals.sarlm spdep
## deviance.sarlm spdep
## coef.sarlm spdep
## vcov.sarlm spdep
## fitted.sarlm spdep
## logLik.sarlm spdep
## anova.sarlm spdep
## predict.sarlm spdep
## print.summary.sarlm spdep
## print.sarlm.pred spdep
## as.data.frame.sarlm.pred spdep
## residuals.spautolm spdep
## deviance.spautolm spdep
## coef.spautolm spdep
## fitted.spautolm spdep
## print.spautolm spdep
## summary.spautolm spdep
## logLik.spautolm spdep
## print.summary.spautolm spdep
## print.WXImpact spdep
## summary.WXImpact spdep
## print.summary.WXImpact spdep
## predict.SLX spdep
##
## Attaching package: 'spatialreg'
## The following objects are masked from 'package:spdep':
##
## anova.sarlm, as.spam.listw, as_dgRMatrix_listw, as_dsCMatrix_I,
## as_dsCMatrix_IrW, as_dsTMatrix_listw, bptest.sarlm, can.be.simmed,
## cheb_setup, coef.gmsar, coef.sarlm, coef.spautolm, coef.stsls,
## create_WX, deviance.gmsar, deviance.sarlm, deviance.spautolm,
## deviance.stsls, do_ldet, eigen_pre_setup, eigen_setup, eigenw,
## errorsarlm, fitted.gmsar, fitted.ME_res, fitted.sarlm,
## fitted.SFResult, fitted.spautolm, get.ClusterOption,
## get.coresOption, get.mcOption, get.VerboseOption,
## get.ZeroPolicyOption, GMargminImage, GMerrorsar, griffith_sone,
## gstsls, Hausman.test, HPDinterval.lagImpact, impacts, intImpacts,
## Jacobian_W, jacobianSetup, l_max, lagmess, lagsarlm, lextrB,
## lextrS, lextrW, lmSLX, logLik.sarlm, logLik.spautolm, LR.sarlm,
## LR1.sarlm, LR1.spautolm, LU_prepermutate_setup, LU_setup,
## Matrix_J_setup, Matrix_setup, mcdet_setup, MCMCsamp, ME, mom_calc,
## mom_calc_int2, moments_setup, powerWeights, predict.sarlm,
## predict.SLX, print.gmsar, print.ME_res, print.sarlm,
## print.sarlm.pred, print.SFResult, print.spautolm, print.stsls,
## print.summary.gmsar, print.summary.sarlm, print.summary.spautolm,
## print.summary.stsls, residuals.gmsar, residuals.sarlm,
## residuals.spautolm, residuals.stsls, sacsarlm, SE_classic_setup,
## SE_interp_setup, SE_whichMin_setup, set.ClusterOption,
## set.coresOption, set.mcOption, set.VerboseOption,
## set.ZeroPolicyOption, similar.listw, spam_setup, spam_update_setup,
## SpatialFiltering, spautolm, spBreg_err, spBreg_lag, spBreg_sac,
## stsls, subgraph_eigenw, summary.gmsar, summary.sarlm,
## summary.spautolm, summary.stsls, trW, vcov.sarlm, Wald1.sarlm
library(readxl)
library(sp)
library(tmap)
## Warning: package 'tmap' was built under R version 4.0.5
library(tmaptools)
## Warning: package 'tmaptools' was built under R version 4.0.5
mc<-read_excel("E:\\data baru pro.xlsx",col_names =T, sheet="JK_T")
dataX <- readOGR(dsn="D:/SumbagselPeta", layer="sumbagsel")
## OGR data source with driver: ESRI Shapefile
## Source: "D:\SumbagselPeta", layer: "sumbagsel"
## with 49 features
## It has 10 fields
## Integer64 fields read as strings: TIPADM
## Warning in readOGR(dsn = "D:/SumbagselPeta", layer = "sumbagsel"): Z-dimension
## discarded
membuat jarak menggunakan >>> jarak Euclidean
jarak_EUC <- dist(coordinates(dataX), method="euclidean")
membuat peta untuk peubah respon Y
k=16
colfunc <-colorRampPalette(c("green","yellow","red"))
color<-colfunc(k)
library(sp)
dataX$WADMKK<-mc$KAB
plot(dataX)
text(dataX,"WADMKK",cex=0.45, col="steelblue")

##Untuk Tahun 2015
dataX$pad2<-mc$`2015`
spplot(dataX, "pad2",col.regions=color)

##Untuk Tahun 2016
dataX$pad2<-mc$`2016`
spplot(dataX, "pad2",col.regions=color)

##Untuk Tahun 2017
dataX$pad2<-mc$`2017`
spplot(dataX, "pad2",col.regions=color)

##Untuk Tahun 2018
dataX$pad2<-mc$`2018`
spplot(dataX, "pad2",col.regions=color)

##Untuk Tahun 2019
dataX$pad2<-mc$`2019`
spplot(dataX, "pad2",col.regions=color)

membuat matriks bobot
w<- as.matrix(1/jarak_EUC)
MORAN InDEX
Untuk Tahun 2015
ww<-mat2listw(w)
moran(mc$`2015`,ww,n=length(ww$neighbours),S0=Szero(ww))
## $I
## [1] 0.06635045
##
## $K
## [1] 5.854993
moran.test(mc$`2015`, ww, randomisation=T, alternative="two.sided")
##
## Moran I test under randomisation
##
## data: mc$`2015`
## weights: ww
##
## Moran I statistic standard deviate = 3.5867, p-value = 0.0003349
## alternative hypothesis: two.sided
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0663504504 -0.0208333333 0.0005908588
a<-moran.plot(mc$`2015`, ww, labels=F,main="Moran Scatterplot JTK 2015",pch=19)
text(a,mc$KAB,cex=0.65, col="red")

Untuk Tahun 2016
moran(mc$`2016`,ww,n=length(ww$neighbours),S0=Szero(ww))
## $I
## [1] 0.07149682
##
## $K
## [1] 5.823776
moran.test(mc$`2016`, ww, randomisation=T, alternative="two.sided")
##
## Moran I test under randomisation
##
## data: mc$`2016`
## weights: ww
##
## Moran I statistic standard deviate = 3.7972, p-value = 0.0001464
## alternative hypothesis: two.sided
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0714968187 -0.0208333333 0.0005912487
a<-moran.plot(mc$`2016`, ww, labels=F,main="Moran Scatterplot JTK 2016",pch=19)
text(a,mc$KAB,cex=0.63, col="red")

Untuk Tahun 2017
moran(mc$`2017`,ww,n=length(ww$neighbours),S0=Szero(ww))
## $I
## [1] 0.0738392
##
## $K
## [1] 5.540035
moran.test(mc$`2017`, ww, randomisation=T, alternative="two.sided")
##
## Moran I test under randomisation
##
## data: mc$`2017`
## weights: ww
##
## Moran I statistic standard deviate = 3.8819, p-value = 0.0001037
## alternative hypothesis: two.sided
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0738391960 -0.0208333333 0.0005947924
a<-moran.plot(mc$`2017`, ww, labels=F,main="Moran Scatterplot JTK 2017",pch=19)
text(a,mc$KAB,cex=0.63, col="red")

Untuk Tahun 2018
moran(mc$`2018`,ww,n=length(ww$neighbours),S0=Szero(ww))
## $I
## [1] 0.07689343
##
## $K
## [1] 5.253535
moran.test(mc$`2018`, ww, randomisation=T, alternative="two.sided")
##
## Moran I test under randomisation
##
## data: mc$`2018`
## weights: ww
##
## Moran I statistic standard deviate = 3.9951, p-value = 6.467e-05
## alternative hypothesis: two.sided
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0768934278 -0.0208333333 0.0005983706
a<-moran.plot(mc$`2018`, ww, labels=F ,main="Moran Scatterplot JTK 2018",pch=19)
text(a,mc$KAB,cex=0.63, col="red")

Untuk Tahun 2019
moran(mc$`2019`,ww,n=length(ww$neighbours),S0=Szero(ww))
## $I
## [1] 0.07807268
##
## $K
## [1] 5.451896
moran.test(mc$`2019`, ww, randomisation=T, alternative="two.sided")
##
## Moran I test under randomisation
##
## data: mc$`2019`
## weights: ww
##
## Moran I statistic standard deviate = 4.0517, p-value = 5.084e-05
## alternative hypothesis: two.sided
## sample estimates:
## Moran I statistic Expectation Variance
## 0.0780726775 -0.0208333333 0.0005958932
a<-moran.plot(mc$`2019`, ww, labels=F ,main="Moran Scatterplot JTK 2019",pch=19)
text(a,mc$KAB,cex=0.65, col="red")

LISA
untuk tahun 2015
localmoran(mc$`2015`, ww)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 0 -0.44546598 -0.8110239 12.719912 0.10249770 4.591808e-01
## 1 -1.51640255 -0.8047693 13.329646 -0.19491574 5.772705e-01
## 2 6.99542293 -0.5653731 6.229656 3.02925251 1.225798e-03
## 3 -3.89447652 -0.5451819 6.837512 -1.28086782 8.998800e-01
## 4 3.92516921 -0.8542038 43.114408 0.72787987 2.333436e-01
## 5 -0.60499452 -0.7371863 12.170525 0.03789221 4.848868e-01
## 6 13.84176765 -0.8178755 25.241455 2.91787181 1.762146e-03
## 7 1.59859629 -0.7291991 35.680852 0.38969712 3.483803e-01
## 8 2.44736926 -0.7111448 10.893112 0.95698873 1.692865e-01
## 9 4.29962767 -0.8042002 31.511486 0.90920450 1.816211e-01
## 10 -0.48582090 -0.6621015 9.377471 0.05756541 4.770474e-01
## 11 0.82375447 -0.8228265 15.847249 0.41362442 3.395746e-01
## 12 4.02545229 -0.5979187 4.972002 2.07344779 1.906531e-02
## 13 0.77352485 -0.4958173 15.541840 0.32197895 3.737343e-01
## 14 1.67384201 -0.5220053 7.573475 0.79791113 2.124610e-01
## 15 5.14024439 -0.7475720 20.086791 1.31370839 9.447218e-02
## 16 1.15599607 -0.3276701 8.719468 0.50244810 3.076762e-01
## 17 4.56365623 -0.8288482 18.477801 1.25448470 1.048329e-01
## 18 -19.41741903 -0.8479986 35.402916 -3.12089265 9.990985e-01
## 19 1.65010747 -0.3735221 2.846070 1.19952207 1.151625e-01
## 20 8.25454494 -0.8064937 45.817494 1.33863543 9.034469e-02
## 21 4.03353669 -0.8411229 24.710077 0.98063466 1.633865e-01
## 22 1.33531858 -0.3511512 8.868348 0.56631388 2.855902e-01
## 23 1.25266643 -0.5187336 18.235929 0.41481332 3.391393e-01
## 24 2.71599338 -0.7512846 22.007132 0.73910635 2.299212e-01
## 25 -4.12632212 -0.7931277 15.832161 -0.83770394 7.989015e-01
## 26 0.28376524 -0.5375654 3.900416 0.41587478 3.387508e-01
## 27 -0.57790928 -0.4643666 6.784100 -0.04359264 5.173854e-01
## 28 0.01355357 -0.7636514 10.969112 0.23466583 4.072341e-01
## 29 3.95330657 -0.8205539 21.020078 1.04124412 1.488811e-01
## 30 -0.64529281 -0.8718293 59.800648 0.02929444 4.883149e-01
## 31 -0.97244459 -0.8544991 39.473028 -0.01877289 5.074889e-01
## 32 17.44159914 -0.8720046 59.457662 2.37503438 8.773658e-03
## 33 2.65924341 -0.7929540 11.605304 1.01336841 1.554421e-01
## 34 1.10083768 -0.7352655 11.721011 0.53630836 2.958727e-01
## 35 3.58282836 -0.6550171 9.476894 1.37661380 8.431584e-02
## 36 8.60201024 -0.8779357 46.308867 1.39307271 8.179890e-02
## 37 4.75042183 -0.7352874 16.146093 1.36520875 8.609372e-02
## 38 -0.08919091 -0.6909903 12.857392 0.16783220 4.333576e-01
## 39 0.21828101 -0.4900322 9.180074 0.23377726 4.075790e-01
## 40 1.14118409 -0.5177346 14.867297 0.43023833 3.335111e-01
## 41 2.28726741 -0.5691754 7.868146 1.01833187 1.542601e-01
## 42 -3.34971809 -0.7859468 15.846440 -0.64404087 7.402255e-01
## 43 17.40078366 -0.6902395 25.148207 3.60752720 1.545646e-04
## 44 -5.05906172 -0.6878060 10.820960 -1.32884195 9.080499e-01
## 45 18.55260793 -0.6864301 18.727748 4.44570433 4.380218e-06
## 46 -0.57435351 -0.8212124 17.841731 0.05844270 4.766980e-01
## 47 -2.05150621 -0.7276531 11.860357 -0.38440666 6.496615e-01
## 48 -0.22672831 -0.7378928 18.037535 0.12035720 4.521001e-01
## attr(,"call")
## localmoran(x = mc$`2015`, listw = ww)
## attr(,"class")
## [1] "localmoran" "matrix" "array"
untuk tahun 2016
localmoran(mc$`2016`, ww)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 0 -0.356712902 -0.8110239 12.706434 0.12745045 4.492919e-01
## 1 -1.306153350 -0.8047693 13.316973 -0.13739400 5.546403e-01
## 2 6.934080281 -0.5653731 6.223143 3.00624746 1.322468e-03
## 3 -3.864892673 -0.5451819 6.832229 -1.27004481 8.979657e-01
## 4 3.975601438 -0.8542038 43.120942 0.73550478 2.310161e-01
## 5 -0.447624972 -0.7371863 12.160621 0.08303529 4.669117e-01
## 6 14.188053462 -0.8178755 25.236864 2.98706858 1.408333e-03
## 7 1.756184402 -0.7291991 35.688770 0.41603285 3.386930e-01
## 8 2.518710874 -0.7111448 10.883575 0.97903300 1.637818e-01
## 9 4.337341075 -0.8042002 31.512312 0.91591083 1.798568e-01
## 10 -0.448246407 -0.6621015 9.369155 0.06986656 4.721499e-01
## 11 0.702239453 -0.8228265 15.835417 0.38324270 3.507699e-01
## 12 4.213344255 -0.5979187 4.963239 2.15961590 1.540121e-02
## 13 0.730549488 -0.4958173 15.544793 0.31104834 3.778819e-01
## 14 2.190524105 -0.5220053 7.569599 0.98591169 1.620882e-01
## 15 5.040859166 -0.7475720 20.082214 1.29168043 9.823392e-02
## 16 1.150997559 -0.3276701 8.722188 0.50067723 3.082992e-01
## 17 4.081237174 -0.8288482 18.467571 1.14257351 1.266079e-01
## 18 -19.700871082 -0.8479986 35.404105 -3.16847817 9.992338e-01
## 19 1.728215467 -0.3735221 2.843321 1.24642329 1.063045e-01
## 20 8.400334125 -0.8064937 45.828787 1.36000604 8.691401e-02
## 21 4.064457279 -0.8411229 24.703750 0.98698131 1.618259e-01
## 22 1.347031683 -0.3511512 8.870624 0.57017396 2.842799e-01
## 23 1.242760566 -0.5187336 18.240068 0.41244683 3.400060e-01
## 24 2.159018248 -0.7512846 22.003783 0.62042530 2.674889e-01
## 25 -3.768762378 -0.7931277 15.821988 -0.74808179 7.727946e-01
## 26 0.242708380 -0.5375654 3.893245 0.39544964 3.462555e-01
## 27 -0.588065953 -0.4643666 6.781619 -0.04750080 5.189430e-01
## 28 -0.004168323 -0.7636514 10.956935 0.22944235 4.092626e-01
## 29 4.224111355 -0.8205539 21.012208 1.10051638 1.355536e-01
## 30 0.549775951 -0.8718293 59.818482 0.18380669 4.270826e-01
## 31 -1.538728572 -0.8544991 39.476847 -0.10890067 5.433594e-01
## 32 18.851239786 -0.8720046 59.475231 2.55746848 5.271856e-03
## 33 2.730419339 -0.7929540 11.592011 1.03485447 1.503684e-01
## 34 1.589710566 -0.7352655 11.710872 0.67939740 2.484430e-01
## 35 3.941108130 -0.6550171 9.468977 1.49362074 6.763739e-02
## 36 8.687644045 -0.8779357 46.316335 1.40554322 7.992990e-02
## 37 4.861913002 -0.7352874 16.139231 1.39325126 8.177191e-02
## 38 0.348803298 -0.6909903 12.850294 0.29006184 3.858845e-01
## 39 0.180964013 -0.4900322 9.178514 0.22147968 4.123595e-01
## 40 1.204086403 -0.5177346 14.868978 0.44652672 3.276084e-01
## 41 2.299085990 -0.5691754 7.862696 1.02289957 1.531777e-01
## 42 -3.158540259 -0.7859468 15.836673 -0.59619916 7.244789e-01
## 43 19.611255048 -0.6902395 25.150249 4.04815255 2.581175e-05
## 44 -4.847732200 -0.6878060 10.812505 -1.26509302 8.970810e-01
## 45 19.008745451 -0.6864301 18.725216 4.55141499 2.664316e-06
## 46 -0.487665360 -0.8212124 17.831468 0.07898843 4.685209e-01
## 47 -2.112274395 -0.7276531 11.850709 -0.40221552 6.562373e-01
## 48 0.406811902 -0.7378928 18.031941 0.26957042 3.937454e-01
## attr(,"call")
## localmoran(x = mc$`2016`, listw = ww)
## attr(,"class")
## [1] "localmoran" "matrix" "array"
untuk tahun 2017
localmoran(mc$`2017`, ww)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 0 -0.418479637 -0.8110239 12.583938 0.11065736 4.559440e-01
## 1 -1.649623981 -0.8047693 13.201779 -0.23252293 5.919341e-01
## 2 6.604551425 -0.5653731 6.163939 2.88792176 1.938982e-03
## 3 -4.049383959 -0.5451819 6.784213 -1.34536279 9.107459e-01
## 4 4.248982102 -0.8542038 43.180324 0.77660189 2.186968e-01
## 5 -0.412800730 -0.7371863 12.070598 0.09336781 4.628057e-01
## 6 14.657961396 -0.8178755 25.195137 3.08315799 1.024082e-03
## 7 2.101526993 -0.7291991 35.760737 0.47336334 3.179770e-01
## 8 2.658410004 -0.7111448 10.796887 1.02547069 1.525706e-01
## 9 4.002143431 -0.8042002 31.519817 0.85609699 1.959721e-01
## 10 -0.467214321 -0.6621015 9.293574 0.06392811 4.745137e-01
## 11 0.675399198 -0.8228265 15.727873 0.37778287 3.527960e-01
## 12 4.274189868 -0.5979187 4.883588 2.20468968 1.373794e-02
## 13 0.753642910 -0.4958173 15.571640 0.31663232 3.757613e-01
## 14 2.370291754 -0.5220053 7.534364 1.05370633 1.460087e-01
## 15 5.194898070 -0.7475720 20.040608 1.32742977 9.218328e-02
## 16 1.130974578 -0.3276701 8.746918 0.49319876 3.109361e-01
## 17 4.068845848 -0.8288482 18.374591 1.14256999 1.266086e-01
## 18 -19.833928551 -0.8479986 35.414912 -3.19035339 9.992895e-01
## 19 1.769537893 -0.3735221 2.818334 1.27655071 1.008805e-01
## 20 8.566173916 -0.8064937 45.931439 1.38295544 8.333926e-02
## 21 4.128372938 -0.8411229 24.646242 1.00100667 1.584118e-01
## 22 1.329529429 -0.3511512 8.891313 0.56364059 2.864994e-01
## 23 1.274536004 -0.5187336 18.277696 0.41945449 3.374420e-01
## 24 2.414816007 -0.7512846 21.973345 0.67542420 2.497031e-01
## 25 -3.827154084 -0.7931277 15.729529 -0.76500011 7.778643e-01
## 26 0.225778123 -0.5375654 3.828064 0.39014895 3.482132e-01
## 27 -0.527309624 -0.4643666 6.759059 -0.02421055 5.096577e-01
## 28 0.008246624 -0.7636514 10.846255 0.23437973 4.073451e-01
## 29 4.388175878 -0.8205539 20.940672 1.13824702 1.275087e-01
## 30 1.213281273 -0.8718293 59.980578 0.26923019 3.938763e-01
## 31 -1.577930043 -0.8544991 39.511553 -0.11508932 5.458128e-01
## 32 20.179682257 -0.8720046 59.634920 2.72606734 3.204696e-03
## 33 2.553735204 -0.7929540 11.471181 0.98812370 1.615460e-01
## 34 1.580543828 -0.7352655 11.618718 0.67939713 2.484431e-01
## 35 3.909576292 -0.6550171 9.397017 1.48904249 6.823809e-02
## 36 8.868166277 -0.8779357 46.384217 1.43102045 7.621218e-02
## 37 5.000124562 -0.7352874 16.076859 1.43042149 7.629804e-02
## 38 0.569448049 -0.6909903 12.785772 0.35249919 3.622320e-01
## 39 0.168240255 -0.4900322 9.164334 0.21744790 4.139297e-01
## 40 1.247971299 -0.5177346 14.884254 0.45767253 3.235939e-01
## 41 2.228573242 -0.5691754 7.813158 1.00091085 1.584350e-01
## 42 -3.338784558 -0.7859468 15.747898 -0.64329759 7.399845e-01
## 43 20.801315676 -0.6902395 25.168803 4.28387274 9.183400e-06
## 44 -4.958461148 -0.6878060 10.735663 -1.30340708 9.037821e-01
## 45 19.308755856 -0.6864301 18.702204 4.62358714 1.885801e-06
## 46 -0.345599462 -0.8212124 17.738192 0.11292730 4.550441e-01
## 47 -2.044884413 -0.7276531 11.763017 -0.38406317 6.495342e-01
## 48 -0.326484439 -0.7378928 17.981088 0.09702087 4.613549e-01
## attr(,"call")
## localmoran(x = mc$`2017`, listw = ww)
## attr(,"class")
## [1] "localmoran" "matrix" "array"
untuk tahun 2018
localmoran(mc$`2018`, ww)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 0 -0.48874539 -0.8110239 12.460251 0.09129940 4.636273e-01
## 1 -1.84823880 -0.8047693 13.085465 -0.28845972 6.135026e-01
## 2 5.98322838 -0.5653731 6.104159 2.65054772 4.018069e-03
## 3 -4.49375885 -0.5451819 6.735730 -1.52141704 9.359224e-01
## 4 4.45758107 -0.8542038 43.240283 0.80778580 2.096070e-01
## 5 -0.53687944 -0.7371863 11.979701 0.05787259 4.769251e-01
## 6 16.17829914 -0.8178755 25.153005 3.38888044 3.508930e-04
## 7 1.92459601 -0.7291991 35.833404 0.44332617 3.287649e-01
## 8 2.81347966 -0.7111448 10.709356 1.07703836 1.407316e-01
## 9 4.23385491 -0.8042002 31.527395 0.89726115 1.847898e-01
## 10 -0.61373169 -0.6621015 9.217258 0.01593211 4.936443e-01
## 11 0.98118376 -0.8228265 15.619284 0.45646602 3.240275e-01
## 12 3.95990313 -0.5979187 4.803162 2.07966660 1.877806e-02
## 13 0.82067144 -0.4958173 15.598748 0.33332837 3.694432e-01
## 14 1.83670298 -0.5220053 7.498787 0.86134815 1.945232e-01
## 15 5.62731463 -0.7475720 19.998598 1.42551794 7.700377e-02
## 16 1.08197977 -0.3276701 8.771888 0.47595370 3.170537e-01
## 17 4.91633351 -0.8288482 18.280706 1.34371537 8.952022e-02
## 18 -19.92748375 -0.8479986 35.425823 -3.20558041 9.993260e-01
## 19 1.76956212 -0.3735221 2.793105 1.28231760 9.986563e-02
## 20 8.61946273 -0.8064937 46.035089 1.38925169 8.237811e-02
## 21 4.25189909 -0.8411229 24.588175 1.02709922 1.521869e-01
## 22 1.26778101 -0.3511512 8.912202 0.54229570 2.938074e-01
## 23 1.32251441 -0.5187336 18.315690 0.43022995 3.335142e-01
## 24 3.78353588 -0.7512846 21.942612 0.96809045 1.664996e-01
## 25 -4.38643745 -0.7931277 15.636171 -0.90871867 8.182507e-01
## 26 0.10358424 -0.5375654 3.762250 0.33054882 3.704927e-01
## 27 -0.40045625 -0.4643666 6.736281 0.02462413 4.901774e-01
## 28 0.07431229 -0.7636514 10.734500 0.25576100 3.990677e-01
## 29 4.55846646 -0.8205539 20.868441 1.17749261 1.194995e-01
## 30 1.29935528 -0.8718293 60.144249 0.27996239 3.897532e-01
## 31 -0.76865367 -0.8544991 39.546598 0.01365094 4.945542e-01
## 32 22.08711651 -0.8720046 59.796163 2.96905746 1.493574e-03
## 33 2.37323601 -0.7929540 11.349177 0.93984187 1.736493e-01
## 34 0.71196276 -0.7352655 11.525668 0.42628887 3.349487e-01
## 35 2.91163975 -0.6550171 9.324358 1.16802423 1.213985e-01
## 36 9.10169426 -0.8779357 46.452758 1.46422794 7.156584e-02
## 37 5.17875427 -0.7352874 16.013880 1.47786954 6.972135e-02
## 38 0.54837686 -0.6909903 12.720623 0.34749277 3.641106e-01
## 39 0.19592642 -0.4900322 9.150017 0.22677072 4.103010e-01
## 40 1.24159486 -0.5177346 14.899678 0.45578365 3.242728e-01
## 41 2.40080447 -0.5691754 7.763138 1.06594511 1.432242e-01
## 42 -3.06987971 -0.7859468 15.658260 -0.57718043 7.180912e-01
## 43 21.21192245 -0.6902395 25.187538 4.36409429 6.382526e-06
## 44 -5.38212236 -0.6878060 10.658073 -1.43791431 9.247708e-01
## 45 20.23562277 -0.6864301 18.678969 4.84091932 6.461992e-07
## 46 -0.49873476 -0.8212124 17.644009 0.07677166 4.694026e-01
## 47 -1.66250888 -0.7276531 11.674473 -0.27360621 6.078064e-01
## 48 -0.29578196 -0.7378928 17.929741 0.10441050 4.584218e-01
## attr(,"call")
## localmoran(x = mc$`2018`, listw = ww)
## attr(,"class")
## [1] "localmoran" "matrix" "array"
untuk tahun 2019
localmoran(mc$`2019`, ww)
## Ii E.Ii Var.Ii Z.Ii Pr(z > 0)
## 0 -0.34072224 -0.8110239 12.545887 0.13277790 4.471845e-01
## 1 -1.77620080 -0.8047693 13.165996 -0.26772277 6.055436e-01
## 2 5.89983207 -0.5653731 6.145548 2.60796641 4.554095e-03
## 3 -4.19350560 -0.5451819 6.769297 -1.40223746 9.195778e-01
## 4 4.55038734 -0.8542038 43.198769 0.82229406 2.054548e-01
## 5 -0.54134425 -0.7371863 12.042635 0.05643458 4.774978e-01
## 6 16.36256719 -0.8178755 25.182176 3.42363712 3.089454e-04
## 7 1.49786232 -0.7291991 35.783092 0.37230020 3.548347e-01
## 8 2.90276247 -0.7111448 10.769959 1.10120959 1.354027e-01
## 9 4.13404355 -0.8042002 31.522148 0.87955827 1.895493e-01
## 10 -0.51541328 -0.6621015 9.270096 0.04817848 4.807870e-01
## 11 1.53449661 -0.8228265 15.694467 0.59503956 2.759085e-01
## 12 4.19569510 -0.5979187 4.858846 2.17468570 1.482684e-02
## 13 0.73246476 -0.4958173 15.579979 0.31118214 3.778311e-01
## 14 1.96805198 -0.5220053 7.523419 0.90782410 1.819856e-01
## 15 5.54651913 -0.7475720 20.027684 1.40642850 7.979846e-02
## 16 1.07974124 -0.3276701 8.754600 0.47566685 3.171559e-01
## 17 4.93261540 -0.8288482 18.345708 1.34513410 8.929097e-02
## 18 -19.27015568 -0.8479986 35.418269 -3.09547156 9.990175e-01
## 19 1.75135231 -0.3735221 2.810573 1.26746463 1.024946e-01
## 20 8.70465109 -0.8064937 45.963326 1.40290114 8.032316e-02
## 21 4.58554150 -0.8411229 24.628378 1.09349059 1.370892e-01
## 22 1.26032966 -0.3511512 8.897739 0.54023825 2.945164e-01
## 23 1.19912463 -0.5187336 18.289384 0.40168699 3.439572e-01
## 24 3.03542818 -0.7512846 21.963890 0.80799324 2.095472e-01
## 25 -4.34342012 -0.7931277 15.700808 -0.89598992 8.148709e-01
## 26 0.07200791 -0.5375654 3.807817 0.31238339 3.773746e-01
## 27 -0.50111898 -0.4643666 6.752052 -0.01414386 5.056424e-01
## 28 0.05850620 -0.7636514 10.811875 0.25003718 4.012793e-01
## 29 4.82620942 -0.8205539 20.918451 1.23462432 1.084852e-01
## 30 1.25654161 -0.8718293 60.030930 0.27470071 3.917731e-01
## 31 -0.51329806 -0.8544991 39.522334 0.05427365 4.783586e-01
## 32 21.99767571 -0.8720046 59.684525 2.96025568 1.536919e-03
## 33 2.34339733 -0.7929540 11.433648 0.92753927 1.768233e-01
## 34 0.80047020 -0.7352655 11.590092 0.45110024 3.259587e-01
## 35 2.57899387 -0.6550171 9.374665 1.05624248 1.454287e-01
## 36 9.18989950 -0.8779357 46.405303 1.47792466 6.971397e-02
## 37 5.33754874 -0.7352874 16.057484 1.51548911 6.482429e-02
## 38 0.47857367 -0.6909903 12.765730 0.32734156 3.717048e-01
## 39 0.14393424 -0.4900322 9.159930 0.20946921 4.170410e-01
## 40 1.11526486 -0.5177346 14.888999 0.42320745 3.360720e-01
## 41 2.40729677 -0.5691754 7.797770 1.06590039 1.432343e-01
## 42 -3.07933137 -0.7859468 15.720322 -0.57842383 7.185110e-01
## 43 20.77818619 -0.6902395 25.174567 4.27877249 9.396341e-06
## 44 -5.15479034 -0.6878060 10.711793 -1.36484504 9.138491e-01
## 45 20.53225079 -0.6864301 18.695056 4.90743994 4.613645e-07
## 46 -0.17686841 -0.8212124 17.709218 0.15311512 4.391537e-01
## 47 -1.70935517 -0.7276531 11.735777 -0.28656540 6.127774e-01
## 48 -0.05624429 -0.7378928 17.965292 0.16082122 4.361171e-01
## attr(,"call")
## localmoran(x = mc$`2019`, listw = ww)
## attr(,"class")
## [1] "localmoran" "matrix" "array"
PLOT Local Moran
s<-localmoran(mc$`2019`, ww)
moran.map <- cbind(dataX, s)
tm_shape(moran.map) +
tm_fill(col = "Ii",
style = "quantile",
title = "local moran statistic")
## Warning in sp::proj4string(obj): CRS object has comment, which is lost in output
## Variable(s) "Ii" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

PLOT LISA
s<-localmoran(mc$`2019`, ww)
moran.map <- cbind(dataX, s)
quadrant <- vector(mode="numeric",length=nrow(s))
quadrant
## [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [39] 0 0 0 0 0 0 0 0 0 0 0
m.qualification <- mc$`2019` - mean(mc$`2019`)
# centers the local Moran's around the mean
m.local <- s[,1] - mean(s[,1])
# significance threshold
signif <- 0.1
# builds a data quadrant
quadrant[m.qualification >0 & m.local>0] <- 4
quadrant[m.qualification <0 & m.local<0] <- 1
quadrant[m.qualification <0 & m.local>0] <- 2
quadrant[m.qualification >0 & m.local<0] <- 3
quadrant[s[,5]>signif] <- 0
# plot in r
brks <- c(0,1,2,3,4)
colors <- c("white","blue",rgb(0,0,1,alpha=0.4),rgb(1,0,0,alpha=0.4),"red")
plot(dataX,border="lightgray",main="Local Moran's",col=colors[findInterval(quadrant,brks,all.inside=FALSE)])
box()
legend("bottomleft", legend = c("insignificant","low-low","low-high","high-low","high-high"),
fill=colors,bty="n")
text(dataX,"WADMKK",cex=0.45, col="black")

#LINK>>>https://rpubs.com/quarcs-lab/spatial-autocorrelation