Overview

You are tasked to develop an electricity demand forecasting model for ABC. The objective of the forecasting model is to better inform ABC and the industry so as to ensure that sufficient infrastructure is to be put in place to cater for increasing electricity demand.

We used the following abbreviations to denote the Different Sectors and Types of Household in Energy Consumption:

  1. MFG = Manufacturing
  2. CON = Construction
  3. UTI = Utilities
  4. OIR = Other Industrial-related
  5. WRT = Wholesale and Retail Trade
  6. AFS = Accommodation and Food Services
  7. ICM = Information and Communications
  8. FIA = Financial and Insurance Activities
  9. REA = Real Estate Activities
  10. PST = Professional, Scientific & Technical, Administration & Support Activities
  11. OCS = Other Commerce and Services-related
  12. TRP = Transport-related
  13. OTH = Others
  14. X1R2R = 1-Room / 2-Room HDB
  15. X3R = 3-Room HDB
  16. X4R = 4-Room HDB
  17. X5REX = 5-Room and Executive HDB
  18. PAC = Private Apartments and Condominiums
  19. LPP = Landed Properties

Loading Libraries

# Loading Libraries
library(datetime)
## Warning: package 'datetime' was built under R version 3.6.3
library(Hmisc)
## Warning: package 'Hmisc' was built under R version 3.6.3
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## Loading required package: ggplot2
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(corrplot)
## corrplot 0.84 loaded
library(caret)
## 
## Attaching package: 'caret'
## The following object is masked from 'package:survival':
## 
##     cluster
library(vars)
## Warning: package 'vars' was built under R version 3.6.3
## Loading required package: MASS
## Warning: package 'MASS' was built under R version 3.6.3
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 3.6.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.6.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.6.3
## Loading required package: urca
## Warning: package 'urca' was built under R version 3.6.3
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.6.3
library(forecast)
## Warning: package 'forecast' was built under R version 3.6.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(strucchange)

Loading and Cleaning Data on Energy Consumption

# Loading Data on Energy Consumption
ecData <- read.csv('./EC_05_18.csv', header = TRUE)
ecData$Year <- as.year(ecData$Year)

# Cleaning Data on Energy Consumption
ecData <- ecData[, colSums(is.na(ecData)) == 0]
summary(ecData)
##       Year           MFG             CON             UTI        
##  Min.   :2005   Min.   :13836   Min.   :234.8   Min.   : 411.0  
##  1st Qu.:2008   1st Qu.:14966   1st Qu.:302.7   1st Qu.: 674.2  
##  Median :2012   Median :16932   Median :397.6   Median : 953.7  
##  Mean   :2012   Mean   :16712   Mean   :395.4   Mean   : 958.2  
##  3rd Qu.:2015   3rd Qu.:18205   3rd Qu.:489.0   3rd Qu.:1227.4  
##  Max.   :2018   Max.   :19582   Max.   :551.6   Max.   :1518.7  
##       OIR             WRT            AFS            ICM              FIA      
##  Min.   :25.88   Min.   :1821   Min.   :1031   Min.   : 667.2   Min.   :1292  
##  1st Qu.:29.34   1st Qu.:1913   1st Qu.:1170   1st Qu.: 849.9   1st Qu.:1946  
##  Median :35.58   Median :1972   Median :1263   Median :1036.5   Median :2110  
##  Mean   :36.26   Mean   :1994   Mean   :1265   Mean   :1190.6   Mean   :2114  
##  3rd Qu.:41.66   3rd Qu.:2060   3rd Qu.:1346   3rd Qu.:1393.7   3rd Qu.:2355  
##  Max.   :48.26   Max.   :2293   Max.   :1464   Max.   :2230.5   Max.   :2718  
##       REA            PST             OCS            TRP            OTH       
##  Min.   :3712   Min.   :650.2   Min.   :3613   Min.   :1200   Min.   :237.7  
##  1st Qu.:3961   1st Qu.:706.3   1st Qu.:4244   1st Qu.:1452   1st Qu.:277.1  
##  Median :4455   Median :759.4   Median :4393   Median :2276   Median :325.2  
##  Mean   :4280   Mean   :787.9   Mean   :4384   Mean   :2071   Mean   :369.6  
##  3rd Qu.:4516   3rd Qu.:874.8   3rd Qu.:4697   3rd Qu.:2444   3rd Qu.:446.7  
##  Max.   :4701   Max.   :934.1   Max.   :4860   Max.   :2944   Max.   :612.1  
##      X1R2R             X3R             X4R           X5REX           PAC      
##  Min.   : 70.90   Min.   :690.1   Min.   :1475   Min.   :1486   Min.   :1349  
##  1st Qu.: 77.05   1st Qu.:708.4   1st Qu.:1511   1st Qu.:1517   1st Qu.:1444  
##  Median : 87.75   Median :731.5   Median :1597   Median :1564   Median :1605  
##  Mean   : 96.62   Mean   :733.2   Mean   :1620   Mean   :1568   Mean   :1647  
##  3rd Qu.:117.60   3rd Qu.:747.9   3rd Qu.:1731   3rd Qu.:1592   3rd Qu.:1831  
##  Max.   :135.63   Max.   :801.8   Max.   :1839   Max.   :1708   Max.   :2001  
##       LPP        
##  Min.   : 953.6  
##  1st Qu.: 970.2  
##  Median :1016.9  
##  Mean   :1012.0  
##  3rd Qu.:1037.8  
##  Max.   :1098.0

