1 Overview

For this exercise, we will be tasked with using the appropriate R functions and spatial point pattern analysis techniques to analyse and gain insight about the distribution of Airbnb listings.

2 Provided Data

  • listings.csv contains information of the various Airbnb listings in Singapore. It contains data such as the type of room listing, neighbourhood price etc.

For this exercise we will be looking at analysing spatial point pattern of the various room type listings firstly across the entirety of Singapore followed by a few specific subzones.

3 Getting Started

3.1 Importing the required packages

packages = c('rgdal', 'maptools', 'raster','spatstat', 'tmap', 'sf','tidyverse','tmaptools','OpenStreetMap','leaflet')
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p,character.only = T)
}

3.2 Importing the required data into R

ABListing <- read_csv("data/aspatial/listings.csv")
## Parsed with column specification:
## cols(
##   id = col_double(),
##   name = col_character(),
##   host_id = col_double(),
##   host_name = col_character(),
##   neighbourhood_group = col_character(),
##   neighbourhood = col_character(),
##   latitude = col_double(),
##   longitude = col_double(),
##   room_type = col_character(),
##   price = col_double(),
##   minimum_nights = col_double(),
##   number_of_reviews = col_double(),
##   last_review = col_date(format = ""),
##   reviews_per_month = col_double(),
##   calculated_host_listings_count = col_double(),
##   availability_365 = col_double()
## )
sg_sf <- st_read(dsn = "data/geospatial", layer="CostalOutline")
## Reading layer `CostalOutline' from data source `C:\Users\jiiireh\Desktop\Take-home_Ex02\data\geospatial' using driver `ESRI Shapefile'
## Simple feature collection with 60 features and 4 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 2663.926 ymin: 16357.98 xmax: 56047.79 ymax: 50244.03
## projected CRS:  SVY21
mpsz_sf = st_read(dsn = "data/geospatial", layer="MP14_SUBZONE_WEB_PL")
## Reading layer `MP14_SUBZONE_WEB_PL' from data source `C:\Users\jiiireh\Desktop\Take-home_Ex02\data\geospatial' using driver `ESRI Shapefile'
## Simple feature collection with 323 features and 15 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
## projected CRS:  SVY21
mppa_sf = st_read(dsn = "data/geospatial", layer="MP14_PLNG_AREA_NO_SEA_PL")
## Reading layer `MP14_PLNG_AREA_NO_SEA_PL' from data source `C:\Users\jiiireh\Desktop\Take-home_Ex02\data\geospatial' using driver `ESRI Shapefile'
## Simple feature collection with 55 features and 12 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
## projected CRS:  SVY21

mppa_sf is imported for it’s planning area coordinates that would allow us to pair with the neighbourhood column in ABListing to perform analysis and gain insights.

mpsz_sf is the imported subzone data to be used for our specified subzone analysis later.

sg_sf imports the boundary that will be used to constain our spatial point datas.

The output of the above code chunks inform us that both sg and mpsz are inthe SVY21 projected coordinate system.

Also, we will need to convert our aspatial data into a spatial data before moving forward.

4 Section A

5 Data Wrangling

Since the current coordinate locations provided by the AirBnb listings are in lon/lat, we know that it is based on the ESPG:4326 coordinate system.

Hence we will convert it into a simple feature data frame and do a transform to match the projections from sg_sp and mpsz_sp (ESPG:3414)

ABListing_sf <- st_as_sf(ABListing, coords = c("longitude", "latitude"), crs = 4326)
ABListing_sf <- st_transform(ABListing_sf,3414)

5.0.1 Data NA Checks

ABListing_sf[rowSums(is.na(ABListing_sf))!=0,]
## Simple feature collection with 2826 features and 14 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 10737.87 ymin: 25166.35 xmax: 43401.32 ymax: 48466.72
## projected CRS:  SVY21 / Singapore TM
## # A tibble: 2,826 x 15
##        id name  host_id host_name neighbourhood_g~ neighbourhood room_type price
##     <dbl> <chr>   <dbl> <chr>     <chr>            <chr>         <chr>     <dbl>
##  1 1.18e5 Priv~  448620 Lynnity   North-East Regi~ Sengkang      Private ~    67
##  2 3.56e5 Doub~ 1759905 Aresha    Central Region   Geylang       Private ~    80
##  3 4.82e5 Mast~ 2386154 Susan     East Region      Tampines      Private ~    38
##  4 6.43e5 BEST~ 3212572 Roger     Central Region   Rochor        Private ~   174
##  5 7.20e5 HDB ~ 3648224 Audrey    Central Region   Queenstown    Shared r~   217
##  6 7.34e5 Home~ 3824517 Shirlnet  North-East Regi~ Serangoon     Private ~    26
##  7 7.56e5 Bedr~ 3981177 Sharon    East Region      Pasir Ris     Private ~   206
##  8 7.68e5 Comm~ 4053150 Immellym~ North-East Regi~ Punggol       Private ~   174
##  9 8.24e5 Apar~ 4177147 Tania     East Region      Bedok         Private ~   290
## 10 1.56e6 Delu~ 8270362 Domus     Central Region   Novena        Private ~    30
## # ... with 2,816 more rows, and 7 more variables: minimum_nights <dbl>,
## #   number_of_reviews <dbl>, last_review <date>, reviews_per_month <dbl>,
## #   calculated_host_listings_count <dbl>, availability_365 <dbl>,
## #   geometry <POINT [m]>
sg_sf[rowSums(is.na(sg_sf))!=0,]
## Simple feature collection with 0 features and 4 fields
## bbox:           xmin: NA ymin: NA xmax: NA ymax: NA
## projected CRS:  SVY21
## [1] GDO_GID    MSLINK     MAPID      COSTAL_NAM geometry  
## <0 rows> (or 0-length row.names)
mpsz_sf[rowSums(is.na(mpsz_sf))!=0,]
## Simple feature collection with 0 features and 15 fields
## bbox:           xmin: NA ymin: NA xmax: NA ymax: NA
## projected CRS:  SVY21
##  [1] OBJECTID   SUBZONE_NO SUBZONE_N  SUBZONE_C  CA_IND     PLN_AREA_N
##  [7] PLN_AREA_C REGION_N   REGION_C   INC_CRC    FMEL_UPD_D X_ADDR    
## [13] Y_ADDR     SHAPE_Leng SHAPE_Area geometry  
## <0 rows> (or 0-length row.names)

Looking at the data, ABListing_sf has NA values when a location has 0 reviews. Since the data table will be dropped for our point pattern analysis, the NA data will not affect our study.

5.0.2 Data Validity Checks to ensure no invalid data exists.

isValid <- st_is_valid(ABListing_sf)
unique(isValid)
## [1] TRUE
isValid2 <- st_is_valid(sg_sf)
unique(isValid2)
## [1]  TRUE FALSE
isValid3 <- st_is_valid(mpsz_sf)
unique(isValid3)
## [1]  TRUE FALSE

We see that both sg_sf and mpsz_sf have some invalid data that we have to handle.

sg_sf <- st_make_valid(sg_sf)
mpsz_sf <- st_make_valid(mpsz_sf)

5.0.3 Ensuring the data has no invalid data once again.

isValid2 <- st_is_valid(sg_sf)
unique(isValid2)
## [1] TRUE
isValid3 <- st_is_valid(mpsz_sf)
unique(isValid3)
## [1] TRUE

The output informs up that no invalid data remains.

5.0.4 Load OpenStreetMap Data

sg_osm <- read_osm(ABListing_sf, ext=1.3)
al_bb <- st_bbox(mpsz_sf %>% filter(SUBZONE_N == "ALJUNIED"))
ba_bb <- st_bbox(mpsz_sf %>% filter(SUBZONE_N == "BALESTIER"))
la_bb <- st_bbox(mpsz_sf %>% filter(SUBZONE_N == "LAVENDER"))
tp_bb <- st_bbox(mpsz_sf %>% filter(SUBZONE_N == "TANJONG PAGAR"))
al_osm <- read_osm(al_bb, ext=1.1)
ba_osm <- read_osm(ba_bb, ext=1.1)
la_osm <- read_osm(la_bb, ext=1.1)
tp_osm <- read_osm(tp_bb, ext=1.1)

5.1 Converting sf dataframes into sp format

We will proceed to convert all the simple feature dataframes into sp format as sf in unsupported by spadstat

ABListing_sp <- as_Spatial(ABListing_sf)
sg_sp <- as_Spatial(sg_sf)
mpsz_sp <- as_Spatial(mpsz_sf)

Checking whether all the projections are the same.

crs(ABListing_sp)
## CRS arguments:
##  +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1
## +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0
## +units=m +no_defs
crs(sg_sp)
## CRS arguments:
##  +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1
## +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=m +no_defs
## +ellps=WGS84 +towgs84=0,0,0
crs(mpsz_sp)
## CRS arguments:
##  +proj=tmerc +lat_0=1.36666666666667 +lon_0=103.833333333333 +k=1
## +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=m +no_defs
## +ellps=WGS84 +towgs84=0,0,0

As we can observe, all are in the same projected system.

tmap_mode("view")
## tmap mode set to interactive viewing
  tm_basemap("OpenStreetMap")+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
  tm_shape(ABListing_sp) +
    tm_dots(col = 'room_type', size = 0.02, alpha = 0.8)
tmap_mode("plot")
## tmap mode set to plotting

From the plot above, many dense clusters of room_type listing “Entire home/apt” can be observed in the central / south region of Singapore as compared to the distribution across the rest of the map.

Large clusters of room_type “Hotel room” and “Shared Room” can also be seen in the central / southern regions as compared to the distribution of the mentioned types across the rest of the map.

Private Rooms appear to be occur at more subzone locations in singapore listed room type while hotel rooms appear to occur is the least amount of subzone locations

However, overall we can see that a large distribution of the room types occur at the central south area of Singapore. This is expected in my opinion as Airbnb targets tourists mainly and tourists would want a better location in the central / near town areas to reduce the overall travel distance to the tourist attractions and shopping districts.

We will see if our point pattern analysis provides us with a similar insight.

Note that the observations of points occuring in more subzones does not imply a lesser degree of clustering, but is simply an observation.

Plotting the room types separately will provide us with an easier viewing of the distribution of each room type.

  tm_shape(sg_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.1)+
  tm_shape(ABListing_sp) +
    tm_dots(col = 'room_type', 
            size = 0.05, legend.show = FALSE) +
  tm_facets(by="room_type")
## Warning: Raster values found that are outside the range [0, 255]

This output backs the above analysis as we see that the occurance of hotel room airbnb listings appears to display clustering and occurs at mainly the central south region (less subzones), of singapore, shared rooms appear to display clustering at the central south region as well and private rooms occur at the most subzone areas of the four with entire home/apt coming in second.

table(ABListing_sp$room_type)
## 
## Entire home/apt      Hotel room    Private room     Shared room 
##            3728             507            3206             272

Entire home has the highest number of listings while private room comes in at a near second place.

Since entire home/apt has a higher listing count over private rooms although it appears to be less spread out, we can expect a denser distribution in the areas with entire home/apt, especially at the central south areas.

6 Subsetting the dataset into room types

Since we are concerned with the spatial patterns observed with each room type, we will be subsetting the data into the various room types

Hotel <- ABListing_sp[ABListing_sp@data$room_type == "Hotel room",]
Entire <- ABListing_sp[ABListing_sp@data$room_type == "Entire home/apt",]
Shared <- ABListing_sp[ABListing_sp@data$room_type == "Shared room",]
Private <- ABListing_sp[ABListing_sp@data$room_type == "Private room",]

6.1 Converting our sp data into ppp objects (1st Step)

To proceed with our point pattern data anaylsis, our various spatial point dataframes of our different room types as well as sg_sp will require further conversions to drop the dataframe data table.

Currently ABListing_sp is in a spatial points dataframe format while sg_sp and mpsz_sp are in spatial polygons dataframe format

Hotel_sp <- as(Hotel, "SpatialPoints")
Entire_sp <- as(Entire, "SpatialPoints")
Shared_sp <- as(Shared, "SpatialPoints")
Private_sp <- as(Private, "SpatialPoints")
sg_sp <- as(sg_sp, "SpatialPolygons")

6.2 Converting our spatial points dataframes into ppp objects (2nd Step)

Hotel_ppp <- as(Hotel_sp, "ppp")
Entire_ppp <- as(Entire_sp, "ppp")
Shared_ppp <- as(Shared_sp, "ppp")
Private_ppp <- as(Private_sp, "ppp")

Hotel_ppp
## Planar point pattern: 507 points
## window: rectangle = [20126.35, 36915.62] x [28442.68, 39865.12] units
Entire_ppp
## Planar point pattern: 3728 points
## window: rectangle = [7215.57, 42932.86] x [25166.35, 48181.41] units
Shared_ppp
## Planar point pattern: 272 points
## window: rectangle = [13607.1, 43401.32] x [28185.04, 48252.18] units
Private_ppp
## Planar point pattern: 3206 points
## window: rectangle = [10737.87, 43386.87] x [26334.02, 48466.72] units
summary(Hotel_ppp)
## Planar point pattern:  507 points
## Average intensity 2.643733e-06 points per square unit
## 
## *Pattern contains duplicated points*
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: rectangle = [20126.35, 36915.62] x [28442.68, 39865.12] units
##                     (16790 x 11420 units)
## Window area = 191774000 square units
summary(Entire_ppp)
## Planar point pattern:  3728 points
## Average intensity 4.535082e-06 points per square unit
## 
## *Pattern contains duplicated points*
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: rectangle = [7215.57, 42932.86] x [25166.35, 48181.41] units
##                     (35720 x 23020 units)
## Window area = 822036000 square units
summary(Shared_ppp)
## Planar point pattern:  272 points
## Average intensity 4.549374e-07 points per square unit
## 
## *Pattern contains duplicated points*
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: rectangle = [13607.1, 43401.32] x [28185.04, 48252.18] units
##                     (29790 x 20070 units)
## Window area = 597885000 square units
summary(Private_ppp)
## Planar point pattern:  3206 points
## Average intensity 4.436692e-06 points per square unit
## 
## *Pattern contains duplicated points*
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: rectangle = [10737.87, 43386.87] x [26334.02, 48466.72] units
##                     (32650 x 22130 units)
## Window area = 722610000 square units

