Setup
#devtools::install_github("amvallone/estdaR")
#install.packages("ggrepel")
suppressWarnings(suppressMessages({
library(estdaR)
library(sf)
library(spdep)
library(rgeos)
library(tidyverse)
library(ggrepel)
library(ExPanDaR)
library(plotly)
library (skimr)
}))
options(repr.plot.width = 6, repr.plot.height = 4)
Import data
sh <- st_read("datafinal.gpkg")
shdf = read_csv("eksplorfin1.csv")
skim(shdf)
glimpse(shdf)
LQ2010 <- sh$LQ2010/mean(sh$LQ2010)
LQ2021 <- sh$LQ2021/mean(sh$LQ2021)
growth2010 <- sh$growth2010/mean(sh$growth2010)
growth2021 <- sh$growth2021/mean(sh$growth2021)
ProvinceName <- sh$NAME
Weights matrix
Spatial lags
Wgrowth2010<- lag.listw(w, growth2010)
Wgrowth2021<- lag.listw(w, growth2021)
WLQ2010<- lag.listw(w, LQ2010)
WLQ2021<- lag.listw(w, LQ2021)
ProvinsiMaxP <- sh$MAXP
Directional LISA
dy <- growth2010 - growth2021
dW <- Wgrowth2010 - Wgrowth2021
NofRows <- nrow(sh)
y0 <- rep(0, NofRows)
W0 <- rep(0, NofRows)
df <- as.data.frame(cbind(growth2010, growth2021, dy, Wgrowth2010,Wgrowth2021, dW, y0, W0))
head(df)
Rose Diagram of Regional Growth
t0 <- growth2010
t1 <- growth2021
Region <- sh$Region
dl <- d.LISA(t0, t1, w, Region, k = 5, mean.rel = FALSE, nsim = 999, arrow = FALSE, only = NULL)
a<-dl$lisamap
b<-a$data
b<-as.data.frame(b)
dl_plot <-
ggplot(b, aes(x = x0, xend = x1, y = y0, yend = y1)) +
geom_segment(aes(color = Province), alpha=0.8, arrow = arrow(length = unit(0.1, "cm"))) +
labs(title = "Directional LISAs plot of Growth", color="Province", y="", x="") +
theme_set(theme_bw())+
theme(plot.title=element_text(hjust=0.5, lineheight=1.2),
axis.text.y = element_blank(),
axis.text.x = element_blank())
ggsave(dl_plot, file="Directional LISAs plot of Growth.png")
dl_plot
Rose Diagram of Industrial Agglomeration
t0 <- LQ2010
t1 <- LQ2021
Region <- sh$Region
dl1 <- d.LISA(t0, t1, w, Region, k = 5, mean.rel = FALSE, nsim = 999, arrow = FALSE, only = NULL)
a<-dl1$lisamap
b<-a$data
b<-as.data.frame(b)
dl1_plot <-
ggplot(b, aes(x = x0, xend = x1, y = y0, yend = y1)) +
geom_segment(aes(color = Province), alpha=0.8, arrow = arrow(length = unit(0.1, "cm"))) +
labs(title = "Directional LISAs plot of Industrial Agglomeration", color="Province", y="", x="") +
theme_set(theme_bw())+
theme(plot.title=element_text(hjust=0.5, lineheight=1.2),
axis.text.y = element_blank(),
axis.text.x = element_blank())
ggsave(dl1_plot, file="Directional LISAs plot of Industrial Agglomeration.png")
dl1_plot