Plotting a Correlation Matrix for Data on Energy Consumption

# Plotting a Correlation Matrix for Data on Energy Consumption
ecMatrix <- rcorr(as.matrix(ecData))
flattenCorrMatrix <- function(cormat, pmat){
  ut <- upper.tri(cormat)
  data.frame(row = rownames(cormat)[row(cormat)[ut]],
             column = rownames(cormat)[col(cormat)[ut]],
             cor = (cormat)[ut],
             p = pmat[ut])}
flattenecMatrix <- flattenCorrMatrix(ecMatrix$r, ecMatrix$P)
summary(flattenecMatrix)
##       row         column        cor                p            
##  Year   :19   LPP    :19   Min.   :-0.9540   Min.   :0.0000000  
##  MFG    :18   PAC    :18   1st Qu.: 0.5072   1st Qu.:0.0000009  
##  CON    :17   X5REX  :17   Median : 0.8389   Median :0.0000789  
##  UTI    :16   X4R    :16   Mean   : 0.5731   Mean   :0.0631629  
##  OIR    :15   X3R    :15   3rd Qu.: 0.9313   3rd Qu.:0.0016110  
##  WRT    :14   X1R2R  :14   Max.   : 0.9951   Max.   :0.8441051  
##  (Other):91   (Other):91

Plotting a Correlation Plot for Data on Energy Consumption

# Plotting a Correlation Plot for Data on Energy Consumption
corrplot(ecMatrix$r, type = "upper", order = "FPC", method = "color",
         p.mat = ecMatrix$P, sig.level = 0.01, insig = "pch",
         tl.cex = 0.8, tl.col = "black", tl.srt = 45)

In the Correlation Plot shown above, the variables that are highly correlated are highlighted at the dark blue intersections. We used a level of significance of 0.01 to determine correlations that are statistically significant. Correlations with a p-value > 0.01 are considered statistically insignificant and marked with a cross.

Unlike for Question Part (a) where we used Highly Uncorrelated Variables to build our Forecasting Model, we will use Highly Uncorrelated Variables to build our Forecasting Model in this Question. From the Correlation Plot, there are 3 out of 19 variables that are highly uncorrelated with the rest of the variables in our Data on Energy Consumption. They have correlations that are statistically insignificant at the level of significance of 0.01. These correlations have been marked with a cross in the Correlation Plot. We will use these variables to build our Forecasting Model. Therefore, we will only be using the variables, “WRT”, “PST”, and “OTH” to build our Forecasting Model.

Building our Forecasting Model

For this Research Assignment, we will use a Vector Autoregression (VAR) Model as our Forecasting Model. It is a causal / Econometric Forecasting Method used to identify underlying factors that might influence the variable that is being forecasted.

Converting Data on Energy Consumption to a Time Series Object

# Define Manufacturing (MFG) as a Time Series Object
MFG <- ts(ecData$MFG, start = c(2005), end = c(2018), frequency = 1)

# Define Construction (CON) as a Time Series Object
CON <- ts(ecData$CON, start = c(2005), end = c(2018), frequency = 1)

# Define Utilities (UTI) as a Time Series Object
UTI <- ts(ecData$UTI, start = c(2005), end = c(2018), frequency = 1)

# Define Other Industrial-related (OIR) as a Time Series Object
OIR <- ts(ecData$OIR, start = c(2005), end = c(2018), frequency = 1)

# Define Wholesale and Retail Trade (WRT) as a Time Series Object
WRT <- ts(ecData$WRT, start = c(2005), end = c(2018), frequency = 1)

# Define Accommodation and Food Services (AFS) as a Time Series Object
AFS <- ts(ecData$AFS, start = c(2005), end = c(2018), frequency = 1)

# Define Information and Communications (ICM) as a Time Series Object
ICM <- ts(ecData$ICM, start = c(2005), end = c(2018), frequency = 1)

# Define Financial and Insurance Activities (FIA) as a Time Series Object
FIA <- ts(ecData$FIA, start = c(2005), end = c(2018), frequency = 1)

# Define Real Estate Activities (REA) as a Time Series Object
REA <- ts(ecData$REA, start = c(2005), end = c(2018), frequency = 1)

# Define Professional, Scientific & Technical, Administration
# & Support Activities (PST) as a Time Series Object
PST <- ts(ecData$PST, start = c(2005), end = c(2018), frequency = 1)

# Define Other Commerce and Services-related (OCS) as a Time Series Object
OCS <- ts(ecData$OCS, start = c(2005), end = c(2018), frequency = 1)

