Take Home Exercise 1

Author

Oh Jia Wen

Published

November 25, 2023

Modified

December 3, 2023

1. Overview

The digitization of city-wide urban infrastructures such as buses,mass rapid transit enable collection of massive data sets on patterns such as human movement and behaviors within the city. In real-world practices, the use of these data are confined to simple tracking and mapping with GIS applications due to the lack of functions in conventional GIS.

1.1 The Task

This exercise aims to reveals the spatial and spatio-temporal mobility patterns of public bus passengers in Singapore using appropriate geovisualisation techniques and analysis. Also, we would explore the computation of Local Indicators of Spatial Association (LISA) Analysis

The original data set was downloaded on 18th November 2023 from LTA DataMall under Section 2.6 - Passenger Volume by Origin Destination Bus Stops. It records the number of trips by weekdays and weekends from origin to destination bus stops. For the purpose of this exercise, we will be using the August data - origin_destination_bus_202308.csv.

2. Data preparation

2.1 Install R packages

The code chunk below uses pacman:: p_load() to load and install the following libraries:

  • mapview : Used to create interactive visualization of spatial data

  • knitr: Used for dynamic report generation

  • patchwork : Used to combine multiple ggplot graphs into the same graphic

  • sf : Used for geospatial data handling

  • spdep : Used to create spatial weights matrix objects

  • sfdep : Used to integrate with 'sf' objects and the 'tidyverse'

  • tidyverse: A collection of R packages use in everyday data analyses. It is able to support data science, data wrangling, and analysis

  • tmap : Used for thematic mapping

pacman::p_load(mapview, knitr, patchwork, sf, spdep, sfdep, tidyverse, tmap)

2.2 Import and Load Dataset

Two data and a hexagon layer will be used for this study :

  • origin_destination_bus_202308.csv : A csv file containing information about all the bus stops currently being serviced by bus, which includes bus stop identifier, and location coordinates.

  • Bus Stop Location . A geospatial file from LTA DataMall

  • hexagon : A hexagon layer of 250m to replace the relative coarse and irregular Master Plan 2019 Planning Sub-Zone GIS data of URA

2.2.1 Importing Aspatial data

First, we will import the Passenger Volume by Origin Destination Bus Stops data set for August by using readr::read_csv() and store it in variable odbus. Also, we will be using glimpse() report to reveal the data type of each field.

Point to note: ORIGIN_PT_CODE and DESTINATION_PT_CODE are in <chr> format.

Show the code
odbus <- read_csv("data/aspatial/origin_destination_bus_202308.csv")
glimpse(odbus)
Rows: 5,709,512
Columns: 7
$ YEAR_MONTH          <chr> "2023-08", "2023-08", "2023-08", "2023-08", "2023-…
$ DAY_TYPE            <chr> "WEEKDAY", "WEEKENDS/HOLIDAY", "WEEKENDS/HOLIDAY",…
$ TIME_PER_HOUR       <dbl> 16, 16, 14, 14, 17, 17, 17, 17, 7, 17, 14, 10, 10,…
$ PT_TYPE             <chr> "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "…
$ ORIGIN_PT_CODE      <chr> "04168", "04168", "80119", "80119", "44069", "4406…
$ DESTINATION_PT_CODE <chr> "10051", "10051", "90079", "90079", "17229", "1722…
$ TOTAL_TRIPS         <dbl> 7, 2, 3, 10, 5, 4, 3, 22, 3, 3, 7, 1, 3, 1, 3, 1, …

2.2.2 Importing Geospatial data

Thereafter, we will import the Bus Stops Location.

2.2.2.1 Import Bus Stop data

We will be using sf::st_read() to import and sf::st_transform() to ensure that the projected coordinate system is in the right format before storing in variable busstop. Also, we will be using glimpse() report to reveal the data type of each field.

busstop <- st_read(dsn = "data/geospatial",layer = "BusStop") %>%
    st_transform(crs = 3414)
Reading layer `BusStop' from data source 
  `/Users/smu/Rworkshop/jiawenoh/ISSS624/Take-Home_Ex/Take-Home_Ex01/data/geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 5161 features and 3 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 26482.1 xmax: 48284.56 ymax: 52983.82
Projected CRS: SVY21

The message above shows that there are a total of 5161 features and 3 fields in busstop point feature data frame and it is in SVY21 projected coordinates system.

glimpse(busstop)
Rows: 5,161
Columns: 4
$ BUS_STOP_N <chr> "22069", "32071", "44331", "96081", "11561", "66191", "2338…
$ BUS_ROOF_N <chr> "B06", "B23", "B01", "B05", "B05", "B03", "B02A", "B02", "B…
$ LOC_DESC   <chr> "OPP CEVA LOGISTICS", "AFT TRACK 13", "BLK 239", "GRACE IND…
$ geometry   <POINT [m]> POINT (13576.31 32883.65), POINT (13228.59 44206.38),…

crs : to provide the coordinates system in EPSG format.

EPSG: 4326 is wgs84 Geographic Coordinate System

EPSG : 3414 is Singapore SVY21 Projected Coordinate System.

For more information, do refer to epsg.io

2.3 Data Wrangling

Looking at the section 2.2.1, we noticed a few problem:

  • ORIGIN_PT_CODE : is in <chr> format.

  • DESTINATION_PT_CODE : is in <chr> format.

We will be using dplyr::mutate() to convert the <chr> data type to <fct> and store it in a new variable odbus_new.

Show the code
odbus_new <- odbus %>%
 mutate(ORIGIN_PT_CODE = as.factor(ORIGIN_PT_CODE),
        DESTINATION_PT_CODE = as.factor(DESTINATION_PT_CODE))

glimpse(odbus_new)
Rows: 5,709,512
Columns: 7
$ YEAR_MONTH          <chr> "2023-08", "2023-08", "2023-08", "2023-08", "2023-…
$ DAY_TYPE            <chr> "WEEKDAY", "WEEKENDS/HOLIDAY", "WEEKENDS/HOLIDAY",…
$ TIME_PER_HOUR       <dbl> 16, 16, 14, 14, 17, 17, 17, 17, 7, 17, 14, 10, 10,…
$ PT_TYPE             <chr> "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "BUS", "…
$ ORIGIN_PT_CODE      <fct> 04168, 04168, 80119, 80119, 44069, 44069, 20281, 2…
$ DESTINATION_PT_CODE <fct> 10051, 10051, 90079, 90079, 17229, 17229, 20141, 2…
$ TOTAL_TRIPS         <dbl> 7, 2, 3, 10, 5, 4, 3, 22, 3, 3, 7, 1, 3, 1, 3, 1, …

Additionally, we confirmed that there are no missing values in the odbus_new data set.

any(is.na(odbus_new))
[1] FALSE

2.3.1 Data Extraction

In this section, we will extract commuting flows based on the table below.

Peak hour period Bus tap on time
Weekday morning peak 6am to 9am
Weekday afternoon peak 5pm to 8pm
Weekend/holiday morning peak 11am to 2pm
Weekend/holiday evening peak 4pm to 7pm

The code is extracted in the following manner:

  • filter() is used to extract subset of data

  • between() is used to express a range condition

  • group_by() and summarise() are used to sum the total trips

  • arrange(desc()) to sort in descending order

  • ungroup() is used to end a definition, often use with group_by()

Show the code
#weekday morning peak 
wkd6_9 <- odbus_new %>%
  filter(DAY_TYPE == "WEEKDAY",
         between(TIME_PER_HOUR, 6, 9)) %>%
  group_by(ORIGIN_PT_CODE) %>%
  summarise(TRIPS = sum(TOTAL_TRIPS)) %>%
  arrange(desc(TRIPS)) %>%
  ungroup()

#weekday afternoon peak 
wkd17_20 <- odbus_new %>%
  filter(DAY_TYPE == "WEEKDAY",
         between(TIME_PER_HOUR, 17, 20)) %>%
  group_by(ORIGIN_PT_CODE) %>%
  summarise(TRIPS = sum(TOTAL_TRIPS)) %>%
  arrange(desc(TRIPS)) %>%
  ungroup()

#weekend/holiday morning peak 
wknd11_14 <- odbus_new %>%
  filter(DAY_TYPE == "WEEKENDS/HOLIDAY",
         between(TIME_PER_HOUR, 11, 14)) %>%
  group_by(ORIGIN_PT_CODE) %>%
  summarise(TRIPS = sum(TOTAL_TRIPS)) %>%
  arrange(desc(TRIPS)) %>%
  ungroup()

#weekend/holiday afternoon peak 
wknd16_19 <- odbus_new %>%
  filter(DAY_TYPE == "WEEKENDS/HOLIDAY",
         between(TIME_PER_HOUR, 16, 19)) %>%
  group_by(ORIGIN_PT_CODE) %>%
  summarise(TRIPS = sum(TOTAL_TRIPS)) %>%
  arrange(desc(TRIPS)) %>%
  ungroup()
kable(head(wkd6_9))
ORIGIN_PT_CODE TRIPS
22009 365871
46009 294601
75009 170187
52009 144079
24009 141698
55509 129362
kable(head(wkd17_20))
ORIGIN_PT_CODE TRIPS
22009 536630
46009 457783
75009 352578
59009 315889
84009 227886
52009 224010
kable(head(wknd11_14))
ORIGIN_PT_CODE TRIPS
22009 102210
46009 95185
59009 73678
75009 73479
84009 67932
52009 63651
kable(head(wknd16_19))
ORIGIN_PT_CODE TRIPS
22009 143443
46009 118771
75009 97207
59009 88385
84009 74928
52009 70262

Thereafter, we will save a copy of the output in rds format and reload it into the environment.

Show the code
#weekday morning peak 
write_rds(wkd6_9, "data/rds/wkd6_9.rds")
wkd6_9 <- read_rds("data/rds/wkd6_9.rds")

#weekday afternoon peak 
write_rds(wkd17_20, "data/rds/wkd17_20.rds")
wkd17_20 <- read_rds("data/rds/wkd17_20.rds")

