Take-home Exercise 1

Author

Zou Jiaxun

Published

April 13, 2024

1 Overview

1.1 Background

There are two major residential property market in Singapore, namely public and private housing. Public housing aims to meet the basic need of the general public with monthly household income less than or equal to S$14,000. For families with monthly household income more than S$14,000, they need to turn to the private residential market.

We will go to prepare minimum two and maximum three data visualisation to reveal the private residential market and sub-markets of Singapore for the 1st quarter of 2024.

1.2 Data Import

There are five files in the folder. Each file provdes transacion data for a quarter. The study period is from 1st January 2023 until 31st March 2024.

First, let us merge the csv files.
Click to view code
pacman::p_load(dplyr, purrr, readr, ggiraph,
               ggplot2, lubridate, ggrepel,
               patchwork, ggthemes, hrbrthemes, tidyverse)
data_dir <- "data-2"
file_paths <- file.path(data_dir,
                        c("2023Q1.csv",
                          "2023Q2.csv",
                          "2023Q3.csv",
                          "2023Q4.csv",
                          "2024Q1.csv"))
combined_data <- purrr::map_df(file_paths, readr::read_csv)
glimpse(combined_data)
Rows: 26,806
Columns: 21
$ `Project Name`                <chr> "THE REEF AT KING'S DOCK", "URBAN TREASU…
$ `Transacted Price ($)`        <dbl> 2317000, 1823500, 1421112, 1258112, 1280…
$ `Area (SQFT)`                 <dbl> 882.65, 882.65, 1076.40, 1033.34, 871.88…
$ `Unit Price ($ PSF)`          <dbl> 2625, 2066, 1320, 1218, 1468, 1767, 1095…
$ `Sale Date`                   <chr> "01 Jan 2023", "02 Jan 2023", "02 Jan 20…
$ Address                       <chr> "12 HARBOURFRONT AVENUE #05-32", "205 JA…
$ `Type of Sale`                <chr> "New Sale", "New Sale", "New Sale", "New…
$ `Type of Area`                <chr> "Strata", "Strata", "Strata", "Strata", …
$ `Area (SQM)`                  <dbl> 82.0, 82.0, 100.0, 96.0, 81.0, 308.7, 42…
$ `Unit Price ($ PSM)`          <dbl> 28256, 22238, 14211, 13105, 15802, 19015…
$ `Nett Price($)`               <chr> "-", "-", "-", "-", "-", "-", "-", "-", …
$ `Property Type`               <chr> "Condominium", "Condominium", "Executive…
$ `Number of Units`             <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Tenure                        <chr> "99 yrs from 12/01/2021", "Freehold", "9…
$ `Completion Date`             <chr> "Uncompleted", "Uncompleted", "Uncomplet…
$ `Purchaser Address Indicator` <chr> "HDB", "Private", "HDB", "HDB", "HDB", "…
$ `Postal Code`                 <chr> "097996", "419535", "269343", "269294", …
$ `Postal District`             <chr> "04", "14", "27", "27", "28", "19", "10"…
$ `Postal Sector`               <chr> "09", "41", "26", "26", "79", "54", "27"…
$ `Planning Region`             <chr> "Central Region", "East Region", "North …
$ `Planning Area`               <chr> "Bukit Merah", "Bedok", "Yishun", "Yishu…
Click to view code
readr::write_csv(combined_data,
                 file.path(data_dir,"merged_transaction_data.csv"))

1.3 Data check

According to the combined_data, there are 26,806 observation of 21 variables before we make a data cleaning.

Now we need to check the duplicate.

Click to view code
duplicate <- combined_data %>% 
  group_by_all() %>% 
  filter(n()>1) %>% 
  ungroup()
  
duplicate
# A tibble: 0 × 21
# ℹ 21 variables: Project Name <chr>, Transacted Price ($) <dbl>,
#   Area (SQFT) <dbl>, Unit Price ($ PSF) <dbl>, Sale Date <chr>,
#   Address <chr>, Type of Sale <chr>, Type of Area <chr>, Area (SQM) <dbl>,
#   Unit Price ($ PSM) <dbl>, Nett Price($) <chr>, Property Type <chr>,
#   Number of Units <dbl>, Tenure <chr>, Completion Date <chr>,
#   Purchaser Address Indicator <chr>, Postal Code <chr>,
#   Postal District <chr>, Postal Sector <chr>, Planning Region <chr>, …

Congratulation, there is no duplicate according to our find!

1.4 Variable Selection