# Define Transport-related (TRP) as a Time Series Object
TRP <- ts(ecData$TRP, start = c(2005), end = c(2018), frequency = 1)

# Define Others (OTH) as a Time Series Object
OTH <- ts(ecData$OTH, start = c(2005), end = c(2018), frequency = 1)

# Define 1-Room / 2-Room HDB (X1R2R) as a Time Series Object
X1R2R <- ts(ecData$X1R2R, start = c(2005), end = c(2018), frequency = 1)

# Define 3-Room HDB (X3R) as a Time Series Object
X3R <- ts(ecData$X3R, start = c(2005), end = c(2018), frequency = 1)

# Define 4-Room HDB (X4R) as a Time Series Object
X4R <- ts(ecData$X4R, start = c(2005), end = c(2018), frequency = 1)

# Define 5-Room and Executive HDB (X5REX) as a Time Series Object
X5REX <- ts(ecData$X5REX, start = c(2005), end = c(2018), frequency = 1)

# Define Private Apartments and Condominiums (PAC) as a Time Series Object
PAC <- ts(ecData$PAC, start = c(2005), end = c(2018), frequency = 1)

# Define Landed Properties (LPP) as a Time Series Object
LPP <- ts(ecData$LPP, start = c(2005), end = c(2018), frequency = 1)

Plotting Data on Energy Consumption by Different Sectors and Types of Household

# Plotting Data on Energy Consumption by Different Sectors and Types of Household
plot(cbind(MFG, CON, UTI, OIR, WRT, AFS, ICM, FIA, REA, PST),
     main = "Energy Consumption by Different Sectors and Households")

plot(cbind(OCS, TRP, OTH, X1R2R, X3R, X4R, X5REX, PAC, LPP),
     main = "Energy Consumption by Different Sectors and Households")

Model Selection and Estimation

# Model Selection and Estimation
VAR_Data <- cbind(WRT, PST, OTH)
colnames(VAR_Data) <- c("WRT", "PST", "OTH")
VAR_Data_info <- VARselect(VAR_Data, lag.max = 10, type = "const")
VAR_Data_info
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      1      1      1      2 
## 
## $criteria
##           1    2    3    4    5    6    7    8    9   10
## AIC(n) -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf
## HQ(n)  -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf
## SC(n)  -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf -Inf
## FPE(n)  NaN    0    0    0    0    0    0    0    0    0
VAR_Est <- VAR(VAR_Data, p = 2, type = "const", season = NULL, exogen = NULL)
summary(VAR_Est)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: WRT, PST, OTH 
## Deterministic variables: const 
## Sample size: 12 
## Log Likelihood: -164.588 
## Roots of the characteristic polynomial:
## 0.8378 0.8378 0.6709 0.6709 0.4706 0.4706
## Call:
## VAR(y = VAR_Data, p = 2, type = "const", exogen = NULL)
## 
## 
## Estimation results for equation WRT: 
## ==================================== 
## WRT = WRT.l1 + PST.l1 + OTH.l1 + WRT.l2 + PST.l2 + OTH.l2 + const 
## 
##          Estimate Std. Error t value Pr(>|t|)  
## WRT.l1   -0.63428    0.61676  -1.028   0.3509  
## PST.l1   -0.33718    0.43745  -0.771   0.4757  
## OTH.l1   -3.52879    2.98519  -1.182   0.2903  
## WRT.l2    0.09707    0.63132   0.154   0.8838  
## PST.l2   -0.91284    0.68010  -1.342   0.2372  
## OTH.l2    1.82163    2.43680   0.748   0.4884  
## const  4598.69602 2078.27730   2.213   0.0778 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 86.01 on 5 degrees of freedom
## Multiple R-Squared: 0.7891,  Adjusted R-squared: 0.5359 
## F-statistic: 3.117 on 6 and 5 DF,  p-value: 0.1164 
## 
## 
## Estimation results for equation PST: 
## ==================================== 
## PST = WRT.l1 + PST.l1 + OTH.l1 + WRT.l2 + PST.l2 + OTH.l2 + const 
## 
##         Estimate Std. Error t value Pr(>|t|)
## WRT.l1   -0.7871     0.6357  -1.238    0.271
## PST.l1    0.2475     0.4509   0.549    0.607
## OTH.l1   -0.1763     3.0769  -0.057    0.957
## WRT.l2   -0.1673     0.6507  -0.257    0.807
## PST.l2   -0.2950     0.7010  -0.421    0.691
## OTH.l2    0.1640     2.5117   0.065    0.950
## const  2711.4388  2142.1264   1.266    0.261
## 
## 
## Residual standard error: 88.65 on 5 degrees of freedom
## Multiple R-Squared: 0.656,   Adjusted R-squared: 0.2431 
## F-statistic: 1.589 on 6 and 5 DF,  p-value: 0.314 
## 
## 
## Estimation results for equation OTH: 
## ==================================== 
## OTH = WRT.l1 + PST.l1 + OTH.l1 + WRT.l2 + PST.l2 + OTH.l2 + const 
## 
##         Estimate Std. Error t value Pr(>|t|)   
## WRT.l1   0.08011    0.05996   1.336  0.23911   
## PST.l1  -0.24098    0.04253  -5.666  0.00238 **
## OTH.l1   0.81154    0.29022   2.796  0.03816 * 
## WRT.l2  -0.07224    0.06138  -1.177  0.29215   
## PST.l2   0.08167    0.06612   1.235  0.27164   
## OTH.l2   0.08695    0.23690   0.367  0.72863   
## const  124.80651  202.04763   0.618  0.56381   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 8.361 on 5 degrees of freedom
## Multiple R-Squared: 0.9957,  Adjusted R-squared: 0.9905 
## F-statistic: 191.9 on 6 and 5 DF,  p-value: 9.623e-06 
## 
## 
## 
## Covariance matrix of residuals:
##         WRT      PST    OTH
## WRT  7397.0 -2868.17 408.14
## PST -2868.2  7858.46 -46.31
## OTH   408.1   -46.31  69.91
## 
## Correlation matrix of residuals:
##         WRT      PST      OTH
## WRT  1.0000 -0.37619  0.56756
## PST -0.3762  1.00000 -0.06248
## OTH  0.5676 -0.06248  1.00000

