Handon_Ex09

Calibrating Hedonic Pricing Model for Private Highrise Property with GWR Method

Overview

Geographically weighted regression (GWR) is a spatial statistical technique that takes non-stationary 非稳态的 variables into consideration ( climate, demographic factors) In this hand-on, I will build hedonic pricing model by using GWR methods

The Data

Two data sets will be used in this model building exercise, they are:

  • URA Master Plan subzone boundary in shapefile format (i.e. MP14_SUBZONE_WEB_PL)

  • condo_resale_2015 in csv format (i.e. condo_resale_2015.csv)

Getting Started

Load necessary Package

pacman::p_load(olsrr, corrplot, ggpubr, sf, spdep, GWmodel, tmap, tidyverse, gtsummary)
Installing package into 'C:/Users/65917/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)
also installing the dependencies 'rlang', 'purrr', 'vctrs', 'tidyr'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/4.2:
  cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/4.2/PACKAGES'
package 'rlang' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'rlang'
Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
C:\Users\65917\AppData\Local\R\win-library\4.2\00LOCK\rlang\libs\x64\rlang.dll
to C:\Users\65917\AppData\Local\R\win-library\4.2\rlang\libs\x64\rlang.dll:
Permission denied
Warning: restored 'rlang'
package 'purrr' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'purrr'
Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
C:\Users\65917\AppData\Local\R\win-library\4.2\00LOCK\purrr\libs\x64\purrr.dll
to C:\Users\65917\AppData\Local\R\win-library\4.2\purrr\libs\x64\purrr.dll:
Permission denied
Warning: restored 'purrr'
package 'vctrs' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'vctrs'
Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
C:\Users\65917\AppData\Local\R\win-library\4.2\00LOCK\vctrs\libs\x64\vctrs.dll
to C:\Users\65917\AppData\Local\R\win-library\4.2\vctrs\libs\x64\vctrs.dll:
Permission denied
Warning: restored 'vctrs'
package 'tidyr' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'tidyr'
Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
C:\Users\65917\AppData\Local\R\win-library\4.2\00LOCK\tidyr\libs\x64\tidyr.dll
to C:\Users\65917\AppData\Local\R\win-library\4.2\tidyr\libs\x64\tidyr.dll:
Permission denied
Warning: restored 'tidyr'
package 'ggpubr' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\65917\AppData\Local\Temp\Rtmp4sEPm8\downloaded_packages

ggpubr installed
Warning: package 'ggpubr' was built under R version 4.2.3
Warning in pacman::p_load(olsrr, corrplot, ggpubr, sf, spdep, GWmodel, tmap, : Failed to install/load:
ggpubr

Importing geospatial data

mpsz = st_read(dsn = "data/geospatial", layer = "MP14_SUBZONE_WEB_PL")
Reading layer `MP14_SUBZONE_WEB_PL' from data source 
  `C:\Quanfang777\IS415-GAA\WeeklyExercise\week9\Hands-on_Ex09\data\geospatial' 
  using driver `ESRI Shapefile'
Simple feature collection with 323 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21

Updating CRS information

mpsz_svy21 <- st_transform(mpsz, 3414)
st_crs(mpsz_svy21)
Coordinate Reference System:
  User input: EPSG:3414 
  wkt:
PROJCRS["SVY21 / Singapore TM",
    BASEGEOGCRS["SVY21",
        DATUM["SVY21",
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4757]],
    CONVERSION["Singapore Transverse Mercator",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",1.36666666666667,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",103.833333333333,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",1,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",28001.642,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",38744.572,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["northing (N)",north,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["easting (E)",east,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Cadastre, engineering survey, topographic mapping."],
        AREA["Singapore - onshore and offshore."],
        BBOX[1.13,103.59,1.47,104.07]],
    ID["EPSG",3414]]
condo_resale = read_csv("data/aspatial/Condo_resale_2015.csv")
Rows: 1436 Columns: 23
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (23): LATITUDE, LONGITUDE, POSTCODE, SELLING_PRICE, AREA_SQM, AGE, PROX_...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.