Data Used

Aspatial

  1. listings.csv - Provided

Geospatial

  1. MP14_SUBZONE_WEB_PL

Install relevant R packages

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

Import MP14_SUBZONE layer and named it as mpsz

mpsz <- readOGR(dsn = "data/geospatial", layer="MP14_SUBZONE_WEB_PL")
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\IS415 Geospatial Analytics and Applications\take-home2\Take_home_Exe02\data\geospatial", layer: "MP14_SUBZONE_WEB_PL"
## with 323 features
## It has 15 fields
mpsz
## class       : SpatialPolygonsDataFrame 
## features    : 323 
## extent      : 2667.538, 56396.44, 15748.72, 50256.33  (xmin, xmax, ymin, ymax)
## crs         : +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
## variables   : 15
## names       : OBJECTID, SUBZONE_NO, SUBZONE_N, SUBZONE_C, CA_IND, PLN_AREA_N, PLN_AREA_C,       REGION_N, REGION_C,          INC_CRC, FMEL_UPD_D,     X_ADDR,     Y_ADDR,    SHAPE_Leng,    SHAPE_Area 
## min values  :        1,          1, ADMIRALTY,    AMSZ01,      N, ANG MO KIO,         AM, CENTRAL REGION,       CR, 00F5E30B5C9B7AD8, 2014/12/05,  5092.8949,  19579.069, 871.554887798, 39437.9352703 
## max values  :      323,         17,    YUNNAN,    YSSZ09,      Y,     YISHUN,         YS,    WEST REGION,       WR, FFCCF172717C2EAF, 2014/12/05, 50424.7923, 49552.7904, 68083.9364708,  69748298.792

Import listings data set and named it as airbnb.

airbnb <- read_csv("data/aspatial/listings.csv")

After looking through the details of the data set, the coords of the data set is in longitude and latitude format. One key point to take note is the CRS of the langitude and latitude. It should be in WGS84 (EPSG:4326).

Commonly used by organizations that provide GIS data for the entire globe or many countries. CRS used by Google Earth.

airbnb_sf <- st_as_sf(airbnb, coords = c("longitude","latitude"), crs = 4326)

By using function st_transform, we are able to convert the longitude and latitude to XY coords by defining the EPSG as 3414 (SV21).

airbnb_sf <-st_transform(airbnb_sf, CRS("+init=epsg:3414"))
airbnb_sf
## Simple feature collection with 7713 features and 14 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 7215.566 ymin: 25166.35 xmax: 43401.32 ymax: 48466.72
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs
## # A tibble: 7,713 x 15
##        id name  host_id host_name neighbourhood_g~ neighbourhood room_type price
##     <dbl> <chr>   <dbl> <chr>     <chr>            <chr>         <chr>     <dbl>
##  1  49091 "COZ~  266763 Francesca North Region     Woodlands     Private ~    87
##  2  50646 "Ple~  227796 Sujatha   Central Region   Bukit Timah   Private ~    80
##  3  56334 "COZ~  266763 Francesca North Region     Woodlands     Private ~    72
##  4  71609 "Ens~  367042 Belinda   East Region      Tampines      Private ~   214
##  5  71896 "B&B~  367042 Belinda   East Region      Tampines      Private ~    99
##  6  71903 "Roo~  367042 Belinda   East Region      Tampines      Private ~   109
##  7  71907 "3rd~  367042 Belinda   East Region      Tampines      Private ~   217
##  8 117957 "Pri~  448620 Lynnity   North-East Regi~ Sengkang      Private ~    67
##  9 241503 "Lon~ 1017645 Bianca    East Region      Bedok         Private ~    52
## 10 241508 "Lon~ 1017645 Bianca    East Region      Bedok         Private ~    54
## # ... with 7,703 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]>

Converting the airbnb data set in to SpatialPointsDataFrame format.

airbnb_sp <- as(airbnb_sf, "Spatial")

Extract the target planning areas