While a R-Squared value does not provide a formal hypothesis test for goodness-of-fit, it provides an estimate for the strength of the relationship between our variables. We determined the Simple Linear Regression Models for each of our Highly Uncorrelated Variables, “WRT”, “PST”, and “OTH”. They gave Adjusted R-Squared values of 0.54, 0.24, and 0.99, respectively. This suggests that “WRT” and “PST” are highly uncorrelated with the rest of the variables, while “OTH” is highly negatively correlated with the rest of the variables. The models also gave p-values of 0.1164, 0.314, and 9.623e-06, respectively. This suggests that the correlations for “WRT” and “PST” are statistically insignificant, while the correlations for “OTH” are statistically significant.

Diagnostic Tests on Residuals of our Model

To consider the Model Fit, we performed some Diagnostic Tests on Residuals of our Model.

Portmanteau Test

To test for Serial Correlation, we performed a Portmanteau Test. Serial Correlation is the relationship between a given variable and a lagged version of itself over various time intervals. A variable that is serially correlated has a pattern and is not random.

# Portmanteau Test
VAR_Est_serial <- serial.test(VAR_Est, lags.pt = 10, type = "PT.asymptotic")
VAR_Est_serial
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object VAR_Est
## Chi-squared = 51.296, df = 72, p-value = 0.9692
# Plotting Serial Correlations of Highly Uncorrelated Variables
plot(VAR_Est_serial, names = "WRT")

plot(VAR_Est_serial, names = "PST")

plot(VAR_Est_serial, names = "OTH")

From the Portmanteau Test shown above, we obtained a p-value of 0.9692 which does not reject the null hypothesis at the level of significance of 0.05. This suggests that there is an absence of Serial Correlation for our Highly Uncorrelated Variables, “WRT”, “PST”, and “OTH”. There is no apparent relationship between these variables and the lagged versions of themselves over various time intervals. The variables are not serially correlated and their predictions are random and do not display a pattern.

Engle’s Autoregressive Conditional Heteroscedasticity (ARCH) Lagrange Multiplier (LM) Test

To test for Heteroscedasticity, we performed an Engle’s Autoregressive Conditional Heteroscedasticity (ARCH) Lagrange Multiplier (LM) Test. An uncorrelated time series can still be serially dependent due to a dynamic conditional variance process. A time series exhibiting Conditional Heteroscedasticity is said to have ARCH effects. Engle’s ARCH LM Test assesses the significance of these effects.

# Engle's ARCH LM Test
VAR_Est_ARCH <- arch.test(VAR_Est, lags.multi = 1, multivariate.only = TRUE)
VAR_Est_ARCH
## 
##  ARCH (multivariate)
## 
## data:  Residuals of VAR object VAR_Est
## Chi-squared = 38.337, df = 36, p-value = 0.364

From the Engle’s ARCH LM Test shown above, we obtained a p-value of 0.364 which does not reject the null hypothesis at the level of significance of 0.05. This suggests that there is an absence of ARCH effects for our Highly Uncorrelated Variables, “WRT”, “PST”, and “OTH”. There is no apparent Heteroscedasticity for these variables.

Normality Test

To consider the distribution of residuals in our model, we performed a Normality Test. It is used to determine if a dataset is well modelled by a normal distribution and to compute how likely it is for a random variable underlying the dataset to be normally distributed.

# Normality Test
VAR_Est_norm <- normality.test(VAR_Est, multivariate.only = TRUE)
VAR_Est_norm
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object VAR_Est
## Chi-squared = 2.3569, df = 6, p-value = 0.8841
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object VAR_Est
## Chi-squared = 1.9951, df = 3, p-value = 0.5734
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object VAR_Est
## Chi-squared = 0.3618, df = 3, p-value = 0.948