Category Sample Description Type Choose or not
Project.Name “THE REEF AT KING’S DOCK” chr Not Choose
Transacted Price ($) “2317000” num Choose
Area (SQFT) “883” num Choose
Unit Price ($ PSF) “2625 = 2317000/883” num Choose
Sale Data “01 Jan 2023” chr Choose
Address “12 HARBOURFRONT AVENUE #05-32” chr Not Choose
Type of sale “New Sale” chr Choose
Area (SQM) “Strata” num Not Choose
Unit Price ($ PSM) “82” num Not Choose
Nett Price ($) “-” chr Not Choose
Property Type “Condominium” chr Choose
Number of Units “1” num Choose Choose
Tenure “99 yrs from 12/01/2021” chr Not Choose
Completion Data “Uncompleted” chr Not Choose
Purchaser Address Indicator “HDB” chr Choose
Postal Code “097996” chr Not Choose
Postal District “04” chr Not Choose
Postal Sector “09” chr Not Choose
Planning Region “Central Region” chr Choose
Planning Area “Bukit Merah” chr Not Choose
We choose “Transacted Price ($)”, “Area (SQFT)”, “Unit Price ($ PSF)”, “Sale Data”, “Type of sale”, “Property Type”, “Purchaser Address Indicator”, and “Planning Region” as our values.

1.5 Missing Values

Now we need to check the missing values, since too many N/A will influence certain calculations.
Click to view code
sum(is.na(combined_data$`Transacted Price ($)`))
[1] 0
Click to view code
sum(is.na(combined_data$`Area (SQFT)`))
[1] 0
Click to view code
sum(is.na(combined_data$`Unit Price ($ PSF)`))
[1] 0
Click to view code
sum(is.na(combined_data$`Sale Date`))
[1] 0
Click to view code
sum(is.na(combined_data$`Type of Sale`))
[1] 0
Click to view code
sum(is.na(combined_data$`Property Type`))
[1] 0
Click to view code
sum(is.na(combined_data$`Purchaser Address Indicator`))
[1] 0
Click to view code
sum(is.na(combined_data$`Planning Region`))
[1] 0

Congratulation, there is no missing data according to our find!

2. Problem Solveing

To solve this problem, we will make a visualization.

2.1 Property Type & Planning Region

First, we want to know which property type is popular in private residential market and sub-markets of Singapore, and how the resident located in Singapore.

Click to view code
F1 <- ggplot(combined_data, aes(x = `Property Type`)) + 
    geom_bar_interactive(aes(fill = `Planning Region`), position = "dodge") +  
    labs(x = "Property Type", y = "Frequency",
         title = "Frequency of Property Types by Planning Region") +
    facet_wrap(~ `Planning Region`, scales = "free") +
    theme_stata(base_size = 2.5)
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) 
List of 1
 $ axis.text.x:List of 11
  ..$ family       : NULL
  ..$ face         : NULL
  ..$ colour       : NULL
  ..$ size         : NULL
  ..$ hjust        : num 1
  ..$ vjust        : NULL
  ..$ angle        : num 45
  ..$ lineheight   : NULL
  ..$ margin       : NULL
  ..$ debug        : NULL
  ..$ inherit.blank: logi FALSE
  ..- attr(*, "class")= chr [1:2] "element_text" "element"
 - attr(*, "class")= chr [1:2] "theme" "gg"
 - attr(*, "complete")= logi FALSE
 - attr(*, "validate")= logi TRUE
Click to view code
F1

We have now acquired transaction data pertaining to six distinct property types: Apartment, Condominium, Terrace House, Executive Condominium, Detached House, and Semi-Detached House. These properties are situated across five planning regions: Central Region, East Region, North East Region, North Region, and West Region.

Upon analysis, it is evident that the market for detached houses, semi-detached houses, and terrace houses is considerably limited, with minimal activity observed.

Furthermore, our findings reveal noteworthy trends across different regions. In the North Region, Executive Condominiums emerge as the most sought-after property type, boasting the highest number of transactions compared to other regions. Similarly, in the West Region, Executive Condominiums exhibit robust trading activity.

Across most regions, Apartments and Condominiums consistently dominate the market as preferred sale properties, with the exception of the North Region, where unique market dynamics are observed.

2.2 Quarterly Boxplot of Transacted Price & Area

Click to view code
P1 <- Boxplot_Q_TP + coord_cartesian(ylim = c(0, 3000000)) +  
  scale_y_continuous(labels = scales::comma_format(scale = 1e-3))
P1

Click to view code
P2 <- Boxplot_Q_A + coord_cartesian(ylim = c(0, 2000))
P2