#weekend/holiday morning peak 
write_rds(wknd11_14, "data/rds/wknd11_14.rds")
wknd11_14 <- read_rds("data/rds/wknd11_14.rds")

#weekend/holiday afternoon peak 
write_rds(wknd16_19, "data/rds/wknd16_19.rds")
wknd16_19 <- read_rds("data/rds/wknd16_19.rds")

2.3.2 Combining Data

Before we proceed, we will used mapview() as a default visualization.

Show the code
mapview_check = mapview(busstop, cex = 3, alpha = .5, popup = NULL)

mapview_check

As observed, there are 5 bus stops that are not within Singapore Map that includes Passenger Volume by Origin Destination Bus Stop. Although we are able to filter and remove bus stops that are not within the Singapore Boundary, it might be interesting to observe the community flows from Singapore to Johor Bahru. As such we will not remove these data points.

2.3.2.1 Combine commuting flow into busstop

After populating the commuting flow, we will combine it into busstop sf data frame. To ensure that all bus stops are distinct, we will be using dplyr:: mutate() to replace N/A to 0 and add unique() function into our code to keep distinct flows.

Show the code
#weekday morning peak 
origin_SZ_wkd6_9 <- left_join(busstop, wkd6_9,
            by = c("BUS_STOP_N" = "ORIGIN_PT_CODE")) %>%
      mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  unique() %>%
  ungroup()

#weekday afternoon peak 
origin_SZ_wkd17_20 <- left_join(busstop, wkd17_20,
            by = c("BUS_STOP_N" = "ORIGIN_PT_CODE")) %>%
      mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  unique() %>%
  ungroup()

#weekend/holiday morning peak 
origin_SZ_wknd11_14 <- left_join(busstop, wknd11_14,
            by = c("BUS_STOP_N" = "ORIGIN_PT_CODE")) %>%
      mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  unique() %>%
  ungroup()

#weekend/holiday afternoon peak 
origin_SZ_wknd16_19 <- left_join(busstop, wknd16_19,
            by = c("BUS_STOP_N" = "ORIGIN_PT_CODE")) %>%
      mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  unique() %>%
  ungroup()

2.3.2.2 Create Hexagon Layer

Hexagons are the densest way to pack circles in tessellation and reduce edge effects. With reference to Urban Data Palette, we will create honeycomb grid through the following steps:

  • st_make_grid() : create a regular grid of spatial polygons. Revision have been done to the cell width and height to c(500,500).

  • st_sf() : convert the honeycomb grid object to an sf object. Grid ID is created to count the number of bus stops and sum of trips in the grid.

  • st_intersects() : determine whether two sets of spatial objects intersect.

  • st_join() : join two spatial objects based on their spatial relationships by intersections.

Show the code
#weekday morning peak 
honeycomb_grid_wkd6_9 = st_make_grid(origin_SZ_wkd6_9, c(500, 500), #cell revised
                              what = "polygons", square = FALSE)
honeycomb_grid_sf_0609 = st_sf(honeycomb_grid_wkd6_9) %>%
  mutate(grid_id = 1:length(lengths(honeycomb_grid_wkd6_9)))
intersections0609 <- st_intersects(origin_SZ_wkd6_9, honeycomb_grid_sf_0609)
join_df0609 <- st_join(honeycomb_grid_sf_0609, origin_SZ_wkd6_9, by = intersections0609)

#weekday afternoon peak 
honeycomb_grid_wkd17_20 = st_make_grid(origin_SZ_wkd17_20, c(500, 500), 
                              what = "polygons", square = FALSE)
honeycomb_grid_sf_1720 = st_sf(honeycomb_grid_wkd17_20) %>%
  mutate(grid_id = 1:length(lengths(honeycomb_grid_wkd17_20)))
intersections1720 <- st_intersects(origin_SZ_wkd17_20, honeycomb_grid_sf_1720)
join_df1720 <- st_join(honeycomb_grid_sf_1720, origin_SZ_wkd17_20, by = intersections1720)

#weekend/holiday morning peak 
honeycomb_grid_wknd11_14 = st_make_grid(origin_SZ_wknd11_14, c(500, 500), 
                              what = "polygons", square = FALSE)
honeycomb_grid_sf_1114 = st_sf(honeycomb_grid_wknd11_14) %>%
  mutate(grid_id = 1:length(lengths(honeycomb_grid_wknd11_14)))
intersections1114 <- st_intersects(origin_SZ_wknd11_14, honeycomb_grid_sf_1114)
join_df1114 <- st_join(honeycomb_grid_sf_1114, origin_SZ_wknd11_14, by = intersections1114)

#weekend/holiday afternoon peak 
honeycomb_grid_wknd16_19 = st_make_grid(origin_SZ_wknd16_19, c(500, 500), 
                              what = "polygons", square = FALSE)
honeycomb_grid_sf_1619 = st_sf(honeycomb_grid_wknd16_19) %>%
  mutate(grid_id = 1:length(lengths(honeycomb_grid_wknd16_19)))
intersections1619 <- st_intersects(origin_SZ_wknd16_19, honeycomb_grid_sf_1619)
join_df1619 <- st_join(honeycomb_grid_sf_1619, origin_SZ_wknd16_19, by = intersections1619)

2.3.2.3 Extract Data

After creating the joined data frame, we are interested in knowing the number of bus stops that is in the grid_id and the total number of trips. As such, we performed the following steps:

  • mutate() : Used to replace TRIPS with N/A to 0.

  • filter() : Used to remove data with 0 trip

  • group_by(): Used to group data based on grid_id.

  • summarize() :

    • n() : Used to count number of bus stops and save as bus_stop_count

    • sum() : Used to sum the TRIPS values and save as total_trips

  • ungroup() : Used to end a definition, often use with group_by()

Show the code
#weekday morning peak 
join_df_wkd6_9_group <- join_df0609 %>%
        mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  filter(TRIPS > 0) %>%
  group_by(grid_id) %>%
  summarize(
    bus_stop_count = n(),
    total_trips = sum(TRIPS)
  ) %>%
  ungroup()

#weekday afternoon peak 
join_df_wkd17_20_group <- join_df1720 %>%
        mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  filter(TRIPS > 0) %>%
  group_by(grid_id) %>%
  summarize(
    bus_stop_count = n(),
    total_trips = sum(TRIPS)
  ) %>%
  ungroup()

#weekend/holiday morning peak 
join_df_wknd11_14_group <- join_df1114 %>%
        mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  filter(TRIPS > 0) %>%
  group_by(grid_id) %>%
  summarize(
    bus_stop_count = n(),
    total_trips = sum(TRIPS)
  ) %>%
  ungroup()

#weekend/holiday afternoon peak 
join_df_wknd16_19_group <- join_df1619 %>%
        mutate(TRIPS = ifelse(is.na(TRIPS), 0, TRIPS)) %>%
  filter(TRIPS > 0) %>%
  group_by(grid_id) %>%
  summarize(
    bus_stop_count = n(),
    total_trips = sum(TRIPS)
  ) %>%
  ungroup()

To validate that our sf data frame does not contain any missing value, we used any(is.na()) to check :

Show the code
cat('Are there any missing value for Weekday Morning Peak?: ', any(is.na(join_df_wkd6_9_group)),'\n')
Are there any missing value for Weekday Morning Peak?:  FALSE 
Show the code
cat('Are there any missing value for Weekday Afternoon Peak?: ', any(is.na(join_df_wkd17_20_group)),'\n')
Are there any missing value for Weekday Afternoon Peak?:  FALSE 
Show the code
cat('Are there any missing value for Weekend/Holiday Morning Peak?: ', any(is.na(join_df_wknd11_14_group)),'\n')
Are there any missing value for Weekend/Holiday Morning Peak?:  FALSE 
Show the code
cat('Are there any missing value for Weekend/Holiday Afternoon Peak?: ', any(is.na(join_df_wknd16_19_group)),'\n')
Are there any missing value for Weekend/Holiday Afternoon Peak?:  FALSE 

We have confirmed that there are no missing values for any of data frame.

3. Geovisualisation

After extracting the data, we are able to observe the number of bus stops in each grid based on the grid_id. We will use the ggplot() funcion to visualize the distribution of bus stops in the hexagon grid.

Show the code
ggplot(data= join_df_wkd6_9_group, 
       aes(x= bus_stop_count)) +
  geom_bar(aes(fill = bus_stop_count), show.legend = FALSE) +
  geom_text(stat = 'count',
           aes(label= paste0(stat(count), ', ', 
                             round(stat(count)/sum(stat(count))*100, 
                             2), '%')), vjust= -0.5, size= 2.0) +
  labs(y= 'No. of Grids', x= 'Count',
       title = "Distribution of Bus Stops in Hexagon Grid ") +
  scale_x_continuous(breaks = join_df_wkd6_9_group$bus_stop_count) +
  theme_minimal() 

Show the code
ggplot(data= join_df_wkd17_20_group, 
       aes(x= bus_stop_count)) +
  geom_bar(aes(fill = bus_stop_count), show.legend = FALSE) +
  geom_text(stat = 'count',
           aes(label= paste0(stat(count), ', ', 
                             round(stat(count)/sum(stat(count))*100, 
                             2), '%')), vjust= -0.5, size= 2.0) +
  labs(y= 'No. of Grids', x= 'Count',
       title = "Distribution of Bus Stops in Hexagon Grid ") +
  scale_x_continuous(breaks = join_df_wkd17_20_group$bus_stop_count) +
  theme_minimal() 

Show the code
ggplot(data= join_df_wknd11_14_group, 
       aes(x= bus_stop_count)) +
  geom_bar(aes(fill = bus_stop_count), show.legend = FALSE) +
  geom_text(stat = 'count',
           aes(label= paste0(stat(count), ', ', 
                             round(stat(count)/sum(stat(count))*100, 
                             2), '%')), vjust= -0.5, size= 2.0) +
  labs(y= 'No. of Grids', x= 'Count',
       title = "Distribution of Bus Stops in Hexagon Grid ") +
  scale_x_continuous(breaks = join_df_wknd11_14_group$bus_stop_count) +
  theme_minimal() 