From the Normality Test shown above, we obtained p-values of 0.8841 for the Jarque-Bera (JB) Test, 0.5734 for Skewness, and 0.948 for Kurtosis. They do not reject the null hypothesis at the level of significance of 0.05. This suggests that the distribution of residuals in our model is a fairly normal distribution.

Cumulative Sum Control Chart (CUSUM) Test

To test for Structural Breaks in the residuals of our model, we performed a Cumulative Sum Control Chart (CUSUM) Test. It is a sequential analysis technique used to monitor change detection for statistical quality control. In econometrics and statistics, a Structural Break is an unexpected change over time in the parameters of regression models, which can lead to huge forecasting errors and reduced reliability of the model. Structural Stability is the time-invariance of regression coefficients and a central issue in all applications of linear regression models. The lack of Structural Stability of coefficients frequently caused forecast failure and should be tested for routinely.

# Cumulative Sum Control Chart (CUSUM) Test
VAR_Est_CUSUM <- stability(VAR_Est, type = "OLS-CUSUM")
plot(VAR_Est_CUSUM)

From the CUSUM Test shown above, there is no apparent Structural Break in the respective Confidence Intervals of our Highly Uncorrelated Variables, “WRT”, “PST”, and “OTH”.

The Chow Test

The Chow Test is used to test whether the true coefficients in two linear regressions on different data sets are equal. In econometrics, it is most commonly used in time series analysis to test for the presence of a structural break at a period which can be assumed to be known a priori. In program evaluation, The Chow Test is often used to determine whether the independent variables have different impacts on different subgroups of the population.