Aljunied <- mpsz[mpsz@data$SUBZONE_N == "ALJUNIED",]
Balestier <- mpsz[mpsz@data$SUBZONE_N == "BALESTIER",]
Lavender <- mpsz[mpsz@data$SUBZONE_N == "LAVENDER",]
Tanjong_Pagar <- mpsz[mpsz@data$SUBZONE_N == "TANJONG PAGAR",]

Plotting target planning areas

par(mfrow = c(2,2))
plot(Aljunied, main = "Aljunied")
plot(Balestier, main = "Balestier")
plot(Lavender, main = "Lavender")
plot(Tanjong_Pagar, main = "Tanjong Pagar")

Converting the spatial point data frame into generic sp format

Aljunied_sp <- as(Aljunied, "SpatialPolygons")
Balestier_sp <- as(Balestier, "SpatialPolygons")
Lavender_sp <- as(Lavender, "SpatialPolygons")
Tanjong_Pagar_sp <- as(Tanjong_Pagar, "SpatialPolygons")

Creating owin object

Aljunied_owin <- as(Aljunied_sp, "owin")
Balestier_owin <- as(Balestier_sp, "owin")
Lavender_owin <- as(Lavender_sp, "owin")
Tanjong_Pagar_owin <- as(Tanjong_Pagar_sp, "owin")

12. Analysing Marked Point Patterns for Aljunied

12.1.1 Marked Point preparation for Aljunied

airbnb_A_cross <- airbnb_sp
airbnb_A_cross <- subset(airbnb_A_cross, select =-c(name, host_id,host_name,neighbourhood_group,price,minimum_nights,number_of_reviews,last_review,reviews_per_month, calculated_host_listings_count,availability_365,id,neighbourhood))

NOTE: By using as.factor function, we are able to convert from char to factor for Marked Point.

airbnb_A_cross$room_type <- as.factor(airbnb_A_cross$room_type)
A_cross <- as(airbnb_A_cross, "ppp")
plot(A_cross)

any(duplicated(A_cross))
## [1] TRUE
A_ppp_jit <- rjitter(A_cross, retry=TRUE, nsim=1, drop=TRUE)
any(duplicated(A_ppp_jit))
## [1] FALSE
A_owin <- A_ppp_jit[Aljunied_owin]
A_owin
## Marked planar point pattern: 834 points
## Multitype, with levels = 
##    Entire home/apt Hotel room Private room Shared room
## window: polygonal boundary
## enclosing rectangle: [32605.74, 34569.28] x [31880.27, 33909.48] units
plot(A_owin)

12.2.1 Working with Cross K-Function

A_Kcross <- Kcross(A_owin, i="Hotel room", j="Private room", correction='border')
plot(A_Kcross)

12.2.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Private room are at random.

H1= The distribution of Hotel room and Private room are not at random.

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