Show the code
ggplot(data= join_df_wknd16_19_group, 
       aes(x= bus_stop_count)) +
  geom_bar(aes(fill = bus_stop_count), show.legend = FALSE) +
  geom_text(stat = 'count',
           aes(label= paste0(stat(count), ', ', 
                             round(stat(count)/sum(stat(count))*100, 
                             2), '%')), vjust= -0.5, size= 2.0) +
  labs(y= 'No. of Grids', x= 'Count',
       title = "Distribution of Bus Stops in Hexagon Grid ") +
  scale_x_continuous(breaks = join_df_wknd16_19_group$bus_stop_count) +
  theme_minimal() 

From the graphs, we noticed that the distributions based on the commuting flow at any given time frame, are right-skewed. In comparison, the differences between various time period are not significant. 27% of the grids contain two bus stops while 75% of the grids range between one to four bus stops.

3.1 Commuting flows

We will now plot the choropleth map using tmap and compare between quantile and jenks classification. Quantile maps try to arrange groups so they have the same quantity. As a result, the shading will look equally distributed in quantile types of maps. Jenks map is an optimization method for choropleth maps as it arranges each grouping so there is less variation in each class or shading.

In the code chuck below, we will use tmap to plot the spatial distribution of the passenger volume (Total Trips) based on the hexagon grid. We will use tmap_arrange() to show the plots together.