# Finding Structural Breaks in Energy Consumption for Manufacturing (MFG)
MFG_bp <- breakpoints(MFG ~ 1)
summary(MFG_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = MFG ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1     5       
## m = 2     5   9   
## m = 3     5   9 12
## m = 4   2 5   9 12
## m = 5   2 5 7 9 12
## 
## Corresponding to breakdates:
##                                 
## m = 1        2009               
## m = 2        2009      2013     
## m = 3        2009      2013 2016
## m = 4   2006 2009      2013 2016
## m = 5   2006 2009 2011 2013 2016
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 4.738e+07 1.101e+07 3.434e+06 1.393e+06 7.675e+05 4.373e+05
## BIC 2.555e+02 2.403e+02 2.293e+02 2.220e+02 2.189e+02 2.163e+02
# Plotting Structural Breaks in Energy Consumption for Manufacturing (MFG)
MFG_ci <- confint(MFG_bp)
plot(MFG)
lines(MFG_bp)
lines(MFG_ci)

# Finding Structural Breaks in Energy Consumption for Construction (CON)
CON_bp <- breakpoints(CON ~ 1)
summary(CON_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = CON ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1       7     
## m = 2   3   7     
## m = 3   3   7   12
## m = 4   3   7 9 12
## m = 5   2 5 7 9 12
## 
## Corresponding to breakdates:
##                                 
## m = 1             2011          
## m = 2   2007      2011          
## m = 3   2007      2011      2016
## m = 4   2007      2011 2013 2016
## m = 5   2006 2009 2011 2013 2016
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 161986.9  24737.3  15679.9  12040.7   6250.8   3696.8
## BIC    176.0    155.0    153.9    155.4    151.5    149.5
# Plotting Structural Breaks in Energy Consumption for Construction (CON)
CON_ci <- confint(CON_bp)
plot(CON)
lines(CON_bp)
lines(CON_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for Utilities (UTI)
UTI_bp <- breakpoints(UTI ~ 1)
summary(UTI_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = UTI ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1       8     
## m = 2     5   9   
## m = 3     5 8   11
## m = 4   2 5 8   11
## m = 5   2 5 7 9 11
## 
## Corresponding to breakdates:
##                                 
## m = 1             2012          
## m = 2        2009      2013     
## m = 3        2009 2012      2015
## m = 4   2006 2009 2012      2015
## m = 5   2006 2009 2011 2013 2015
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 1789444.8  463239.5  169872.2   95870.1   39499.5   24758.2
## BIC     209.6     196.0     187.2     184.5     177.4     176.1
# Plotting Structural Breaks in Energy Consumption for Utilities (UTI)
UTI_ci <- confint(UTI_bp)
plot(UTI)
lines(UTI_bp)
lines(UTI_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for Other Industrial-related (OIR)
OIR_bp <- breakpoints(OIR ~ 1)
summary(OIR_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = OIR ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1       7      
## m = 2       7 11   
## m = 3   4   7 11   
## m = 4   3 5 7 11   
## m = 5   3 5 7 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1             2011          
## m = 2             2011 2015     
## m = 3   2008      2011 2015     
## m = 4   2007 2009 2011 2015     
## m = 5   2007 2009 2011 2014 2016
## 
## Fit:
##                                              
## m   0      1      2      3      4      5     
## RSS 796.02 166.75  69.98  25.67  17.17  12.57
## BIC 101.58  84.97  78.09  69.33  68.98  69.89
# Plotting Structural Breaks in Energy Consumption for Other Industrial-related (OIR)
OIR_ci <- confint(OIR_bp)
## Warning in confint.breakpointsfull(OIR_bp): Confidence interval 3 cannot be
## computed: P(argmax V <= 0) = 0.0089
plot(OIR)
lines(OIR_bp)

# Finding Structural Breaks in Energy Consumption for Wholesale and Retail Trade (WRT)
WRT_bp <- breakpoints(WRT ~ 1)
summary(WRT_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = WRT ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1         10   
## m = 2   2   9      
## m = 3   2   8 10   
## m = 4   2   8 10 12
## m = 5   2 5 8 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1                  2014     
## m = 2   2006      2013          
## m = 3   2006      2012 2014     
## m = 4   2006      2012 2014 2016
## m = 5   2006 2009 2012 2014 2016
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 189907.5 104723.4  75971.6  65470.9  62629.4  61182.0
## BIC    178.2    175.2    176.0    179.1    183.8    188.8
# Plotting Structural Breaks in Energy Consumption for Wholesale and Retail Trade (WRT)
WRT_ci <- confint(WRT_bp)
plot(WRT)
lines(WRT_bp)
lines(WRT_ci)

# Finding Structural Breaks in Energy Consumption
# for Accommodation and Food Services (AFS)
AFS_bp <- breakpoints(AFS ~ 1)
summary(AFS_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = AFS ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1       7     
## m = 2     5     11
## m = 3   2   6   11
## m = 4   2 5   8 11
## m = 5   2 4 6 8 11
## 
## Corresponding to breakdates:
##                                 
## m = 1             2011          
## m = 2        2009           2015
## m = 3   2006      2010      2015
## m = 4   2006 2009      2012 2015
## m = 5   2006 2008 2010 2012 2015
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 247295.7  67943.9  27709.9  12648.4   4606.7   4401.8
## BIC    181.9    169.1    161.8    156.1    147.3    151.9
# Plotting Structural Breaks in Energy Consumption
# for Accommodation and Food Services (AFS)
AFS_ci <- confint(AFS_bp)
plot(AFS)
lines(AFS_bp)
lines(AFS_ci)

# Finding Structural Breaks in Energy Consumption
# for Information and Communications (ICM)
ICM_bp <- breakpoints(ICM ~ 1)
summary(ICM_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = ICM ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1           11
## m = 2       7   11
## m = 3     5   9 11
## m = 4   3   7 9 11
## m = 5   3 5 7 9 11
## 
## Corresponding to breakdates:
##                                 
## m = 1                       2015
## m = 2             2011      2015
## m = 3        2009      2013 2015
## m = 4   2007      2011 2013 2015
## m = 5   2007 2009 2011 2013 2015
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 3086051.5  682801.0  243179.3  158961.9  119331.5  108966.2
## BIC     217.3     201.4     192.2     191.6     192.8     196.8
# Plotting Structural Breaks in Energy Consumption
# for Information and Communications (ICM)
ICM_ci <- confint(ICM_bp)
plot(ICM)
lines(ICM_bp)
lines(ICM_ci)

# Finding Structural Breaks in Energy Consumption
# for Financial and Insurance Activities (FIA)
FIA_bp <- breakpoints(FIA ~ 1)
summary(FIA_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = FIA ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1       7     
## m = 2   2   7     
## m = 3   2     9 11
## m = 4   2   7 9 11
## m = 5   2 4 7 9 11
## 
## Corresponding to breakdates:
##                                 
## m = 1             2011          
## m = 2   2006      2011          
## m = 3   2006           2013 2015
## m = 4   2006      2011 2013 2015
## m = 5   2006 2008 2011 2013 2015
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 1790176.2  623655.0  281779.6  198527.2   97398.5   89160.3
## BIC     209.6     200.1     194.3     194.7     190.0     194.0
# Plotting Structural Breaks in Energy Consumption
# for Financial and Insurance Activities (FIA)
FIA_ci <- confint(FIA_bp)
## Warning in confint.breakpointsfull(FIA_bp): Confidence interval 4 cannot be
## computed: P(argmax V <= 0) = 0.9869
plot(FIA)
lines(FIA_bp)

# Finding Structural Breaks in Energy Consumption for Real Estate Activities (REA)
REA_bp <- breakpoints(REA ~ 1)
summary(REA_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = REA ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1     5       
## m = 2     5     12
## m = 3   3 5     12
## m = 4   3 5 7   12
## m = 5   3 5 7 9 12
## 
## Corresponding to breakdates:
##                                 
## m = 1        2009               
## m = 2        2009           2016
## m = 3   2007 2009           2016
## m = 4   2007 2009 2011      2016
## m = 5   2007 2009 2011 2013 2016
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 1547808.7  158582.6   97551.1   37704.9   23974.0   21164.6
## BIC     207.6     181.0     179.5     171.4     170.4     173.9
# Plotting Structural Breaks in Energy Consumption for Real Estate Activities (REA)
REA_ci <- confint(REA_bp)
plot(REA)
lines(REA_bp)
lines(REA_ci)

# Finding Structural Breaks in Professional, Scientific
# & Technical, Administration & Support Activities (PST)
PST_bp <- breakpoints(PST ~ 1)
summary(PST_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = PST ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1         9   
## m = 2   2     9   
## m = 3   2 5   9   
## m = 4   2 5 7 9   
## m = 5   2 5 7 9 12
## 
## Corresponding to breakdates:
##                                 
## m = 1                  2013     
## m = 2   2006           2013     
## m = 3   2006 2009      2013     
## m = 4   2006 2009 2011 2013     
## m = 5   2006 2009 2011 2013 2016
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 138267.0  78663.7  27410.2   9355.5   8878.5   8439.0
## BIC    173.8    171.2    161.7    151.9    156.5    161.0
# Plotting Structural Breaks in Professional, Scientific
# & Technical, Administration & Support Activities (PST)
PST_ci <- confint(PST_bp)
plot(PST)
lines(PST_bp)
lines(PST_ci)

# Finding Structural Breaks in Energy Consumption
# for Other Commerce and Services-related (OCS)
OCS_bp <- breakpoints(OCS ~ 1)
summary(OCS_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = OCS ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1       7      
## m = 2   2   8      
## m = 3   2   7 9    
## m = 4   2   8 10   
## m = 5   2 4 7 9  11
## 
## Corresponding to breakdates:
##                                 
## m = 1             2011          
## m = 2   2006      2012          
## m = 3   2006      2011 2013     
## m = 4   2006      2012 2014     
## m = 5   2006 2008 2011 2013 2015
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 1773883.7  565284.5  152763.0   92536.4   71005.7   65095.4
## BIC     209.5     198.8     185.7     184.0     185.6     189.6
# Plotting Structural Breaks in Energy Consumption
# for Other Commerce and Services-related (OCS)
OCS_ci <- confint(OCS_bp)
plot(OCS)
lines(OCS_bp)
lines(OCS_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for Transport-related (TRP)
TRP_bp <- breakpoints(TRP ~ 1)
summary(TRP_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = TRP ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1     5        
## m = 2     5   11   
## m = 3   3 5   11   
## m = 4   3 5 7 11   
## m = 5   3 5 7 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1        2009               
## m = 2        2009      2015     
## m = 3   2007 2009      2015     
## m = 4   2007 2009 2011 2015     
## m = 5   2007 2009 2011 2014 2016
## 
## Fit:
##                                                                
## m   0         1         2         3         4         5        
## RSS 4702156.2  666651.4  243111.0  164897.3   91601.9   78537.9
## BIC     223.2     201.1     192.2     192.1     189.1     192.3
# Plotting Structural Breaks in Energy Consumption for Transport-related (TRP)
TRP_ci <- confint(TRP_bp)
plot(TRP)
lines(TRP_bp)
lines(TRP_ci)

# Finding Structural Breaks in Energy Consumption for Others (OTH)
OTH_bp <- breakpoints(OTH ~ 1)
summary(OTH_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = OTH ~ 1)
## 
## Breakpoints at observation number:
##                   
## m = 1     5       
## m = 2   3   7     
## m = 3   2 4 7     
## m = 4   2 4 6 8   
## m = 5   2 4 6 8 10
## 
## Corresponding to breakdates:
##                                 
## m = 1        2009               
## m = 2   2007      2011          
## m = 3   2006 2008 2011          
## m = 4   2006 2008 2010 2012     
## m = 5   2006 2008 2010 2012 2014
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 185510.9  40193.6  15202.7   7827.7   5754.9   4849.6
## BIC    177.9    161.8    153.4    149.4    150.4    153.3
# Plotting Structural Breaks in Energy Consumption for Others (OTH)
OTH_ci <- confint(OTH_bp)
plot(OTH)
lines(OTH_bp)
lines(OTH_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for 1-Room / 2-Room HDB (X1R2R)
X1R2R_bp <- breakpoints(X1R2R ~ 1)
summary(X1R2R_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = X1R2R ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1         9    
## m = 2       7 10   
## m = 3     6   9  11
## m = 4     5 7 9  11
## m = 5   2 5 7 9  11
## 
## Corresponding to breakdates:
##                                 
## m = 1                  2013     
## m = 2             2011 2014     
## m = 3        2010      2013 2015
## m = 4        2009 2011 2013 2015
## m = 5   2006 2009 2011 2013 2015
## 
## Fit:
##                                              
## m   0      1      2      3      4      5     
## RSS 7741.4 1184.1  456.7  259.4  166.5  164.9
## BIC  133.4  112.4  104.4  101.7  100.8  105.9
# Plotting Structural Breaks in Energy Consumption for 1-Room / 2-Room HDB (X1R2R)
X1R2R_ci <- confint(X1R2R_bp)
plot(X1R2R)
lines(X1R2R_bp)
lines(X1R2R_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for 3-Room HDB (X3R)
X3R_bp <- breakpoints(X3R ~ 1)
summary(X3R_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = X3R ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1   5          
## m = 2   4     10   
## m = 3   4     10 12
## m = 4   4   8 10 12
## m = 5   4 6 8 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1   2009                    
## m = 2   2008           2014     
## m = 3   2008           2014 2016
## m = 4   2008      2012 2014 2016
## m = 5   2008 2010 2012 2014 2016
## 
## Fit:
##                                                    
## m   0       1       2       3       4       5      
## RSS 13617.4  5240.3  2234.0  1245.5  1101.3  1065.3
## BIC   141.3   133.2   126.6   123.7   127.2   132.0
# Plotting Structural Breaks in Energy Consumption for 3-Room HDB (X3R)
X3R_ci <- confint(X3R_bp)
plot(X3R)
lines(X3R_bp)
lines(X3R_ci)
## Warning: Confidence intervals outside data time interval
##   from 2005 to 2018 (14 observations)

# Finding Structural Breaks in Energy Consumption for 4-Room HDB (X4R)
X4R_bp <- breakpoints(X4R ~ 1)
summary(X4R_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = X4R ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1       9      
## m = 2     5   10   
## m = 3     4 8 10   
## m = 4     4 8 10 12
## m = 5   2 4 8 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1             2013          
## m = 2        2009      2014     
## m = 3        2008 2012 2014     
## m = 4        2008 2012 2014 2016
## m = 5   2006 2008 2012 2014 2016
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 189287.7  40785.4  15637.0   8159.4   7237.7   7146.5
## BIC    178.2    162.0    153.8    150.0    153.6    158.7
# Plotting Structural Breaks in Energy Consumption for 4-Room HDB (X4R)
X4R_ci <- confint(X4R_bp)
plot(X4R)
lines(X4R_bp)
lines(X4R_ci)

# Finding Structural Breaks in Energy Consumption for 5-Room and Executive HDB (X5REX)
X5REX_bp <- breakpoints(X5REX ~ 1)
summary(X5REX_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = X5REX ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1       9      
## m = 2   4     10   
## m = 3   4     10 12
## m = 4   4   8 10 12
## m = 5   4 6 8 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1             2013          
## m = 2   2008           2014     
## m = 3   2008           2014 2016
## m = 4   2008      2012 2014 2016
## m = 5   2008 2010 2012 2014 2016
## 
## Fit:
##                                                    
## m   0       1       2       3       4       5      
## RSS 50728.6 20559.9 11020.2  5514.5  4625.3  3882.7
## BIC   159.7   152.4   148.9   144.5   147.3   150.2
# Plotting Structural Breaks in Energy Consumption for 5-Room and Executive HDB (X5REX)
X5REX_ci <- confint(X5REX_bp)
plot(X5REX)
lines(X5REX_bp)
lines(X5REX_ci)
## Warning: Confidence intervals outside data time interval
##   from 2005 to 2018 (14 observations)

# Finding Structural Breaks in Energy Consumption
# for Private Apartments and Condominiums (PAC)
PAC_bp <- breakpoints(PAC ~ 1)
summary(PAC_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = PAC ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1         9    
## m = 2     5   10   
## m = 3     4 7 10   
## m = 4     4 7 9  11
## m = 5   2 4 7 9  11
## 
## Corresponding to breakdates:
##                                 
## m = 1                  2013     
## m = 2        2009      2014     
## m = 3        2008 2011 2014     
## m = 4        2008 2011 2013 2015
## m = 5   2006 2008 2011 2013 2015
## 
## Fit:
##                                                          
## m   0        1        2        3        4        5       
## RSS 677875.4 151956.0  46720.7  23562.3  14560.8  12916.5
## BIC    196.0    180.4    169.1    164.8    163.4    167.0
# Plotting Structural Breaks in Energy Consumption
# for Private Apartments and Condominiums (PAC)
PAC_ci <- confint(PAC_bp)
plot(PAC)
lines(PAC_bp)
lines(PAC_ci)
## Warning: Overlapping confidence intervals

# Finding Structural Breaks in Energy Consumption for Landed Properties (LPP)
LPP_bp <- breakpoints(LPP ~ 1)
summary(LPP_bp)
## 
##   Optimal (m+1)-segment partition: 
## 
## Call:
## breakpoints.formula(formula = LPP ~ 1)
## 
## Breakpoints at observation number:
##                    
## m = 1   4          
## m = 2   4   9      
## m = 3   4     10 12
## m = 4   4   8 10 12
## m = 5   4 6 8 10 12
## 
## Corresponding to breakdates:
##                                 
## m = 1   2008                    
## m = 2   2008      2013          
## m = 3   2008           2014 2016
## m = 4   2008      2012 2014 2016
## m = 5   2008 2010 2012 2014 2016
## 
## Fit:
##                                                    
## m   0       1       2       3       4       5      
## RSS 25743.1  7970.4  4603.1  2287.6  1593.0  1468.6
## BIC   150.2   139.1   136.7   132.2   132.4   136.5
# Plotting Structural Breaks in Energy Consumption for Landed Properties (LPP)
LPP_ci <- confint(LPP_bp)
plot(LPP)
lines(LPP_bp)
lines(LPP_ci)