The code chunk informs us of the presence of duplicated points within ur ABListings that we need to handle.

6.2.1 Visualing our “room_type”_ppp.

plot(Hotel_ppp)

plot(Entire_ppp)

plot(Shared_ppp)

plot(Private_ppp)

As we can observe, due to Singapore’s shape we have large amounts of empty spaces. Therefore our following step once we handle the duplicated point issue will be to reduce the window area to Singapore’s boundary.

sum(multiplicity(Hotel_ppp) > 1)
## [1] 59
sum(multiplicity(Entire_ppp) > 1)
## [1] 35
sum(multiplicity(Shared_ppp) > 1)
## [1] 16
sum(multiplicity(Private_ppp) > 1)
## [1] 120

In total there are 243 duplicated points; 59 duplicated hotel room points, 35 duplicated entire home/apt points, 16 shared room points and 120 private room points

6.2.2 We will use the jitter method to handle the duplicated points.

Hotel_ppp_jit <- rjitter(Hotel_ppp, retry=TRUE, nsim=1, drop=TRUE)
Entire_ppp_jit <- rjitter(Entire_ppp, retry=TRUE, nsim=1, drop=TRUE)
Shared_ppp_jit <- rjitter(Shared_ppp, retry=TRUE, nsim=1, drop=TRUE)
Private_ppp_jit <- rjitter(Private_ppp, retry=TRUE, nsim=1, drop=TRUE)

6.2.3 Visualising the jittered version of our “room_type”_ppp.

plot(Hotel_ppp)

plot(Entire_ppp)

plot(Shared_ppp)

plot(Private_ppp)

We can observe minor changes in the points as a result of our jittering.

6.2.4 Next we ensure that no duplicated points remain.

sum(multiplicity(Hotel_ppp_jit) > 1)
## [1] 0
sum(multiplicity(Entire_ppp_jit) > 1)
## [1] 0
sum(multiplicity(Shared_ppp_jit) > 1)
## [1] 0
sum(multiplicity(Private_ppp_jit) > 1)
## [1] 0

As observed, as a result of the jittering, no duplicated points are left.

6.2.5 Converting our sg boundary into owin object

sg_owin <- as(sg_sp, "owin")
sg_owin
## window: polygonal boundary
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units

6.2.6 Ensuring our sg_owin is correct

plot(sg_owin)

summary(sg_owin)
## Window: polygonal boundary
## 61 separate polygons (1 hole)
##                   vertices         area relative.area
## polygon 1               38  1.56140e+04      2.09e-05
## polygon 2              735  4.69093e+06      6.27e-03
## polygon 3               49  1.66986e+04      2.23e-05
## polygon 4               76  3.12332e+05      4.17e-04
## polygon 5             5141  6.36179e+08      8.50e-01
## polygon 6               42  5.58317e+04      7.46e-05
## polygon 7               67  1.31354e+06      1.75e-03
## polygon 8               15  4.46420e+03      5.96e-06
## polygon 9               14  5.46674e+03      7.30e-06
## polygon 10              37  5.26194e+03      7.03e-06
## polygon 11              53  3.44003e+04      4.59e-05
## polygon 12              74  5.82234e+04      7.78e-05
## polygon 13              69  5.63134e+04      7.52e-05
## polygon 14             143  1.45139e+05      1.94e-04
## polygon 15             165  3.38736e+05      4.52e-04
## polygon 16             130  9.40465e+04      1.26e-04
## polygon 17              19  1.80977e+03      2.42e-06
## polygon 18              16  2.01046e+03      2.69e-06
## polygon 19              93  4.30642e+05      5.75e-04
## polygon 20              90  4.15092e+05      5.54e-04
## polygon 21             721  1.92795e+06      2.57e-03
## polygon 22             330  1.11896e+06      1.49e-03
## polygon 23             115  9.28394e+05      1.24e-03
## polygon 24              37  1.01705e+04      1.36e-05
## polygon 25              25  1.66227e+04      2.22e-05
## polygon 26              10  2.14507e+03      2.86e-06
## polygon 27             190  2.02489e+05      2.70e-04
## polygon 28             175  9.25904e+05      1.24e-03
## polygon 29            1990  9.99217e+06      1.33e-02
## polygon 30 (hole)        3 -1.06765e+00     -1.43e-09
## polygon 31              38  2.42492e+04      3.24e-05
## polygon 32              24  6.35239e+03      8.48e-06
## polygon 33              53  6.35791e+05      8.49e-04
## polygon 34              41  1.60161e+04      2.14e-05
## polygon 35              22  2.54368e+03      3.40e-06
## polygon 36              30  1.08382e+04      1.45e-05
## polygon 37             327  2.16921e+06      2.90e-03
## polygon 38             111  6.62927e+05      8.85e-04
## polygon 39              90  1.15991e+05      1.55e-04
## polygon 40              98  6.26829e+04      8.37e-05
## polygon 41             415  3.25384e+06      4.35e-03
## polygon 42             222  1.51142e+06      2.02e-03
## polygon 43             107  6.33039e+05      8.45e-04
## polygon 44               7  2.48299e+03      3.32e-06
## polygon 45              17  3.28303e+04      4.38e-05
## polygon 46              26  8.34758e+03      1.11e-05
## polygon 47             177  4.67446e+05      6.24e-04
## polygon 48              16  3.19460e+03      4.27e-06
## polygon 49              15  4.87296e+03      6.51e-06
## polygon 50              66  1.61841e+04      2.16e-05
## polygon 51             149  5.63430e+06      7.53e-03
## polygon 52             609  2.62570e+07      3.51e-02
## polygon 53               8  7.82256e+03      1.04e-05
## polygon 54             976  2.33447e+07      3.12e-02
## polygon 55              55  8.25379e+04      1.10e-04
## polygon 56             976  2.33447e+07      3.12e-02
## polygon 57              61  3.33449e+05      4.45e-04
## polygon 58               6  1.68410e+04      2.25e-05
## polygon 59               4  9.45963e+03      1.26e-05
## polygon 60              46  6.99702e+05      9.35e-04
## polygon 61              13  7.00873e+04      9.36e-05
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
##                      (53380 x 33890 units)
## Window area = 748741000 square units
## Fraction of frame area: 0.414

7 Combining Airbnb listing points and the study area

HotelSG_ppp = Hotel_ppp_jit[sg_owin]
EntireSG_ppp = Entire_ppp_jit[sg_owin]
SharedSG_ppp = Shared_ppp_jit[sg_owin]
PrivateSG_ppp = Private_ppp_jit[sg_owin]

Contain the jittered version of ABListing_ppp inside sg_owin

Visualising our combination to ensure that it is working

plot(HotelSG_ppp)

plot(EntireSG_ppp)

plot(SharedSG_ppp)

plot(PrivateSG_ppp)

As we can observe, empty areas still exists however it is much less than with the previous window.