A_Kcross.csr <- envelope(A_owin, i="Hotel room", j="Private room", correction='border', 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(A_Kcross.csr, xlab="distance(m)", xlim=c(0,500))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

12.3.1 Working with Cross K-Function

A1_Kcross <- Kcross(A_owin, i="Hotel room", j="Entire home/apt", correction='border')
plot(A1_Kcross)

12.3.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Entire room are at random.

H1= The distribution of Hotel room and Entire room are not at random.

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

A1_Kcross.csr <- envelope(A_owin, i="Hotel room", j="Entire home/apt", correction='border', 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(A1_Kcross.csr, xlab="distance(m)", xlim=c(0,500))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

12.4.1 Working with Cross K-Function

A2_Kcross <- Kcross(A_owin, i="Private room", j="Entire home/apt", correction='border')
plot(A2_Kcross)

12.4.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Private room and Entire room are at random.

H1= The distribution of Private room and Entire room are not at random.

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

A2_Kcross.csr <- envelope(A_owin, i="Private room", j="Entire home/apt", correction='border', 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(A2_Kcross.csr, xlab="distance(m)", xlim=c(0,500))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

13. Analysing Marked Point Patterns for Balestier

13.1.1 Marked Point preparation for Balestier

airbnb_B_cross <- airbnb_sp
airbnb_B_cross <- subset(airbnb_B_cross, select =-c(name, host_id,host_name,neighbourhood_group,price,minimum_nights,number_of_reviews,last_review,reviews_per_month, calculated_host_listings_count,availability_365,id,neighbourhood))

NOTE: By using as.factor function, we are able to convert from char to factor for Marked Point.

airbnb_B_cross$room_type <- as.factor(airbnb_B_cross$room_type)
B_cross <- as(airbnb_B_cross, "ppp")
plot(B_cross)

any(duplicated(B_cross))
## [1] TRUE
B_ppp_jit <- rjitter(B_cross, retry=TRUE, nsim=1, drop=TRUE)
any(duplicated(B_ppp_jit))
## [1] FALSE
B_owin <- B_ppp_jit[Balestier_owin]
B_owin
## Marked planar point pattern: 475 points
## Multitype, with levels = 
##    Entire home/apt Hotel room Private room Shared room
## window: polygonal boundary
## enclosing rectangle: [28807.862, 31231.154] x [33417.93, 34748.59] units
plot(B_owin)

13.2.1 Working with Cross K-Function

B_Kcross <- Kcross(B_owin, i="Hotel room", j="Private room", correction='border')
plot(A_Kcross)

13.2.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Private room are at random.

H1= The distribution of Hotel room and Private room are not at random.

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

B_Kcross.csr <- envelope(B_owin, i="Hotel room", j="Private room", correction='border', 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(B_Kcross.csr, xlab="distance(m)", xlim=c(0,350))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

13.3.1 Working with Cross K-Function

B1_Kcross <- Kcross(B_owin, i="Hotel room", j="Entire home/apt", correction='border')
plot(B1_Kcross)

## 13.3.2 Performing CSR testing on the Cross K-Function The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Entire room are at random.

H1= The distribution of Hotel room and Entire room are not at random.

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

B1_Kcross.csr <- envelope(B_owin, i="Hotel room", j="Entire home/apt", correction='border', 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(B1_Kcross.csr, xlab="distance(m)", xlim=c(0,350))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

13.4.1 Working with Cross K-Function

B2_Kcross <- Kcross(B_owin, i="Private room", j="Entire home/apt", correction='border')
plot(B2_Kcross)

13.4.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Private room and Entire room are at random.

H1= The distribution of Private room and Entire room are not at random.

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

B2_Kcross.csr <- envelope(B_owin, i="Private room", j="Entire home/apt", correction='border', 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(B2_Kcross.csr, xlab="distance(m)", xlim=c(0,350))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

14. Analysing Marked Point Patterns for Lavender

14.1.1 Marked Point preparation for Lavender

airbnb_L_cross <- airbnb_sp
airbnb_L_cross <- subset(airbnb_L_cross, select =-c(name, host_id,host_name,neighbourhood_group,price,minimum_nights,number_of_reviews,last_review,reviews_per_month, calculated_host_listings_count,availability_365,id,neighbourhood))

NOTE: By using as.factor function, we are able to convert from char to factor for Marked Point.

airbnb_L_cross$room_type <- as.factor(airbnb_L_cross$room_type)
L_cross <- as(airbnb_L_cross, "ppp")
plot(L_cross)

any(duplicated(L_cross))
## [1] TRUE
L_ppp_jit <- rjitter(L_cross, retry=TRUE, nsim=1, drop=TRUE)
any(duplicated(L_ppp_jit))
## [1] FALSE
L_owin <- L_ppp_jit[Lavender_owin]
L_owin
## Marked planar point pattern: 492 points
## Multitype, with levels = 
##    Entire home/apt Hotel room Private room Shared room
## window: polygonal boundary
## enclosing rectangle: [30342.648, 31453.964] x [32035.6, 33233.11] units
plot(L_owin)

14.2.1 Working with Cross K-Function

L_Kcross <- Kcross(L_owin, i="Hotel room", j="Private room", correction='border')
plot(L_Kcross)

14.2.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Private room are at random.

H1= The distribution of Hotel room and Private room are not at random.

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

L_Kcross.csr <- envelope(L_owin, i="Hotel room", j="Private room", correction='border', 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(L_Kcross.csr, xlab="distance(m)", xlim=c(0,300))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

14.3.1 Working with Cross K-Function

L1_Kcross <- Kcross(L_owin, i="Hotel room", j="Entire home/apt", correction='border')
plot(L1_Kcross)

14.3.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Entire room are at random.

H1= The distribution of Hotel room and Entire room are not at random.

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

L1_Kcross.csr <- envelope(L_owin, i="Hotel room", j="Entire home/apt", correction='border', 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(L1_Kcross.csr, xlab="distance(m)", xlim=c(0,300))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

14.4.1 Working with Cross K-Function

L2_Kcross <- Kcross(L_owin, i="Private room", j="Entire home/apt", correction='border')
plot(L2_Kcross)

14.4.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Private room and Entire room are at random.

H1= The distribution of Private room and Entire room are not at random.

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

L2_Kcross.csr <- envelope(L_owin, i="Private room", j="Entire home/apt", correction='border', 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(L2_Kcross.csr, xlab="distance(m)", xlim=c(0,300))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

15. Analysing Marked Point Patterns for Tanjong Pagar

15.1.1 Marked Point preparation for Tanjong Pagar

airbnb_T_cross <- airbnb_sp
airbnb_T_cross <- subset(airbnb_T_cross, select =-c(name, host_id,host_name,neighbourhood_group,price,minimum_nights,number_of_reviews,last_review,reviews_per_month, calculated_host_listings_count,availability_365,id,neighbourhood))

NOTE: By using as.factor function, we are able to convert from char to factor for Marked Point.

airbnb_T_cross$room_type <- as.factor(airbnb_T_cross$room_type)
T_cross <- as(airbnb_T_cross, "ppp")
plot(T_cross)

any(duplicated(T_cross))
## [1] TRUE
T_ppp_jit <- rjitter(T_cross, retry=TRUE, nsim=1, drop=TRUE)
any(duplicated(T_ppp_jit))
## [1] FALSE
T_owin <- T_ppp_jit[Tanjong_Pagar_owin]
T_owin
## Marked planar point pattern: 160 points
## Multitype, with levels = 
##    Entire home/apt Hotel room Private room Shared room
## window: polygonal boundary
## enclosing rectangle: [29169.126, 29650.236] x [28430.253, 29068.585] units
plot(T_owin)

15.2.1 Working with Cross K-Function

T_Kcross <- Kcross(T_owin, i="Hotel room", j="Private room", correction='border')
plot(T_Kcross)

15.2.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Private room are at random.

H1= The distribution of Hotel room and Private room are not at random.

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

T_Kcross.csr <- envelope(T_owin, i="Hotel room", j="Private room", correction='border', 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(T_Kcross.csr, xlab="distance(m)", xlim=c(0,150))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

15.3.1 Working with Cross K-Function

T1_Kcross <- Kcross(T_owin, i="Hotel room", j="Entire home/apt", correction='border')
plot(T1_Kcross)

15.3.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Hotel room and Entire room are at random.

H1= The distribution of Hotel room and Entire room are not at random.

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

T1_Kcross.csr <- envelope(T_owin, i="Hotel room", j="Entire home/apt", correction='border', 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(T1_Kcross.csr, xlab="distance(m)", xlim=c(0,150))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.

15.4.1 Working with Cross K-Function

T2_Kcross <- Kcross(T_owin, i="Private room", j="Entire home/apt", correction='border')
plot(T2_Kcross)

15.4.2 Performing CSR testing on the Cross K-Function

The hypothesis and test are as follows:

Ho = The distribution of Private room and Entire room are at random.

H1= The distribution of Private room and Entire room are not at random.

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

T2_Kcross.csr <- envelope(T_owin, i="Private room", j="Entire home/apt", correction='border', 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(T2_Kcross.csr, xlab="distance(m)", xlim=c(0,150))

Conclusion: Since it is above the envelop, therefore it shows a significant cluster pattern.