Show the code
#weekday morning peak 
plot0609 <- tm_shape(join_df_wkd6_9_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "quantile", 
          palette = "Blues",
          title = "Total Trips") +
  tm_layout(main.title = "Weekday Morning Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekday afternoon peak 
plot1720 <- tm_shape(join_df_wkd17_20_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "quantile", 
          palette = "Blues",
          title = "Total Trips") +
  tm_layout(main.title = "Weekday Afternoon Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekend/holiday morning peak 
plot1114 <- tm_shape(join_df_wknd11_14_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "quantile", 
          palette = "Blues",
          title = "Total Trips") +
  tm_layout(main.title = "Weekend/Holiday Morning Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekend/holiday afternoon peak 
plot1619 <- tm_shape(join_df_wknd16_19_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "quantile", 
          palette = "Blues",
          title = "Total Trips") +
  tm_layout(main.title = "Weekend/Holiday Afternoon Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15,       
             position = c("left", "bottom"))

tmap_arrange(plot0609, plot1720, plot1114, plot1619, asp=2, ncol=2)

Show the code
#weekday morning peak 
plot0609j <- tm_shape(join_df_wkd6_9_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "jenks", 
          palette = "Reds",
          title = "Total Trips") +
  tm_layout(main.title = "Weekday Morning Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekday afternoon peak 
plot1720j <- tm_shape(join_df_wkd17_20_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "jenks", 
          palette = "Reds",
          title = "Total Trips") +
  tm_layout(main.title = "Weekday Afternoon Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekend/holiday morning peak 
plot1114j <- tm_shape(join_df_wknd11_14_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "jenks", 
          palette = "Reds",
          title = "Total Trips") +
  tm_layout(main.title = "Weekend/Holiday Morning Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15, 
             position = c("left", "bottom"))

#weekend/holiday afternoon peak 
plot1619j <- tm_shape(join_df_wknd16_19_group) +
  tm_borders(alpha = 0.5) +
  tm_fill("total_trips", 
          style = "jenks", 
          palette = "Reds",
          title = "Total Trips") +
  tm_layout(main.title = "Weekend/Holiday Afternoon Peak passenger trips by Origin",
            main.title.position = "center",
            main.title.fontface = "bold",
            main.title.size = 0.6,
            legend.height = 0.3, 
            legend.width = 0.3,
            frame = TRUE) +
  tm_credits("Source: Population data from \n Department of Statistics (DOS)", 
             fontface = "italic",  
             size = 0.15,       
             position = c("left", "bottom"))

tmap_arrange(plot0609j, plot1720j, plot1114j, plot1619j, asp=2, ncol=2)

Observations:

By looking at the 4 quantitle chloropleth maps (in blue), we could infer the following:

  • Passenger volume is significantly higher on Weekday than Weekends/Holidays. It ranges around 400k-550k on Weekdays and 110k-150k on Weekends/Holidays.

  • Majority of the bus stops in the Central and Southern region of Singapore have a relatively higher passenger volume compared to other regions.

  • A quick visualization from the mapview in Section 2.3.2 revealed the location in the red circle as Woodlands - Johor Bahru, Malaysia while the red rectangle is in Tanan Merah. Interestingly, as seen in the red circle, the volume have not declined regardless of time period. People are still travelling to Johor Bahru, Malaysia at any given point.

  • On the contrary, as seen in the red rectangle, the volume changes. It peaks during the Weekend/Holiday period compared to Weekdays. which could be a popular hangout for people over the weekends.

As observed in Section 3, our data are skewed to one end. Thus, it is not as ideal for us to use the quantile data classification method. We will look at the 4 jenks chloropleth maps (in red).

  • As identified earlier in the quantile map about the red rectangle at Tanan Merah, we noted the peak is only on the Weekend/Holiday Afternoon. Based on the natural grouping in the data, we are affirmed that the passenger volume towards Johor Bahru, Malaysia remains at the peak throughout the week, and throughout the day.

  • From the Jenks Classification maps, we have two new observations. From the red and blue circle, we identified that the passenger volume surge on Weekday Morning Peak hour.

  • In comparison, there are more bus stops with higher passenger volume in Weekday Morning followed by Weekend/Holiday Afternoon.

4. GeoSpatial Autocorrelation

In this section, we will explore the computation of Global and Local Measures of Spatial Association, with further focus on Local Indicators of Spatial Association (LISA) Analysis through the sfdep package. We will perform the Moran’s I test which can be classified as positive, negative, and with no spatial auto-correlation. The goal is our analysis is to understand more about the passenger volume across the time period.

4.1 Define Neighborhood

Before we perform the Moran’s I test, we would need to determine which locations are considered neighbors. As such, we will be using the queen method from the spdep:: poly2nb() package to compute contiguity spatial weights to identify adjacent neighbors.

wm_q0609 <- poly2nb(join_df_wkd6_9_group, queen=TRUE)
summary(wm_q0609)
Neighbour list object:
Number of regions: 1493 
Number of nonzero links: 6726 
Percentage nonzero weights: 0.301743 
Average number of links: 4.505023 
12 regions with no links:
276 296 454 550 713 964 1030 1388 1478 1481 1485 1493
Link number distribution:

  0   1   2   3   4   5   6 
 12  40 102 207 286 359 487 
40 least connected regions:
1 7 22 38 98 166 183 184 185 191 207 214 253 257 260 551 595 629 683 695 719 738 755 771 855 990 1004 1005 1029 1069 1194 1437 1444 1455 1473 1474 1476 1479 1483 1492 with 1 link
487 most connected regions:
10 13 16 17 24 25 31 35 42 43 48 53 55 60 63 67 73 77 80 81 84 85 87 88 91 92 97 102 107 111 117 121 127 132 138 139 141 145 146 147 151 152 153 154 160 161 162 170 171 172 179 180 181 187 188 189 190 196 197 198 201 202 203 204 212 225 235 239 240 242 252 268 272 280 287 289 290 291 293 299 300 302 303 306 311 314 315 317 327 328 329 330 333 342 345 353 358 380 381 390 392 393 397 404 408 413 415 421 426 427 428 430 433 440 441 442 450 456 457 458 459 463 467 470 471 478 482 483 485 491 492 496 502 503 506 507 512 518 523 528 532 537 538 539 541 545 547 553 557 562 563 565 566 570 579 580 583 587 588 592 593 597 603 607 611 613 620 623 624 625 635 636 637 641 642 644 645 646 656 657 658 664 667 668 669 674 675 677 678 687 688 691 692 693 700 703 704 711 714 715 716 727 728 742 744 745 747 758 761 762 763 764 769 770 774 775 776 779 780 781 782 786 787 792 793 796 797 798 799 805 806 809 810 811 816 817 818 827 829 830 832 833 834 836 837 838 839 840 846 849 851 852 853 857 858 862 863 864 866 867 868 870 871 874 877 879 882 885 888 890 891 895 899 904 906 911 912 913 915 916 920 928 929 930 931 932 933 938 942 943 946 947 952 953 955 956 957 961 967 968 969 970 971 973 979 980 981 982 987 994 995 996 997 1007 1008 1009 1011 1012 1019 1020 1021 1025 1033 1034 1037 1039 1040 1045 1046 1047 1049 1050 1051 1052 1059 1061 1062 1063 1066 1072 1076 1083 1084 1085 1088 1089 1093 1094 1100 1103 1104 1105 1111 1116 1117 1118 1119 1124 1125 1127 1128 1129 1130 1131 1133 1139 1140 1141 1145 1146 1147 1149 1151 1152 1153 1154 1158 1159 1160 1161 1162 1166 1168 1171 1172 1173 1174 1175 1181 1182 1183 1184 1185 1186 1187 1190 1191 1197 1198 1199 1200 1201 1207 1213 1214 1215 1219 1224 1225 1231 1233 1234 1235 1240 1244 1245 1250 1251 1252 1256 1259 1261 1267 1276 1279 1280 1281 1294 1299 1300 1301 1302 1304 1305 1306 1309 1310 1312 1318 1327 1329 1330 1338 1339 1341 1344 1345 1350 1353 1354 1355 1357 1361 1364 1366 1368 1371 1379 1381 1385 1390 1391 1393 1397 1398 1399 1400 1401 1406 1407 1408 1409 1413 1414 1415 1419 1420 1422 1424 1426 1429 1430 1432 1433 1434 1435 1442 with 6 links
wm_q1720 <- poly2nb(join_df_wkd17_20_group, queen=TRUE)
summary(wm_q1720)
Neighbour list object:
Number of regions: 1495 
Number of nonzero links: 6734 
Percentage nonzero weights: 0.3012942 
Average number of links: 4.504348 
12 regions with no links:
277 297 455 551 714 965 1032 1390 1480 1483 1487 1495
Link number distribution:

  0   1   2   3   4   5   6 
 12  37 107 206 287 359 487 
37 least connected regions:
1 7 22 38 98 166 184 192 208 215 254 258 261 552 596 630 684 696 720 739 756 772 856 1006 1007 1031 1071 1196 1439 1446 1457 1475 1476 1478 1481 1485 1494 with 1 link
487 most connected regions:
10 13 16 17 24 25 31 35 42 43 48 53 55 60 63 67 73 77 80 81 84 85 87 88 91 92 97 102 107 111 117 121 127 132 138 139 141 145 146 147 151 152 153 154 160 161 162 170 171 172 180 181 182 188 189 190 191 197 198 199 202 203 204 205 213 226 236 240 241 243 253 269 273 281 288 290 291 292 294 300 301 303 304 307 312 315 316 318 328 329 330 331 334 343 346 354 359 381 382 391 393 394 398 405 409 414 416 422 427 428 429 431 434 441 442 443 451 457 458 459 460 464 468 471 472 479 483 484 486 492 493 497 503 504 507 508 513 519 524 529 533 538 539 540 542 546 548 554 558 563 564 566 567 571 580 581 584 588 589 593 594 598 604 608 612 614 621 624 625 626 636 637 638 642 643 645 646 647 657 658 659 665 668 669 670 675 676 678 679 688 689 692 693 694 701 704 705 712 715 716 717 728 729 743 745 746 748 759 762 763 764 765 770 771 775 776 777 780 781 782 783 787 788 793 794 797 798 799 800 806 807 810 811 812 817 818 819 828 830 831 833 834 835 837 838 839 840 841 847 850 852 853 854 858 859 863 864 865 867 868 869 871 872 875 878 880 883 886 889 891 892 896 900 905 907 912 913 914 916 917 921 929 930 931 932 933 934 939 943 944 947 948 953 954 956 957 958 962 969 970 971 972 973 975 981 982 983 984 989 996 997 998 999 1009 1010 1011 1013 1014 1021 1022 1023 1027 1035 1036 1039 1041 1042 1047 1048 1049 1051 1052 1053 1054 1061 1063 1064 1065 1068 1074 1078 1085 1086 1087 1090 1091 1095 1096 1102 1105 1106 1107 1113 1118 1119 1120 1121 1126 1127 1129 1130 1131 1132 1133 1135 1141 1142 1143 1147 1148 1149 1151 1153 1154 1155 1156 1160 1161 1162 1163 1164 1168 1170 1173 1174 1175 1176 1177 1183 1184 1185 1186 1187 1188 1189 1192 1193 1199 1200 1201 1202 1203 1209 1215 1216 1217 1221 1226 1227 1233 1235 1236 1237 1242 1246 1247 1252 1253 1254 1258 1261 1263 1269 1278 1281 1282 1283 1296 1301 1302 1303 1304 1306 1307 1308 1311 1312 1314 1320 1329 1331 1332 1340 1341 1343 1346 1347 1352 1355 1356 1357 1359 1363 1366 1368 1370 1373 1381 1383 1387 1392 1393 1395 1399 1400 1401 1402 1403 1408 1409 1410 1411 1415 1416 1417 1421 1422 1424 1426 1428 1431 1432 1434 1435 1436 1437 1444 with 6 links
wm_q1114 <- poly2nb(join_df_wknd11_14_group, queen=TRUE)
summary(wm_q1114)
Neighbour list object:
Number of regions: 1499 
Number of nonzero links: 6734 
Percentage nonzero weights: 0.2996883 
Average number of links: 4.492328 
11 regions with no links:
297 454 550 712 963 1030 1394 1484 1487 1491 1499
Link number distribution:

  0   1   2   3   4   5   6 
 11  41 109 206 286 363 483 
41 least connected regions:
1 7 22 38 96 164 180 181 182 188 204 211 250 251 256 259 277 551 594 628 682 694 718 737 754 770 854 1004 1005 1029 1069 1196 1443 1450 1461 1479 1480 1482 1485 1489 1498 with 1 link
483 most connected regions:
10 13 16 17 24 25 31 35 42 43 48 53 54 59 62 66 72 76 79 80 83 86 87 89 100 105 109 115 119 125 130 136 137 139 143 144 145 150 151 152 159 160 167 168 169 176 177 178 184 185 186 187 193 194 195 198 199 200 201 209 222 232 236 237 239 249 269 273 281 288 290 291 292 294 300 301 303 304 307 312 315 316 318 328 329 330 331 334 343 346 354 359 381 382 391 393 394 397 404 408 413 415 421 426 427 428 430 433 440 441 442 450 456 457 458 459 463 467 470 471 478 482 483 485 491 492 496 502 503 506 507 512 518 523 528 532 537 538 539 541 545 547 552 556 562 564 565 569 578 579 582 586 587 591 592 596 602 606 610 612 619 622 623 624 634 635 636 640 641 643 644 645 655 656 657 663 666 667 668 673 674 676 677 686 687 690 691 692 699 702 703 710 713 714 715 726 727 741 743 744 746 757 760 761 762 763 768 769 773 774 775 778 779 780 781 785 786 791 792 795 796 797 798 804 805 808 809 810 815 816 817 826 828 829 831 832 833 835 836 837 838 839 845 848 850 851 852 856 857 861 862 863 865 866 867 869 870 873 876 878 881 884 887 889 890 894 898 903 905 910 911 912 914 915 919 927 928 929 930 931 932 937 941 942 945 946 951 952 954 955 956 960 967 968 969 970 971 973 979 980 981 982 987 994 995 996 997 1007 1008 1009 1011 1012 1019 1020 1021 1025 1033 1034 1037 1039 1040 1045 1046 1047 1049 1050 1051 1052 1059 1061 1062 1063 1066 1072 1076 1083 1084 1085 1088 1089 1093 1094 1100 1103 1104 1105 1111 1116 1117 1118 1119 1124 1125 1127 1128 1129 1130 1131 1133 1139 1140 1141 1145 1146 1147 1149 1152 1153 1154 1155 1159 1160 1161 1162 1163 1167 1169 1172 1173 1174 1175 1176 1183 1184 1185 1186 1187 1188 1189 1192 1193 1199 1200 1201 1202 1203 1209 1215 1216 1217 1221 1226 1227 1233 1235 1236 1237 1243 1247 1248 1253 1254 1255 1259 1262 1264 1270 1279 1281 1282 1283 1284 1296 1298 1304 1305 1306 1307 1309 1310 1311 1314 1315 1317 1323 1332 1334 1335 1344 1345 1347 1350 1351 1356 1359 1360 1361 1363 1367 1370 1372 1374 1377 1385 1387 1391 1396 1397 1399 1403 1404 1405 1406 1407 1412 1413 1414 1415 1419 1420 1421 1425 1426 1428 1430 1432 1435 1436 1438 1439 1440 1441 1448 with 6 links
wm_q1619 <- poly2nb(join_df_wknd16_19_group, queen=TRUE)
summary(wm_q1619)
Neighbour list object:
Number of regions: 1489 
Number of nonzero links: 6688 
Percentage nonzero weights: 0.3016525 
Average number of links: 4.491605 
11 regions with no links:
300 457 553 712 960 1026 1390 1476 1479 1483 1489
Link number distribution:

  0   1   2   3   4   5   6 
 11  42 108 208 277 360 483 
42 least connected regions:
1 7 22 38 98 166 183 184 185 191 207 214 253 254 259 262 280 554 596 629 682 694 718 737 754 770 805 851 986 1000 1001 1025 1065 1192 1439 1446 1456 1471 1472 1474 1477 1481 with 1 link
483 most connected regions:
10 13 16 17 24 25 31 35 42 43 48 53 55 60 63 67 73 77 80 81 84 85 87 88 91 92 97 102 107 111 117 121 127 132 138 139 141 145 146 147 151 152 153 154 160 161 162 170 171 172 179 180 181 187 188 189 190 196 197 198 201 202 203 204 212 225 235 239 240 242 252 272 276 284 291 293 294 295 297 303 304 306 307 310 315 318 319 321 331 332 333 334 337 346 349 357 362 384 385 394 396 397 400 407 411 416 418 424 429 430 431 433 436 443 444 445 453 459 460 461 462 466 470 473 474 481 485 486 488 494 495 499 505 506 509 510 515 521 526 531 535 540 541 542 544 548 550 555 559 565 567 568 572 581 582 585 589 590 593 594 598 604 608 611 613 620 623 624 625 634 635 636 640 643 644 645 655 656 657 663 666 667 668 673 674 676 677 686 687 690 691 692 699 702 703 710 713 714 715 726 727 741 743 744 746 757 760 761 762 763 768 769 773 774 775 778 779 780 781 785 786 790 791 794 795 796 797 803 804 806 807 808 813 814 815 824 828 829 830 832 833 834 835 836 842 847 848 849 853 854 858 859 860 862 863 866 867 870 873 875 878 881 884 886 887 891 895 900 902 907 908 909 911 912 916 924 925 926 927 928 929 934 938 939 942 943 948 949 951 952 953 957 963 964 965 966 967 969 975 976 977 978 983 990 991 992 993 1003 1004 1005 1007 1008 1015 1016 1017 1021 1029 1030 1033 1035 1036 1041 1042 1043 1045 1046 1047 1048 1055 1057 1058 1059 1062 1068 1072 1079 1080 1081 1084 1085 1089 1090 1096 1099 1100 1101 1107 1112 1113 1114 1115 1120 1121 1123 1124 1125 1126 1127 1129 1135 1136 1137 1141 1142 1143 1145 1148 1149 1150 1151 1155 1156 1157 1158 1159 1163 1165 1168 1169 1170 1171 1172 1179 1180 1181 1182 1183 1184 1185 1188 1189 1195 1196 1197 1198 1199 1205 1211 1212 1213 1217 1222 1223 1229 1231 1232 1233 1239 1243 1244 1249 1250 1251 1255 1258 1260 1266 1275 1277 1278 1279 1280 1292 1294 1300 1301 1302 1303 1305 1306 1307 1310 1311 1313 1319 1328 1330 1331 1340 1341 1343 1346 1347 1352 1355 1356 1357 1359 1363 1366 1368 1370 1373 1381 1383 1387 1392 1393 1395 1399 1400 1401 1402 1403 1408 1409 1410 1411 1415 1416 1417 1421 1422 1424 1426 1428 1431 1432 1434 1435 1436 1437 1444 with 6 links

From the summary report above, the region range from 1,483 to 1,499. On average , each area is contigious with about 4 other grids. However, there are 11/12 regions that does not have any contigious neighbors. Therefore, we would not be using Contiguity-based Spatial Weights for further analysis.

4.2 Deriving the centroid

Instead, we are interested in the distanced-based contiguity. To begin, we will get the coordinates of polygon centroids for each area of the commuting flows. We will be using the st_centroid() function to calculate the geometric center of a spatial object.

Show the code
#weekday morning peak 
coords0609 <- st_centroid(st_geometry(join_df_wkd6_9_group))
coords0609[1]
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 28214.15 xmax: 3970.122 ymax: 28214.15
Projected CRS: SVY21 / Singapore TM
Show the code
#weekday afternoon peak 
coords1720 <- st_centroid(st_geometry(join_df_wkd17_20_group))
coords1720[1]
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 28214.15 xmax: 3970.122 ymax: 28214.15
Projected CRS: SVY21 / Singapore TM
Show the code
#weekend/holiday morning peak 
coords1114 <- st_centroid(st_geometry(join_df_wknd11_14_group))
coords1114[1]
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 28214.15 xmax: 3970.122 ymax: 28214.15
Projected CRS: SVY21 / Singapore TM
Show the code
#weekend/holiday afternoon peak 
coords1619 <- st_centroid(st_geometry(join_df_wknd16_19_group))
coords1619[1]
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 3970.122 ymin: 28214.15 xmax: 3970.122 ymax: 28214.15
Projected CRS: SVY21 / Singapore TM

4.3 Determine the cut-off distance

Thereafter, we will need to determine the cut-off distance by looking at the upper bound. We will be using knearneigh() of spdep to identify the k nearest neighbors of each other. If longlat = TRUE, it computes the Euclidean distance with a lower and upper bounds by doing the following:

  • Return a matrix with the indices of points belonging to the set of the k nearest neighbors of each other by using knearneigh() of spdep.

  • Convert the knn object returned by knearneigh() into a neighbors list of class nb with a list of integer vectors containing neighbor region number ids by using knn2nb().

  • Return the length of neighbor relationship edges by using nbdists() of spdep. The function returns in the units of the coordinates if the coordinates are projected, in km otherwise.

  • Remove the list structure of the returned object by using unlist().

k0609 <- knn2nb(knearneigh(coords0609, k = 1))
k0609dists <- unlist(nbdists(k0609, coords0609))
summary(k0609dists)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  500.0   500.0   500.0   507.2   500.0  4582.6 
k1720 <- knn2nb(knearneigh(coords1720, k = 1))
k1720dists <- unlist(nbdists(k1720, coords1720))
summary(k1720dists)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  500.0   500.0   500.0   507.2   500.0  4582.6 
k1114 <- knn2nb(knearneigh(coords1114, k = 1))
k1114dists <- unlist(nbdists(k1114, coords1114))
summary(k1114dists)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    500     500     500     507     500    4583 
k1619 <- knn2nb(knearneigh(coords1619, k = 1))
k1619dists <- unlist(nbdists(k1619, coords1619))
summary(k1619dists)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    500     500     500     507     500    4583 

From the summary reports above, the largest first nearest neighbor distance is 4,582km (lowest value among the four commuting flows). Thus, we will use this as the upper threshold such that all units will have at least one neighbor.

4.4 Computing Fixed distance weight matrix

Knowing the upper threshold, we will be able to compute the fixed distance weight matrix. We will compute the distance weight matrix by using dnearneigh() as shown below.

Show the code
#weekday morning peak 
wm_d0609 <- dnearneigh(coords0609,0,4582)
wm_d0609
Neighbour list object:
Number of regions: 1493 
Number of nonzero links: 229408 
Percentage nonzero weights: 10.29174 
Average number of links: 153.6557 
1 region with no links:
296
Show the code
#weekday afternoon peak 
wm_d1720 <- dnearneigh(coords1720,0,4582)
wm_d1720
Neighbour list object:
Number of regions: 1495 
Number of nonzero links: 229676 
Percentage nonzero weights: 10.27622 
Average number of links: 153.6294 
1 region with no links:
297
Show the code
#weekend/holiday morning peak 
wm_d1114 <- dnearneigh(coords1114,0,4582)
wm_d1114
Neighbour list object:
Number of regions: 1499 
Number of nonzero links: 230220 
Percentage nonzero weights: 10.24566 
Average number of links: 153.5824 
1 region with no links:
297
Show the code
#weekend/holiday afternoon peak 
wm_d1619 <- dnearneigh(coords1619,0,4582)
wm_d1619
Neighbour list object:
Number of regions: 1489 
Number of nonzero links: 228436 
Percentage nonzero weights: 10.30327 
Average number of links: 153.4157 
1 region with no links:
300

From the output across the commuting flows, we identify an average of 153 neighbors per grid using the distance based weight matrix.

Next, nb2listw() is used to convert the nb object into spatial weights object.

Show the code
#weekday morning peak 
wm0609_lw <- nb2listw(wm_d0609, style = 'B',zero.policy = TRUE)

#weekday afternoon peak 
wm1720_lw <- nb2listw(wm_d1720, style = 'B',zero.policy = TRUE)

#weekend/holiday morning peak 
wm1114_lw <- nb2listw(wm_d1114, style = 'B',zero.policy = TRUE)

#weekend/holiday afternoon peak 
wm1619_lw <- nb2listw(wm_d1619, style = 'B',zero.policy = TRUE)

#summary(wm0609_lw)

4.5 Computing Adaptive distance weight matrix

Alternatively, we could directly control the number of neighbors using k-nearest neighbors by using knearneigh() function. For our analysis, we will set the number of neighbors to 8. (i.e., all grids will have 8 neighbors).

Show the code
#weekday morning peak 
knn0609 <- knn2nb(knearneigh(coords0609, k=8))
knn0609
Neighbour list object:
Number of regions: 1493 
Number of nonzero links: 11944 
Percentage nonzero weights: 0.5358339 
Average number of links: 8 
Non-symmetric neighbours list
Show the code
#weekday afternoon peak 
knn1720 <- knn2nb(knearneigh(coords1720, k=8))
knn1720
Neighbour list object:
Number of regions: 1495 
Number of nonzero links: 11960 
Percentage nonzero weights: 0.5351171 
Average number of links: 8 
Non-symmetric neighbours list
Show the code
#weekend/holiday morning peak 
knn1114 <- knn2nb(knearneigh(coords1114, k=8))
knn1114
Neighbour list object:
Number of regions: 1499 
Number of nonzero links: 11992 
Percentage nonzero weights: 0.5336891 
Average number of links: 8 
Non-symmetric neighbours list
Show the code
#weekend/holiday afternoon peak 
knn1619 <- knn2nb(knearneigh(coords1619, k=8))
knn1619
Neighbour list object:
Number of regions: 1489 
Number of nonzero links: 11912 
Percentage nonzero weights: 0.5372733 
Average number of links: 8 
Non-symmetric neighbours list

Next, nb2listw() is used to convert the nb object into spatial weights object.

Show the code
#weekday morning peak 
knn0609_lw <- nb2listw(knn0609, style = 'B')
summary(knn0609_lw)
Characteristics of weights list object:
Neighbour list object:
Number of regions: 1493 
Number of nonzero links: 11944 
Percentage nonzero weights: 0.5358339 
Average number of links: 8 
Non-symmetric neighbours list
Link number distribution:

   8 
1493 
1493 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 with 8 links
1493 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 with 8 links

Weights style: B 
Weights constants summary:
     n      nn    S0    S1     S2
B 1493 2229049 11944 22284 387046
Show the code
#weekday afternoon peak 
knn1720_lw <- nb2listw(knn1720, style = 'B')
summary(knn1720_lw)
Characteristics of weights list object:
Neighbour list object:
Number of regions: 1495 
Number of nonzero links: 11960 
Percentage nonzero weights: 0.5351171 
Average number of links: 8 
Non-symmetric neighbours list
Link number distribution:

   8 
1495 
1495 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 with 8 links
1495 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 with 8 links

Weights style: B 
Weights constants summary:
     n      nn    S0    S1     S2
B 1495 2235025 11960 22314 387584
Show the code
#weekend/holiday morning peak 
knn1114_lw <- nb2listw(knn1114, style = 'B')
summary(knn1114_lw)
Characteristics of weights list object:
Neighbour list object:
Number of regions: 1499 
Number of nonzero links: 11992 
Percentage nonzero weights: 0.5336891 
Average number of links: 8 
Non-symmetric neighbours list
Link number distribution:

   8 
1499 
1499 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 with 8 links
1499 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 with 8 links

Weights style: B 
Weights constants summary:
     n      nn    S0    S1     S2
B 1499 2247001 11992 22362 388608
Show the code
#weekend/holiday afternoon peak 
knn1619_lw <- nb2listw(knn1619, style = 'B')
summary(knn1619_lw)
Characteristics of weights list object:
Neighbour list object:
Number of regions: 1489 
Number of nonzero links: 11912 
Percentage nonzero weights: 0.5372733 
Average number of links: 8 
Non-symmetric neighbours list
Link number distribution:

   8 
1489 
1489 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 with 8 links
1489 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 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 with 8 links

Weights style: B 
Weights constants summary:
     n      nn    S0    S1     S2
B 1489 2217121 11912 22206 386064

With the spatial weights objects, we are able to plot and compare the fixed and adaptive distance-based neighbors.

Show the code
par(mfrow=c(1,2))
plot(join_df_wkd6_9_group$honeycomb_grid_wkd6_9, border="lightgrey", main="Adaptive Distance (8)")
plot(knn0609, coords0609, add=TRUE, col="red", length=0.08)
plot(join_df_wkd6_9_group$honeycomb_grid_wkd6_9, border="lightgrey", main="Fixed Distance")
plot(wm_d0609, coords0609, add=TRUE, pch = 19, cex = 0.6)

Show the code
par(mfrow=c(1,2))
plot(join_df_wkd17_20_group$honeycomb_grid_wkd17_20, border="lightgrey", main="Adaptive Distance (8)")
plot(knn1720, coords1720, add=TRUE, col="red", length=0.08)
plot(join_df_wkd17_20_group$honeycomb_grid_wkd17_20, border="lightgrey", main="Fixed Distance")
plot(wm_d1720, coords1720, add=TRUE, pch = 19, cex = 0.6)

Show the code
par(mfrow=c(1,2))
plot(join_df_wknd11_14_group$honeycomb_grid_wknd11_14, border="lightgrey", main="Adaptive Distance (8)")
plot(knn1114, coords1114, add=TRUE, col="red", length=0.08)
plot(join_df_wknd11_14_group$honeycomb_grid_wknd11_14, border="lightgrey", main="Fixed Distance")
plot(wm_d1114, coords1114, add=TRUE, pch = 19, cex = 0.6)

Show the code
par(mfrow=c(1,2))
plot(join_df_wknd16_19_group$honeycomb_grid_wknd16_19, border="lightgrey", main="Adaptive Distance (8)")
plot(knn1619, coords1619, add=TRUE, col="red", length=0.08)
plot(join_df_wknd16_19_group$honeycomb_grid_wknd16_19, border="lightgrey", main="Fixed Distance")
plot(wm_d1619, coords1619, add=TRUE, pch = 19, cex = 0.6)

Due to the high volume, the graph have a high density that makes it hard to us to interpret. However, by looking at the commuting flow, we could see the changes in the neighbor links at the north regions.

By looking at the fixed and adaptive distanced-based matrics, we noticed that there is a decrease in the percentage of nonzero weight, infering that there might be grid with more neighbors.

As such, we will select adaptive distanced-based spatial weight matrix for our subsequent analysis.

4.6 Computing Global Moran’s I

We will perform Moran’s I statistical testing by using moran.test() of spdep on the passenger volume at hexagon level to detect cluster and/or outlier. The global Moran’s I will be performed on the adaptive distance weight matrix.

Moran’s I describe how features differ from the values in the study area as a whole. The Moran I statistic ranges from -1 to 1. If the Moran’s I is:

  • positive (I>0): Clustered, observations tend to be similar

  • negative (I<0): Disperse, observations tend to be dissimilar

  • approximately zero: observations arranged randomly over space

Show the code
moran.test(join_df_wkd6_9_group$total_trips, 
           listw=knn0609_lw, 
           zero.policy = TRUE, 
           na.action=na.omit)

    Moran I test under randomisation

data:  join_df_wkd6_9_group$total_trips  
weights: knn0609_lw    

Moran I statistic standard deviate = 16.351, p-value < 2.2e-16
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance 
     0.2001083712     -0.0006702413      0.0001507761 
Show the code
moran.test(join_df_wkd17_20_group$total_trips, 
           listw=knn1720_lw, 
           zero.policy = TRUE, 
           na.action=na.omit)

    Moran I test under randomisation

data:  join_df_wkd17_20_group$total_trips  
weights: knn1720_lw    

Moran I statistic standard deviate = 4.9447, p-value = 3.814e-07
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance 
      0.059133974      -0.000669344       0.000146277 
Show the code
moran.test(join_df_wknd11_14_group$total_trips, 
           listw=knn1114_lw, 
           zero.policy = TRUE, 
           na.action=na.omit)

    Moran I test under randomisation

data:  join_df_wknd11_14_group$total_trips  
weights: knn1114_lw    

Moran I statistic standard deviate = 12.549, p-value < 2.2e-16
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance 
     0.1528562501     -0.0006675567      0.0001496745 
Show the code
moran.test(join_df_wknd16_19_group$total_trips, 
           listw=knn1619_lw, 
           zero.policy = TRUE, 
           na.action=na.omit)

    Moran I test under randomisation

data:  join_df_wknd16_19_group$total_trips  
weights: knn1619_lw    

Moran I statistic standard deviate = 8.1125, p-value = 2.479e-16
alternative hypothesis: greater
sample estimates:
Moran I statistic       Expectation          Variance 
     0.0981293618     -0.0006720430      0.0001483252 

Interpretation of results

Based on the all the results above, we conclude that the p-value is below the alpha value of 0.05, therefore, we have sufficient statistical evidence to reject the null hypothesis at 95% confidence level that the attribute is randomly distributed.

In addition, the Moran’s I value is greater than 0. This shows that the observations are clustered, and tend to be similar to one another.

4.7 Computing Monte Carlo Moran’s I

We will perform permutation test for Moran’s statistic by using moran.mc() of spdep. A total of 1000 simulation will be performed through random assignment:

Show the code
set.seed=123

moran.mc(join_df_wkd6_9_group$total_trips, 
         listw=knn0609_lw, 
         nsim=999,
         zero.policy = TRUE, 
         na.action=na.exclude)

    Monte-Carlo simulation of Moran I

data:  join_df_wkd6_9_group$total_trips 
weights: knn0609_lw  
number of simulations + 1: 1000 

statistic = 0.20011, observed rank = 1000, p-value = 0.001
alternative hypothesis: greater
Show the code
set.seed=123

moran.mc(join_df_wkd17_20_group$total_trips, 
         listw=knn1720_lw, 
         nsim=999,
         zero.policy = TRUE, 
         na.action=na.exclude)

    Monte-Carlo simulation of Moran I

data:  join_df_wkd17_20_group$total_trips 
weights: knn1720_lw  
number of simulations + 1: 1000 

statistic = 0.059134, observed rank = 999, p-value = 0.001
alternative hypothesis: greater
Show the code
set.seed=123

moran.mc(join_df_wknd11_14_group$total_trips, 
         listw=knn1114_lw, 
         nsim=999,
         zero.policy = TRUE, 
         na.action=na.exclude)

    Monte-Carlo simulation of Moran I

data:  join_df_wknd11_14_group$total_trips 
weights: knn1114_lw  
number of simulations + 1: 1000 

statistic = 0.15286, observed rank = 1000, p-value = 0.001
alternative hypothesis: greater
Show the code
set.seed=123

moran.mc(join_df_wknd16_19_group$total_trips, 
         listw=knn1619_lw, 
         nsim=999,
         zero.policy = TRUE, 
         na.action=na.exclude)

    Monte-Carlo simulation of Moran I

data:  join_df_wknd16_19_group$total_trips 
weights: knn1619_lw  
number of simulations + 1: 1000 

statistic = 0.098129, observed rank = 1000, p-value = 0.001
alternative hypothesis: greater

Interpretation of results

Based on the all the results above, we have sufficient statistical evidence to reject the null hypothesis at 95% confidence level. This suggests that there are some degree of clustering in the commuting flows.

5. Cluster and Outlier Analysis

5.1 Computing local Moran’s I

We will perform Local Moran’s I statistical testing using localmoran() of spdep. The code chunks below are used to compute local Moran’s I of Passenger volume at the hexagon level (grid_id).

If the Local Moran’s I value is:

  • positive: Part of a cluster. Feature has neighboring features with similarly high/low attribute values

  • negative: part of an outlier. Feature has neighboring features with dissimilar values.

Before we map, we would need to compute them using localmoran() function of spdep package. Given a set of Z.Li values, it computes Ii , and a listw object providing neighbor weighting information for the polygon associated with the Z.Ii values.

Show the code
fips <- order(join_df_wkd6_9_group$grid_id)
#weekday morning peak 
localMI_0609ad <- localmoran(join_df_wkd6_9_group$total_trips, knn0609_lw)
#weekday afternoon peak 
localMI_1720ad <- localmoran(join_df_wkd17_20_group$total_trips, knn1720_lw)
#weekend/holiday morning peak 
localMI_1114ad <- localmoran(join_df_wknd11_14_group$total_trips, knn1114_lw)
#weekend/holiday afternoon peak 
localMI_1619ad <- localmoran(join_df_wknd16_19_group$total_trips, knn1619_lw)

The code chunk below is used to compute the passenger volume at hexagon level.

head(localMI_0609ad)
        Ii         E.Ii   Var.Ii     Z.Ii Pr(z != E(Ii))
1 3.152419 -0.002143441 3.184279 1.767802     0.07709406
2 3.154305 -0.002146380 3.188644 1.767649     0.07711954
3 3.108213 -0.002147850 3.190828 1.741242     0.08164121
4 3.137787 -0.002120731 3.150551 1.768983     0.07689676
5 2.928987 -0.001873637 2.783555 1.756691     0.07897057
6 3.103321 -0.002140748 3.180281 1.741380     0.08161704
head(localMI_1720ad)
        Ii          E.Ii   Var.Ii     Z.Ii Pr(z != E(Ii))
1 1.700003 -0.0011511528 1.712658 1.299895      0.1936368
2 1.727508 -0.0011943067 1.776852 1.296864      0.1946778
3 1.644804 -0.0011746696 1.747641 1.245083      0.2131013
4 1.573339 -0.0009653196 1.436213 1.313648      0.1889645
5 1.410563 -0.0008212796 1.221931 1.276797      0.2016738
6 1.640923 -0.0011787531 1.753715 1.239997      0.2149766
head(localMI_1114ad)
        Ii         E.Ii   Var.Ii     Z.Ii Pr(z != E(Ii))
1 2.568884 -0.001774997 2.647692 1.579831      0.1141455
2 2.560523 -0.001761759 2.627948 1.580589      0.1139720
3 2.469920 -0.001759673 2.624838 1.525601      0.1271093
4 2.505731 -0.001676576 2.500912 1.585535      0.1128449
5 2.266525 -0.001438716 2.146165 1.548119      0.1215935
6 2.443412 -0.001726468 2.575319 1.523659      0.1275938
head(localMI_1619ad)
        Ii          E.Ii   Var.Ii     Z.Ii Pr(z != E(Ii))
1 1.846640 -0.0012721723 1.885048 1.345923      0.1783275
2 1.859088 -0.0012919427 1.914338 1.344597      0.1787553
3 1.755175 -0.0012777331 1.893286 1.276522      0.2017710
4 1.770061 -0.0011548255 1.711194 1.354010      0.1757332
5 1.582794 -0.0009997195 1.481390 1.301260      0.1931696
6 1.759842 -0.0012873668 1.907558 1.275124      0.2022654

localmoran() returns a matrix of values whose columns are:

  1. “Ii” : the local Moran’s I statistics

  2. “E.Ii” : the expectation of local moran statistics under the randomisation hypothesis

  3. “Var.Ii” : the variance of local moran statistic under the randomisation hypothesis

  4. “Z.Ii” : the standard deviation of local moran statistic

  5. “Pr()” : the p-value of local moran statistic

5.2 Mapping the local Moran’s I

Next, we will be using cbind() function to combine the local Moran’s dataframe (e.g., localMI_0609ad) with our existing spatial data frame (e.g. join_df_wkd6_9_group) before plotting.

Show the code
#weekday morning peak 
join_df_wkd6_9_group.localMI_0609ad <- cbind(join_df_wkd6_9_group,localMI_0609ad) %>%
  rename(Pr.Ii = Pr.z....E.Ii..)   #adaptive distance 

#weekday afternoon peak 

join_df_wkd17_20_group.localMI_1720ad <- cbind(join_df_wkd17_20_group,localMI_1720ad) %>%
  rename(Pr.Ii = Pr.z....E.Ii..)   #adaptive distance 

#weekend/holiday morning peak 

join_df_wknd11_14_group.localMI_1114ad <- cbind(join_df_wknd11_14_group,localMI_1114ad) %>%
  rename(Pr.Ii = Pr.z....E.Ii..)   #adaptive distance 

#weekend/holiday afternoon peak 

join_df_wknd16_19_group.localMI_1619ad <- cbind(join_df_wknd16_19_group,localMI_1619ad) %>%
  rename(Pr.Ii = Pr.z....E.Ii..)   #adaptive distance 

5.2.1 Mapping Local Moran’s I values and p-values

Using the choropleth mapping function from the tmap package, we will do a visualization for the Local Moran’s I values and its corresponding p-values.

Show the code
localMI_0609ad.map <- tm_shape(join_df_wkd6_9_group.localMI_0609ad) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

pvalue_0609ad.map <- tm_shape(join_df_wkd6_9_group.localMI_0609ad) + 
                tm_fill(col = "Pr.Ii",
                       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.3)+ 
  tm_layout(main.title = "Local Moran's I p-values Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

tmap_arrange(localMI_0609ad.map, pvalue_0609ad.map, asp = 1, ncol = 2)

Show the code
localMI_1720ad.map <- tm_shape(join_df_wkd17_20_group.localMI_1720ad) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

pvalue_1720ad.map <- tm_shape(join_df_wkd17_20_group.localMI_1720ad) + 
                tm_fill(col = "Pr.Ii",
                       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.3)+ 
  tm_layout(main.title = "Local Moran's I p-values Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

tmap_arrange(localMI_1720ad.map, pvalue_1720ad.map, asp = 1, ncol = 2)

Show the code
localMI_1114ad.map <- tm_shape(join_df_wknd11_14_group.localMI_1114ad) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

pvalue_1114ad.map <- tm_shape(join_df_wknd11_14_group.localMI_1114ad) + 
                tm_fill(col = "Pr.Ii",
                       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.3)+ 
  tm_layout(main.title = "Local Moran's I p-values Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

tmap_arrange(localMI_1114ad.map, pvalue_1114ad.map, asp = 1, ncol = 2)

Show the code
localMI_1619ad.map <- tm_shape(join_df_wknd16_19_group.localMI_1619ad) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

pvalue_1619ad.map <- tm_shape(join_df_wknd16_19_group.localMI_1619ad) + 
                tm_fill(col = "Pr.Ii",
                       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.3)+ 
  tm_layout(main.title = "Local Moran's I p-values Map",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

tmap_arrange(localMI_1619ad.map, pvalue_1619ad.map, asp = 1, ncol = 2)

From the graphs above, we could see the gradient of the color that might not be that intuitive. Alternatively, we could look into the following section where we only retain grid that are statistically significant.

5.2.1.1 Areas that are Statistically Significant

First, we will filter out all the areas that are not statistically significant (p-value >=0.05), Then we will plot the base hexagon map and plot accordingly.

Show the code
#weekday morning peak (Adaptive)

join_df_wkd6_9_group.localMI_0609ad_sig <- join_df_wkd6_9_group.localMI_0609ad %>%
  filter(Pr.Ii < 0.05)

base <- tm_shape(join_df_wkd6_9_group) + 
  tm_fill(col = 'gray98') + 
  tm_borders(alpha = 0.3)

localMI_0609sig_ad.map <- base + 
  tm_shape(join_df_wkd6_9_group.localMI_0609ad_sig) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I (Sig.) Map \n (Weekday Morning)",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.35, 
            legend.width = 0.35,
            frame = TRUE)

#weekday afternoon peak 
join_df_wkd17_20_group.localMI_1720ad_sig <- join_df_wkd17_20_group.localMI_1720ad%>%
  filter(Pr.Ii < 0.05)

base <- tm_shape(join_df_wkd17_20_group) + 
  tm_fill(col = 'gray98') + 
  tm_borders(alpha = 0.3)

localMI_1720sig_ad.map <- base + 
  tm_shape(join_df_wkd17_20_group.localMI_1720ad_sig) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I (Sig.) Map \n (Weekday Afternoon)",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.35, 
            legend.width = 0.35,
            frame = TRUE)

#weekends/holiday morning peak 
join_df_wknd11_14_group.localMI_1114ad_sig <- join_df_wknd11_14_group.localMI_1114ad%>%
  filter(Pr.Ii < 0.05)

base <- tm_shape(join_df_wknd11_14_group) + 
  tm_fill(col = 'gray98') + 
  tm_borders(alpha = 0.3)

localMI_1114sig_ad.map <- base + 
  tm_shape(join_df_wknd11_14_group.localMI_1114ad_sig) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I (Sig.) Map \n (Weekends/Holidays Morning)",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.35, 
            legend.width = 0.35,
            frame = TRUE)

#weekends/holiday afternoon peak 
join_df_wknd16_19_group.localMI_1619ad_sig <- join_df_wknd16_19_group.localMI_1619ad%>%
  filter(Pr.Ii < 0.05)

base <- tm_shape(join_df_wknd16_19_group) + 
  tm_fill(col = 'gray98') + 
  tm_borders(alpha = 0.3)

localMI_1619sig_ad.map <- base + 
  tm_shape(join_df_wknd16_19_group.localMI_1619ad_sig) +
  tm_fill(col = "Ii", 
          style = "pretty",
          title = "Local Moran I Statistics") +
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "Local Moran's I (Sig.) Map \n (Weekends/Holidays Afternoon)",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.35, 
            legend.width = 0.35,
            frame = TRUE)

tmap_arrange(localMI_0609sig_ad.map,localMI_1720sig_ad.map,
             localMI_1114sig_ad.map, localMI_1619sig_ad.map,
            ncol = 2)

As iterated earlier, a positive value indicates a cluster while a negative value indicates an outlier. From the maps above, we can see that most regions are orange in color which correspond to a negative value. We could see that there are multiple outliers instead of a cluster, inferring that there are more popular bus stops at various part of Singapore.

5.3 Moran Scatterplot

After identifying the cluster and outlier, we are going to plot the scatterplot using the variables above. First, we will calculate the scaled attribute and the lagged scaled attribute using the scale() function and lag.listw() function.

Show the code
DV0609ad <- scale(join_df_wkd6_9_group.localMI_0609ad$total_trips) %>%
  as.vector 
DV1720ad <- scale(join_df_wkd17_20_group.localMI_1720ad$total_trips) %>%
  as.vector
DV1114ad <- scale(join_df_wknd11_14_group.localMI_1114ad$total_trips) %>%
  as.vector
DV1619ad <- scale(join_df_wknd16_19_group.localMI_1619ad$total_trips) %>%
  as.vector

We will plot the Moran scatterplot using the standardised values and moran.plot() of spdep.

Show the code
nci_0609 <- moran.plot(DV0609ad, knn0609_lw,
                  labels = as.character(join_df_wkd6_9_group$grid_id),
                  xlab = "Weekday Morning Peak",
                  ylab = "Spatially Lag Weekday Morning Peak")

Show the code
nci_1720 <- moran.plot(DV1720ad, knn1720_lw,
                  labels = as.character(join_df_wkd17_20_group$grid_id),
                  xlab = "Weekday Afternoon Peak",
                  ylab = "Spatially Lag Weekday Afternoon Peak")

Show the code
nci_1114 <- moran.plot(DV1114ad, knn1114_lw,
                  labels = as.character(join_df_wknd11_14_group$grid_id),
                  xlab = "Weekends/Holidays Morning Peak",
                  ylab = "Spatially Lag Weekends/Holidays Morning Peak")

Show the code
nci_1619 <- moran.plot(DV1619ad, knn1619_lw,
                  labels = as.character(join_df_wknd16_19_group$grid_id),
                  xlab = "Weekends/Holidays Afternoon Peak",
                  ylab = "Spatially Lag Weekends/Holidays Afternoon Peak")

From the figures above, we note that there are a huge number of grids in the scatterplot for us to draw any statistical conclusion. However, we observe that most of the points are scattered to the left.

Notably, there are four quadrants in the Moran Scatterplot:

  • High-High” - Top right corner : Positive Autocorrelation Cluster.

  • “Low-High” - Top left corner: Negative Autocorrelation Cluster.

  • “High-Low” - Bottom right corner: Negative Autocorrelation Cluster.

  • Low-Low” - Bottom left corner : Positive Autocorrelation Cluster.

Unfortunately, we are not able to determine which points/regions are significant. Therefore, we could look into the LISA Cluster Maps.

5.4 LISA Cluster Maps

The LISA Cluster Maps is able to significant location color coded by type of spatial autocorrelation.

We will retrieve the quadrant for each area based on the following criteria and place non-significant Moran (p-value that are <0.05) as 0.

Show the code
#weekday morning peak 
#Step 1
quadrant <- vector(mode = 'numeric', length = nrow(localMI_0609ad))
#Step 2
join_df_wkd6_9_group$lag <- lag.listw(knn0609_lw,join_df_wkd6_9_group$total_trips)
DV_0609 <- join_df_wkd6_9_group$lag - mean(join_df_wkd6_9_group$lag)
#Step 3
LM_I_0609 <- localMI_0609ad[,1] 
#Step 4
signif <- 0.05
#Step 5
quadrant[DV_0609 <0 & LM_I_0609>0] <- 1 #low-low
quadrant[DV_0609 >0 & LM_I_0609<0] <- 2 #high-low
quadrant[DV_0609 <0 & LM_I_0609<0] <- 3 #low-high
quadrant[DV_0609 >0 & LM_I_0609>0] <- 4 #high-high
#Step 6
quadrant[localMI_0609ad[,5]>signif] <- 0

After running the code chunk above, we will plot the LISA map using tmap.

Show the code
#weekday morning peak 
#Assign each region  to its respective quardrant
join_df_wkd6_9_group.localMI_0609ad$quadrant <- quadrant

#Set the colours--one for each quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c") 

clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")

LISAmap_0609 <- tm_shape(join_df_wkd6_9_group.localMI_0609ad) + 
  tm_fill(col = "quadrant",
          style = "cat", 
          palette = colors[c(sort(unique(quadrant)))+1],
          labels = clusters[c(sort(unique(quadrant)))+1])  + 
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "LISA Cluster Map \n (Weekday Morning) ",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

We will retrieve the quadrant for each area based on the following criteria and place non-significant Moran (p-value that are <0.05) as 0.

Show the code
#weekday afternoon peak 
#Step 1
quadrant <- vector(mode = 'numeric', length = nrow(localMI_1720ad))
#Step 2
join_df_wkd17_20_group$lag <- lag.listw(knn1720_lw,join_df_wkd17_20_group$total_trips)
DV_1720 <- join_df_wkd17_20_group$lag - mean(join_df_wkd17_20_group$lag)
#Step 3
LM_I_1720 <- localMI_1720ad[,1] 
#Step 4
signif <- 0.05
#Step 5
quadrant[DV_1720 <0 & LM_I_1720>0] <- 1 #low-low
quadrant[DV_1720 >0 & LM_I_1720<0] <- 2 #high-low
quadrant[DV_1720 <0 & LM_I_1720<0] <- 3 #low-high
quadrant[DV_1720 >0 & LM_I_1720>0] <- 4 #high-high
#Step 6
quadrant[localMI_1720ad[,5]>signif] <- 0

After running the code chunk above, we will plot the LISA map using tmap.

Show the code
#weekday morning peak 
#Assign each region  to its respective quardrant
join_df_wkd17_20_group.localMI_1720ad$quadrant <- quadrant

#Set the colours--one for each quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c") 

clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")

LISAmap_1720 <- tm_shape(join_df_wkd17_20_group.localMI_1720ad) + 
  tm_fill(col = "quadrant",
          style = "cat", 
          palette = colors[c(sort(unique(quadrant)))+1],
          labels = clusters[c(sort(unique(quadrant)))+1])  + 
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "LISA Cluster Map \n (Weekday Afternoon) ",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

We will retrieve the quadrant for each area based on the following criteria and place non-significant Moran (p-value that are <0.05) as 0.

Show the code
#weekends/holidays morning peak 
#Step 1
quadrant <- vector(mode = 'numeric', length = nrow(localMI_1114ad))
#Step 2
join_df_wknd11_14_group$lag <- lag.listw(knn1114_lw,join_df_wknd11_14_group$total_trips)
DV_1114<- join_df_wknd11_14_group$lag - mean(join_df_wknd11_14_group$lag)
#Step 3
LM_I_1114 <- localMI_1114ad[,1] 
#Step 4
signif <- 0.05
#Step 5
quadrant[DV_1114 <0 & LM_I_1114>0] <- 1 #low-low
quadrant[DV_1114 >0 & LM_I_1114<0] <- 2 #high-low
quadrant[DV_1114 <0 & LM_I_1114<0] <- 3 #low-high
quadrant[DV_1114 >0 & LM_I_1114>0] <- 4 #high-high
#Step 6
quadrant[localMI_1114ad[,5]>signif] <- 0

After running the code chunk above, we will plot the LISA map using tmap.

Show the code
#weekends/holiday morning peak 
#Assign each region  to its respective quardrant
join_df_wknd11_14_group.localMI_1114ad$quadrant <- quadrant

#Set the colours--one for each quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c") 

clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")

LISAmap_1114 <- tm_shape(join_df_wknd11_14_group.localMI_1114ad) + 
  tm_fill(col = "quadrant",
          style = "cat", 
          palette = colors[c(sort(unique(quadrant)))+1],
          labels = clusters[c(sort(unique(quadrant)))+1])  + 
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "LISA Cluster Map \n (Weekends/Holidays Morning) ",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

We will retrieve the quadrant for each area based on the following criteria and place non-significant Moran (p-value that are <0.05) as 0.

Show the code
#weekends/holidays afternoon peak 
#Step 1
quadrant <- vector(mode = 'numeric', length = nrow(localMI_1619ad))
#Step 2
join_df_wknd16_19_group$lag <- lag.listw(knn1619_lw,join_df_wknd16_19_group$total_trips)
DV_1619<- join_df_wknd16_19_group$lag - mean(join_df_wknd16_19_group$lag)
#Step 3
LM_I_1619 <- localMI_1619ad[,1] 
#Step 4
signif <- 0.05
#Step 5
quadrant[DV_1619 <0 & LM_I_1619>0] <- 1 #low-low
quadrant[DV_1619 >0 & LM_I_1619<0] <- 2 #high-low
quadrant[DV_1619 <0 & LM_I_1619<0] <- 3 #low-high
quadrant[DV_1619 >0 & LM_I_1619>0] <- 4 #high-high
#Step 6
quadrant[localMI_1619ad[,5]>signif] <- 0

After running the code chunk above, we will plot the LISA map using tmap.

Show the code
#weekends/holiday morning peak 
#Assign each region  to its respective quardrant
join_df_wknd16_19_group.localMI_1619ad$quadrant <- quadrant

#Set the colours--one for each quadrant
colors <- c("#ffffff", "#2c7bb6", "#abd9e9", "#fdae61", "#d7191c") 

clusters <- c("insignificant", "low-low", "low-high", "high-low", "high-high")

LISAmap_1619 <- tm_shape(join_df_wknd16_19_group.localMI_1619ad) + 
  tm_fill(col = "quadrant",
          style = "cat", 
          palette = colors[c(sort(unique(quadrant)))+1],
          labels = clusters[c(sort(unique(quadrant)))+1])  + 
  tm_borders(alpha = 0.3) + 
  tm_layout(main.title = "LISA Cluster Map \n (Weekends/Holidays Morning) ",
            main.title.size = 1,
            main.title.position = "center",
            legend.height = 0.45, 
            legend.width = 0.35,
            frame = TRUE)

We will be using tmap_arrange() to plot the LISA Cluster Map based on commuting flow.

Show the code
tmap_arrange(LISAmap_0609, LISAmap_1720,
  LISAmap_1114, LISAmap_1619, ncol =2)

We observed that majority of the quadrant are insignificant, while most falls to Low-High and High-High. For Weekdays, there are more High-High (in red), suggesting a cluster. We could infer that the bus stops in the route are popular due to the service it provides - i.e, feeder bus. There are not much differences during the weekends. However, it is important to monitor the Low-High area.

Thereafter, we do a comparison to see between Local Moran’s I and Lisa Cluster Map. by plotting them together. We would be able to observe the similarity between the shades regions.

Show the code
tmap_arrange(localMI_0609sig_ad.map, LISAmap_0609, 
             localMI_1720sig_ad.map, LISAmap_1720,
             ncol =2)

Show the code
tmap_arrange(localMI_1114sig_ad.map, LISAmap_1114, 
             localMI_1619sig_ad.map, LISAmap_1619, 
             ncol =2)

There are multiple high high cluster areas. This regions in the grid have neighbors with similar volume in terms of passenger trips, with the largest cluster in the southern region.

6. Conclusion

In our exercise, we examine the commuting flow of passenger based on the total trips taken in August. We utilized visualiztion tools to generate insights that there are more outliers than clusters. Moreover, the use of LISA would allow us to better understand the geographical relationship and helped improve the decision-making process in terms of adjusting the bus frequency.

References

  1. DiBiase, D., DeMers, M., Johnson, A., Kemp, K., Luck, A. T., Plewe, B., & Wentz, E. (2023, October). Choropleth Maps: Data Classification. GIS Geography. Retrieved from https://gisgeography.com/choropleth-maps-data-classification/

  2. DiBiase, D., DeMers, M., Johnson, A., Kemp, K., Luck, A. T., Plewe, B., & Wentz, E. (2023, November). Spatial Autocorrelation: Moran’s I in GIS. GIS Geography. Retrieved from https://gisgeography.com/spatial-autocorrelation-moran-i-gis/

  3. Land Transport Authority. (2023). DataMall. Retrieved from https://datamall.lta.gov.sg/content/datamall/en.html

  4. Wong, K. (2021, August). Tessellation SF: A Map Design Pattern. Retrieved from https://urbandatapalette.com/post/2021-08-tessellation-sf/