summary(HotelSG_ppp)
## Planar point pattern:  507 points
## Average intensity 6.771365e-07 points per square unit
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: polygonal boundary
## 61 separate polygons (1 hole)
##                   vertices         area relative.area
## polygon 1               38  1.56140e+04      2.09e-05
## polygon 2              735  4.69093e+06      6.27e-03
## polygon 3               49  1.66986e+04      2.23e-05
## polygon 4               76  3.12332e+05      4.17e-04
## polygon 5             5141  6.36179e+08      8.50e-01
## polygon 6               42  5.58317e+04      7.46e-05
## polygon 7               67  1.31354e+06      1.75e-03
## polygon 8               15  4.46420e+03      5.96e-06
## polygon 9               14  5.46674e+03      7.30e-06
## polygon 10              37  5.26194e+03      7.03e-06
## polygon 11              53  3.44003e+04      4.59e-05
## polygon 12              74  5.82234e+04      7.78e-05
## polygon 13              69  5.63134e+04      7.52e-05
## polygon 14             143  1.45139e+05      1.94e-04
## polygon 15             165  3.38736e+05      4.52e-04
## polygon 16             130  9.40465e+04      1.26e-04
## polygon 17              19  1.80977e+03      2.42e-06
## polygon 18              16  2.01046e+03      2.69e-06
## polygon 19              93  4.30642e+05      5.75e-04
## polygon 20              90  4.15092e+05      5.54e-04
## polygon 21             721  1.92795e+06      2.57e-03
## polygon 22             330  1.11896e+06      1.49e-03
## polygon 23             115  9.28394e+05      1.24e-03
## polygon 24              37  1.01705e+04      1.36e-05
## polygon 25              25  1.66227e+04      2.22e-05
## polygon 26              10  2.14507e+03      2.86e-06
## polygon 27             190  2.02489e+05      2.70e-04
## polygon 28             175  9.25904e+05      1.24e-03
## polygon 29            1990  9.99217e+06      1.33e-02
## polygon 30 (hole)        3 -1.06765e+00     -1.43e-09
## polygon 31              38  2.42492e+04      3.24e-05
## polygon 32              24  6.35239e+03      8.48e-06
## polygon 33              53  6.35791e+05      8.49e-04
## polygon 34              41  1.60161e+04      2.14e-05
## polygon 35              22  2.54368e+03      3.40e-06
## polygon 36              30  1.08382e+04      1.45e-05
## polygon 37             327  2.16921e+06      2.90e-03
## polygon 38             111  6.62927e+05      8.85e-04
## polygon 39              90  1.15991e+05      1.55e-04
## polygon 40              98  6.26829e+04      8.37e-05
## polygon 41             415  3.25384e+06      4.35e-03
## polygon 42             222  1.51142e+06      2.02e-03
## polygon 43             107  6.33039e+05      8.45e-04
## polygon 44               7  2.48299e+03      3.32e-06
## polygon 45              17  3.28303e+04      4.38e-05
## polygon 46              26  8.34758e+03      1.11e-05
## polygon 47             177  4.67446e+05      6.24e-04
## polygon 48              16  3.19460e+03      4.27e-06
## polygon 49              15  4.87296e+03      6.51e-06
## polygon 50              66  1.61841e+04      2.16e-05
## polygon 51             149  5.63430e+06      7.53e-03
## polygon 52             609  2.62570e+07      3.51e-02
## polygon 53               8  7.82256e+03      1.04e-05
## polygon 54             976  2.33447e+07      3.12e-02
## polygon 55              55  8.25379e+04      1.10e-04
## polygon 56             976  2.33447e+07      3.12e-02
## polygon 57              61  3.33449e+05      4.45e-04
## polygon 58               6  1.68410e+04      2.25e-05
## polygon 59               4  9.45963e+03      1.26e-05
## polygon 60              46  6.99702e+05      9.35e-04
## polygon 61              13  7.00873e+04      9.36e-05
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
##                      (53380 x 33890 units)
## Window area = 748741000 square units
## Fraction of frame area: 0.414
summary(EntireSG_ppp)
## Planar point pattern:  3727 points
## Average intensity 4.977688e-06 points per square unit
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: polygonal boundary
## 61 separate polygons (1 hole)
##                   vertices         area relative.area
## polygon 1               38  1.56140e+04      2.09e-05
## polygon 2              735  4.69093e+06      6.27e-03
## polygon 3               49  1.66986e+04      2.23e-05
## polygon 4               76  3.12332e+05      4.17e-04
## polygon 5             5141  6.36179e+08      8.50e-01
## polygon 6               42  5.58317e+04      7.46e-05
## polygon 7               67  1.31354e+06      1.75e-03
## polygon 8               15  4.46420e+03      5.96e-06
## polygon 9               14  5.46674e+03      7.30e-06
## polygon 10              37  5.26194e+03      7.03e-06
## polygon 11              53  3.44003e+04      4.59e-05
## polygon 12              74  5.82234e+04      7.78e-05
## polygon 13              69  5.63134e+04      7.52e-05
## polygon 14             143  1.45139e+05      1.94e-04
## polygon 15             165  3.38736e+05      4.52e-04
## polygon 16             130  9.40465e+04      1.26e-04
## polygon 17              19  1.80977e+03      2.42e-06
## polygon 18              16  2.01046e+03      2.69e-06
## polygon 19              93  4.30642e+05      5.75e-04
## polygon 20              90  4.15092e+05      5.54e-04
## polygon 21             721  1.92795e+06      2.57e-03
## polygon 22             330  1.11896e+06      1.49e-03
## polygon 23             115  9.28394e+05      1.24e-03
## polygon 24              37  1.01705e+04      1.36e-05
## polygon 25              25  1.66227e+04      2.22e-05
## polygon 26              10  2.14507e+03      2.86e-06
## polygon 27             190  2.02489e+05      2.70e-04
## polygon 28             175  9.25904e+05      1.24e-03
## polygon 29            1990  9.99217e+06      1.33e-02
## polygon 30 (hole)        3 -1.06765e+00     -1.43e-09
## polygon 31              38  2.42492e+04      3.24e-05
## polygon 32              24  6.35239e+03      8.48e-06
## polygon 33              53  6.35791e+05      8.49e-04
## polygon 34              41  1.60161e+04      2.14e-05
## polygon 35              22  2.54368e+03      3.40e-06
## polygon 36              30  1.08382e+04      1.45e-05
## polygon 37             327  2.16921e+06      2.90e-03
## polygon 38             111  6.62927e+05      8.85e-04
## polygon 39              90  1.15991e+05      1.55e-04
## polygon 40              98  6.26829e+04      8.37e-05
## polygon 41             415  3.25384e+06      4.35e-03
## polygon 42             222  1.51142e+06      2.02e-03
## polygon 43             107  6.33039e+05      8.45e-04
## polygon 44               7  2.48299e+03      3.32e-06
## polygon 45              17  3.28303e+04      4.38e-05
## polygon 46              26  8.34758e+03      1.11e-05
## polygon 47             177  4.67446e+05      6.24e-04
## polygon 48              16  3.19460e+03      4.27e-06
## polygon 49              15  4.87296e+03      6.51e-06
## polygon 50              66  1.61841e+04      2.16e-05
## polygon 51             149  5.63430e+06      7.53e-03
## polygon 52             609  2.62570e+07      3.51e-02
## polygon 53               8  7.82256e+03      1.04e-05
## polygon 54             976  2.33447e+07      3.12e-02
## polygon 55              55  8.25379e+04      1.10e-04
## polygon 56             976  2.33447e+07      3.12e-02
## polygon 57              61  3.33449e+05      4.45e-04
## polygon 58               6  1.68410e+04      2.25e-05
## polygon 59               4  9.45963e+03      1.26e-05
## polygon 60              46  6.99702e+05      9.35e-04
## polygon 61              13  7.00873e+04      9.36e-05
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
##                      (53380 x 33890 units)
## Window area = 748741000 square units
## Fraction of frame area: 0.414
summary(SharedSG_ppp)
## Planar point pattern:  272 points
## Average intensity 3.632764e-07 points per square unit
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: polygonal boundary
## 61 separate polygons (1 hole)
##                   vertices         area relative.area
## polygon 1               38  1.56140e+04      2.09e-05
## polygon 2              735  4.69093e+06      6.27e-03
## polygon 3               49  1.66986e+04      2.23e-05
## polygon 4               76  3.12332e+05      4.17e-04
## polygon 5             5141  6.36179e+08      8.50e-01
## polygon 6               42  5.58317e+04      7.46e-05
## polygon 7               67  1.31354e+06      1.75e-03
## polygon 8               15  4.46420e+03      5.96e-06
## polygon 9               14  5.46674e+03      7.30e-06
## polygon 10              37  5.26194e+03      7.03e-06
## polygon 11              53  3.44003e+04      4.59e-05
## polygon 12              74  5.82234e+04      7.78e-05
## polygon 13              69  5.63134e+04      7.52e-05
## polygon 14             143  1.45139e+05      1.94e-04
## polygon 15             165  3.38736e+05      4.52e-04
## polygon 16             130  9.40465e+04      1.26e-04
## polygon 17              19  1.80977e+03      2.42e-06
## polygon 18              16  2.01046e+03      2.69e-06
## polygon 19              93  4.30642e+05      5.75e-04
## polygon 20              90  4.15092e+05      5.54e-04
## polygon 21             721  1.92795e+06      2.57e-03
## polygon 22             330  1.11896e+06      1.49e-03
## polygon 23             115  9.28394e+05      1.24e-03
## polygon 24              37  1.01705e+04      1.36e-05
## polygon 25              25  1.66227e+04      2.22e-05
## polygon 26              10  2.14507e+03      2.86e-06
## polygon 27             190  2.02489e+05      2.70e-04
## polygon 28             175  9.25904e+05      1.24e-03
## polygon 29            1990  9.99217e+06      1.33e-02
## polygon 30 (hole)        3 -1.06765e+00     -1.43e-09
## polygon 31              38  2.42492e+04      3.24e-05
## polygon 32              24  6.35239e+03      8.48e-06
## polygon 33              53  6.35791e+05      8.49e-04
## polygon 34              41  1.60161e+04      2.14e-05
## polygon 35              22  2.54368e+03      3.40e-06
## polygon 36              30  1.08382e+04      1.45e-05
## polygon 37             327  2.16921e+06      2.90e-03
## polygon 38             111  6.62927e+05      8.85e-04
## polygon 39              90  1.15991e+05      1.55e-04
## polygon 40              98  6.26829e+04      8.37e-05
## polygon 41             415  3.25384e+06      4.35e-03
## polygon 42             222  1.51142e+06      2.02e-03
## polygon 43             107  6.33039e+05      8.45e-04
## polygon 44               7  2.48299e+03      3.32e-06
## polygon 45              17  3.28303e+04      4.38e-05
## polygon 46              26  8.34758e+03      1.11e-05
## polygon 47             177  4.67446e+05      6.24e-04
## polygon 48              16  3.19460e+03      4.27e-06
## polygon 49              15  4.87296e+03      6.51e-06
## polygon 50              66  1.61841e+04      2.16e-05
## polygon 51             149  5.63430e+06      7.53e-03
## polygon 52             609  2.62570e+07      3.51e-02
## polygon 53               8  7.82256e+03      1.04e-05
## polygon 54             976  2.33447e+07      3.12e-02
## polygon 55              55  8.25379e+04      1.10e-04
## polygon 56             976  2.33447e+07      3.12e-02
## polygon 57              61  3.33449e+05      4.45e-04
## polygon 58               6  1.68410e+04      2.25e-05
## polygon 59               4  9.45963e+03      1.26e-05
## polygon 60              46  6.99702e+05      9.35e-04
## polygon 61              13  7.00873e+04      9.36e-05
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
##                      (53380 x 33890 units)
## Window area = 748741000 square units
## Fraction of frame area: 0.414
summary(PrivateSG_ppp)
## Planar point pattern:  3206 points
## Average intensity 4.281853e-06 points per square unit
## 
## Coordinates are given to 3 decimal places
## i.e. rounded to the nearest multiple of 0.001 units
## 
## Window: polygonal boundary
## 61 separate polygons (1 hole)
##                   vertices         area relative.area
## polygon 1               38  1.56140e+04      2.09e-05
## polygon 2              735  4.69093e+06      6.27e-03
## polygon 3               49  1.66986e+04      2.23e-05
## polygon 4               76  3.12332e+05      4.17e-04
## polygon 5             5141  6.36179e+08      8.50e-01
## polygon 6               42  5.58317e+04      7.46e-05
## polygon 7               67  1.31354e+06      1.75e-03
## polygon 8               15  4.46420e+03      5.96e-06
## polygon 9               14  5.46674e+03      7.30e-06
## polygon 10              37  5.26194e+03      7.03e-06
## polygon 11              53  3.44003e+04      4.59e-05
## polygon 12              74  5.82234e+04      7.78e-05
## polygon 13              69  5.63134e+04      7.52e-05
## polygon 14             143  1.45139e+05      1.94e-04
## polygon 15             165  3.38736e+05      4.52e-04
## polygon 16             130  9.40465e+04      1.26e-04
## polygon 17              19  1.80977e+03      2.42e-06
## polygon 18              16  2.01046e+03      2.69e-06
## polygon 19              93  4.30642e+05      5.75e-04
## polygon 20              90  4.15092e+05      5.54e-04
## polygon 21             721  1.92795e+06      2.57e-03
## polygon 22             330  1.11896e+06      1.49e-03
## polygon 23             115  9.28394e+05      1.24e-03
## polygon 24              37  1.01705e+04      1.36e-05
## polygon 25              25  1.66227e+04      2.22e-05
## polygon 26              10  2.14507e+03      2.86e-06
## polygon 27             190  2.02489e+05      2.70e-04
## polygon 28             175  9.25904e+05      1.24e-03
## polygon 29            1990  9.99217e+06      1.33e-02
## polygon 30 (hole)        3 -1.06765e+00     -1.43e-09
## polygon 31              38  2.42492e+04      3.24e-05
## polygon 32              24  6.35239e+03      8.48e-06
## polygon 33              53  6.35791e+05      8.49e-04
## polygon 34              41  1.60161e+04      2.14e-05
## polygon 35              22  2.54368e+03      3.40e-06
## polygon 36              30  1.08382e+04      1.45e-05
## polygon 37             327  2.16921e+06      2.90e-03
## polygon 38             111  6.62927e+05      8.85e-04
## polygon 39              90  1.15991e+05      1.55e-04
## polygon 40              98  6.26829e+04      8.37e-05
## polygon 41             415  3.25384e+06      4.35e-03
## polygon 42             222  1.51142e+06      2.02e-03
## polygon 43             107  6.33039e+05      8.45e-04
## polygon 44               7  2.48299e+03      3.32e-06
## polygon 45              17  3.28303e+04      4.38e-05
## polygon 46              26  8.34758e+03      1.11e-05
## polygon 47             177  4.67446e+05      6.24e-04
## polygon 48              16  3.19460e+03      4.27e-06
## polygon 49              15  4.87296e+03      6.51e-06
## polygon 50              66  1.61841e+04      2.16e-05
## polygon 51             149  5.63430e+06      7.53e-03
## polygon 52             609  2.62570e+07      3.51e-02
## polygon 53               8  7.82256e+03      1.04e-05
## polygon 54             976  2.33447e+07      3.12e-02
## polygon 55              55  8.25379e+04      1.10e-04
## polygon 56             976  2.33447e+07      3.12e-02
## polygon 57              61  3.33449e+05      4.45e-04
## polygon 58               6  1.68410e+04      2.25e-05
## polygon 59               4  9.45963e+03      1.26e-05
## polygon 60              46  6.99702e+05      9.35e-04
## polygon 61              13  7.00873e+04      9.36e-05
## enclosing rectangle: [2663.93, 56047.79] x [16357.98, 50244.03] units
##                      (53380 x 33890 units)
## Window area = 748741000 square units
## Fraction of frame area: 0.414

Now that we’ve ensured that no duplicate data exists and have reduced the window to singapore’s boundary area, we can proceed on to perform our spatial point pattern analysis.

8 Performing 1st Order Testing on Airbnb room_types

8.1 Quadrat Test for Hotel room Airbnb Listings

For testing the spatial point pattern of Hotel room distributions, The test hypotheses are:

Ho = The distribution of Hotel room airbnb listings are randomly distributed.

H1= The distribution of Hotel room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

qt_Hotel <- quadrat.test(HotelSG_ppp, 
                   nx = 20, ny = 15)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
qt_Hotel
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  HotelSG_ppp
## X2 = 9134.4, df = 184, p-value < 2.2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of hotel room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 9239), we can conclude that clustering is exhibited by the distributions of hotel room airbnb listings.

plot(HotelSG_ppp)
plot(qt_Hotel, add = TRUE, cex =.1)

quadrat.test(HotelSG_ppp, 
             nx = 20, ny = 15,
             method="M",
             nsim=999)
## 
##  Conditional Monte Carlo test of CSR using quadrat counts
##  Test statistic: Pearson X2 statistic
## 
## data:  HotelSG_ppp
## X2 = 9134.4, p-value = 0.002
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Similar to the analysis above, since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of hotel room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 9239), we can conclude that clustering is exhibited by the distributions of hotel room airbnb listings.

This is in line with our initial observations where we would see many clusters of hotel room airbnb listingsin the central south regions of Singapore. Also this could be expected as hotels are primarily situated in areas located in the central / town regions of Singapore to facilitate the ease of travel for tourists staying in them, hence the clustering.

8.2 Neareast Neighbour Analysis of Hotel room Airbnb Listings

The test hypotheses are:

Ho = The distribution of Hotel room airbnb listings are randomly distributed.

H1= The distribution of Hotel room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

clarkevans.test(HotelSG_ppp,
                correction="none",
                clipregion="sg_owin",
                alternative=c("two.sided"),
                nsim=999)
## 
##  Clark-Evans test
##  No edge correction
##  Monte Carlo test based on 999 simulations of CSR with fixed n
## 
## data:  HotelSG_ppp
## R = 0.10096, p-value = 0.002
## alternative hypothesis: two-sided

Since our p value is lower than our alpha value of 0.05, we reject the null hypothesis. Next, since NNI is < 1, we can observe that the distributon of Hotel room airbnb listings exhibits clustering.

This test results also affirm our observations made from our quadrat analysis results.Therefore, we may conclude that the distributon of Hotel room airbnb listings exhibits clustering.

8.3 Quadrat Test for Entire home/apt airbnb listings

For testing the spatial point pattern of Entire home/apt distributions, The test hypotheses are:

Ho = The distribution of Entire home/apt airbnb listings are randomly distributed.

H1= The distribution of Entire home/apt airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

qt_Entire <- quadrat.test(EntireSG_ppp, 
                   nx = 20, ny = 15)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
qt_Entire
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  EntireSG_ppp
## X2 = 43838, df = 184, p-value < 2.2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Entire room/apt airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 43783), we can conclude that clustering is exhibited by the distributions of hotel room airbnb listings.

