Overview

Since 2013, Singapore has an active Open Data initiative. It aims to enhance transparency, public participation, and collaboration in the nation. The nation has big data ambitions and believes that the bountiful pool of available data should be used to gain new insight that will improve economic welfare. With the inception of The Smart Nation vision in 2017, Open Data is seen as a necessary component of this initiative, especially in the promotion of public-private collaborations (co-innovation). However, most of the effort to date tend to focus on hosting online open data portal by various government agency such as data.gov.sg, SLA OneMap, URA SPACE and LTA LTA DataMall , just to mention a few of them. There are very little work on how to integrate information shared by these agencies to gain better understanding on national development or public services issues.

Objectives

In view of this, we are going to conduct a use-case to demonstrate the potential contribution of geospatial analytics in R to integrate, analyse and communicate the analysis results by using open data provided by different government agencies. The specific objectives of the study are as follow:

Data Acquisition

Four data sets will be used in this study. They are:

  1. Passenger Volume by Bus Stops from LTA DataMall
  2. Singapore Residents by Planning AreaSubzone, Age Group, Sex and Type of Dwelling, June 2011-2019 from Singapore Department of Statistics
  3. Master Plan 2014 Subzone Boundary (Web) from data.gov.sg
  4. Bus Stop Location from LTA DataMall

Setting the Environment

packages = c('rgdal','sf', 'spdep', 'tmap', 'tidyverse')
for (p in packages){
  if(!require(p, character.only = T)){
    install.packages(p)
  }
  library(p,character.only = T)
}

Importing Data & Data Wrangling

Passenger Volume Data

passenger_vol <- read_csv('data/aspatial/passenger volume by busstop.csv')
## Parsed with column specification:
## cols(
##   YEAR_MONTH = col_character(),
##   DAY_TYPE = col_character(),
##   TIME_PER_HOUR = col_double(),
##   PT_TYPE = col_character(),
##   PT_CODE = col_character(),
##   TOTAL_TAP_IN_VOLUME = col_double(),
##   TOTAL_TAP_OUT_VOLUME = col_double()
## )
colnames(passenger_vol)[5] = 'BUS_STOP_N' #making the column name consistent with the Bus Stop Location data set 

passenger_vol <- passenger_vol %>%
  group_by(BUS_STOP_N = BUS_STOP_N) %>% # Group the in and out volume according to bus stop number 
  summarise(TOTAL_TAP_IN_VOLUME = sum(TOTAL_TAP_IN_VOLUME),
            TOTAL_TAP_OUT_VOLUME = sum(TOTAL_TAP_OUT_VOLUME))
list(passenger_vol)
## [[1]]
## # A tibble: 5,030 x 3
##    BUS_STOP_N TOTAL_TAP_IN_VOLUME TOTAL_TAP_OUT_VOLUME
##    <chr>                    <dbl>                <dbl>
##  1 01012                    35842                42043
##  2 01013                    24545                14435
##  3 01019                    18858                28741
##  4 01029                    37311                24811
##  5 01039                    64089                59856
##  6 01059                    14719                80673
##  7 01109                     5575                11148
##  8 01112                   213014               117028
##  9 01113                   149798                71915
## 10 01119                    70805                75543
## # ... with 5,020 more rows

Residential Population Data

respop <- read_csv('data/aspatial/respopagesextod2011to2019.csv') %>%
  filter (Time == '2019' ) %>% # Filter to get the population in 2019 only
  group_by(SZ = SZ) %>% # Group the population according to Subzone
  summarise(Pop = sum(Pop)) %>% 
  mutate(SZ = toupper(SZ)) # Convert the names to uppercase so it is consistent with the values in mpsz
## Parsed with column specification:
## cols(
##   PA = col_character(),
##   SZ = col_character(),
##   AG = col_character(),
##   Sex = col_character(),
##   TOD = col_character(),
##   Pop = col_double(),
##   Time = col_double()
## )
summary(respop)
##       SZ                 Pop        
##  Length:323         Min.   :     0  
##  Class :character   1st Qu.:     0  
##  Mode  :character   Median :  4890  
##                     Mean   : 12487  
##                     3rd Qu.: 17065  
##                     Max.   :132900
list(respop)
## [[1]]
## # A tibble: 323 x 2
##    SZ                       Pop
##    <chr>                  <dbl>
##  1 ADMIRALTY              14110
##  2 AIRPORT ROAD               0
##  3 ALEXANDRA HILL         13780
##  4 ALEXANDRA NORTH         2120
##  5 ALJUNIED               40190
##  6 ANAK BUKIT             22250
##  7 ANCHORVALE             46610
##  8 ANG MO KIO TOWN CENTRE  4890
##  9 ANSON                      0
## 10 BALESTIER              32760
## # ... with 313 more rows

Master Planning Subzone Layer

mpsz <- st_read(dsn = 'data/geospatial', layer = 'MP14_SUBZONE_WEB_PL')
## Reading layer `MP14_SUBZONE_WEB_PL' from data source `C:\IS415-Geospatial Analytics and Applications\Take Home Ex\IS415_Take-home_Ex01\data\geospatial' using driver `ESRI Shapefile'
## Simple feature collection with 323 features and 15 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
## proj4string:    +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=m +no_defs

Working with Projection

Checking the projection of Master Planning Subzone layer.

st_crs(mpsz)
## Coordinate Reference System:
##   No user input
##   wkt:
## PROJCS["SVY21",
##     GEOGCS["SVY21[WGS84]",
##         DATUM["WGS_1984",
##             SPHEROID["WGS_84",6378137.0,298.257223563]],
##         PRIMEM["Greenwich",0.0],
##         UNIT["Degree",0.0174532925199433],
##         AUTHORITY["EPSG","4326"]],
##     PROJECTION["Transverse_Mercator"],
##     PARAMETER["False_Easting",28001.642],
##     PARAMETER["False_Northing",38744.572],
##     PARAMETER["Central_Meridian",103.8333333333333],
##     PARAMETER["Scale_Factor",1.0],
##     PARAMETER["Latitude_Of_Origin",1.366666666666667],
##     UNIT["Meter",1.0]]

Assigning EPSG (for SVY21) 3414 to mpsz simple feature dataframe, without changing the measuring unit (Meter).

mpsz <- st_set_crs(mpsz, 3414)
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
## that
testing <- st_is_valid(mpsz)
plot(mpsz)
## Warning: plotting the first 9 out of 15 attributes; use max.plot = 15 to plot
## all

Bus Stop Location Layer

busstop <- st_read(dsn = 'data/geospatial', layer = 'BusStop')
## Reading layer `BusStop' from data source `C:\IS415-Geospatial Analytics and Applications\Take Home Ex\IS415_Take-home_Ex01\data\geospatial' using driver `ESRI Shapefile'
## Simple feature collection with 5040 features and 3 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 4427.938 ymin: 26482.1 xmax: 48282.5 ymax: 52983.82
## proj4string:    +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=m +no_defs

Working with Projection

Checking the projection of Bus Stop Location layer.

st_crs(busstop)
## Coordinate Reference System:
##   No user input
##   wkt:
## PROJCS["SVY21",
##     GEOGCS["GCS_WGS_1984",
##         DATUM["WGS_1984",
##             SPHEROID["WGS_84",6378137.0,298.257223563]],
##         PRIMEM["Greenwich",0.0],
##         UNIT["Degree",0.0174532925199433],
##         AUTHORITY["EPSG","4326"]],
##     PROJECTION["Transverse_Mercator"],
##     PARAMETER["False_Easting",28001.642],
##     PARAMETER["False_Northing",38744.572],
##     PARAMETER["Central_Meridian",103.8333333333333],
##     PARAMETER["Scale_Factor",1.0],
##     PARAMETER["Latitude_Of_Origin",1.366666666666667],
##     UNIT["Meter",1.0]]

Assigning EPSG (for SVY21) 3414 to busstop_location simple feature dataframe, without changing the measuring unit (Meter).

busstop <- st_set_crs(busstop, 3414)
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
## that

Plotting Proportional Symbol Map

A quick overview of the distribution of bus stops in Singapore:

tmap_mode('view')
## tmap mode set to interactive viewing
tm_shape(busstop) + 
  tm_bubbles(col = 'blue', size = 0.001, alpha = 0.5, border.col = "lightgrey", border.lwd = 0.01)

Joining the attribute data and geospatial data

busstop_passenger_vol <- left_join(busstop, passenger_vol) %>% #Renamed Column Name to "BUS_STOP_N" to match the Name in busstop data set, thus no need to specify the unique identifier.
  select(BUS_STOP_N, TOTAL_TAP_IN_VOLUME, TOTAL_TAP_OUT_VOLUME) #Only selected the relevant columns needed for analysis because "BUS_ROOF_N" and "LOC_DESC" is dependent on "BUS_STOP_N".
## Joining, by = "BUS_STOP_N"
## Warning: Column `BUS_STOP_N` joining factor and character vector, coercing into
## character vector
mpsz_respop <- left_join(mpsz, respop, by = c(SUBZONE_N = 'SZ')) %>%
  select(SUBZONE_N, Pop)
## Warning: Column `SUBZONE_N`/`SZ` joining factor and character vector, coercing
## into character vector

Converting data set into a simple feature data frame

busstop_passenger_vol <- st_as_sf(busstop_passenger_vol, 3414)
mpsz_respop <- st_as_sf(mpsz_respop, 3414)

Aggregating Bus Stop Location (with passenger volume) to Subzone Level (with population count)

combined_data <- st_join(mpsz_respop, busstop_passenger_vol) %>%
  drop_na()%>% # drop subzones with no bus stops because there will be no commuter flow 
  filter(TOTAL_TAP_IN_VOLUME != 0 | TOTAL_TAP_OUT_VOLUME !=0 |Pop != 0) %>% # drop subzones with no tap-in, tap-out and population because there will be no relation between commuter flow and residential population 
  group_by(SUBZONE_N = SUBZONE_N) %>%
  summarise(TOTAL_TAP_IN_VOLUME = sum(TOTAL_TAP_IN_VOLUME),
            TOTAL_TAP_OUT_VOLUME = sum(TOTAL_TAP_OUT_VOLUME),
            Pop = first(Pop))
    
summary(combined_data)
##   SUBZONE_N         TOTAL_TAP_IN_VOLUME TOTAL_TAP_OUT_VOLUME      Pop        
##  Length:305         Min.   :     70     Min.   :    154      Min.   :     0  
##  Class :character   1st Qu.:  91448     1st Qu.:  92241      1st Qu.:    70  
##  Mode  :character   Median : 227690     Median : 224722      Median :  6510  
##                     Mean   : 378572     Mean   : 377915      Mean   : 13207  
##                     3rd Qu.: 485104     3rd Qu.: 468349      3rd Qu.: 19460  
##                     Max.   :3754337     Max.   :3660297      Max.   :132900  
##           geometry  
##  MULTIPOLYGON :305  
##  epsg:3414    :  0  
##  +proj=tmer...:  0  
##                     
##                     
## 

Plotting Choropleth Maps

A quick overview of the population by planning subzone:

tm_shape(mpsz_respop) +
  tm_polygons(col = 'Pop',
              n = 8,
              style = 'equal',
              palette = 'Greens') +
  tm_layout(main.title = 'Distribution of Population by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)
## Warning: The shape mpsz_respop is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.

A quick overview of tap-in and tap-out volumes:

tapin_map <- tm_shape(combined_data) +
  tm_polygons(col = "TOTAL_TAP_IN_VOLUME",
          n = 8,
          style = "equal",
          palette = "Blues") +
  tm_layout(main.title = 'Distribution of Tap-in Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tapout_map <-tm_shape(combined_data) +
  tm_polygons(col = "TOTAL_TAP_OUT_VOLUME",
          n = 8,
          style = "equal",
          palette = "PuRd") +
  tm_layout(main.title = 'Distribution of Tap-out Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tmap_arrange(tapin_map, tapout_map, ncol = 2)
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.

Simple Linear Regression Model at the Subzone Level

Tap-in Volume and Residential Population

lm_tapin <- lm(TOTAL_TAP_IN_VOLUME ~ Pop, data = combined_data)
summary(lm_tapin)
## 
## Call:
## lm(formula = TOTAL_TAP_IN_VOLUME ~ Pop, data = combined_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -863762 -123199  -63290   34580 1950650 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.245e+05  2.107e+04   5.907 9.34e-09 ***
## Pop         1.924e+01  9.370e-01  20.535  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 297800 on 303 degrees of freedom
## Multiple R-squared:  0.5819, Adjusted R-squared:  0.5805 
## F-statistic: 421.7 on 1 and 303 DF,  p-value: < 2.2e-16
lm_tapin_plot <- ggplot(data = lm_tapin, aes(Pop, TOTAL_TAP_IN_VOLUME)) +
  geom_point(color = "blue") +
  geom_smooth(method = lm, color ="black") +
  geom_segment(aes(xend = Pop, yend = .fitted), color = "darkgrey", size =0.05)

lm_tapin_plot
## `geom_smooth()` using formula 'y ~ x'

Tap-out Volume and Residential Population

lm_tapout <- lm(TOTAL_TAP_OUT_VOLUME ~ Pop, data = combined_data)
summary(lm_tapout)
## 
## Call:
## lm(formula = TOTAL_TAP_OUT_VOLUME ~ Pop, data = combined_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -823156 -122534  -58009   31081 1644315 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.249e+05  2.040e+04   6.125 2.81e-09 ***
## Pop         1.916e+01  9.072e-01  21.114  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 288300 on 303 degrees of freedom
## Multiple R-squared:  0.5954, Adjusted R-squared:  0.594 
## F-statistic: 445.8 on 1 and 303 DF,  p-value: < 2.2e-16
lm_tapout_plot <- ggplot(data = lm_tapout, aes(Pop, TOTAL_TAP_OUT_VOLUME)) +
  geom_point(color = "magenta") +
  geom_segment(aes(xend = Pop, yend = .fitted), color = "darkgrey", size =0.05) +
  geom_smooth(method = lm, color ="black")

lm_tapout_plot
## `geom_smooth()` using formula 'y ~ x'

Assumption Checks for both Tap-in and Tap-out Model

Diagnostic Plot: Tap-in

par(mfrow=c(2, 3))

plot(lm_tapin, which=1:6)

Diagnostic Plot: Tap-in

par(mfrow=c(2, 3))

plot(lm_tapout, which=1:6)

Interpretations on the Linear Regression

  1. Linearity: Weak linear relationship between Tap-in/Tap-out Volume and Population.

  2. Homoscedasticity: Non-constant variance of error terms as the difference between min. residuals and max. residuals is very big for both.

  3. Independence: Observations are not independent of each other.

  4. Normality: For any fixed value of Population, Tap-in/Tap-out volume is not normally distributed.

Spatial autocorrelation analysis on the residuals

Retrieving the Residuals

tapin_residuals <- residuals(lm_tapin)

tapout_residuals <- residuals(lm_tapout)

Append Residuals to Combined_data

combined_data <- combined_data %>%
  add_column(Tap_in_residuals = tapin_residuals, Tap_out_residuals = tapout_residuals)

Mapping Residuals

tapin_res_map <- tm_shape(combined_data) +
  tm_polygons(col = "Tap_in_residuals",
          n = 8,
          style = "equal",
          palette = "RdBu") +
  tm_layout(main.title = 'Residuals of Tap-in Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tapout_res_map <-tm_shape(combined_data) +
  tm_polygons(col = "Tap_out_residuals",
          n = 8,
          style = "equal",
          palette = "-PiYG") +
  tm_layout(main.title = 'Residuals of Tap-out Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tmap_arrange(tapin_res_map, tapout_res_map, ncol = 2)
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_in_residuals" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_out_residuals" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

Using Residuals to test Spatial Autocorrelation

Modelling Spatial Neighbours by Creating contiguity spatial weightes

wm_q <- poly2nb(combined_data, queen=TRUE)
# Queen contiguity will be more suitable because bus will travel diagonally across common boundary too  
summary(wm_q)
## Neighbour list object:
## Number of regions: 305 
## Number of nonzero links: 1844 
## Percentage nonzero weights: 1.982263 
## Average number of links: 6.045902 
## Link number distribution:
## 
##  2  3  4  5  6  7  8  9 10 11 12 14 17 
##  6 11 27 79 76 50 36 13  2  2  1  1  1 
## 6 least connected regions:
## 2 41 132 170 228 275 with 2 links
## 1 most connected region:
## 39 with 17 links

A quick overview of the links:

plot(combined_data$geometry, border="lightgrey")
plot(wm_q, st_centroid(combined_data$geometry), pch= 19, cex = 0.6, add = TRUE, col= "blue")

Computing Fixed Distance Weight Matrix

Determine the cut-off distance

coords <- st_centroid(combined_data$geometry)
k1 <- knn2nb(knearneigh(coords))
k1dists <- unlist(nbdists(k1, coords, longlat = TRUE))
## Warning in nbdists(k1, coords, longlat = TRUE): dnearneigh: longlat argument
## overrides object
summary(k1dists)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   182.5   616.7   891.7   941.4  1169.9  5404.1

The max distance is 5404.1m, thus we will set the cut-off distance at 5410m.

wm_d5410 <- dnearneigh(coords, 0, 5410, longlat = TRUE)
## Warning in dnearneigh(coords, 0, 5410, longlat = TRUE): dnearneigh: longlat
## argument overrides object
wm_d5410
## Neighbour list object:
## Number of regions: 305 
## Number of nonzero links: 16652 
## Percentage nonzero weights: 17.90056 
## Average number of links: 54.59672
str(wm_d5410)
## List of 305
##  $ : int [1:24] 85 123 145 146 158 166 168 169 215 216 ...
##  $ : int [1:56] 5 7 14 15 18 20 21 23 25 44 ...
##  $ : int [1:86] 4 9 17 22 26 28 30 35 36 37 ...
##  $ : int [1:96] 3 9 10 12 17 22 26 28 30 35 ...
##  $ : int [1:72] 2 10 12 17 18 20 21 22 23 25 ...
##  $ : int [1:52] 11 29 31 32 33 34 39 54 55 56 ...
##  $ : int [1:38] 2 8 44 50 60 64 75 96 97 98 ...
##  $ : int [1:50] 7 10 20 21 25 27 39 44 50 60 ...
##  $ : int [1:77] 3 4 12 17 22 26 28 30 35 36 ...
##  $ : int [1:101] 4 5 8 12 17 18 20 21 22 23 ...
##  $ : int [1:31] 6 29 31 32 33 34 39 48 49 63 ...
##  $ : int [1:79] 4 5 9 10 17 18 22 23 26 28 ...
##  $ : int [1:16] 14 15 16 69 76 78 109 118 121 152 ...
##  $ : int [1:25] 2 13 15 16 64 69 76 78 81 109 ...
##  $ : int [1:36] 2 13 14 16 64 69 76 78 81 96 ...
##  $ : int [1:18] 13 14 15 69 76 78 81 109 118 121 ...
##  $ : int [1:99] 3 4 5 9 10 12 18 20 21 22 ...
##  $ : int [1:93] 2 5 10 12 17 20 21 22 23 25 ...
##  $ : int [1:23] 24 45 87 88 94 103 106 107 108 124 ...
##  $ : int [1:77] 2 5 8 10 17 18 21 23 25 27 ...
##  $ : int [1:73] 2 5 8 10 17 18 20 23 25 27 ...
##  $ : int [1:89] 3 4 5 9 10 12 17 18 23 25 ...
##  $ : int [1:94] 2 5 10 12 17 18 20 21 22 25 ...
##  $ : int [1:35] 19 29 31 32 33 34 45 86 94 95 ...
##  $ : int [1:87] 2 5 8 10 17 18 20 21 22 23 ...
##  $ : int [1:104] 3 4 9 10 12 17 18 22 23 25 ...
##  $ : int [1:83] 5 8 10 17 18 20 21 23 25 26 ...
##  $ : int [1:97] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:45] 6 11 24 31 32 33 34 45 48 49 ...
##  $ : int [1:97] 3 4 5 9 10 12 17 18 20 22 ...
##  $ : int [1:50] 6 11 24 29 32 33 34 45 48 49 ...
##  $ : int [1:49] 6 11 24 29 31 33 34 45 48 49 ...
##  $ : int [1:52] 6 11 24 29 31 32 34 45 48 54 ...
##  $ : int [1:50] 6 11 24 29 31 32 33 45 48 49 ...
##  $ : int [1:94] 3 4 9 10 12 17 18 22 26 28 ...
##  $ : int [1:88] 3 4 9 12 17 22 26 28 30 35 ...
##  $ : int [1:82] 3 4 9 10 12 17 18 22 23 26 ...
##  $ : int [1:76] 3 4 9 12 17 18 22 23 26 28 ...
##  $ : int [1:26] 6 8 11 63 72 79 83 90 91 102 ...
##  $ : int [1:8] 41 42 76 140 141 180 236 293
##  $ : int [1:10] 40 42 76 140 141 179 180 181 183 248
##  $ : int [1:14] 40 41 76 140 141 179 180 181 183 236 ...
##  $ : int [1:100] 3 4 9 10 12 17 18 22 25 26 ...
##  $ : int [1:55] 2 7 8 10 20 21 25 27 50 60 ...
##  $ : int [1:36] 19 24 29 31 32 33 34 71 86 88 ...
##  $ : int [1:86] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:82] 3 4 9 10 12 17 18 22 23 26 ...
##  $ : int [1:30] 11 29 31 32 33 34 49 63 72 79 ...
##  $ : int [1:29] 11 29 31 32 34 48 63 72 79 83 ...
##  $ : int [1:57] 2 7 8 10 18 20 21 25 27 44 ...
##  $ : int [1:96] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:71] 3 4 9 12 17 22 26 28 30 35 ...
##  $ : int [1:94] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:49] 6 29 31 32 33 34 55 56 57 59 ...
##  $ : int [1:51] 6 29 31 32 33 34 54 56 57 59 ...
##  $ : int [1:43] 6 31 32 33 54 55 57 59 61 67 ...
##  $ : int [1:45] 3 6 31 32 33 54 55 56 59 61 ...
##  $ : int [1:86] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:74] 3 4 6 26 35 36 43 53 54 55 ...
##  $ : int [1:44] 2 7 8 20 44 50 64 75 96 97 ...
##  $ : int [1:64] 3 4 6 26 33 35 36 43 54 55 ...
##  $ : int [1:95] 4 5 9 10 12 17 18 20 22 23 ...
##  $ : int [1:34] 6 11 29 31 32 33 34 39 48 49 ...
##  $ : int [1:57] 2 5 7 14 15 18 20 21 23 25 ...
##  $ : int [1:79] 3 4 9 17 22 26 28 35 36 37 ...
##  $ : int [1:100] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:51] 3 4 6 33 36 43 54 55 56 57 ...
##  $ : int [1:88] 3 4 10 17 18 21 22 25 26 27 ...
##  $ : int [1:27] 5 13 14 15 16 23 62 78 80 81 ...
##  $ : int [1:82] 3 4 9 12 17 22 26 28 30 35 ...
##  $ : int [1:48] 6 29 31 32 33 34 45 54 55 56 ...
##  $ : int [1:29] 6 11 29 31 32 33 34 39 48 49 ...
##  $ : int [1:77] 3 4 6 10 17 26 35 36 43 53 ...
##  $ : int [1:102] 3 4 5 9 10 12 17 18 20 21 ...
##  $ : int [1:43] 2 7 8 44 50 60 64 96 97 98 ...
##  $ : int [1:21] 13 14 15 16 40 41 42 140 141 179 ...
##  $ : int [1:99] 3 4 5 9 10 12 17 18 22 23 ...
##  $ : int [1:27] 2 5 13 14 15 16 23 64 69 81 ...
##  $ : int [1:27] 11 39 48 49 63 72 83 86 91 95 ...
##  $ : int [1:90] 2 5 10 12 17 18 20 21 22 23 ...
##  $ : int [1:51] 2 5 10 14 15 16 18 20 23 30 ...
##  $ : int [1:61] 3 4 6 26 32 33 35 36 43 54 ...
##  $ : int [1:37] 6 11 29 31 32 33 34 39 48 49 ...
##  $ : int [1:105] 3 4 9 10 12 17 18 21 22 23 ...
##  $ : int [1:22] 1 127 145 146 147 158 168 203 215 216 ...
##  $ : int [1:47] 6 11 24 29 31 32 33 34 45 48 ...
##  $ : int [1:17] 19 88 103 106 108 124 134 194 208 209 ...
##  $ : int [1:18] 19 45 87 103 108 124 134 194 208 209 ...
##  $ : int [1:93] 3 4 9 10 12 17 22 26 28 30 ...
##  $ : int [1:59] 3 4 6 10 21 25 26 27 35 39 ...
##  $ : int [1:46] 6 11 29 31 32 33 34 39 48 49 ...
##  $ : int [1:66] 3 4 6 26 35 36 43 54 55 56 ...
##  $ : int [1:49] 3 6 31 32 33 34 54 55 56 57 ...
##  $ : int [1:40] 19 24 29 31 32 33 34 45 48 71 ...
##  $ : int [1:42] 6 11 24 29 31 32 33 34 45 48 ...
##  $ : int [1:53] 2 7 8 15 20 21 44 50 60 64 ...
##  $ : int [1:47] 2 7 15 20 44 50 60 64 75 96 ...
##  $ : int [1:58] 2 7 8 20 21 44 50 60 64 75 ...
##  $ : int [1:101] 3 4 9 10 12 17 18 22 23 25 ...
##   [list output truncated]
##  - attr(*, "class")= chr "nb"
##  - attr(*, "nbtype")= chr "distance"
##  - attr(*, "distances")= num [1:2] 0 5410
##  - attr(*, "region.id")= chr [1:305] "1" "2" "3" "4" ...
##  - attr(*, "call")= language dnearneigh(x = coords, d1 = 0, d2 = 5410, longlat = TRUE)
##  - attr(*, "dnn")= num [1:2] 0 5410
##  - attr(*, "bounds")= chr [1:2] "GT" "LE"
##  - attr(*, "sym")= logi TRUE
par(mfrow=c(1,2))
plot(combined_data$geometry, border="lightgrey", main="1st nearest neighbours")
plot(k1, coords, add=TRUE, col="blue", length=0.08)

plot(combined_data$geometry, border="lightgrey", main="Distance link")
plot(wm_d5410, coords, add=TRUE, pch = 19, cex = 0.6)

The blue lines show the links of 1st nearest neighbour of the polygons and the black lines show the links of neighbours within the cut-off distance of 5410m. For Singapore, Fixed Distance Weight Matrix may not be the best because the difference between the min (182.5m) and the max value (5404.1m) is large. As a result, some polygons will have a lot of links and some only a few. For example, 26th polygon has 104 neighbours but 132th polygon only has 6.

Computing adaptive distance weight matrix

wm_knn5 <- knn2nb(knearneigh(coords, k=5)) # setting numbers of neighbours as 5
wm_knn5
## Neighbour list object:
## Number of regions: 305 
## Number of nonzero links: 1525 
## Percentage nonzero weights: 1.639344 
## Average number of links: 5 
## Non-symmetric neighbours list
str(wm_knn5)
## List of 305
##  $ : int [1:5] 215 216 218 219 262
##  $ : int [1:5] 64 117 136 195 246
##  $ : int [1:5] 36 65 148 157 202
##  $ : int [1:5] 36 43 89 202 264
##  $ : int [1:5] 23 111 112 143 162
##  $ : int [1:5] 33 93 165 243 268
##  $ : int [1:5] 60 75 155 221 270
##  $ : int [1:5] 44 120 233 269 298
##  $ : int [1:5] 37 47 70 156 253
##  $ : int [1:5] 18 25 125 160 265
##  $ : int [1:5] 63 72 102 210 223
##  $ : int [1:5] 38 58 149 151 201
##  $ : int [1:5] 14 16 235 236 293
##  $ : int [1:5] 13 15 16 236 250
##  $ : int [1:5] 14 109 121 185 250
##  $ : int [1:5] 13 14 78 235 236
##  $ : int [1:5] 30 133 142 211 282
##  $ : int [1:5] 10 80 110 125 197
##  $ : int [1:5] 88 103 124 208 234
##  $ : int [1:5] 104 224 229 280 292
##  $ : int [1:5] 27 135 137 154 189
##  $ : int [1:5] 46 53 58 193 201
##  $ : int [1:5] 5 80 110 111 112
##  $ : int [1:5] 45 94 108 247 284
##  $ : int [1:5] 27 125 135 189 265
##  $ : int [1:5] 131 172 173 184 251
##  $ : int [1:5] 25 135 189 265 266
##  $ : int [1:5] 51 66 77 211 282
##  $ : int [1:5] 31 34 86 95 304
##  $ : int [1:5] 17 113 207 242 282
##  $ : int [1:5] 29 32 33 34 86
##  $ : int [1:5] 31 33 34 86 91
##  $ : int [1:5] 6 31 32 267 268
##  $ : int [1:5] 29 31 267 303 304
##  $ : int [1:5] 89 99 206 263 264
##  $ : int [1:5] 89 115 202 259 264
##  $ : int [1:5] 38 47 156 201 253
##  $ : int [1:5] 37 156 201 241 253
##  $ : int [1:5] 11 63 72 217 245
##  $ : int [1:5] 42 76 140 141 293
##  $ : int [1:5] 42 140 141 180 181
##  $ : int [1:5] 41 76 140 141 180
##  $ : int [1:5] 4 89 172 184 251
##  $ : int [1:5] 8 50 232 269 296
##  $ : int [1:5] 24 108 124 247 276
##  $ : int [1:5] 22 47 156 193 201
##  $ : int [1:5] 37 46 156 192 253
##  $ : int [1:5] 49 119 190 223 256
##  $ : int [1:5] 48 190 223 256 294
##  $ : int [1:5] 8 44 230 232 269
##  $ : int [1:5] 22 28 58 149 282
##  $ : int [1:5] 9 70 237 253 258
##  $ : int [1:5] 22 46 77 188 193
##  $ : int [1:5] 55 56 57 175 285
##  $ : int [1:5] 54 71 238 243 285
##  $ : int [1:5] 54 57 164 175 285
##  $ : int [1:5] 54 56 67 164 238
##  $ : int [1:5] 12 22 51 193 201
##  $ : int [1:5] 92 148 171 204 252
##  $ : int [1:5] 7 97 98 221 270
##  $ : int [1:5] 73 90 130 244 278
##  $ : int [1:5] 30 113 149 207 242
##  $ : int [1:5] 11 83 91 102 165
##  $ : int [1:5] 2 117 136 195 246
##  $ : int [1:5] 3 36 200 202 257
##  $ : int [1:5] 28 77 101 174 211
##  $ : int [1:5] 57 82 164 238 279
##  $ : int [1:5] 90 144 161 163 278
##  $ : int [1:5] 78 118 152 162 235
##  $ : int [1:5] 9 47 115 192 237
##  $ : int [1:5] 54 55 100 268 285
##  $ : int [1:5] 11 63 102 210 223
##  $ : int [1:5] 59 61 92 130 278
##  $ : int [1:5] 17 114 133 142 242
##  $ : int [1:5] 7 212 214 222 270
##  $ : int [1:5] 42 140 141 180 248
##  $ : int [1:5] 22 28 53 66 174
##  $ : int [1:5] 69 118 121 152 235
##  $ : int [1:5] 49 72 210 223 294
##  $ : int [1:5] 18 23 110 111 224
##  $ : int [1:5] 5 116 118 143 162
##  $ : int [1:5] 67 92 130 238 279
##  $ : int [1:5] 86 95 102 119 256
##  $ : int [1:5] 26 159 160 167 173
##  $ : int [1:5] 158 168 227 289 291
##  $ : int [1:5] 29 31 32 91 95
##  $ : int [1:5] 19 88 103 194 234
##  $ : int [1:5] 19 87 103 194 272
##  $ : int [1:5] 4 35 36 202 264
##  $ : int [1:5] 61 68 73 244 278
##  $ : int [1:5] 32 63 83 86 165
##  $ : int [1:5] 59 82 130 171 252
##  $ : int [1:5] 6 82 243 244 279
##  $ : int [1:5] 24 247 260 284 304
##  $ : int [1:5] 29 31 83 86 119
##  $ : int [1:5] 97 98 117 126 138
##  $ : int [1:5] 60 96 98 117 138
##  $ : int [1:5] 60 96 97 126 270
##  $ : int [1:5] 35 131 174 206 239
##   [list output truncated]
##  - attr(*, "region.id")= chr [1:305] "1" "2" "3" "4" ...
##  - attr(*, "call")= language knearneigh(x = coords, k = 5)
##  - attr(*, "sym")= logi FALSE
##  - attr(*, "type")= chr "knn"
##  - attr(*, "knn-k")= num 5
##  - attr(*, "class")= chr "nb"
plot(combined_data$geometry, border="lightgrey")
plot(wm_knn5, coords, pch = 19, cex = 0.6, add = TRUE, col = "blue")

Therefore, Adaptive Distance Weight Matrix is more suitable and each subzone has exactly 5 neighbours.

Row-standardised weights matrix

rswm_q <- nb2listw(wm_q, style="W", zero.policy = TRUE)
rswm_q
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 305 
## Number of nonzero links: 1844 
## Percentage nonzero weights: 1.982263 
## Average number of links: 6.045902 
## 
## Weights style: W 
## Weights constants summary:
##     n    nn  S0      S1       S2
## W 305 93025 305 106.114 1253.543
rswm_q$weights[1]
## [[1]]
## [1] 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667

Computing Spatially Lagged Values

Which is the average neighbour tap-in/tap-out redusials for each polygon.

tapin.lag <- lag.listw(rswm_q, combined_data$Tap_in_residuals)

tapin.lag
##   [1] -114279.0919  -30691.6686  -48372.3127  -43730.5649   87093.8305
##   [6]  -79608.7331 -235279.2447    3322.1041  -26179.5632   98204.3346
##  [11]  -26960.6865  -43091.8335   -2873.2585  -22024.1626  144952.9655
##  [16]  244878.3723  108353.4839   58921.6063  -24302.7401 -100036.1451
##  [21]  -81707.1925   25269.1332  191146.9270  144804.6541  113781.8315
##  [26]  -24963.5695  172053.8027  130700.6368  -49655.7793   89422.4350
##  [31] -105266.9973  -15727.0265    4012.7122  -11653.1646    8303.5882
##  [36]   17138.4827  -32914.5055  -63444.4729  -88617.6529   26053.2068
##  [41]  353947.6872  191383.5948  -87720.8863   43611.8753  219219.7131
##  [46]    4241.3224  -14992.9263 -182847.8927   48089.7310  116595.8609
##  [51]   62754.6381     334.3686   15633.2863  -87644.0586  144913.2489
##  [56]  126889.0206  169782.7427   27754.9665 -122024.2676 -261399.6160
##  [61]  -59638.0845   77157.1951   14735.3706  -14135.1825   13399.3660
##  [66]   21284.8481   38450.5125  -59617.6965  -49776.2158   -1581.4358
##  [71]  161075.3180   17894.5216  -42506.5988  -13901.7797 -196887.0389
##  [76]  152729.6066   62359.3513  217012.8171 -193972.6405  106021.8380
##  [81]  123362.7100  -24299.0749 -125703.2295  117850.2038  336455.6200
##  [86]  -45331.2660  -75433.1686  -19661.7401   19148.0192  -20893.6881
##  [91]  -42005.5044  -77781.2481  -63278.7346  -14259.4452 -164465.6477
##  [96]  -98305.6890  -47196.7178  -24837.1117  -77593.0425  104779.8327
## [101]   64269.2512 -202092.3872  -19782.9664   23112.4390  -47642.4095
## [106]  -60042.1686  -24795.6988 -101869.3360  255832.9724    8586.6910
## [111]  103059.8030  168599.1468  107690.7391   82563.7617   20796.1828
## [116]  170715.1830    8129.8110  254607.8970  -13704.6984  111566.7444
## [121]  427973.3393   32439.5004   88575.9622  141670.0736   94602.5974
## [126]  168783.6270   82622.1183  127689.4510  -15974.8592  -67698.4368
## [131]   86558.4947  120404.7413  133518.9320   -5306.5098  -68596.6267
## [136]  125710.9268   77147.1638 -168513.4567 -123823.5367  -67329.2617
## [141] -123899.1739    1137.4733  273646.7016  153778.3128  -87264.1954
## [146]   96217.3181  -73874.7773  -45083.4178    -109.1344  -59840.3982
## [151]  -33470.4997  -55130.2886  -64685.7837   19719.4893 -384090.6760
## [156]   26773.2819    9945.8885  118512.7897   91038.0026    3546.4741
## [161]   97140.7309  182223.9332   16200.5701   28130.4062  -22466.8802
## [166]  -47666.0485  -17958.7692   -5587.8911  164060.2767 -623256.1232
## [171]  -74994.3881   82952.1665  146397.2068   46715.2620  -91658.2478
## [176]   25287.2954   -8795.6025  115003.0134  104574.3004  159196.4503
## [181]  -66489.0044 -260995.9105   20903.1491  148813.2224  -31104.7569
## [186]  -67451.6749  -53086.7686    4735.4951 -102192.4100   -5045.0099
## [191]  -55238.1078   95163.2759  -55690.7842  -54250.8353  -49291.8340
## [196]  120178.1377  -71382.6125 -283267.5360 -318589.7323  -11905.5686
## [201]   14409.0352   15168.4477   60833.6134  -80812.7014 -161989.3755
## [206]  -64101.0489  135237.9575   81141.9599  -77271.1686  -28130.3125
## [211]   60717.6548 -307067.3557 -274460.8509 -104781.0930 -175836.7029
## [216]  -76081.7287  -72012.2931  -29606.7271  -44296.7570 -151187.7031
## [221] -354857.5663 -230691.4778   -9466.3468  -66889.5063  132492.4044
## [226] -117263.0752   20079.3887  282597.0881 -103734.0855  106356.9798
## [231] -126741.4551  -38931.1249  101810.3616  -89813.1686   30059.1717
## [236]  328075.9687   -6490.2691 -121152.3502   52675.0502  -70266.6859
## [241]  -68855.4997   76067.5990   51338.6488   27514.9020  -61313.3116
## [246]   34378.7400  -17590.9343  -40234.1649   61522.1978  352222.6803
## [251]   74936.9846  -51975.7451   -5534.4731   79359.4765  -62541.1221
## [256]     610.3155   75808.0765   60586.4765   68224.5822  -87532.0349
## [261]  116084.1953 -154159.4883   27653.9270  -54158.2442  -31531.9175
## [266]  172798.2589  120346.6198  -75258.0709  167868.3799 -256258.9719
## [271]  -38236.9686   28241.8314    5404.9680  -29436.1686  -22610.6686
## [276]   28683.5843  -54506.7395  -86663.1776  -63536.0544   78472.6500
## [281]  -71079.0964   52774.0952 -239253.8458  205820.7537   89856.0101
## [286]  -78972.1640  178539.8367  -89318.9394 -222263.5503  121172.1800
## [291]  450104.7203  -39568.9985  383108.8949  -20875.3037   43724.9876
## [296]  205403.6227  -77587.1280  167827.7612  -74559.4889  190888.4510
## [301]  124834.7806   86163.6423  135948.6017  -49119.7126  216483.4051
tapout.lag <- lag.listw(rswm_q, combined_data$Tap_out_residuals)

tapout.lag
##   [1] -117840.68144  -11973.62137  -47257.87688  -47627.95702   71039.93411
##   [6]  -62474.36358 -235351.69473   -6826.61201  -25883.03172   86396.67808
##  [11]  -27115.83221  -29078.83669   44902.57429   25378.81769  180360.89338
##  [16]  282712.05712   95316.19574   58016.23582  -26245.62137  -74963.02152
##  [21]  -77253.07449    9597.87518  222363.27679  153581.01482  101122.88277
##  [26]  -52401.96495  215181.41113  128056.27238  -41853.23074   80728.17903
##  [31]  -86106.18340    1274.68874      54.55908   -7740.23148  -14345.74585
##  [36]   17775.76118  -45140.40075  -67548.02458  -81515.89038   11562.57959
##  [41]  333279.70530  198385.87915 -107693.22056   60794.31105  231635.34744
##  [46]  -26948.21595  -16456.98248 -176675.64864   35093.10966   86498.15414
##  [51]   56097.75845   17898.97347   32268.87142  -72828.05587  114941.52485
##  [56]  107003.21445  150750.99710   44421.96331 -118993.53083 -283096.33375
##  [61]  -60113.80848   81361.52809   -7498.20610   -4431.00643   41606.85732
##  [66]    8573.98516   34685.13000  -71415.50661  -81129.03749  -14936.48854
##  [71]  146860.57991    9592.49539  -59648.98014  -26549.87098 -185360.92048
##  [76]  122476.44992   60142.10489  178694.54662 -185792.28402  126995.87252
##  [81]  178301.68043  -15262.69054  -98338.98114  115746.32356  341784.07011
##  [86]  -83272.71878  -88097.37137  -23236.90708   19601.55219  -28884.88377
##  [91]  -54725.48594  -68661.37436  -58407.82265    6213.89041 -134905.42728
##  [96] -108189.39343  -31782.67878  -16021.81863  -70989.56644  123241.90716
## [101]   49713.74245 -210447.53180  -14196.23848   23061.16734  -27090.40118
## [106]  -54669.62137    7573.77455  -91085.69996  243331.66295   10770.80162
## [111]  110033.45774  191024.41322  124644.90962   68308.61758   15243.11731
## [116]  172552.84698   37737.57799  246496.36530  -65452.65430  101614.17277
## [121]  452956.84757   55728.77730   53220.70805  126122.36997  119228.93520
## [126]  162381.27799  102723.64753  132347.60580     459.14923  -89226.73751
## [131]   69609.28352  141848.60164  105070.98555    2375.52618  -14840.64024
## [136]  128785.93901  120467.42021 -154997.00908 -107849.62231  -61714.59046
## [141] -136662.69590   -2331.66745  253534.32724  133420.22984  -65770.21218
## [146]  166766.43199  -97271.54520  -30844.08245   10843.07554  -79739.08145
## [151]  -14447.14053  -26325.10255  -63219.39523   71681.85943 -396249.18721
## [156]  -12017.90989   20011.63376   66684.49053   56616.78918    5786.41483
## [161]   81022.80599  161500.38003   24308.12912   45299.72931   -7272.52948
## [166]    7419.92605  -21438.86983   74342.00632  159100.49322 -619637.87663
## [171]  -62184.88685   70055.62084  169596.87640   44455.19295  -57604.55880
## [176]   48226.75598  -17946.08900  130666.17667   71361.01911  167877.11544
## [181]  -50343.42252 -264652.41497   37828.77305  145586.23793  -19135.48490
## [186]  -76896.68233  -40088.02137    3014.92017  -79596.35740    8619.19057
## [191]  -36895.48798   35366.58260  -29601.76189  -44645.95470  -27603.68645
## [196]  118926.07249  -66146.92049 -271004.77575 -308971.30776   35501.78961
## [201]   26226.03111   19903.93112   75423.76296 -104574.79716 -169257.28442
## [206]  -80756.60433  121002.38105   86558.87904  -75747.12137   -5760.06863
## [211]   48073.18668 -299163.87199 -283045.33653 -123446.84936 -147867.23925
## [216]  -92083.61424  -76616.02312  -42234.48804  -68340.71778 -135766.08632
## [221] -343780.90600 -226739.16893  -35666.92581  -57468.92377  104263.49624
## [226]  -98830.62481   20836.71371  291675.76979  -77406.36018  109145.93221
## [231] -136533.02488  -11212.40194   50504.03037  -72849.87137   46678.40909
## [236]  337262.72707   -5350.69173 -111859.83531   49750.64919  -58942.88939
## [241]  -48037.39053   49238.62714   39276.16489    4527.33616  -62979.28257
## [246]   76383.55585   -5630.29430  -32446.04731   68920.61917  325419.31645
## [251]   89122.03378  -54520.62426  -14280.89309  107797.05209  -49781.02494
## [256]   -1826.43717   57154.70139   70399.47947   98852.40613  -89125.25800
## [261]   99069.66784 -117993.33105    6212.63843  -38846.35840  -30690.80127
## [266]  171804.94800  122196.69563  -73420.59466  172408.04542 -244779.48197
## [271]  -43657.82137    7167.97863   25382.11964  -35893.95470  -11817.12137
## [276]   38572.26155  -24313.22330 -101389.35815  -80257.45131   59946.27267
## [281]  -71140.53673   57902.52301 -239986.22707  207215.81764   81421.87769
## [286]  -96974.09638  185972.64929 -113605.71756 -181788.70152   62322.87349
## [291]  365132.29113    1724.71579  361633.55589  -17635.64643   23621.39805
## [296]  179938.54984  -65191.85435  150599.19835  -77522.92218  152449.18971
## [301]  174148.13793  112080.58909  139062.81466  -19866.26726  216567.02829

Appending spatially lag values onto SpatialPolygonDataFrame

combined_data <- combined_data %>%
  add_column(Tap_in_residuals_lag = tapin.lag, Tap_out_residuals_lag = tapout.lag)
tapin_res_lag_map <- tm_shape(combined_data) +
  tm_polygons(col = "Tap_in_residuals_lag",
          n = 8,
          style = "equal",
          palette = "RdBu") +
  tm_layout(main.title = 'Lag Residuals of Tap-in Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tapout_res_lag_map <-tm_shape(combined_data) +
  tm_polygons(col = "Tap_out_residuals_lag",
          n = 8,
          style = "equal",
          palette = "-PiYG") +
  tm_layout(main.title = 'Lag Residuals of Tap-out Volume by Planning Subzone',
            main.title.position = "center",
            main.title.size = 1,
            legend.height = 0.5, 
            legend.width = 0.5,
            legend.outside = FALSE,
            legend.position = c("right", "bottom"),
            frame = FALSE)

tmap_arrange(tapin_res_map, tapout_res_map, tapin_res_lag_map, tapout_res_lag_map, ncol = 2, nrow = 2)
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_in_residuals" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_out_residuals" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_in_residuals_lag" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
## Warning: The shape combined_data is invalid. See sf::st_is_valid
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Variable(s) "Tap_out_residuals_lag" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

Measure of Global Spatial Autocorrelation

Moran’s I for Tap-in Residuals

moran.test(combined_data$Tap_in_residuals, listw=rswm_q, zero.policy = TRUE, na.action=na.omit)
## 
##  Moran I test under randomisation
## 
## data:  combined_data$Tap_in_residuals  
## weights: rswm_q    
## 
## Moran I statistic standard deviate = -0.6965, p-value = 0.7569
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.026191817      -0.003289474       0.001081220

Moran’s I for Tap-out Residuals

moran.test(combined_data$Tap_out_residuals, listw=rswm_q, zero.policy = TRUE, na.action=na.omit)
## 
##  Moran I test under randomisation
## 
## data:  combined_data$Tap_out_residuals  
## weights: rswm_q    
## 
## Moran I statistic standard deviate = -0.1357, p-value = 0.554
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.007768023      -0.003289474       0.001089272

Conclusion for both Moran’s I:

Null hypothesis: Tap-in / Tap-out volume is randomly distributed among different planning subzones in Singapore.

Alternate hypothesis: Tap-in / Tap-out volume is not randomly distributed among different planning subzones in Singapore.

p-value (Tap-in) = 0.7569 p-value (Tap-out) = 0.554

alpha value at 95% confidence interval = 0.05

Both p-values are larger than alpha value. Thus, we do not reject the null hypothesis

Monte Carlo Moran’s I for Tap-in Residuals

set.seed(1234)
bperm= moran.mc(combined_data$Tap_in_residuals, listw=rswm_q, nsim=999, zero.policy = TRUE, na.action=na.omit)
bperm
## 
##  Monte-Carlo simulation of Moran I
## 
## data:  combined_data$Tap_in_residuals 
## weights: rswm_q  
## number of simulations + 1: 1000 
## 
## statistic = -0.026192, observed rank = 243, p-value = 0.757
## alternative hypothesis: greater

Monte Carlo Moran’s I for Tap-out Residuals

set.seed(1234)
bperm= moran.mc(combined_data$Tap_out_residuals, listw=rswm_q, nsim=999, zero.policy = TRUE, na.action=na.omit)
bperm
## 
##  Monte-Carlo simulation of Moran I
## 
## data:  combined_data$Tap_out_residuals 
## weights: rswm_q  
## number of simulations + 1: 1000 
## 
## statistic = -0.007768, observed rank = 466, p-value = 0.534
## alternative hypothesis: greater

Conclusion for both Moran’s I:

p-value (Tap-in) = 0.757 p-value (Tap-out) = 0.534

alpha value at 95% confidence interval = 0.05

Both p-values are still larger than alpha value. Thus, we cannot reject the null hypothesis. Based on the test result, both tap-in and tap-out residuals does conform to randomisation assumption.

Cluster and Outlier Analysis

Local Moran’s I for Tap-in Residuals

fips <- order(combined_data$SUBZONE_N)
localMI <- localmoran(combined_data$TOTAL_TAP_IN_VOLUME, rswm_q)
# use tap-in volume because that is where a bus trip is generated
head(localMI)
##           Ii         E.Ii    Var.Ii       Z.Ii  Pr(z > 0)
## 1  0.1002384 -0.003289474 0.1555725  0.2624769 0.39647691
## 2  0.4810975 -0.003289474 0.4726349  0.7045787 0.24053622
## 3 -0.1003840 -0.003289474 0.1159397 -0.2851534 0.61223668
## 4  0.0873004 -0.003289474 0.1555725  0.2296747 0.40917227
## 5  0.4765620 -0.003289474 0.1027288  1.4971342 0.06717917
## 6 -0.2819368 -0.003289474 0.1555725 -0.7064613 0.76004934
printCoefmat(data.frame(localMI[fips,], row.names = combined_data$SUBZONE_N[fips]), check.names=FALSE)
##                                        Ii        E.Ii      Var.Ii        Z.Ii
## ADMIRALTY                      0.10023845 -0.00328947  0.15557254  0.26247686
## AIRPORT ROAD                   0.48109746 -0.00328947  0.47263490  0.70457872
## ALEXANDRA HILL                -0.10038398 -0.00328947  0.11593975 -0.28515337
## ALEXANDRA NORTH                0.08730040 -0.00328947  0.15557254  0.22967471
## ALJUNIED                       0.47656205 -0.00328947  0.10272881  1.49713422
## ANAK BUKIT                    -0.28193677 -0.00328947  0.15557254 -0.70646127
## ANCHORVALE                     0.18665788 -0.00328947  0.23483813  0.39196648
## ANG MO KIO TOWN CENTRE         0.33336642 -0.00328947  0.11593975  0.98871256
## ANSON                          0.29367897 -0.00328947  0.18727878  0.68622418
## BALESTIER                      0.49555202 -0.00328947  0.15557254  1.26472499
## BANGKIT                        0.01941247 -0.00328947  0.23483813  0.04684667
## BAYFRONT SUBZONE               0.43862357 -0.00328947  0.18727878  1.02115703
## BAYSHORE                      -0.20486834 -0.00328947  0.23483813 -0.41596873
## BEDOK NORTH                    5.53104601 -0.00328947  0.11593975 16.25359036
## BEDOK RESERVOIR                0.74169583 -0.00328947  0.15557254  1.88877938
## BEDOK SOUTH                    1.63970700 -0.00328947  0.18727878  3.79657818
## BENCOOLEN                      0.15833332 -0.00328947  0.13292523  0.44330121
## BENDEMEER                      0.02586076 -0.00328947  0.11593975  0.08561026
## BENOI SECTOR                   0.45368975 -0.00328947  0.13292523  1.25340882
## BIDADARI                       0.26356092 -0.00328947  0.18727878  0.61662845
## BISHAN EAST                    0.00408862 -0.00328947  0.10272881  0.02301962
## BOAT QUAY                      0.31528918 -0.00328947  0.15557254  0.80770023
## BOON KENG                     -0.01941504 -0.00328947  0.18727878 -0.03726240
## BOON LAY PLACE                 0.66945734 -0.00328947  0.13292523  1.84521909
## BOON TECK                     -0.07024158 -0.00328947  0.18727878 -0.15471056
## BOULEVARD                     -0.40555422 -0.00328947  0.11593975 -1.18139683
## BRADDELL                      -0.14572927 -0.00328947  0.18727878 -0.32914484
## BRAS BASAH                     0.04952004 -0.00328947  0.18727878  0.12203035
## BRICKWORKS                    -0.00434845 -0.00328947  0.18727878 -0.00244705
## BUGIS                         -0.02882613 -0.00328947  0.18727878 -0.05900920
## BUKIT BATOK CENTRAL           -0.23613777 -0.00328947  0.18727878 -0.53805761
## BUKIT BATOK EAST              -0.02933039 -0.00328947  0.23483813 -0.05373681
## BUKIT BATOK SOUTH             -0.00536140 -0.00328947  0.11593975 -0.00608497
## BUKIT BATOK WEST              -0.03228619 -0.00328947  0.13292523 -0.07953259
## BUKIT HO SWEE                  0.07276119 -0.00328947  0.13292523  0.20859278
## BUKIT MERAH                    0.00256368 -0.00328947  0.13292523  0.01605412
## CECIL                          0.26143427 -0.00328947  0.18727878  0.61171427
## CENTRAL SUBZONE                0.42281271 -0.00328947  0.10272881  1.32943659
## CENTRAL WATER CATCHMENT        0.16269749 -0.00328947  0.05299354  0.72104522
## CHANGI AIRPORT                -0.37189521 -0.00328947  0.31410372 -0.65769653
## CHANGI POINT                  -0.13732470 -0.00328947  0.47263490 -0.19496474
## CHANGI WEST                   -0.26386531 -0.00328947  0.13292523 -0.71471093
## CHATSWORTH                     0.17585654 -0.00328947  0.10272881  0.55893463
## CHENG SAN                      0.22611792 -0.00328947  0.13292523  0.62922170
## CHIN BEE                      -0.81896422 -0.00328947  0.15557254 -2.06800004
## CHINA SQUARE                   0.22953080 -0.00328947  0.15557254  0.59027491
## CHINATOWN                     -0.12054371 -0.00328947  0.09216007 -0.38623992
## CHOA CHU KANG CENTRAL          0.21140549 -0.00328947  0.18727878  0.49610954
## CHOA CHU KANG NORTH           -0.03266941 -0.00328947  0.15557254 -0.07448766
## CHONG BOON                     0.34472356 -0.00328947  0.11593975  1.02206692
## CITY HALL                      0.02119840 -0.00328947  0.08351291  0.08473722
## CITY TERMINALS                 0.24810812 -0.00328947  0.11593975  0.73832052
## CLARKE QUAY                    0.12907361 -0.00328947  0.15557254  0.33558335
## CLEMENTI CENTRAL              -0.28378263 -0.00328947  0.18727878 -0.64815368
## CLEMENTI NORTH                 0.04038645 -0.00328947  0.15557254  0.11073264
## CLEMENTI WEST                 -0.00085023 -0.00328947  0.15557254  0.00618427
## CLEMENTI WOODS                 0.00905793 -0.00328947  0.13292523  0.03386662
## CLIFFORD PIER                  0.29731670 -0.00328947  0.18727878  0.69463012
## COMMONWEALTH                   0.07514351 -0.00328947  0.18727878  0.18124017
## COMPASSVALE                   -0.12242844 -0.00328947  0.13292523 -0.32677598
## CORONATION ROAD                0.12423771 -0.00328947  0.15557254  0.32332278
## CRAWFORD                       0.06395804 -0.00328947  0.11593975  0.19749678
## DAIRY FARM                    -0.05623884 -0.00328947  0.15557254 -0.13424383
## DEFU INDUSTRIAL PARK          -0.00726137 -0.00328947  0.10272881 -0.01239230
## DEPOT ROAD                     0.13263989 -0.00328947  0.15557254  0.34462504
## DHOBY GHAUT                    0.06183878 -0.00328947  0.13292523  0.17863465
## DOVER                          0.05081266 -0.00328947  0.18727878  0.12501730
## DUNEARN                        0.22145472 -0.00328947  0.18727878  0.51933095
## EAST COAST                     0.16774898 -0.00328947  0.23483813  0.35294696
## EVERTON PARK                   0.13716991 -0.00328947  0.15557254  0.35611010
## FABER                         -0.12147230 -0.00328947  0.18727878 -0.27309270
## FAJAR                         -0.04143947 -0.00328947  0.18727878 -0.08815566
## FARRER COURT                   0.28102501 -0.00328947  0.23483813  0.58669809
## FARRER PARK                   -0.09026156 -0.00328947  0.15557254 -0.22050244
## FERNVALE                      -0.00521859 -0.00328947  0.11593975 -0.00566556
## FLORA DRIVE                   -0.60083171 -0.00328947  0.18727878 -1.38077949
## FORT CANNING                   0.25221062 -0.00328947  0.13292523  0.70078911
## FRANKEL                        1.59334211 -0.00328947  0.11593975  4.68908972
## GALI BATU                      0.08267986 -0.00328947  0.09216007  0.28318625
## GEYLANG BAHRU                 -0.03393345 -0.00328947  0.13292523 -0.08405073
## GEYLANG EAST                   1.99896466 -0.00328947  0.11593975  5.88034798
## GHIM MOH                       0.14394953 -0.00328947  0.18727878  0.34023469
## GOMBAK                        -0.00148983 -0.00328947  0.10272881  0.00561489
## GOODWOOD PARK                  0.09797806 -0.00328947  0.15557254  0.25674604
## GREENWOOD PARK                -0.95742611 -0.00328947  0.15557254 -2.41904585
## GUILIN                        -0.03216434 -0.00328947  0.15557254 -0.07320716
## GUL BASIN                      0.57025045 -0.00328947  0.23483813  1.18353021
## GUL CIRCLE                     0.38045570 -0.00328947  0.13292523  1.05254147
## HENDERSON HILL                -0.00212471 -0.00328947  0.15557254  0.00295305
## HILLCREST                      0.24666519 -0.00328947  0.15557254  0.63371615
## HILLVIEW                       0.02142716 -0.00328947  0.13292523  0.06779311
## HOLLAND DRIVE                  0.12193783 -0.00328947  0.15557254  0.31749184
## HOLLAND ROAD                  -0.05082647 -0.00328947  0.15557254 -0.12052171
## HONG KAH                       0.00801292 -0.00328947  0.13292523  0.03100035
## HONG KAH NORTH                -0.04271247 -0.00328947  0.18727878 -0.09109726
## HOUGANG CENTRAL                0.67165505 -0.00328947  0.18727878  1.55963796
## HOUGANG EAST                   0.02967866 -0.00328947  0.18727878  0.07618160
## HOUGANG WEST                   0.56059656 -0.00328947  0.13292523  1.54663427
## INSTITUTION HILL               0.47151664 -0.00328947  0.23483813  0.97978773
## INTERNATIONAL BUSINESS PARK    0.03095157 -0.00328947  0.13292523  0.09391680
## ISTANA NEGARA                  0.25018671 -0.00328947  0.18727878  0.58572382
## JELEBU                        -0.26688524 -0.00328947  0.13292523 -0.72299405
## JOO KOON                      -0.06219239 -0.00328947  0.10272881 -0.18377680
## JOO SENG                       0.01664605 -0.00328947  0.13292523  0.05467943
## JURONG GATEWAY                -0.40028995 -0.00328947  0.23483813 -0.81923165
## JURONG PORT                    0.50557689 -0.00328947  0.23483813  1.05007287
## JURONG RIVER                   0.15140724 -0.00328947  0.13292523  0.42430423
## JURONG WEST CENTRAL            0.55702716 -0.00328947  0.18727878  1.29475989
## KAKI BUKIT                     1.20688569 -0.00328947  0.11593975  3.55411981
## KALLANG BAHRU                 -0.00924711 -0.00328947  0.18727878 -0.01376671
## KALLANG WAY                   -0.14289808 -0.00328947  0.15557254 -0.35395309
## KAMPONG BUGIS                 -0.21392998 -0.00328947  0.15557254 -0.53404201
## KAMPONG GLAM                   0.14127684 -0.00328947  0.23483813  0.29832030
## KAMPONG JAVA                  -0.04307351 -0.00328947  0.11593975 -0.11684029
## KAMPONG TIONG BAHRU            0.06297981 -0.00328947  0.10272881  0.20675980
## KAMPONG UBI                    0.56612995 -0.00328947  0.11593975  1.67230737
## KANGKAR                        0.05764669 -0.00328947  0.13292523  0.16713653
## KATONG                        -0.21957148 -0.00328947  0.23483813 -0.44630944
## KEAT HONG                     -0.00121896 -0.00328947  0.15557254  0.00524942
## KEBUN BAHRU                    0.02326120 -0.00328947  0.15557254  0.06731456
## KEMBANGAN                      1.69777423 -0.00328947  0.15557254  4.31274823
## KENT RIDGE                     0.14689791 -0.00328947  0.11593975  0.44107990
## KHATIB                         0.02016067 -0.00328947  0.11593975  0.06886987
## KIAN TECK                     -0.44289606 -0.00328947  0.13292523 -1.20575892
## KIM KEAT                      -0.27862324 -0.00328947  0.15557254 -0.69806040
## KOVAN                          0.18113544 -0.00328947  0.13292523  0.50584316
## KRANJI                        -0.08290165 -0.00328947  0.15557254 -0.20184268
## LAKESIDE                      -0.25306888 -0.00328947  0.11593975 -0.73356812
## LAVENDER                      -0.13725528 -0.00328947  0.10272881 -0.41797260
## LEEDON PARK                    0.18004724 -0.00328947  0.10272881  0.57200959
## LEONIE HILL                    0.19825924 -0.00328947  0.11593975  0.59192114
## LIM CHU KANG                   0.21325428 -0.00328947  0.47263490  0.31497985
## LITTLE INDIA                   0.10519448 -0.00328947  0.15557254  0.27504201
## LIU FANG                       0.23201761 -0.00328947  0.11593975  0.69106490
## LORONG 8 TOA PAYOH             0.04919578 -0.00328947  0.13292523  0.14395727
## LORONG AH SOO                  0.51947325 -0.00328947  0.13292523  1.43384069
## LORONG CHUAN                  -0.24429315 -0.00328947  0.11593975 -0.70779501
## LORONG HALUS                   0.12195153 -0.00328947  0.18727878  0.28940249
## LOWER SELETAR                  0.06609017 -0.00328947  0.11593975  0.20375858
## LOYANG EAST                    0.32282147 -0.00328947  0.31410372  0.58187384
## LOYANG WEST                    0.09440362 -0.00328947  0.18727878  0.22574575
## MACKENZIE                      0.21160779 -0.00328947  0.23483813  0.44345195
## MACPHERSON                     0.29967027 -0.00328947  0.13292523  0.83096210
## MALCOLM                       -0.13506277 -0.00328947  0.13292523 -0.36142958
## MANDAI EAST                   -0.08569657 -0.00328947  0.07630695 -0.29832013
## MANDAI ESTATE                 -0.43100643 -0.00328947  0.31410372 -0.76316761
## MANDAI WEST                    0.20346168 -0.00328947  0.13292523  0.56707988
## MARGARET DRIVE                 0.06067914 -0.00328947  0.10272881  0.19958173
## MARINA CENTRE                  0.17662106 -0.00328947  0.18727878  0.41573090
## MARINA EAST (MP)               0.14844558 -0.00328947  0.23483813  0.31311337
## MARINA SOUTH                   0.49760337 -0.00328947  0.23483813  1.03361909
## MARINE PARADE                 -0.24328718 -0.00328947  0.15557254 -0.60847204
## MARITIME SQUARE               -0.39590665 -0.00328947  0.13292523 -1.07687571
## MARYMOUNT                      0.30339020 -0.00328947  0.15557254  0.77753244
## MATILDA                        0.45027660 -0.00328947  0.11593975  1.33206185
## MAXWELL                        0.26465250 -0.00328947  0.31410372  0.47808400
## MEI CHIN                       0.04411040 -0.00328947  0.15557254  0.12017406
## MIDVIEW                        0.26314234 -0.00328947  0.15557254  0.67549106
## MONK'S HILL                    0.15149022 -0.00328947  0.18727878  0.35765944
## MOULMEIN                      -0.05320157 -0.00328947  0.15557254 -0.12654336
## MOUNT PLEASANT                -0.04907286 -0.00328947  0.15557254 -0.11607574
## MOUNTBATTEN                   -0.24757887 -0.00328947  0.13292523 -0.67004029
## NASSIM                         0.11543367 -0.00328947  0.11593975  0.34867373
## NATIONAL UNIVERSITY OF S'PORE  0.06286804 -0.00328947  0.18727878  0.15287445
## NATURE RESERVE                 0.09079075 -0.00328947  0.18727878  0.21739725
## NEE SOON                       0.36260753 -0.00328947  0.15557254  0.92766759
## NEWTON CIRCUS                  0.12719535 -0.00328947  0.31410372  0.23282170
## NORTH COAST                   -0.56035011 -0.00328947  0.18727878 -1.28723603
## NORTHLAND                      0.31982058 -0.00328947  0.18727878  0.74663131
## NORTHSHORE                     0.34139689 -0.00328947  0.47263490  0.50137331
## ONE NORTH                      0.05405992 -0.00328947  0.11593975  0.16842736
## ONE TREE HILL                  0.18981973 -0.00328947  0.18727878  0.44622993
## ORANGE GROVE                   0.06250809 -0.00328947  0.31410372  0.11740140
## OXLEY                          0.29364058 -0.00328947  0.18727878  0.68613547
## PANDAN                         0.26502466 -0.00328947  0.18727878  0.62001083
## PANG SUA                       0.15948092 -0.00328947  0.15557254  0.41267575
## PASIR PANJANG 1                0.04421528 -0.00328947  0.15557254  0.12043995
## PASIR PANJANG 2                0.02931254 -0.00328947  0.18727878  0.07533559
## PASIR RIS CENTRAL              2.19631122 -0.00328947  0.18727878  5.08275955
## PASIR RIS DRIVE                1.40542138 -0.00328947  0.15557254  3.57153893
## PASIR RIS PARK                -0.17898541 -0.00328947  0.18727878 -0.40599197
## PASIR RIS WAFER FAB PARK       0.03468511 -0.00328947  0.11593975  0.11152619
## PASIR RIS WEST                -0.03059011 -0.00328947  0.23483813 -0.05633631
## PATERSON                       0.04822248 -0.00328947  0.18727878  0.11903201
## PAYA LEBAR EAST               -0.31238288 -0.00328947  0.15557254 -0.78365204
## PAYA LEBAR NORTH               0.39102410 -0.00328947  0.18727878  0.91116587
## PAYA LEBAR WEST                0.53473060 -0.00328947  0.18727878  1.24323778
## PEARL'S HILL                   0.07905262 -0.00328947  0.10272881  0.25690690
## PEI CHUN                       0.14755052 -0.00328947  0.18727878  0.34855572
## PENG SIANG                     0.05879774 -0.00328947  0.18727878  0.14346895
## PENJURU CRESCENT               0.32254760 -0.00328947  0.23483813  0.67238217
## PEOPLE'S PARK                  0.02514536 -0.00328947  0.31410372  0.05073576
## PHILLIP                        0.53853652 -0.00328947  0.31410372  0.96677030
## PIONEER SECTOR                 0.49565239 -0.00328947  0.31410372  0.89025291
## PLAB                           0.32074025 -0.00328947  0.13292523  0.88875311
## PORT                           0.04084423 -0.00328947  0.18727878  0.10198260
## POTONG PASIR                   0.06888129 -0.00328947  0.13292523  0.19795095
## PUNGGOL FIELD                  0.33075170 -0.00328947  0.15557254  0.84690273
## PUNGGOL TOWN CENTRE           -0.00625467 -0.00328947  0.18727878 -0.00685187
## QUEENSWAY                      0.15727493 -0.00328947  0.18727878  0.37102655
## RAFFLES PLACE                  0.32126953 -0.00328947  0.11593975  0.95318563
## REDHILL                        0.01215100 -0.00328947  0.18727878  0.03567930
## RESERVOIR VIEW                 0.30506668 -0.00328947  0.18727878  0.71253851
## RIDOUT                         0.27498112 -0.00328947  0.13292523  0.76324437
## RIVERVALE                      0.39494142 -0.00328947  0.11593975  1.16954995
## ROBERTSON QUAY                 0.20804565 -0.00328947  0.13292523  0.57965284
## ROCHOR CANAL                   0.06476629 -0.00328947  0.15557254  0.17254344
## SAFTI                         -0.26053360 -0.00328947  0.23483813 -0.53083697
## SAMULUN                        0.57906991 -0.00328947  0.23483813  1.20172964
## SAUJANA                       -0.07621606 -0.00328947  0.23483813 -0.15048789
## SELEGIE                        0.23503044 -0.00328947  0.18727878  0.55070122
## SELETAR                        0.08106378 -0.00328947  0.18727878  0.19492052
## SELETAR AEROSPACE PARK         0.28508086 -0.00328947  0.23483813  0.59506756
## SELETAR HILLS                 -0.00739218 -0.00328947  0.11593975 -0.01204908
## SEMBAWANG CENTRAL              0.09218756 -0.00328947  0.15557254  0.24206524
## SEMBAWANG EAST                -0.08112463 -0.00328947  0.18727878 -0.17985872
## SEMBAWANG HILLS                0.00133693 -0.00328947  0.15557254  0.01172944
## SEMBAWANG NORTH                0.01396279 -0.00328947  0.18727878  0.03986593
## SEMBAWANG SPRINGS             -0.15132643 -0.00328947  0.15557254 -0.37532169
## SEMBAWANG STRAITS              0.40087853 -0.00328947  0.31410372  0.72114963
## SENGKANG TOWN CENTRE           1.48070708 -0.00328947  0.18727878  3.42916679
## SENGKANG WEST                  0.35098249 -0.00328947  0.15557254  0.89819433
## SENJA                         -0.03063001 -0.00328947  0.18727878 -0.06317754
## SENNETT                        0.02887312 -0.00328947  0.11593975  0.09445717
## SENOKO NORTH                  -0.03019569 -0.00328947  0.18727878 -0.06217393
## SENOKO SOUTH                  -0.12314264 -0.00328947  0.15557254 -0.30386664
## SENOKO WEST                   -0.25727049 -0.00328947  0.15557254 -0.64392425
## SENTOSA                       -0.10783455 -0.00328947  0.47263490 -0.15206901
## SERANGOON CENTRAL              0.48276204 -0.00328947  0.18727878  1.12315066
## SERANGOON GARDEN               0.38517559 -0.00328947  0.10272881  1.21200896
## SERANGOON NORTH                0.03529745 -0.00328947  0.15557254  0.09783037
## SERANGOON NORTH IND ESTATE    -0.13561635 -0.00328947  0.15557254 -0.33549154
## SHANGRI-LA                    -0.07795354 -0.00328947  0.15557254 -0.18929763
## SHIPYARD                       0.56073397 -0.00328947  0.23483813  1.16389244
## SIGLAP                        -0.11853607 -0.00328947  0.23483813 -0.23781750
## SIMEI                          2.73164555 -0.00328947  0.15557254  6.93394735
## SINGAPORE GENERAL HOSPITAL     0.07274019 -0.00328947  0.15557254  0.19275985
## SINGAPORE POLYTECHNIC          0.04288692 -0.00328947  0.15557254  0.11707215
## SOMERSET                      -0.11803278 -0.00328947  0.13292523 -0.31471949
## SPRINGLEAF                     0.17109304 -0.00328947  0.13292523  0.47829872
## STRAITS VIEW                   0.56074283 -0.00328947  0.23483813  1.16391072
## SUNGEI ROAD                    0.14242433 -0.00328947  0.18727878  0.33671031
## SUNSET WAY                    -0.06205375 -0.00328947  0.13292523 -0.16117945
## SWISS CLUB                     0.06248586 -0.00328947  0.15557254  0.16676180
## TAGORE                         0.21114818 -0.00328947  0.11593975  0.62977422
## TAI SENG                      -0.00465501 -0.00328947  0.15557254 -0.00346207
## TAMAN JURONG                  -0.12028928 -0.00328947  0.13292523 -0.32090865
## TAMPINES EAST                  4.05764570 -0.00328947  0.11593975 11.92641409
## TAMPINES NORTH                -0.48562423 -0.00328947  0.11593975 -1.41655156
## TAMPINES WEST                  5.27682643 -0.00328947  0.15557254 13.38680642
## TANGLIN                        0.17049590 -0.00328947  0.18727878  0.40157711
## TANGLIN HALT                   0.05286635 -0.00328947  0.18727878  0.12976289
## TANJONG PAGAR                  0.34419109 -0.00328947  0.18727878  0.80294581
## TANJONG RHU                   -0.05216066 -0.00328947  0.18727878 -0.11292981
## TEBAN GARDENS                 -0.05293426 -0.00328947  0.15557254 -0.12586563
## TECK WHYE                      0.08608541 -0.00328947  0.13292523  0.24513864
## TELOK BLANGAH DRIVE           -0.00447644 -0.00328947  0.18727878 -0.00274279
## TELOK BLANGAH RISE             0.03142065 -0.00328947  0.18727878  0.08020692
## TELOK BLANGAH WAY              0.01369340 -0.00328947  0.15557254  0.04305708
## TENGAH                        -0.14269351 -0.00328947  0.08351291 -0.48239027
## TENGEH                         0.23998002 -0.00328947  0.18727878  0.56213854
## THE WHARVES                    0.31303863 -0.00328947  0.23483813  0.65275990
## TIONG BAHRU                    0.03891466 -0.00328947  0.18727878  0.09752382
## TIONG BAHRU STATION           -0.19111807 -0.00328947  0.18727878 -0.43402767
## TOA PAYOH CENTRAL             -0.30944185 -0.00328947  0.13292523 -0.83971890
## TOA PAYOH WEST                -0.11241865 -0.00328947  0.13292523 -0.29932098
## TOH GUAN                      -0.00043202 -0.00328947  0.15557254  0.00724457
## TOH TUCK                       0.07270832 -0.00328947  0.15557254  0.19267904
## TOWNSVILLE                     0.10941826 -0.00328947  0.13292523  0.30913631
## TRAFALGAR                      0.19466379 -0.00328947  0.18727878  0.45742340
## TUAS BAY                       0.37157982 -0.00328947  0.18727878  0.86623471
## TUAS NORTH                     0.29687957 -0.00328947  0.18727878  0.69362003
## TUAS PROMENADE                 0.28500981 -0.00328947  0.15557254  0.73093219
## TUAS VIEW                      0.41708174 -0.00328947  0.31410372  0.75006073
## TUAS VIEW EXTENSION            0.44569952 -0.00328947  0.47263490  0.65308965
## TUKANG                         0.17977261 -0.00328947  0.13292523  0.50210516
## TURF CLUB                      0.07718497 -0.00328947  0.11593975  0.23634248
## TYERSALL                       0.17157896 -0.00328947  0.13292523  0.47963150
## ULU PANDAN                     0.21171076 -0.00328947  0.15557254  0.54509532
## UPPER PAYA LEBAR              -0.04635057 -0.00328947  0.13292523 -0.11810855
## UPPER THOMSON                 -0.14101946 -0.00328947  0.18727878 -0.31826158
## VICTORIA                      -0.11214218 -0.00328947  0.13292523 -0.29856269
## WATERWAY EAST                  0.02066250 -0.00328947  0.18727878  0.05534738
## WENYA                         -0.59666421 -0.00328947  0.15557254 -1.50439741
## WEST COAST                    -0.01623523 -0.00328947  0.15557254 -0.03282170
## WESTERN WATER CATCHMENT       -0.02088671 -0.00328947  0.06498330 -0.06903090
## WOODGROVE                      0.12468553 -0.00328947  0.13292523  0.35101158
## WOODLANDS EAST                -0.21048929 -0.00328947  0.13292523 -0.56831048
## WOODLANDS REGIONAL CENTRE      0.62503838 -0.00328947  0.18727878  1.45191780
## WOODLANDS SOUTH                0.23569011 -0.00328947  0.15557254  0.60589075
## WOODLANDS WEST                 0.53781557 -0.00328947  0.15557254  1.37187680
## WOODLEIGH                      0.12119719 -0.00328947  0.11593975  0.36560040
## XILIN                         -0.94935817 -0.00328947  0.13292523 -2.59489007
## YEW TEE                       -0.08842431 -0.00328947  0.23483813 -0.17568028
## YIO CHU KANG                  -0.00172064 -0.00328947  0.15557254  0.00397749
## YIO CHU KANG EAST             -0.12268826 -0.00328947  0.15557254 -0.30271465
## YIO CHU KANG NORTH             0.26034107 -0.00328947  0.15557254  0.66838895
## YIO CHU KANG WEST             -0.00258454 -0.00328947  0.18727878  0.00162893
## YISHUN CENTRAL                 2.17353803 -0.00328947  0.18727878  5.03013606
## YISHUN EAST                    0.85322140 -0.00328947  0.23483813  1.76745584
## YISHUN SOUTH                   0.71820554 -0.00328947  0.15557254  1.82922386
## YISHUN WEST                    0.41355824 -0.00328947  0.11593975  1.22422503
## YUHUA EAST                     0.02280460 -0.00328947  0.15557254  0.06615695
## YUHUA WEST                     0.04712751 -0.00328947  0.18727878  0.11650178
## YUNNAN                         1.08252739 -0.00328947  0.15557254  2.75289794
##                               Pr.z...0.
## ADMIRALTY                        0.3965
## AIRPORT ROAD                     0.2405
## ALEXANDRA HILL                   0.6122
## ALEXANDRA NORTH                  0.4092
## ALJUNIED                         0.0672
## ANAK BUKIT                       0.7600
## ANCHORVALE                       0.3475
## ANG MO KIO TOWN CENTRE           0.1614
## ANSON                            0.2463
## BALESTIER                        0.1030
## BANGKIT                          0.4813
## BAYFRONT SUBZONE                 0.1536
## BAYSHORE                         0.6613
## BEDOK NORTH                      0.0000
## BEDOK RESERVOIR                  0.0295
## BEDOK SOUTH                      0.0001
## BENCOOLEN                        0.3288
## BENDEMEER                        0.4659
## BENOI SECTOR                     0.1050
## BIDADARI                         0.2687
## BISHAN EAST                      0.4908
## BOAT QUAY                        0.2096
## BOON KENG                        0.5149
## BOON LAY PLACE                   0.0325
## BOON TECK                        0.5615
## BOULEVARD                        0.8813
## BRADDELL                         0.6290
## BRAS BASAH                       0.4514
## BRICKWORKS                       0.5010
## BUGIS                            0.5235
## BUKIT BATOK CENTRAL              0.7047
## BUKIT BATOK EAST                 0.5214
## BUKIT BATOK SOUTH                0.5024
## BUKIT BATOK WEST                 0.5317
## BUKIT HO SWEE                    0.4174
## BUKIT MERAH                      0.4936
## CECIL                            0.2704
## CENTRAL SUBZONE                  0.0919
## CENTRAL WATER CATCHMENT          0.2354
## CHANGI AIRPORT                   0.7446
## CHANGI POINT                     0.5773
## CHANGI WEST                      0.7626
## CHATSWORTH                       0.2881
## CHENG SAN                        0.2646
## CHIN BEE                         0.9807
## CHINA SQUARE                     0.2775
## CHINATOWN                        0.6503
## CHOA CHU KANG CENTRAL            0.3099
## CHOA CHU KANG NORTH              0.5297
## CHONG BOON                       0.1534
## CITY HALL                        0.4662
## CITY TERMINALS                   0.2302
## CLARKE QUAY                      0.3686
## CLEMENTI CENTRAL                 0.7416
## CLEMENTI NORTH                   0.4559
## CLEMENTI WEST                    0.4975
## CLEMENTI WOODS                   0.4865
## CLIFFORD PIER                    0.2436
## COMMONWEALTH                     0.4281
## COMPASSVALE                      0.6281
## CORONATION ROAD                  0.3732
## CRAWFORD                         0.4217
## DAIRY FARM                       0.5534
## DEFU INDUSTRIAL PARK             0.5049
## DEPOT ROAD                       0.3652
## DHOBY GHAUT                      0.4291
## DOVER                            0.4503
## DUNEARN                          0.3018
## EAST COAST                       0.3621
## EVERTON PARK                     0.3609
## FABER                            0.6076
## FAJAR                            0.5351
## FARRER COURT                     0.2787
## FARRER PARK                      0.5873
## FERNVALE                         0.5023
## FLORA DRIVE                      0.9163
## FORT CANNING                     0.2417
## FRANKEL                          0.0000
## GALI BATU                        0.3885
## GEYLANG BAHRU                    0.5335
## GEYLANG EAST                     0.0000
## GHIM MOH                         0.3668
## GOMBAK                           0.4978
## GOODWOOD PARK                    0.3987
## GREENWOOD PARK                   0.9922
## GUILIN                           0.5292
## GUL BASIN                        0.1183
## GUL CIRCLE                       0.1463
## HENDERSON HILL                   0.4988
## HILLCREST                        0.2631
## HILLVIEW                         0.4730
## HOLLAND DRIVE                    0.3754
## HOLLAND ROAD                     0.5480
## HONG KAH                         0.4876
## HONG KAH NORTH                   0.5363
## HOUGANG CENTRAL                  0.0594
## HOUGANG EAST                     0.4696
## HOUGANG WEST                     0.0610
## INSTITUTION HILL                 0.1636
## INTERNATIONAL BUSINESS PARK      0.4626
## ISTANA NEGARA                    0.2790
## JELEBU                           0.7652
## JOO KOON                         0.5729
## JOO SENG                         0.4782
## JURONG GATEWAY                   0.7937
## JURONG PORT                      0.1468
## JURONG RIVER                     0.3357
## JURONG WEST CENTRAL              0.0977
## KAKI BUKIT                       0.0002
## KALLANG BAHRU                    0.5055
## KALLANG WAY                      0.6383
## KAMPONG BUGIS                    0.7033
## KAMPONG GLAM                     0.3827
## KAMPONG JAVA                     0.5465
## KAMPONG TIONG BAHRU              0.4181
## KAMPONG UBI                      0.0472
## KANGKAR                          0.4336
## KATONG                           0.6723
## KEAT HONG                        0.4979
## KEBUN BAHRU                      0.4732
## KEMBANGAN                        0.0000
## KENT RIDGE                       0.3296
## KHATIB                           0.4725
## KIAN TECK                        0.8860
## KIM KEAT                         0.7574
## KOVAN                            0.3065
## KRANJI                           0.5800
## LAKESIDE                         0.7684
## LAVENDER                         0.6620
## LEEDON PARK                      0.2837
## LEONIE HILL                      0.2770
## LIM CHU KANG                     0.3764
## LITTLE INDIA                     0.3916
## LIU FANG                         0.2448
## LORONG 8 TOA PAYOH               0.4428
## LORONG AH SOO                    0.0758
## LORONG CHUAN                     0.7605
## LORONG HALUS                     0.3861
## LOWER SELETAR                    0.4193
## LOYANG EAST                      0.2803
## LOYANG WEST                      0.4107
## MACKENZIE                        0.3287
## MACPHERSON                       0.2030
## MALCOLM                          0.6411
## MANDAI EAST                      0.6173
## MANDAI ESTATE                    0.7773
## MANDAI WEST                      0.2853
## MARGARET DRIVE                   0.4209
## MARINA CENTRE                    0.3388
## MARINA EAST (MP)                 0.3771
## MARINA SOUTH                     0.1507
## MARINE PARADE                    0.7286
## MARITIME SQUARE                  0.8592
## MARYMOUNT                        0.2184
## MATILDA                          0.0914
## MAXWELL                          0.3163
## MEI CHIN                         0.4522
## MIDVIEW                          0.2497
## MONK'S HILL                      0.3603
## MOULMEIN                         0.5503
## MOUNT PLEASANT                   0.5462
## MOUNTBATTEN                      0.7486
## NASSIM                           0.3637
## NATIONAL UNIVERSITY OF S'PORE    0.4392
## NATURE RESERVE                   0.4139
## NEE SOON                         0.1768
## NEWTON CIRCUS                    0.4079
## NORTH COAST                      0.9010
## NORTHLAND                        0.2276
## NORTHSHORE                       0.3081
## ONE NORTH                        0.4331
## ONE TREE HILL                    0.3277
## ORANGE GROVE                     0.4533
## OXLEY                            0.2463
## PANDAN                           0.2676
## PANG SUA                         0.3399
## PASIR PANJANG 1                  0.4521
## PASIR PANJANG 2                  0.4700
## PASIR RIS CENTRAL                0.0000
## PASIR RIS DRIVE                  0.0002
## PASIR RIS PARK                   0.6576
## PASIR RIS WAFER FAB PARK         0.4556
## PASIR RIS WEST                   0.5225
## PATERSON                         0.4526
## PAYA LEBAR EAST                  0.7834
## PAYA LEBAR NORTH                 0.1811
## PAYA LEBAR WEST                  0.1069
## PEARL'S HILL                     0.3986
## PEI CHUN                         0.3637
## PENG SIANG                       0.4430
## PENJURU CRESCENT                 0.2507
## PEOPLE'S PARK                    0.4798
## PHILLIP                          0.1668
## PIONEER SECTOR                   0.1867
## PLAB                             0.1871
## PORT                             0.4594
## POTONG PASIR                     0.4215
## PUNGGOL FIELD                    0.1985
## PUNGGOL TOWN CENTRE              0.5027
## QUEENSWAY                        0.3553
## RAFFLES PLACE                    0.1702
## REDHILL                          0.4858
## RESERVOIR VIEW                   0.2381
## RIDOUT                           0.2227
## RIVERVALE                        0.1211
## ROBERTSON QUAY                   0.2811
## ROCHOR CANAL                     0.4315
## SAFTI                            0.7022
## SAMULUN                          0.1147
## SAUJANA                          0.5598
## SELEGIE                          0.2909
## SELETAR                          0.4227
## SELETAR AEROSPACE PARK           0.2759
## SELETAR HILLS                    0.5048
## SEMBAWANG CENTRAL                0.4044
## SEMBAWANG EAST                   0.5714
## SEMBAWANG HILLS                  0.4953
## SEMBAWANG NORTH                  0.4841
## SEMBAWANG SPRINGS                0.6463
## SEMBAWANG STRAITS                0.2354
## SENGKANG TOWN CENTRE             0.0003
## SENGKANG WEST                    0.1845
## SENJA                            0.5252
## SENNETT                          0.4624
## SENOKO NORTH                     0.5248
## SENOKO SOUTH                     0.6194
## SENOKO WEST                      0.7402
## SENTOSA                          0.5604
## SERANGOON CENTRAL                0.1307
## SERANGOON GARDEN                 0.1128
## SERANGOON NORTH                  0.4610
## SERANGOON NORTH IND ESTATE       0.6314
## SHANGRI-LA                       0.5751
## SHIPYARD                         0.1222
## SIGLAP                           0.5940
## SIMEI                            0.0000
## SINGAPORE GENERAL HOSPITAL       0.4236
## SINGAPORE POLYTECHNIC            0.4534
## SOMERSET                         0.6235
## SPRINGLEAF                       0.3162
## STRAITS VIEW                     0.1222
## SUNGEI ROAD                      0.3682
## SUNSET WAY                       0.5640
## SWISS CLUB                       0.4338
## TAGORE                           0.2644
## TAI SENG                         0.5014
## TAMAN JURONG                     0.6259
## TAMPINES EAST                    0.0000
## TAMPINES NORTH                   0.9217
## TAMPINES WEST                    0.0000
## TANGLIN                          0.3440
## TANGLIN HALT                     0.4484
## TANJONG PAGAR                    0.2110
## TANJONG RHU                      0.5450
## TEBAN GARDENS                    0.5501
## TECK WHYE                        0.4032
## TELOK BLANGAH DRIVE              0.5011
## TELOK BLANGAH RISE               0.4680
## TELOK BLANGAH WAY                0.4828
## TENGAH                           0.6852
## TENGEH                           0.2870
## THE WHARVES                      0.2570
## TIONG BAHRU                      0.4612
## TIONG BAHRU STATION              0.6679
## TOA PAYOH CENTRAL                0.7995
## TOA PAYOH WEST                   0.6177
## TOH GUAN                         0.4971
## TOH TUCK                         0.4236
## TOWNSVILLE                       0.3786
## TRAFALGAR                        0.3237
## TUAS BAY                         0.1932
## TUAS NORTH                       0.2440
## TUAS PROMENADE                   0.2324
## TUAS VIEW                        0.2266
## TUAS VIEW EXTENSION              0.2568
## TUKANG                           0.3078
## TURF CLUB                        0.4066
## TYERSALL                         0.3157
## ULU PANDAN                       0.2928
## UPPER PAYA LEBAR                 0.5470
## UPPER THOMSON                    0.6249
## VICTORIA                         0.6174
## WATERWAY EAST                    0.4779
## WENYA                            0.9338
## WEST COAST                       0.5131
## WESTERN WATER CATCHMENT          0.5275
## WOODGROVE                        0.3628
## WOODLANDS EAST                   0.7151
## WOODLANDS REGIONAL CENTRE        0.0733
## WOODLANDS SOUTH                  0.2723
## WOODLANDS WEST                   0.0851
## WOODLEIGH                        0.3573
## XILIN                            0.9953
## YEW TEE                          0.5697
## YIO CHU KANG                     0.4984
## YIO CHU KANG EAST                0.6189
## YIO CHU KANG NORTH               0.2519
## YIO CHU KANG WEST                0.4994
## YISHUN CENTRAL                   0.0000
## YISHUN EAST                      0.0386
## YISHUN SOUTH                     0.0337
## YISHUN WEST                      0.1104
## YUHUA EAST                       0.4736
## YUHUA WEST                       0.4536
## YUNNAN                           0.0030

Appending Local Moran’s I Dataframe

combined_data.localMI <- cbind(combined_data, localMI)

Mapping Local Moran’s I Values

localMI.map <- tm_shape(combined_data.localMI) +
  tm_fill(col = "Ii", 
          style = "pretty", 
          title = "Local Moran Statistics") +
  tm_borders(alpha = 0.5)

pvalue.map <- tm_shape(combined_data.localMI) +
  tm_fill(col = "Pr.z...0.", 
          breaks=c(-Inf, 0.001, 0.01, 0.05, 0.1, Inf),
          palette="-Blues", 
          title = "Local Moran's I p-values") +
  tm_borders(alpha = 0.5)

tmap_arrange(localMI.map, pvalue.map, asp=1, ncol=2)
## Warning: The shape combined_data.localMI is invalid. See sf::st_is_valid
## 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.
## Warning: The shape combined_data.localMI is invalid. See sf::st_is_valid

Conclusion for Local Moran Statistics:

By comparing Local Moran Statistics and the p-values maps, we can see that there is a cluster around the Tampines West subzone area (darkgreen polygon). There are also outliers such as Yishun Central and Yunnan, and by eyeballing, the significance level are high as they have relatively low p-value. We can create a LISA Cluster Map to confirm our interpretations.

LISA Cluster Map

Plotting Moran scatterplot with standardised variable

combined_data.localMI$Z.TOTAL_TAP_IN_VOLUME <- scale(combined_data.localMI$TOTAL_TAP_IN_VOLUME) %>% 
  as.vector 

nci <- moran.plot(combined_data.localMI$TOTAL_TAP_IN_VOLUME, rswm_q, labels=as.character(combined_data.localMI$SUBZONE_N), xlab="z-Tap-in Volume", ylab="Spatially Lag z-Tap-in Volume")

Getting the Quadrant

quadrant <- vector(mode="numeric",length=nrow(localMI))
DV <- combined_data.localMI$TOTAL_TAP_IN_VOLUME - mean(combined_data.localMI$TOTAL_TAP_IN_VOLUME)     
C_mI <- localMI[,1] - mean(localMI[,1])    
signif <- 0.05       
quadrant[DV >0 & C_mI>0] <- 4      
quadrant[DV <0 & C_mI<0] <- 1      
quadrant[DV <0 & C_mI>0] <- 2
quadrant[DV >0 & C_mI<0] <- 3
quadrant[localMI[,5]>signif] <- 0

Mapping the LISA Map

combined_data.localMI$quadrant <- quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c")
clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")

tm_shape(combined_data.localMI) +
  tm_fill(col = "quadrant", style = "cat", palette = colors[c(sort(unique(quadrant)))+1], labels = clusters[c(sort(unique(quadrant)))+1], popup.vars = c("SUBZONE_N")) +
  tm_view(set.zoom.limits = c(11,17)) +
  tm_borders(alpha=0.5)
## Warning: The shape combined_data.localMI is invalid. See sf::st_is_valid

Based on the LISA Map, the white areas are insignificant and the red areas are high-high quadrant which means that they are polygons with high values and surround by neighbours with high values too. Thus, we can safely say that the red areas are clusters as they are significant and positive. Furthermore, there are no outliers because although there are negative values, they are insignificant.

Hot Spot and Cold Spot Area Analysis

Creating adaptive proximity matrix

knb_lw <- nb2listw(wm_knn5, style = 'B')
summary(knb_lw)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 305 
## Number of nonzero links: 1525 
## Percentage nonzero weights: 1.639344 
## Average number of links: 5 
## Non-symmetric neighbours list
## Link number distribution:
## 
##   5 
## 305 
## 305 least connected regions:
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 with 5 links
## 305 most connected regions:
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 with 5 links
## 
## Weights style: B 
## Weights constants summary:
##     n    nn   S0   S1    S2
## B 305 93025 1525 2719 31372

Gi statistics using adaptive distance

gi.adaptive <- localG(combined_data.localMI$TOTAL_TAP_IN_VOLUME, knb_lw)
combined_data.gi <- cbind(combined_data.localMI, as.matrix(gi.adaptive))
names(combined_data.gi)[16] <- "gstat_adaptive"

Mapping Gi values

tm_shape(combined_data.gi) +
  tm_fill(col = "gstat_adaptive",
          style = "pretty",
          palette = "-RdBu",
          title = "local Gi") +
  tm_borders(alpha = 0.5)
## Warning: The shape combined_data.gi is invalid. See sf::st_is_valid
## Variable(s) "gstat_adaptive" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

The red / orange areas are the hotspots with relatively high local Gi, which means high commuter tap-in flow, large number of trips are generated at that subzone. They can be considered as hotspots because they are both significant and postive. On the other hand, the blue areas are the cold spot; significant and negative.

tmap_mode("plot")
## tmap mode set to plotting