2.3 Scatter Plot of Transacted Price vs. Area

Click to view code
sampled_data <- combined_data[sample(nrow(combined_data), 500), ]
sampled_data$`Transacted Price ($)` <- sampled_data$`Transacted Price ($)` / 1000
P3 <- ggplot(data = sampled_data, aes(x = `Area (SQFT)`, y = `Transacted Price ($)`)) +
  geom_point_interactive() +
  geom_smooth() +
  scale_x_continuous(limits = c(0, 3000)) + 
  scale_y_continuous(limits = c(0, 10000)) +
  labs(x = "Area (SQFT)", y = "Transacted Price ($ thousands)",
       title = "Scatter Plot of Transacted Price vs. Area")
P3

After thorough analysis, it becomes apparent that each quarter exhibits a comparable range of transacted prices, with Q1 2024 demonstrating a notably higher transacted price compared to Q1 2023.

Moreover, the distribution of transacted prices and areas across all transactions reveals that 99% of deals fall within the range of 300 to 1,500 square feet, with corresponding prices ranging from 1,100 to 3,750 thousand SGD. This distribution underscores the prevailing market trends and preferences within the real estate landscape.

2.4 Unit Price Analysis

As we mentioned about the individual market is focus on the apartment and condominium above, and we know the distribution of total preoperty, what about the first quarter unit price of these two popular goods?

Click to view code
filtered_data <- combined_data %>%
  mutate(Sale_Date = dmy(`Sale Date`)) %>%
  filter((year(Sale_Date) == 2023 & 
          month(Sale_Date) %in% 1:12) |
         (year(Sale_Date) == 2024 & 
          month(Sale_Date) %in% 1:3)) %>%
  mutate(Quarter_Sale_Data = case_when(
    between(Sale_Date, as.Date("2023-01-01"), as.Date("2023-03-31")) ~ "Q1_2023",
    between(Sale_Date, as.Date("2023-04-01"), as.Date("2023-06-30")) ~ "Q2_2023",
    between(Sale_Date, as.Date("2023-07-01"), as.Date("2023-09-30")) ~ "Q3_2023",
    between(Sale_Date, as.Date("2023-10-01"), as.Date("2023-12-31")) ~ "Q4_2023",
    between(Sale_Date, as.Date("2024-01-01"), as.Date("2024-03-31")) ~ "Q1_2024",
    TRUE ~ NA_character_
  )) %>%
  filter(!is.na(Quarter_Sale_Data)) %>%
  mutate(Month_Sale_Data = paste0(year(Sale_Date), "-", month(Sale_Date)))

filtered_data <- filtered_data %>%
  filter(`Property Type` %in% c("Apartment", "Condominium"))

ggplot(filtered_data, aes(x = Month_Sale_Data, y = `Unit Price ($ PSF)`, color = `Property Type`)) +
  geom_violin() +
  geom_point(position = "jitter",
             size = 0.1) +
  labs(title = "Unit Price per Square Foot for Apartments and Condominiums",
       x = "Month",
       y = "Unit Price ($ PSF)") +
  theme_light(base_size = 6) +
  xlim(c("2024-1","2024-2","2024-3"))

Click to view code
ggplot(filtered_data, aes(x = Month_Sale_Data, y = `Unit Price ($ PSF)`, color = `Property Type`)) +
  geom_violin() +
  geom_point(position = "jitter",
             size = 0.1) +
  labs(title = "Unit Price per Square Foot for Apartments and Condominiums",
       x = "Month",
       y = "Unit Price ($ PSF)") +
  theme_light(base_size = 6) +
  xlim(c("2023-1","2023-2","2023-3"))

Upon examination of the violin plots, a clear disparity emerges between the average unit prices of condominiums and apartments, standing at approximately $1,500 and $2,000, respectively, for the period spanning January to March. Noteworthy is the discernible uptick in both unit price and transaction volume from January to March 2024. Despite an overall reduction in total transactions vis-a-vis the preceding year, there is an unmistakable trend towards growth within specific sub-markets, suggesting an increasing inclination towards higher-value properties

3 Summary

Through this exercise, we illustrated the situation of current private residential market and sub-markets of Singapore. The current private residential market in Singapore showcases diverse property types distributed across different planning regions. While Apartments and Condominiums remain popular choices in most areas, Executive Condominiums demonstrate significant demand, particularly in the North and West Regions. Detached houses, semi-detached houses, and terrace houses, however, exhibit minimal activity in the market. These trends underscore a nuanced landscape within the Singaporean real estate sector, reflecting varying preferences and dynamics across different sub-markets.