plot(EntireSG_ppp)
plot(qt_Entire, add = TRUE, cex =.1)

quadrat.test(EntireSG_ppp, 
             nx = 20, ny = 15,
             method="M",
             nsim=999)
## 
##  Conditional Monte Carlo test of CSR using quadrat counts
##  Test statistic: Pearson X2 statistic
## 
## data:  EntireSG_ppp
## X2 = 43838, p-value = 0.002
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Similar to the analysis above, since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Entire room/apt airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 43783), we can conclude that clustering is exhibited by the distributions of Entire room/apt room airbnb listings.

This is in line with our initial observations where we would see many clusters of entire home/apt airbnb listings in the central south regions of Singapore. It is also observed here that among the 4 room types, entire home/apt airbnb listings display the greatest significance of clustering.

8.4 Neareast Neighbour Analysis of Entire home/apt Airbnb Listings

The test hypotheses are:

Ho = The distribution of Entire home/apt airbnb listings are randomly distributed.

H1= The distribution of Entire home/apt airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

clarkevans.test(EntireSG_ppp,
                correction="none",
                clipregion="sg_owin",
                alternative=c("two.sided"),
                nsim=999)
## 
##  Clark-Evans test
##  No edge correction
##  Monte Carlo test based on 999 simulations of CSR with fixed n
## 
## data:  EntireSG_ppp
## R = 0.26487, p-value = 0.002
## alternative hypothesis: two-sided

Since our p value is lower than our alpha value of 0.05, we reject the null hypothesis. Next, since NNI is < 1, we can observe that the distributon of Entire home/apt airbnb listings exhibits clustering.

This test results also affirm our observations made from our quadrat analysis results.Therefore, we may conclude that the distributon of Entire home/apt airbnb listings exhibits clustering.

8.5 Quadrat test for Shared room airbnb listings

For testing the spatial point pattern of Shared room distributions, The test hypotheses are:

Ho = The distribution of Shared room airbnb listings are randomly distributed.

H1= The distribution of Shared room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

qt_Shared <- quadrat.test(SharedSG_ppp, 
                   nx = 20, ny = 15)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
qt_Shared
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  SharedSG_ppp
## X2 = 4478.6, df = 184, p-value < 2.2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Shared room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 4528.7), we can conclude that clustering is exhibited by the distributions of hotel room airbnb listings. It is also observed here that among the 4 room types, Shared room airbnb listings display the least instead significance of clustering over the initially assumed hotel room airbnb listings.

plot(SharedSG_ppp)
plot(qt_Shared, add = TRUE, cex =.1)

quadrat.test(SharedSG_ppp, 
             nx = 20, ny = 15,
             method="M",
             nsim=999)
## 
##  Conditional Monte Carlo test of CSR using quadrat counts
##  Test statistic: Pearson X2 statistic
## 
## data:  SharedSG_ppp
## X2 = 4478.6, p-value = 0.002
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Similar to the analysis above, since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Shared room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 4528.7), we can conclude that clustering is exhibited by the distributions of Shared room airbnb listings.

This is in line with our initial observations where we would see many clusters of Shared room airbnb listings in the central south regions of Singapore. It is also observed here that among the 4 room types, entire home/apt airbnb listings display the greatest significance of clustering.

8.6 Neareast Neighbour Analysis of Shared room Airbnb Listings

The test hypotheses are:

Ho = The distribution of Shared room airbnb listings are randomly distributed.

H1= The distribution of Shared room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

clarkevans.test(SharedSG_ppp,
                correction="none",
                clipregion="sg_owin",
                alternative=c("two.sided"),
                nsim=999)
## 
##  Clark-Evans test
##  No edge correction
##  Monte Carlo test based on 999 simulations of CSR with fixed n
## 
## data:  SharedSG_ppp
## R = 0.35514, p-value = 0.002
## alternative hypothesis: two-sided

Since our p value is lower than our alpha value of 0.05, we reject the null hypothesis. Next, since NNI is < 1, we can observe that the distributon of Shared room airbnb listings exhibits clustering.

This test results also affirm our observations made from our quadrat analysis results.Therefore, we may conclude that the distributon of Shared room airbnb listings exhibits clustering.

8.7 Quadrat test for Private room airbnb listings

For testing the spatial point pattern of Private room distributions, The test hypotheses are:

Ho = The distribution of Private room airbnb listings are randomly distributed.

H1= The distribution of Private room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

qt_Private <- quadrat.test(PrivateSG_ppp, 
                   nx = 20, ny = 15)
## Warning: Some expected counts are small; chi^2 approximation may be inaccurate
qt_Private
## 
##  Chi-squared test of CSR using quadrat counts
## 
## data:  PrivateSG_ppp
## X2 = 22045, df = 184, p-value < 2.2e-16
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Private room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 21967), we can conclude that clustering is exhibited by the distributions of Private room airbnb listings.

plot(PrivateSG_ppp)
plot(qt_Private, add = TRUE, cex =.1)

quadrat.test(PrivateSG_ppp, 
             nx = 20, ny = 15,
             method="M",
             nsim=999)
## 
##  Conditional Monte Carlo test of CSR using quadrat counts
##  Test statistic: Pearson X2 statistic
## 
## data:  PrivateSG_ppp
## X2 = 22045, p-value = 0.002
## alternative hypothesis: two.sided
## 
## Quadrats: 185 tiles (irregular windows)

Similar to the analysis above, since our p-value is smaller than our alpha value of 0.05, we reject the null hypothesis that the distribution of Private room airbnb listings are randomly distributed.

Next, since the Chi-square value is much greater than 1 (at 21967), we can conclude that clustering is exhibited by the distributions of Private room airbnb listings.

8.8 Neareast Neighbour Analysis of Private room Airbnb Listings

The test hypotheses are:

Ho = The distribution of Private room airbnb listings are randomly distributed.

H1= The distribution of Private room airbnb listings are not randomly distributed.

The 95% confidence interval will be used.

clarkevans.test(PrivateSG_ppp,
                correction="none",
                clipregion="sg_owin",
                alternative=c("two.sided"),
                nsim=999)
## 
##  Clark-Evans test
##  No edge correction
##  Monte Carlo test based on 999 simulations of CSR with fixed n
## 
## data:  PrivateSG_ppp
## R = 0.38098, p-value = 0.002
## alternative hypothesis: two-sided

Since our p value is lower than our alpha value of 0.05, we reject the null hypothesis. Next, since NNI is < 1, we can observe that the distributon of Private room airbnb listings exhibits clustering.

This test results also affirm our observations made from our quadrat analysis results.Therefore, we may conclude that the distributon of Private room airbnb listings exhibits clustering.

9 Kernal Density Estimation

Computing Kernal Density Estimation using automatic bandwidth selection method

kde_Hotel_bw <- density(HotelSG_ppp, sigma=bw.diggle, edge=TRUE, kernel="gaussian") 
## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)

## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)
kde_Hotel_bw
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [2663.9, 56048] x [16358, 50244] units
plot(kde_Hotel_bw)

Current the scale of our kernal density estimation plot is in meters^2. To make the scale easier to read, we will convert our ppp objects into km.

HotelSG_ppp.km <- rescale(HotelSG_ppp, 1000, "km")
EntireSG_ppp.km <- rescale(EntireSG_ppp, 1000, "km")
SharedSG_ppp.km <- rescale(SharedSG_ppp, 1000, "km")
PrivateSG_ppp.km <- rescale(PrivateSG_ppp, 1000, "km")

Using bw.diggle to derive bandwidth

#bw.diggle(HotelSG_ppp.km)
#bw.diggle(EntireSG_ppp.km)
#bw.diggle(SharedSG_ppp.km)
#bw.diggle(PrivateSG_ppp.km)

9.1 Computing KDEs of the different room tpyes

9.1.1 Hotel room

kde_Hotel_bw.km <- density(HotelSG_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian") 
## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)

## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)
kde_Hotel_bw.km
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [2.6639, 56.048] x [16.358, 50.244] km

9.1.2 Entire home/apt

kde_Entire_bw.km <- density(EntireSG_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian") 
## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)
kde_Entire_bw.km
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [2.6639, 56.048] x [16.358, 50.244] km

9.1.3 Shared room

kde_Shared_bw.km <- density(SharedSG_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian") 
## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)

## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)
kde_Shared_bw.km
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [2.6639, 56.048] x [16.358, 50.244] km

9.1.4 Private room

kde_Private_bw.km <- density(PrivateSG_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian") 
## Warning: point-in-polygon test had difficulty with 215 points (total score not 0
## or 1)
kde_Private_bw.km
## real-valued pixel image
## 128 x 128 pixel array (ny, nx)
## enclosing rectangle: [2.6639, 56.048] x [16.358, 50.244] km

9.1.5 Visualising our room type KDEs

plot(kde_Hotel_bw.km)

plot(kde_Entire_bw.km)

plot(kde_Shared_bw.km)

plot(kde_Private_bw.km)

9.1.6 Converting our KDEs into grid objects

gridded_kde_Hotel_bw.km <- as.SpatialGridDataFrame.im(kde_Hotel_bw.km)
gridded_kde_Entire_bw.km <- as.SpatialGridDataFrame.im(kde_Entire_bw.km)
gridded_kde_Shared_bw.km <- as.SpatialGridDataFrame.im(kde_Shared_bw.km)
gridded_kde_Private_bw.km <- as.SpatialGridDataFrame.im(kde_Private_bw.km)

spplot(gridded_kde_Hotel_bw.km)

spplot(gridded_kde_Entire_bw.km)

spplot(gridded_kde_Shared_bw.km)

spplot(gridded_kde_Private_bw.km)

9.1.7 Converting our gridded outputs into rasters and assigning them projection systems

gridded_kde_Hotel_bw.km_raster <- raster(gridded_kde_Hotel_bw.km)
projection(gridded_kde_Hotel_bw.km_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

gridded_kde_Entire_bw.km_raster <- raster(gridded_kde_Entire_bw.km)
projection(gridded_kde_Entire_bw.km_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

gridded_kde_Shared_bw.km_raster <- raster(gridded_kde_Shared_bw.km)
projection(gridded_kde_Shared_bw.km_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

gridded_kde_Private_bw.km_raster <- raster(gridded_kde_Private_bw.km)
projection(gridded_kde_Private_bw.km_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

gridded_kde_Hotel_bw.km_raster
## class      : RasterLayer 
## dimensions : 128, 128, 16384  (nrow, ncol, ncell)
## resolution : 0.4170614, 0.2647348  (x, y)
## extent     : 2.663926, 56.04779, 16.35798, 50.24403  (xmin, xmax, ymin, ymax)
## crs        : +init=EPSG:3414 +datum=WGS84 +units=km +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## source     : memory
## names      : v 
## values     : -8.343841e-14, 579.6246  (min, max)
gridded_kde_Entire_bw.km_raster
## class      : RasterLayer 
## dimensions : 128, 128, 16384  (nrow, ncol, ncell)
## resolution : 0.4170614, 0.2647348  (x, y)
## extent     : 2.663926, 56.04779, 16.35798, 50.24403  (xmin, xmax, ymin, ymax)
## crs        : +init=EPSG:3414 +datum=WGS84 +units=km +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## source     : memory
## names      : v 
## values     : -1.97974e-13, 1204.593  (min, max)
gridded_kde_Shared_bw.km_raster
## class      : RasterLayer 
## dimensions : 128, 128, 16384  (nrow, ncol, ncell)
## resolution : 0.4170614, 0.2647348  (x, y)
## extent     : 2.663926, 56.04779, 16.35798, 50.24403  (xmin, xmax, ymin, ymax)
## crs        : +init=EPSG:3414 +datum=WGS84 +units=km +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## source     : memory
## names      : v 
## values     : -2.51555e-14, 135.557  (min, max)
gridded_kde_Private_bw.km_raster
## class      : RasterLayer 
## dimensions : 128, 128, 16384  (nrow, ncol, ncell)
## resolution : 0.4170614, 0.2647348  (x, y)
## extent     : 2.663926, 56.04779, 16.35798, 50.24403  (xmin, xmax, ymin, ymax)
## crs        : +init=EPSG:3414 +datum=WGS84 +units=km +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## source     : memory
## names      : v 
## values     : -1.220673e-13, 833.2528  (min, max)

9.2 Visualising the output in tmap

9.2.1 Hotel room KDE on OpenStreetMap

  tm_shape(sg_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_Hotel_bw.km_raster) + 
  tm_raster("v", palette = "Reds", alpha = 0.7) +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Hotel room")
## Warning: Raster values found that are outside the range [0, 255]

9.2.2 We will also plot out a map showing Hotel room listing counts by regions in Singapore

Hotel_sf <- st_as_sf(Hotel,3414)
Hotel_sf <- Hotel_sf %>% 
  mutate(count = 1) # adding a count column
Hotel_SZ <-  Hotel_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Hotel_SZ <- st_set_geometry(Hotel_SZ, NULL)
colnames(Hotel_SZ)[1] = "PLN_AREA_N"
Hotel_SZ$PLN_AREA_N = as.factor(Hotel_SZ$PLN_AREA_N)
Hotel_SZ$PLN_AREA_N <- sapply(Hotel_SZ$PLN_AREA_N, toupper)
class(Hotel_SZ)
## [1] "tbl_df"     "tbl"        "data.frame"
class(mppa_sf)
## [1] "sf"         "data.frame"
Hotel_SZ_sf <- left_join(mppa_sf,Hotel_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
Hotel_SZ_sf <- Hotel_SZ_sf %>% drop_na()
Hotel_SZ_sf <- st_as_sf(Hotel_SZ_sf)
Hotel_SZ_sf <- st_transform(Hotel_SZ_sf, 4326)
max(Hotel_SZ_sf$freq)
## [1] 114
bins <- c(0, 20, 40, 60, 80, 100, 120)
pal <- colorBin("YlOrRd", domain = Hotel_SZ_sf$freq, bins = bins)

Hotel_Dist <- Hotel_SZ_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Hotel room Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(Hotel_SZ_sf$PLN_AREA_N,": ",Hotel_SZ_sf$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Hotel_Dist

We will observe that not all areas will be plotted as those regions without any listings will not be represented by our visualisations

9.2.3 Entire home/apt KDE on OpenStreetMap

  tm_shape(sg_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_Entire_bw.km_raster) + 
  tm_raster("v", palette = "Reds", alpha = 0.8) +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Entire home/apt room")
## Warning: Raster values found that are outside the range [0, 255]

9.2.4 We will also plot out a map showing Entire home/apt listing counts by regions in Singapore

Entire_sf <- st_as_sf(Entire,3414)
Entire_sf <- Entire_sf %>% 
  mutate(count = 1) # adding a count column
Entire_SZ <- Entire_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Entire_SZ <- st_set_geometry(Entire_SZ, NULL)
colnames(Entire_SZ)[1] = "PLN_AREA_N"
Entire_SZ$PLN_AREA_N = as.factor(Entire_SZ$PLN_AREA_N)
Entire_SZ$PLN_AREA_N <- sapply(Entire_SZ$PLN_AREA_N, toupper)
Entire_SZ_sf <- right_join(mppa_sf,Entire_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
Entire_SZ_sf <- st_transform(Entire_SZ_sf, 4326)
max(Entire_SZ_sf$freq)
## [1] 615
bins <- c(0, 100, 200, 300, 400, 500, 600, 700)
pal <- colorBin("YlOrRd", domain = Entire_SZ_sf$freq, bins = bins)

Entire_Dist <- Entire_SZ_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Entire home/apt room Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(Entire_SZ_sf$PLN_AREA_N,": ",Entire_SZ_sf$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Entire_Dist

9.2.5 Shared room KDE on OpenStreetMap

  tm_shape(sg_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_Shared_bw.km_raster) + 
  tm_raster("v", palette = "Reds", alpha = 0.7) +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Shared room")
## Warning: Raster values found that are outside the range [0, 255]

9.2.6 We will also plot out a map showing Shared room listing counts by regions in Singapore

Shared_sf <- st_as_sf(Shared,3414)
Shared_sf <- Shared_sf %>% 
  mutate(count = 1) # adding a count column
Shared_SZ <-  Shared_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Shared_SZ <- st_set_geometry(Shared_SZ, NULL)
colnames(Shared_SZ)[1] = "PLN_AREA_N"
Shared_SZ$PLN_AREA_N = as.factor(Shared_SZ$PLN_AREA_N)
Shared_SZ$PLN_AREA_N <- sapply(Shared_SZ$PLN_AREA_N, toupper)
Shared_SZ_sf <- right_join(mppa_sf,Shared_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
Shared_SZ_sf <- st_transform(Shared_SZ_sf, 4326)
max(Shared_SZ_sf$freq)
## [1] 64
bins <- c(0, 10, 20, 30, 40, 50, 60, 70)
pal <- colorBin("YlOrRd", domain = Shared_SZ_sf$freq, bins = bins)

Shared_Dist <- Shared_SZ_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Shared room Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(Shared_SZ_sf$PLN_AREA_N,": ",Shared_SZ_sf$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Shared_Dist

9.2.7 Private room KDE on OpenStreetMap

  tm_shape(sg_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_Private_bw.km_raster) + 
  tm_raster("v", palette = "Reds", alpha = 0.7) +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Private room")
## Warning: Raster values found that are outside the range [0, 255]

9.2.8 We will also plot out a map showing Private room listing counts by regions in Singapore

Private_sf <- st_as_sf(Private,3414)
Private_sf <- Private_sf %>% 
  mutate(count = 1) # adding a count column
Private_SZ <-  Private_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Private_SZ <- st_set_geometry(Private_SZ, NULL)
colnames(Private_SZ)[1] = "PLN_AREA_N"
Private_SZ$PLN_AREA_N = as.factor(Private_SZ$PLN_AREA_N)
Private_SZ$PLN_AREA_N <- sapply(Private_SZ$PLN_AREA_N, toupper)
Private_SZ_sf <- right_join(mppa_sf,Private_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
Private_SZ_sf <- st_transform(Private_SZ_sf, 4326)
max(Private_SZ_sf$freq)
## [1] 474
bins <- c(0, 100, 200, 300, 400, 500)
pal <- colorBin("YlOrRd", domain = Private_SZ_sf$freq, bins = bins)

Private_Dist <- Private_SZ_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Private room Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(Private_SZ_sf$PLN_AREA_N,": ",Private_SZ_sf$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Private_Dist

10 Section B: By Planning Subzones

10.1 We begin by subsetting mpsz dataframe into our specified subzones

aljunied = mpsz_sf[mpsz_sf$SUBZONE_N == "ALJUNIED",]
balestier = mpsz_sf[mpsz_sf$SUBZONE_N == "BALESTIER",]
lavender = mpsz_sf[mpsz_sf$SUBZONE_N == "LAVENDER",]
tanjongpagar = mpsz_sf[mpsz_sf$SUBZONE_N == "TANJONG PAGAR",]

10.1.1 Plotting the specified subzones

par(mfrow=c(2,2))
plot(st_geometry(aljunied), main = "Aljunied")
plot(st_geometry(balestier), main = "Balestier")
plot(st_geometry(lavender), main = "Lavender")
plot(st_geometry(tanjongpagar), main = "Tanjong Pagar")

10.1.2 Next we convert our SpatialPolygonsDataFrame into SpatialPolygons

aljunied_sp = as(as_Spatial(aljunied), "SpatialPolygons")
balestier_sp = as(as_Spatial(balestier), "SpatialPolygons")
lavendar_sp = as(as_Spatial(lavender), "SpatialPolygons")
tanjongpagar_sp = as(as_Spatial(tanjongpagar), "SpatialPolygons")

10.1.3 We then form our boundaries for the specified subzones

aljunied_owin = as(aljunied_sp, "owin")
balestier_owin = as(balestier_sp, "owin")
lavender_owin = as(lavendar_sp, "owin")
tanjongpagar_owin = as(tanjongpagar_sp, "owin")

10.1.4 We create our Hotel_ppp objects with our specified subzone boundaries

aljHotel_ppp = Hotel_ppp_jit[aljunied_owin]
balHotel_ppp = Hotel_ppp_jit[balestier_owin]
lavHotel_ppp = Hotel_ppp_jit[lavender_owin]
tanjHotel_ppp = Hotel_ppp_jit[tanjongpagar_owin]

10.1.5 Distribution of Hotel room listings in the specified subzones

par(mfrow=c(2,2))
plot(aljHotel_ppp,main="Aljunied - Hotel room")
plot(balHotel_ppp,main="Balestier - Hotel room")
plot(lavHotel_ppp,main="Lavender - Hotel room")
plot(tanjHotel_ppp,main="Tanjong Pagar - Hotel room")

Only 2 points are observed in Tanjong pagar

Balestier showing a some sign of clustering towards the central area, lavender shows some clustering at the north region while Aljunied displays clustering at the central area to a lesser extent.

10.1.6 We create our Entire_ppp objects with our specified subzone boundaries

aljEntire_ppp = Entire_ppp_jit[aljunied_owin]
balEntire_ppp = Entire_ppp_jit[balestier_owin]
lavEntire_ppp = Entire_ppp_jit[lavender_owin]
tanjEntire_ppp = Entire_ppp_jit[tanjongpagar_owin]

10.1.7 Distribution of Entire home/apt listings in the specified subzones

par(mfrow=c(2,2))
plot(aljEntire_ppp,main="Aljunied - Entire home/apt")
plot(balEntire_ppp,main="Balestier - Entire home/apt")
plot(lavEntire_ppp,main="Lavender - Entire home/apt")
plot(tanjEntire_ppp,main="Tanjong Pagar - Entire home/apt")

Clusterings are observed at the central regions and central-west regions of Aljunied. Clusters can also be observed in Tajong Pagar at the west region, in Balestier at the central south area and slight central-west.

For Lavender, we can observe some clustering towards the nort reigions.

10.1.8 We create our Shared_ppp objects with our specified subzone boundaries

aljShared_ppp = Shared_ppp_jit[aljunied_owin]
balShared_ppp = Shared_ppp_jit[balestier_owin]
lavShared_ppp = Shared_ppp_jit[lavender_owin]
tanjShared_ppp = Shared_ppp_jit[tanjongpagar_owin]

10.1.9 Distribution of Shared room listings in the specified subzones

par(mfrow=c(2,2))
plot(aljShared_ppp,main="Aljunied - Shared room")
plot(balShared_ppp,main="Balestier - Shared room")
plot(lavShared_ppp,main="Lavender - Shared room")
plot(tanjShared_ppp,main="Tanjong Pagar - Shared room")

Only one and no points are observed in Balestier and Tanjong Pagar respectively.

Lavender displays clustering at the north and central regions.

10.1.10 We create our Private_ppp objects with our specified subzone boundaries

aljPrivate_ppp = Private_ppp_jit[aljunied_owin]
balPrivate_ppp = Private_ppp_jit[balestier_owin]
lavPrivate_ppp = Private_ppp_jit[lavender_owin]
tanjPrivate_ppp = Private_ppp_jit[tanjongpagar_owin]

10.1.11 Distribution of Private room listings in the specified subzones

par(mfrow=c(2,2))
plot(aljPrivate_ppp,main="Aljunied - Private room")
plot(balPrivate_ppp,main="Balestier - Private room")
plot(lavPrivate_ppp,main="Lavender - Private room")
plot(tanjPrivate_ppp,main="Tanjong Pagar - Private room")

Visible clusters are seen in the central region of aljunied and balestier, central / east for lavender and some on the western side of tanjong pagar.

11 Performing 2nd Order Spatial Point Pattern Analysis for the room types

11.1 Hotel room type

11.1.1 Analysing Spatial Point Process Using G-Function

The G function will examine the cumulative frequency distribution of the nearest neighbor distances. It is the simplest measure and is similar to the mean

11.1.2 Computing G-Function Estimation

aljHotel_G = Gest(aljHotel_ppp, correction = "border")
plot(aljHotel_G)

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Aljunied is randomly distributed.

H1= The distribution of Hotel room type at Aljunied is not randomly distributed.

The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

aljHotel_G.csr <- envelope(aljHotel_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljHotel_G.csr)

While r < 20, it is observerd that the black line in within the envelope. Hence we are not able to reject the null hypothesis at and conclude that Aljunied Hotel room type exhibits complete spatial randomness

When r > 20, we can observe the black line above the red line and outside of the envelope. Therefore we can reject the null hypothesis and have enough statiscal significance to delcare that Aljunied hotel room listings exhibit clustering. At least till about r = 125.

balHotel_G = Gest(balHotel_ppp, correction = "border")
plot(balHotel_G)

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Balestier are randomly distributed.

H1= The distribution of Hotel room type at Balestier are not randomly distributed.

The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

balHotel_G.csr <- envelope(balHotel_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balHotel_G.csr)

The black line stays within the envelope save for a small portion where r is around 60 to 110 which could allow us to reject the null hypothesis and conclude that at the distribution exhibits clustering. However for the rest of the points, we are unable to reject the null hypothesis and conclude that the distribution of Hotel room types in Balestier exhibit complete spatial randomness.

lavHotel_G = Gest(lavHotel_ppp, correction = "border")
plot(lavHotel_G)

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Lavender are randomly distributed.

H1= The distribution of Hotel room type at Lavender are not randomly distributed.

The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

lavHotel_G.csr <- envelope(lavHotel_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavHotel_G.csr)

As majority of the black line is observed within the envelope, till about r = 50, we cannot reject the null hypothesis and declare that lavender hotel room type distribution is complete spatial randomness. However it can also be observed that the black line is above the envelope at r > 55 and thus allowing us to reject the null hypothesis and conclude that the distribution exhibits clustering .

As observed, since tanjong pagar only has 2 hotel room type listings, there is insufficient data to do analysis on tanjong pagar.

11.1.3 Analysing Spatial Point Process Using L-Function

aljHotel_L = Lest(aljHotel_ppp, correction = "Ripley")
plot(aljHotel_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Aljunied is randomly distributed.

H1= The distribution of Hotel room type at Aljunied is not randomly distributed.

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

aljHotel_L.csr <- envelope(aljHotel_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljHotel_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

The black line is observed to be inside the envelop from r < 110 and R > 370. Thus not allowing us to reject the null hypothesis

balHotel_L = Lest(balHotel_ppp, correction = "Ripley")
plot(balHotel_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Balestier are randomly distributed.

H1= The distribution of Hotel room type at Balestier are not randomly distributed.

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

balHotel_L.csr <- envelope(balHotel_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balHotel_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

After d > 75, black line is observerd to be above the envelope, hence we reject the null hypothesis and conclude that the distribution exhibits clustering but not before r = 75 where we cannot reject the null hypothesis as the black line is observed to be within the envelope.

lavHotel_L = Lest(lavHotel_ppp, correction = "Ripley")
plot(lavHotel_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Hotel room type at Lavender are randomly distributed.

H1= The distribution of Hotel room type at Lavender are not randomly distributed.

The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

lavHotel_L.csr <- envelope(lavHotel_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavHotel_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

After d > 40, black line is observerd to be above the envelope, hence we reject the null hypothesis and conclude that the distribution exhibits clustering but not before r = 40 where we cannot reject the null hypothesis as the black line is observed to be within the envelope.

As mentioned above, we are unable to perform analysis on tanjong pagar

11.1.4 Entire home/apt

aljEntire_G = Gest(aljEntire_ppp, correction = "border")
plot(aljEntire_G)

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Aljunied are randomly distributed.

H1= The distribution of Entire apt room type at Aljunied are not randomly distributed.

The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

aljEntire_G.csr <- envelope(aljEntire_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljEntire_G.csr)

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering

balEntire_G = Gest(balEntire_ppp, correction = "border")
plot(balEntire_G)

Performing Complete Spatial Randomness Test

To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows:

Ho = The distribution of Entire apt room type at Balestier are randomly distributed.

H1= The distribution of Entire apt room type at Balestier are not randomly distributed.

The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

balEntire_G.csr <- envelope(balEntire_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balEntire_G.csr)

After r = 8, Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

For r < 8 we cannot reject the null hypothesis as the black line is still within the envelope.

lavEntire_G = Gest(lavEntire_ppp, correction = "border")
plot(lavEntire_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Lavender are randomly distributed. H1= The distribution of Entire apt room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

lavEntire_G.csr <- envelope(lavEntire_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavEntire_G.csr)

Only at r = 30 to 40 , the black line is observed to be above the envelope, so only then can we reject the null hypothesis and conclude that distribution exhibits clustering.

Else, for the rest of the points we cannot reject the null as the black list exists within the envelope.

tanjEntire_G = Gest(tanjEntire_ppp, correction = "border")
plot(tanjEntire_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Tanjong Pagar are randomly distributed. H1= The distribution of Entire apt room type at Tanjong Pagar are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

tanjEntire_G.csr <- envelope(tanjEntire_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(tanjEntire_G.csr)

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

aljEntire_L = Lest(aljEntire_ppp, correction = "Ripley")
plot(aljEntire_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Aljunied are randomly distributed. H1= The distribution of Entire apt room type at Aljunied are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

aljEntire_L.csr <- envelope(aljEntire_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10 [etd 6:22] .........20 [etd 6:02] .........
## 30 [etd 5:55] .........40 [etd 5:50] .........50 [etd 5:41] ........
## .60 [etd 5:37] .........70 [etd 5:36] .........80 [etd 5:31] .......
## ..90 [etd 5:27] .........100 [etd 5:22] .........110 [etd 5:17] ......
## ...120 [etd 5:13] .........130 [etd 5:10] .........140 [etd 5:07] .....
## ....150 [etd 5:03] .........160 [etd 5:00] .........170 [etd 4:57] ....
## .....180 [etd 4:54] .........190 [etd 4:50] .........200 [etd 4:47] ...
## ......210 [etd 4:44] .........220 [etd 4:41] .........230 [etd 4:38] ..
## .......240 [etd 4:35] .........250 [etd 4:32] .........260 [etd 4:28] .
## ........270 [etd 4:24] .........280 [etd 4:22] .........290
##  [etd 4:18] .........300 [etd 4:14] .........310 [etd 4:11] .........
## 320 [etd 4:07] .........330 [etd 4:03] .........340 [etd 4:00] ........
## .350 [etd 3:56] .........360 [etd 3:53] .........370 [etd 3:49] .......
## ..380 [etd 3:46] .........390 [etd 3:42] .........400 [etd 3:39] ......
## ...410 [etd 3:35] .........420 [etd 3:31] .........430 [etd 3:27] .....
## ....440 [etd 3:24] .........450 [etd 3:20] .........460 [etd 3:17] ....
## .....470 [etd 3:13] .........480 [etd 3:09] .........490 [etd 3:06] ...
## ......500 [etd 3:02] .........510 [etd 2:58] .........520 [etd 2:55] ..
## .......530 [etd 2:51] .........540 [etd 2:47] .........550 [etd 2:44] .
## ........560 [etd 2:40] .........570 [etd 2:37] .........580
##  [etd 2:33] .........590 [etd 2:29] .........600 [etd 2:26] .........
## 610 [etd 2:22] .........620 [etd 2:19] .........630 [etd 2:15] ........
## .640 [etd 2:11] .........650 [etd 2:08] .........660 [etd 2:04] .......
## ..670 [etd 2:00] .........680 [etd 1:57] .........690 [etd 1:53] ......
## ...700 [etd 1:49] .........710 [etd 1:46] .........720 [etd 1:42] .....
## ....730 [etd 1:38] .........740 [etd 1:35] .........750 [etd 1:31] ....
## .....760 [etd 1:27] .........770 [etd 1:24] .........780 [etd 1:20] ...
## ......790 [etd 1:17] .........800 [etd 1:13] .........810 [etd 1:09] ..
## .......820 [etd 1:06] .........830 [etd 1:02] .........840 [etd 58 sec] .
## ........850 [etd 54 sec] .........860 [etd 51 sec] .........870
##  [etd 47 sec] .........880 [etd 43 sec] .........890 [etd 40 sec] .........
## 900 [etd 36 sec] .........910 [etd 33 sec] .........920 [etd 29 sec] ........
## .930 [etd 25 sec] .........940 [etd 22 sec] .........950 [etd 18 sec] .......
## ..960 [etd 14 sec] .........970 [etd 11 sec] .........980 [etd 7 sec] ......
## ...990 [etd 3 sec] ........ 999.
## 
## Done.
plot(aljEntire_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

balEntire_L = Lest(balEntire_ppp, correction = "Ripley")
plot(balEntire_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Balestier are randomly distributed. H1= The distribution of Entire apt room type at Balestier are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

balEntire_L.csr <- envelope(balEntire_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balEntire_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

lavEntire_L = Lest(lavEntire_ppp, correction = "Ripley")
plot(lavEntire_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Lavender are randomly distributed. H1= The distribution of Entire apt room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

lavEntire_L.csr <- envelope(lavEntire_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavEntire_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

tanjEntire_L = Lest(tanjEntire_ppp, correction = "Ripley")
plot(tanjEntire_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of Entire apt room type at Tanjong Pagar are randomly distributed. H1= The distribution of Entire apt room type at Tanjong Pagar are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

tanjEntire_L.csr <- envelope(tanjEntire_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(tanjEntire_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line is observed to be above the envelope. Hence we reject the null and conclude that the distribution exhibits clustering.

aljShared_G = Gest(aljShared_ppp, correction = "border")
plot(aljShared_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of shared room type at Aljunied are randomly distributed. H1= The distribution of shared room type at Aljunied are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

aljShared_G.csr <- envelope(aljShared_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljShared_G.csr)

Black line is always within the envelope. Hence we cannot reject the null hypothesis.

Only 1 point in balestier, insufficient data point.

lavShared_G = Gest(lavShared_ppp, correction = "border")
plot(lavShared_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of shared room type at Lavender are randomly distributed. H1= The distribution of shared room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

lavShared_G.csr <- envelope(lavShared_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavShared_G.csr)

Black line is always within the envelope. Hence we cannot reject the null hypothesis.

tanjong pagar no listings so we cannot perform analysis on it

aljShared_L = Lest(aljShared_ppp, correction = "Ripley")
plot(aljShared_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

aljShared_L.csr <- envelope(aljShared_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljShared_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line is always within the envelope. Hence we cannot reject the null hypothesis.

Balestier 1 listing so we cannot perform analysis on it

lavShared_L = Lest(lavShared_ppp, correction = "Ripley")
plot(lavShared_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of shared room type at Lavender are randomly distributed. H1= The distribution of shared room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

lavShared_L.csr <- envelope(lavShared_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavShared_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

After r = 25, black line always above envelope. Hence we reject null hypothesis and conclude the distribution exhibits clustering. For r < 25 we cannot reject null hypothesis as black line exists within the envelope.

aljPrivate_G = Gest(aljPrivate_ppp, correction = "border")
plot(aljPrivate_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Aljunied are randomly distributed. H1= The distribution of private room type at Aljunied are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

aljPrivate_G.csr <- envelope(aljPrivate_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljPrivate_G.csr)

Black line is observed above the envelope. Hence reject null hypothesis and conclude that distribution exhibit clustering.

balPrivate_G = Gest(balPrivate_ppp, correction = "border")
plot(balPrivate_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Balestier are randomly distributed. H1= The distribution of private room type at Balestier are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

balPrivate_G.csr <- envelope(balPrivate_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balPrivate_G.csr)

After r = 50, Black line is observed above the envelope. Hence reject null hypothesis and conclude that distribution exhibit clustering.

Before r = 50, Black line is not observed to be above the envelope. hence we cannot reject the null hypothesis.

lavPrivate_G = Gest(lavPrivate_ppp, correction = "border")
plot(lavPrivate_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Lavender are randomly distributed. H1= The distribution of private room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

lavPrivate_G.csr <- envelope(lavPrivate_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavPrivate_G.csr)

After r = 5, Black line is observed above the envelope. Hence reject null hypothesis and conclude that distribution exhibit clustering.

tanjPrivate_G = Gest(tanjPrivate_ppp, correction = "border")
plot(tanjPrivate_G)

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Tanjong Pagar are randomly distributed. H1= The distribution of private room type at Tanjong Pagar are not randomly distributed. The null hypothesis will be rejected if p-value is smaller than alpha value of 0.001.

Monte Carlo test with G-function

tanjPrivate_G.csr <- envelope(tanjPrivate_ppp, Gest, nsim=999)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(tanjPrivate_G.csr)

Black line always exists within the envelope, therefore we cannot reject the null hypothesis.

aljPrivate_L = Lest(aljPrivate_ppp, correction = "Ripley")
plot(aljPrivate_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Aljunied are randomly distributed. H1= The distribution of private room type at Aljunied are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

aljPrivate_L.csr <- envelope(aljPrivate_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(aljPrivate_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line always exists outside the envelope, therefore we reject the null hypothesis and conclude that the distribution exhibits clustering.

balPrivate_L = Lest(balPrivate_ppp, correction = "Ripley")
plot(balPrivate_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Balestier are randomly distributed. H1= The distribution of private room type at Balestier are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

balPrivate_L.csr <- envelope(balPrivate_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(balPrivate_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line always exists outside the envelope, therefore we reject the null hypothesis and conclude that the distribution exhibits clustering.

lavPrivate_L = Lest(lavPrivate_ppp, correction = "Ripley")
plot(lavPrivate_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Lavender are randomly distributed. H1= The distribution of private room type at Lavender are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

lavPrivate_L.csr <- envelope(lavPrivate_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(lavPrivate_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line always exists outside the envelope, therefore we reject the null hypothesis and conclude that the distribution exhibits clustering.

tanjPrivate_L = Lest(tanjPrivate_ppp, correction = "Ripley")
plot(tanjPrivate_L, . -r ~ r, 
     ylab= "L(d)-r", xlab = "d(m)")

Performing Complete Spatial Randomness Test To confirm the observed spatial patterns above, a hypothesis test will be conducted. The hypothesis and test are as follows: Ho = The distribution of private room type at Tanjong Pagar are randomly distributed. H1= The distribution of private room type at Tanjong Pagar are not randomly distributed. The null hypothesis will be rejected if p-value if smaller than alpha value of 0.001.

tanjPrivate_L.csr <- envelope(tanjPrivate_ppp, Lest, nsim=999, rank = 1, glocal=TRUE)
## Generating 999 simulations of CSR  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990........ 999.
## 
## Done.
plot(tanjPrivate_L.csr, . - r ~ r, xlab="d", ylab="L(d)-r")

Black line always exists inside the envelope, therefore we cannot reject the null hypothesis.

12 Kernal Density Estimation

As mentioned above we convert from m to km

aljHotel_ppp.km <- rescale(aljHotel_ppp, 1000, "km")
balHotel_ppp.km <- rescale(balHotel_ppp, 1000, "km")
lavHotel_ppp.km <- rescale(lavHotel_ppp, 1000, "km")
tanjHotel_ppp.km <- rescale(tanjHotel_ppp, 1000, "km")
kde_aljHotel_bw <- density(aljHotel_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_aljHotel_bw)

kde_balHotel_bw <- density(balHotel_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_balHotel_bw)

kde_lavHotel_bw <- density(lavHotel_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_lavHotel_bw)

kde_tanjHotel_bw <- density(tanjHotel_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
## Warning: Berman-Diggle Cross-Validation criterion was minimised at right-hand
## end of interval [0, 0.03]; use argument 'hmax' to specify a wider interval for
## bandwidth 'sigma'
plot(kde_tanjHotel_bw)

aljEntire_ppp.km <- rescale(aljEntire_ppp, 1000, "km")
balEntire_ppp.km <- rescale(balEntire_ppp, 1000, "km")
lavEntire_ppp.km <- rescale(lavEntire_ppp, 1000, "km")
tanjEntire_ppp.km <- rescale(tanjEntire_ppp, 1000, "km")
kde_aljEntire_bw <- density(aljEntire_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_aljEntire_bw)

kde_balEntire_bw <- density(balEntire_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_balEntire_bw)

kde_lavEntire_bw <- density(lavEntire_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_lavEntire_bw)

kde_tanjEntire_bw <- density(tanjEntire_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_tanjEntire_bw)

aljShared_ppp.km <- rescale(aljShared_ppp, 1000, "km")
balShared_ppp.km <- rescale(balShared_ppp, 1000, "km")
lavShared_ppp.km <- rescale(lavShared_ppp, 1000, "km")
tanjShared_ppp.km <- rescale(tanjShared_ppp, 1000, "km")
kde_aljShared_bw <- density(aljShared_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_aljShared_bw)

kde_balShared_bw <- density(balShared_ppp.km, sigma=0.01, edge=TRUE, kernel="gaussian")
plot(kde_balShared_bw)

kde_lavShared_bw <- density(lavShared_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_lavShared_bw)

kde_tanjShared_bw <- density(tanjShared_ppp.km, sigma=0.01, edge=TRUE, kernel="gaussian")
plot(kde_tanjShared_bw)

aljPrivate_ppp.km <- rescale(aljPrivate_ppp, 1000, "km")
balPrivate_ppp.km <- rescale(balPrivate_ppp, 1000, "km")
lavPrivate_ppp.km <- rescale(lavPrivate_ppp, 1000, "km")
tanjPrivate_ppp.km <- rescale(tanjPrivate_ppp, 1000, "km")
kde_aljPrivate_bw <- density(aljPrivate_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_aljPrivate_bw)

kde_balPrivate_bw <- density(balPrivate_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_balPrivate_bw)

kde_lavPrivate_bw <- density(lavPrivate_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_lavPrivate_bw)

kde_tanjPrivate_bw <- density(tanjPrivate_ppp.km, sigma=bw.diggle, edge=TRUE, kernel="gaussian")
plot(kde_tanjPrivate_bw)

szFilter <- c('ALJUNIED', 'BALESTIER', 'LAVENDER' ,'TANJONG PAGAR')
mpsz_filtered <- filter(mpsz_sf, SUBZONE_N %in% szFilter)
Hotel_filter_SZ <- Hotel_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Hotel_filter_SZ <- st_set_geometry(Hotel_filter_SZ, NULL)
colnames(Hotel_filter_SZ)[1] = "PLN_AREA_N"
Hotel_filter_SZ$PLN_AREA_N = as.factor(Hotel_filter_SZ$PLN_AREA_N)
Hotel_filter_SZ$PLN_AREA_N <- sapply(Hotel_filter_SZ$PLN_AREA_N, toupper)
mpsz_filtered_P <- left_join(mpsz_filtered,Hotel_filter_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
mpsz_filtered_P <- st_transform(mpsz_filtered_P, 4326)
max(mpsz_filtered_P$freq)
## [1] 80
bins <- c(0, 10, 20, 30, 40, 50, 60, 70, 80)
pal <- colorBin("YlOrRd", domain = mpsz_filtered_P$freq, bins = bins)

Hotel_filter_Dist <- mpsz_filtered_P %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Filtered Subzone Hotel room <br> Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(mpsz_filtered_P$SUBZONE_N,": ",mpsz_filtered_P$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Hotel_filter_Dist
Entire_filter_SZ <- Entire_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Entire_filter_SZ <- st_set_geometry(Entire_filter_SZ, NULL)
colnames(Entire_filter_SZ)[1] = "PLN_AREA_N"
Entire_filter_SZ$PLN_AREA_N = as.factor(Entire_filter_SZ$PLN_AREA_N)
Entire_filter_SZ$PLN_AREA_N <- sapply(Entire_filter_SZ$PLN_AREA_N, toupper)
mpsz_filtered_E <- left_join(mpsz_filtered,Entire_filter_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
mpsz_filtered_E <- st_transform(mpsz_filtered_E, 4326)
max(mpsz_filtered_E$freq)
## [1] 615
bins <- c(0, 100, 200, 300, 400, 500, 600, 700)
pal <- colorBin("YlOrRd", domain = mpsz_filtered_E$freq, bins = bins)

Entire_filter_Dist <- mpsz_filtered_E %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Filtered Subzone Entire home/apt <br> Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(mpsz_filtered_E$SUBZONE_N,": ",mpsz_filtered_E$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Entire_filter_Dist
Shared_filter_SZ <- Shared_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Shared_filter_SZ <- st_set_geometry(Shared_filter_SZ, NULL)
colnames(Shared_filter_SZ)[1] = "PLN_AREA_N"
Shared_filter_SZ$PLN_AREA_N = as.factor(Shared_filter_SZ$PLN_AREA_N)
Shared_filter_SZ$PLN_AREA_N <- sapply(Shared_filter_SZ$PLN_AREA_N, toupper)
mpsz_filtered_S <- left_join(mpsz_filtered,Shared_filter_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
mpsz_filtered_S <- st_transform(mpsz_filtered_S, 4326)
max(mpsz_filtered_S$freq)
## [1] 64
bins <- c(0, 10, 20, 30, 40, 50, 60, 70)
pal <- colorBin("YlOrRd", domain = mpsz_filtered_S$freq, bins = bins)

Shared_filter_Dist <- mpsz_filtered_S %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Filtered Subzone Shared room <br> Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(mpsz_filtered_S$SUBZONE_N,": ",mpsz_filtered_S$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Shared_filter_Dist
Private_filter_SZ <- Private_sf %>%
  group_by(neighbourhood) %>%
  summarise(freq = sum(count)) # counting UF by Subzone
Private_filter_SZ <- st_set_geometry(Private_filter_SZ, NULL)
colnames(Private_filter_SZ)[1] = "PLN_AREA_N"
Private_filter_SZ$PLN_AREA_N = as.factor(Private_filter_SZ$PLN_AREA_N)
Private_filter_SZ$PLN_AREA_N <- sapply(Private_filter_SZ$PLN_AREA_N, toupper)
mpsz_filtered_P <- left_join(mpsz_filtered,Private_filter_SZ)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
mpsz_filtered_P <- st_transform(mpsz_filtered_P, 4326)
max(mpsz_filtered_P$freq)
## [1] 474
bins <- c(0, 100, 200, 300, 400, 500)
pal <- colorBin("YlOrRd", domain = mpsz_filtered_P$freq, bins = bins)

Private_filter_Dist <- mpsz_filtered_P %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Filtered Subzone Private room <br> Listing Distribution",
            position = "bottomright") %>%
  addPolygons(label = ~paste(mpsz_filtered_P$SUBZONE_N,": ",mpsz_filtered_P$freq),fillColor = ~pal(freq),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Private_filter_Dist

13 Projecting Kernal Density Maps on OpenStreetMap

13.0.1 Converting KDE output into grid object. (Aljunid)

gridded_kde_aljHotel_bw<- as.SpatialGridDataFrame.im(kde_aljHotel_bw)
gridded_kde_aljEntire_bw<- as.SpatialGridDataFrame.im(kde_aljEntire_bw)
gridded_kde_aljShared_bw<- as.SpatialGridDataFrame.im(kde_aljShared_bw)
gridded_kde_aljPrivate_bw<- as.SpatialGridDataFrame.im(kde_aljPrivate_bw)

13.0.2 Converting gridded output into raster (Aljunid)

gridded_kde_aljHotel_bw_raster <- raster(gridded_kde_aljHotel_bw)
gridded_kde_aljEntire_bw_raster <- raster(gridded_kde_aljEntire_bw)
gridded_kde_aljShared_bw_raster <- raster(gridded_kde_aljShared_bw)
gridded_kde_aljPrivate_bw_raster <- raster(gridded_kde_aljPrivate_bw)

13.0.3 Assigning projection systems (Aljunid)

projection(gridded_kde_aljHotel_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_aljEntire_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_aljShared_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_aljPrivate_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

13.0.4 Converting KDE output into grid object. (Balestier)

gridded_kde_balHotel_bw<- as.SpatialGridDataFrame.im(kde_balHotel_bw)
gridded_kde_balEntire_bw<- as.SpatialGridDataFrame.im(kde_balEntire_bw)
gridded_kde_balShared_bw<- as.SpatialGridDataFrame.im(kde_balShared_bw)
gridded_kde_balPrivate_bw<- as.SpatialGridDataFrame.im(kde_balPrivate_bw)

13.0.5 Converting gridded output into raster (Balestier)

gridded_kde_balHotel_bw_raster <- raster(gridded_kde_balHotel_bw)
gridded_kde_balEntire_bw_raster <- raster(gridded_kde_balEntire_bw)
gridded_kde_balShared_bw_raster <- raster(gridded_kde_balShared_bw)
gridded_kde_balPrivate_bw_raster <- raster(gridded_kde_balPrivate_bw)

13.0.6 Assigning projection systems (Balestier)

projection(gridded_kde_balHotel_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_balEntire_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_balShared_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_balPrivate_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

13.0.7 Converting KDE output into grid object. (Lavender)

gridded_kde_lavHotel_bw<- as.SpatialGridDataFrame.im(kde_lavHotel_bw)
gridded_kde_lavEntire_bw<- as.SpatialGridDataFrame.im(kde_lavEntire_bw)
gridded_kde_lavShared_bw <- as.SpatialGridDataFrame.im(kde_lavShared_bw)
gridded_kde_lavPrivate_bw<- as.SpatialGridDataFrame.im(kde_lavPrivate_bw)

13.0.8 Converting gridded output into raster (Lavender)

gridded_kde_lavHotel_bw_raster <- raster(gridded_kde_lavHotel_bw)
gridded_kde_lavEntire_bw_raster <- raster(gridded_kde_lavEntire_bw)
gridded_kde_lavShared_bw_raster <- raster(gridded_kde_lavShared_bw)
gridded_kde_lavPrivate_bw_raster <- raster(gridded_kde_lavPrivate_bw)

13.0.9 Assigning projection systems (Lavender)

projection(gridded_kde_lavHotel_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_lavEntire_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_lavShared_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_lavPrivate_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

13.0.10 Converting KDE output into grid object. (Tanjong Pagar)

gridded_kde_tanjHotel_bw<- as.SpatialGridDataFrame.im(kde_tanjHotel_bw)
gridded_kde_tanjEntire_bw<- as.SpatialGridDataFrame.im(kde_tanjEntire_bw)
gridded_kde_tanjShared_bw<- as.SpatialGridDataFrame.im(kde_tanjShared_bw)
gridded_kde_tanjPrivate_bw<- as.SpatialGridDataFrame.im(kde_tanjPrivate_bw)

13.0.11 Converting gridded output into raster (Tanjong Pagar)

gridded_kde_tanjHotel_bw_raster <- raster(gridded_kde_tanjHotel_bw)
gridded_kde_tanjEntire_bw_raster <- raster(gridded_kde_tanjEntire_bw)
gridded_kde_tanjShared_bw_raster <- raster(gridded_kde_tanjShared_bw)
gridded_kde_tanjPrivate_bw_raster <- raster(gridded_kde_tanjPrivate_bw)

13.0.12 Assigning projection systems (Tanjong Pagar)

projection(gridded_kde_tanjHotel_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_tanjEntire_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_tanjShared_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")
projection(gridded_kde_tanjPrivate_bw_raster) <- CRS("+init=EPSG:3414 +datum=WGS84 +units=km")

14 Analysing Spatial Patterns of room types in each subzone

14.0.1 Aljunied

class(al_bb)
## [1] "bbox"
aljHotelMap <- tm_shape(al_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_aljHotel_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Aljunied - Hotel room")

aljEntireMap <- tm_shape(al_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_aljEntire_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Aljunied - Entire home/apt")

aljSharedMap <- tm_shape(al_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_aljShared_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Aljunied - Shared room")

aljPrivateMap <- tm_shape(al_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_aljPrivate_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Aljunied - Private room")

tmap_arrange(aljHotelMap, aljEntireMap, aljSharedMap, aljPrivateMap, asp=2, ncol=2)
## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]
## Some legend labels were too wide. These labels have been resized to 0.60, 0.60, 0.60, 0.60, 0.60. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

Clustering is observed in aljunied shared room in the central and east regions, in the central and west regions for entire home/apt and similar in hotel room. Private room cluster observed in central area.

14.0.2 Balestier

balHotelMap <- tm_shape(ba_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_balHotel_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Balestier - Hotel room")

balEntireMap <- tm_shape(ba_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_balEntire_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Balestier - Entire home/apt")

balSharedMap <- tm_shape(ba_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_balShared_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Balestier - Shared room")

balPrivateMap <- tm_shape(ba_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_balPrivate_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Balestier - Private room")

tmap_arrange(balHotelMap, balEntireMap, balSharedMap, balPrivateMap, asp=2, ncol=2)
## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
## Warning: Raster values found that are outside the range [0, 255]

Clustering is observed in the central south regions for hotel room, entire home/apt and private room types, additional some clustering is noted at the northern region of hotel and entire home/apt.

Since shared room only has 1 point, we will not draw conclusions on it.

14.0.3 Lavender

lavHotelMap <- tm_shape(la_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_lavHotel_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Lavender - Hotel room")

lavEntireMap <- tm_shape(la_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_lavEntire_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Lavender - Entire home/apt")

lavSharedMap <- tm_shape(la_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_lavShared_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Lavender - Shared room")

lavPrivateMap <- tm_shape(la_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_lavPrivate_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Lavender - Private room")

tmap_arrange(lavHotelMap, lavEntireMap, lavSharedMap, lavPrivateMap, asp=2, ncol=2)
## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59, 0.59. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

Clusters are observed in the northern regions of hotel & entire home/apt and towards the central south region in private room. Central and North region exhibit clustering in shared room

14.0.4 Tanjong Pagar

tanjHotelMap <- tm_shape(tp_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_tanjHotel_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Tanjong Pagar -  Hotelroom")

tanjEntireMap <- tm_shape(tp_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_tanjEntire_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Tanjong Pagar - Entire home/apt")

tanjSharedMap <- tm_shape(tp_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_tanjShared_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Tanjong Pagar - Shared room")

tanjPrivateMap <- tm_shape(tp_osm) +
    tm_layout(legend.outside = TRUE)+
    tm_rgb()+
  tm_shape(mpsz_sp)+
    tm_borders(alpha=0.5, col = "black", lwd = 0.5)+
tm_shape(gridded_kde_tanjPrivate_bw_raster) + 
  tm_raster("v", alpha = 0.8, palette = "Reds") +
  tm_layout(legend.position = c("right", "bottom"), frame = FALSE, title = "Tanjong Pagar - Private room")

tmap_arrange(tanjHotelMap, tanjEntireMap, tanjSharedMap, tanjPrivateMap, asp=2, ncol=2)
## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]
## Some legend labels were too wide. These labels have been resized to 0.59, 0.59, 0.59, 0.59. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
## Warning: Raster values found that are outside the range [0, 255]

## Warning: Raster values found that are outside the range [0, 255]

Some clustering exhibited in the west regions for private room and entire home/apt. Since shared and hotel rooms have 2 and none values respectively, we will not draw conconlusions for them.

15 Extra

We will be displaying the average prices of each room type airbnb listings in the various subzones and regions

15.0.1 Hotel room

ABHotel <- ABListing %>% 
  filter(room_type == 'Hotel room')
ABHotel <- select(ABHotel,neighbourhood,price)
colnames(ABHotel)[1] = "PLN_AREA_N"
ABHotel$PLN_AREA_N = as.factor(ABHotel$PLN_AREA_N)
ABHotel$PLN_AREA_N <- sapply(ABHotel$PLN_AREA_N, toupper)
ABHotel_sf <- left_join(mpsz_sf,ABHotel)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_sf <- select(ABHotel_sf,SUBZONE_N,PLN_AREA_N,price,geometry)
ABHotel_sf <- aggregate (price ~ SUBZONE_N, ABHotel_sf, mean)
ABHotel_sf <- left_join(mpsz_sf,ABHotel_sf)
## Joining, by = "SUBZONE_N"
ABHotel_sf <- na.omit(ABHotel_sf)
ABHotel_sf <-st_transform(ABHotel_sf,4326)
max(ABHotel_sf$price)
## [1] 417.0714

Although the highlights provide the subzone name and price, since ABListing’s data is stored via planning area data instead, the visualisation here may be inaccurate, although it may provide a deeper look into the subzones of each region. However since it still shows only the planning area cost, we will opt not to display the individual subzones.

Hence we will plot a planning area region map as well.

ABHotel_PA_sf <- left_join(mppa_sf,ABHotel)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_PA_sf <- select(ABHotel_PA_sf,PLN_AREA_N,price,geometry)
ABHotel_PA_sf <- aggregate (price ~ PLN_AREA_N, ABHotel_PA_sf, mean)
ABHotel_PA_sf <- left_join(mppa_sf,ABHotel_PA_sf)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_PA_sf <- na.omit(ABHotel_PA_sf)
ABHotel_PA_sf <-st_transform(ABHotel_PA_sf,4326)
max(ABHotel_PA_sf$price)
## [1] 417.0714
bins <- c(0, 100, 200, 300, 400, 500)
pal <- colorBin("YlOrRd", domain = ABHotel_PA_sf$price, bins = bins)

Hotel_Price_Dist_PA <- ABHotel_PA_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Hotel room Average <br> Planning Area Pricing",
            position = "bottomright") %>%
  addPolygons(label = ~paste(ABHotel_PA_sf$PLN_AREA_N,": S$",ABHotel_PA_sf$price),fillColor = ~pal(price),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Hotel_Price_Dist_PA
ABHotel <- ABListing %>% 
  filter(room_type == 'Hotel room')
ABHotel <- select(ABHotel,neighbourhood,price)
colnames(ABHotel)[1] = "PLN_AREA_N"
ABHotel$PLN_AREA_N = as.factor(ABHotel$PLN_AREA_N)
ABHotel$PLN_AREA_N <- sapply(ABHotel$PLN_AREA_N, toupper)
ABHotel_sf <- left_join(mpsz_sf,ABHotel)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_sf <- select(ABHotel_sf,SUBZONE_N,PLN_AREA_N,price,geometry)
ABHotel_sf <- aggregate (price ~ SUBZONE_N, ABHotel_sf, mean)
ABHotel_sf <- left_join(mpsz_sf,ABHotel_sf)
## Joining, by = "SUBZONE_N"
ABHotel_sf <- na.omit(ABHotel_sf)
ABHotel_sf <-st_transform(ABHotel_sf,4326)
max(ABHotel_sf$price)
## [1] 417.0714
ABHotel_PA_sf <- left_join(mppa_sf,ABHotel)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_PA_sf <- select(ABHotel_PA_sf,PLN_AREA_N,price,geometry)
ABHotel_PA_sf <- aggregate (price ~ PLN_AREA_N, ABHotel_PA_sf, mean)
ABHotel_PA_sf <- left_join(mppa_sf,ABHotel_PA_sf)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABHotel_PA_sf <- na.omit(ABHotel_PA_sf)
ABHotel_PA_sf <-st_transform(ABHotel_PA_sf,4326)
max(ABHotel_PA_sf$price)
## [1] 417.0714
bins <- c(0, 100, 200, 300, 400, 500)
pal <- colorBin("YlOrRd", domain = ABHotel_PA_sf$price, bins = bins)

Hotel_Price_Dist_PA <- ABHotel_PA_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Hotel room Average <br> Planning Area Pricing",
            position = "bottomright") %>%
  addPolygons(label = ~paste(ABHotel_PA_sf$PLN_AREA_N,": S$",ABHotel_PA_sf$price),fillColor = ~pal(price),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Hotel_Price_Dist_PA

15.0.2 Entire room/apt room

ABEntire <- ABListing %>% 
  filter(room_type == 'Entire home/apt')
ABEntire <- select(ABEntire,neighbourhood,price)
colnames(ABEntire)[1] = "PLN_AREA_N"
ABEntire$PLN_AREA_N = as.factor(ABEntire$PLN_AREA_N)
ABEntire$PLN_AREA_N <- sapply(ABEntire$PLN_AREA_N, toupper)
ABEntire_sf <- left_join(mpsz_sf,ABEntire)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABEntire_sf <- select(ABEntire_sf,SUBZONE_N,PLN_AREA_N,price,geometry)
ABEntire_sf <- aggregate (price ~ SUBZONE_N, ABEntire_sf, mean)
ABEntire_sf <- left_join(mpsz_sf,ABEntire_sf)
## Joining, by = "SUBZONE_N"
ABEntire_sf <- na.omit(ABEntire_sf)
ABEntire_sf <-st_transform(ABEntire_sf,4326)
max(ABEntire_sf$price)
## [1] 9999
ABEntire_PA_sf <- left_join(mppa_sf,ABEntire)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABEntire_PA_sf <- select(ABEntire_PA_sf,PLN_AREA_N,price,geometry)
ABEntire_PA_sf <- aggregate (price ~ PLN_AREA_N, ABEntire_PA_sf, mean)
ABEntire_PA_sf <- left_join(mppa_sf,ABEntire_PA_sf)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABEntire_PA_sf <- na.omit(ABEntire_PA_sf)
ABEntire_PA_sf <-st_transform(ABEntire_PA_sf,4326)
max(ABEntire_PA_sf$price)
## [1] 9999
bins <- c(0, 100, 200, 300, 400, 500, 10000)
pal <- colorBin("YlOrRd", domain = ABEntire_PA_sf$price, bins = bins)

Entire_Price_Dist_PA <- ABEntire_PA_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Entire home/apt Average <br> Planning Area Pricing",
            position = "bottomright") %>%
  addPolygons(label = ~paste(ABEntire_PA_sf$PLN_AREA_N,": S$",ABEntire_PA_sf$price),fillColor = ~pal(price),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Entire_Price_Dist_PA

15.0.3 Shared room/apt room

ABShared <- ABListing %>% 
  filter(room_type == 'Shared room')
ABShared <- select(ABShared,neighbourhood,price)
colnames(ABShared)[1] = "PLN_AREA_N"
ABShared$PLN_AREA_N = as.factor(ABShared$PLN_AREA_N)
ABShared$PLN_AREA_N <- sapply(ABShared$PLN_AREA_N, toupper)
ABShared_sf <- left_join(mpsz_sf,ABShared)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABShared_sf <- select(ABShared_sf,SUBZONE_N,PLN_AREA_N,price,geometry)
ABShared_sf <- aggregate (price ~ SUBZONE_N, ABShared_sf, mean)
ABShared_sf <- left_join(mpsz_sf,ABShared_sf)
## Joining, by = "SUBZONE_N"
ABShared_sf <- na.omit(ABShared_sf)
ABShared_sf <-st_transform(ABShared_sf,4326)
max(ABShared_sf$price)
## [1] 350
ABShared_PA_sf <- left_join(mppa_sf,ABShared)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABShared_PA_sf <- select(ABShared_PA_sf,PLN_AREA_N,price,geometry)
ABShared_PA_sf <- aggregate (price ~ PLN_AREA_N, ABShared_PA_sf, mean)
ABShared_PA_sf <- left_join(mppa_sf,ABShared_PA_sf)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABShared_PA_sf <- na.omit(ABShared_PA_sf)
ABShared_PA_sf <-st_transform(ABShared_PA_sf,4326)
max(ABShared_PA_sf$price)
## [1] 350
bins <- c(0, 50, 100, 150, 200, 250, 300, 350)
pal <- colorBin("YlOrRd", domain = ABShared_PA_sf$price, bins = bins)

Shared_Price_Dist_PA <- ABShared_PA_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Shared room Average <br> Planning Area Pricing",
            position = "bottomright") %>%
  addPolygons(label = ~paste(ABShared_PA_sf$PLN_AREA_N,": S$",ABShared_PA_sf$price),fillColor = ~pal(price),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Shared_Price_Dist_PA

15.0.4 Private room/apt room

ABPrivate <- ABListing %>% 
  filter(room_type == 'Private room')
ABPrivate <- select(ABPrivate,neighbourhood,price)
colnames(ABPrivate)[1] = "PLN_AREA_N"
ABPrivate$PLN_AREA_N = as.factor(ABPrivate$PLN_AREA_N)
ABPrivate$PLN_AREA_N <- sapply(ABPrivate$PLN_AREA_N, toupper)
ABPrivate_sf <- left_join(mpsz_sf,ABPrivate)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABPrivate_sf <- select(ABPrivate_sf,SUBZONE_N,PLN_AREA_N,price,geometry)
ABPrivate_sf <- aggregate (price ~ SUBZONE_N, ABPrivate_sf, mean)
ABPrivate_sf <- left_join(mpsz_sf,ABPrivate_sf)
## Joining, by = "SUBZONE_N"
ABPrivate_sf <- na.omit(ABPrivate_sf)
ABPrivate_sf <-st_transform(ABPrivate_sf,4326)
max(ABPrivate_sf$price)
## [1] 514.1667
ABPrivate_PA_sf <- left_join(mppa_sf,ABPrivate)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABPrivate_PA_sf <- select(ABPrivate_PA_sf,PLN_AREA_N,price,geometry)
ABPrivate_PA_sf <- aggregate (price ~ PLN_AREA_N, ABPrivate_PA_sf, mean)
ABPrivate_PA_sf <- left_join(mppa_sf,ABPrivate_PA_sf)
## Joining, by = "PLN_AREA_N"
## Warning: Column `PLN_AREA_N` joining factor and character vector, coercing into
## character vector
ABPrivate_PA_sf <- na.omit(ABPrivate_PA_sf)
ABPrivate_PA_sf <-st_transform(ABPrivate_PA_sf,4326)
max(ABPrivate_PA_sf$price)
## [1] 514.1667
bins <- c(0, 100, 200, 300, 400, 500, 600)
pal <- colorBin("YlOrRd", domain = ABPrivate_PA_sf$price, bins = bins)

Private_Price_Dist_PA <- ABPrivate_PA_sf %>%
  leaflet() %>%
  addLegend(pal = pal,
            values = ~n,
            opacity = 0.7,
            title = "Airbnb Private room Average <br> Planning Area Pricing",
            position = "bottomright") %>%
  addPolygons(label = ~paste(ABPrivate_PA_sf$PLN_AREA_N,": S$",ABPrivate_PA_sf$price),fillColor = ~pal(price),
              color = "#888888",
              weight = 1,
              smoothFactor = 0.5,
              opacity = 1.0,
              fillOpacity = 0.5,
              highlightOptions = highlightOptions(color = "white",
                                                  weight = 2,
                                                  bringToFront = TRUE)) %>%
  addTiles()
## Warning in is.na(values): is.na() applied to non-(list or vector) of type
## 'closure'
Private_Price_Dist_PA