CPI in Canada: Exploring Beyond the Money Supply
by Jacob Coyle
Assignment 2
ECON 4403
Professor Hui Xiao
1
April 13, 2025
Contents
1. Introduction ............................................................................................................................... 3
2. Literature Review ..................................................................................................................... 4
3. Data ............................................................................................................................................ 7
Table 1: Variables and Source .................................................................................................... 8
Table 2: Descriptive Statistics .................................................................................................... 8
Table 3: ADF Test for Stationary Root....................................................................................... 9
4. Model ........................................................................................................................................ 10
Table 4: Joint Significance Test ................................................................................................ 10
5. Preliminary Estimation .......................................................................................................... 11
Table 5: Preliminary OLS Estimation Results .......................................................................... 11
6. Residual Diagnostics ............................................................................................................... 12
Table 6: VIF Test Results ......................................................................................................... 12
Table 7: Breusch-Pagan Test for Heteroskedasticity ................................................................ 12
Table 8: Breusch-Godfrey Test for Autocorrelation ................................................................. 12
Table 9: HAC Estimation Results ............................................................................................. 13
7. Forecasting............................................................................................................................... 14
Table 10: Forecast Evaluation .................................................................................................. 14
8. Conclusion ............................................................................................................................... 15
9. Bibliography ............................................................................................................................ 17
10. Appendix ................................................................................................................................ 18
11. R or Stata Code ..................................................................................................................... 20
2
1. Introduction
Inflation is one of the most closely watched macroeconomic indicators for economies across the
globe. Along with housing starts, Gross Domestic Product (GDP) and Purchasing Managers
Index (PMI) — investors and economists alike pay close attention to the monthly inflation
reports. Inflation influences monetary policy, investment decisions, and consumer behavior
(Mankiw, 2019). Understanding the underlying forces of inflation is a necessary endeavor for
policymakers and economists. Policymakers, like the Bank of Canada (BoC), aim for price
stability (BoC, 2020). A chief mandate of the BoC is to keep inflation within a target range.
Stable, predictable inflation enables businesses to reasonably plan, and for consumers to
maintain purchasing power. A better understanding of the driving forces of inflation could
potentially allow economic agents and interested parties to gain predictive power about future
inflations prints.
The Consumer Price Index (CPI), defined by Mankiw (2019), measures the overall cost of goods
and services purchased by the typical consumer. CPI is also used to track purchasing power
changes across time. The BoC monitors headline CPI (along with other CPI measurements) –
which aims to capture the broadest changes in price levels in the Canadian economy. Headline
CPI serves as the primary inflation gauge. Notably, CPI does not include certain items like
financial assets (stocks and bonds), second hand-goods, and black-market transactions, as these
don’t immediately affect spending on new goods and services (BoC, 2021).
3
Foundational economic models, such as the Quantity Theory of Money, simply but effectively
showcase how the money supply determines price levels. The argument is that as the money
supply growth outpaces real output (Real GDP), inflation occurs ( Mankiw, 2019). This study
aims to take broad but comprehensive look at identifying key drivers of inflation in Canada. Data
utilized will include measures of monetary policy (money supply, overnight rates), financial
asset performance (namely, Canadian and US major stock indices), exchange rates (USD/CAD),
unemployment rate, and Canadian energy prices. This research aims to uncover the predictive
power and influencing factors of major economic indicators to view inflationary trends.
Additionally, housing prices – often cited as a source of inflationary pressure – have statistically
meaningful short-term effects on CPI (Goodhart & Hofmann, 2000)
The data collected and used in this research project was primarily collected form secondary
sources — mainly, government statistical agencies within Canada and the US. The aim was
ensure dataset accuracy, integrity and reliability. Given the revisional nature of statistics, it is
possible that some of that data has been revised by their statistical agencies after the data was
collected for this study. Therefore, there may be discrepancies between the data in this study and
what is actively accessible in the future. Where gaps existed in the data, i.e, missing dates or
inconclusive timeframes, tertiary sources were utilized to supplement. Most data was collected
directly form secondary sources (Government Agencies).
2. Literature Review
2.1 Seminal Paper
This study is humbly trying to add to the literature by grounding its foundation in Milton
Friedman’s 1968 seminal paper, “The Role of Monetary Policy.” Friedman’s work built a theory
around monetary-based inflation. Friedman’s argument is summarized by the quote “Inflation is
always and everywhere a monetary phenomenon.” This work cemented the role of money supply
growth in driving long term inflation (Friedman, 1968). One of the key variables in our model is
money supply growth. The Quantity Theory of Money (QTM), posited that when the money
supply expands quicker than economic output, inflation is the result (Mankiw, 2019). While
Freidman’s body of work and QTM provide a strong theoretical foundation, our paper aims to
4
include some modern inflation dynamics. Looking beyond just the money supply, we hope to
address effects such as interest rates, exchange rates and financial market conditions and the role
they play in inflationary activity. Also, we hope to see if the variables included in our model play
a more immediate role in shaping inflation, along with the growth in money supply.
Inflation is influenced dynamically by an intertwined set of macroeconomic factors and
consumer behavior. The economy is inherently complex, and therefore inflation and its
determinants follow suit. Some key determinants include money supply, exchange rates,
financial markers, labor markets, interest rates, savings behavior, and energy costs. Surveying
the literature has led us to studies that have detailed the above determinants, providing empirical
evidence for meaningful relationships with inflation, and therefore justifying inclusion in the
model.
2.2 Money Supply
The relationship between money supply and inflation is well documented and detailed above.
The Quantity Theory of Money (Mankiw, 2019) asserts that an increase in money supply,
holding velocity constant, results in higher price levels. Empirical studies in Canada confirm this
classical economic theory, with Dion (1999) and Nyoni (2021) finding that broad money supply
growth significantly drives inflation. The inclusion of the M2++ money supply as a variable in
this study coincides with these findings.
2.3 Exchange Rate
The Overshooting Model (Dornbusch, 1976) suggests that deprecation in a country’s exchange
rate increases inflation by raising import costs. Empirical research supports this, demonstrating
exchange rate pass-through effects in developed economies (Goodhart & Hofmann, 2000). In
Canada, Tsimklus (2022) found that changes in the exchange rate can have a measured impact on
consumer prices, supporting the inclusion of the USD/CAD fluctuations in this study.
2.4 Financial Markets
Returns on financial assets affect wealth and potentially medium to long-term inflation.
Goodhart & Hofmann (2000) studied the relationship between financial markets and inflation,
concluding that equity markets can serve as leading indicators of inflationary trends. Given this,
5
TSX and S&P 500 returns have been included within this preliminary model to examine their
predictive power for inflation in Canada.
2.5 Housing Price Appreciation
Housing prices have also been cited as drivers of inflation and influence wealth over the medium
to long-term. Goodhart & Hofmann once again found rising house prices can contribute to
inflation in certain circumstances. Given the evidence and the relevance in Canada, the New
Housing Price Index (NHPI) is included in this study to examine the effects on inflation in
Canada.
2.6 Unemployment
The Phillips Curve (Phillips, 1958) suggests an inverse relationship between unemployment and
inflation. The Phillips Curve demonstrates that lower unemployment leads to wage pressures and
rising prices. Dion (1999) found that the labor market conditions in Canada affect inflation.
Unemployment rate changes are included to evaluate the influence on price levels.
2.7 Overnight Money Market Rate (OMMR)
As discussed, monetary policy is geared towards managing inflation. The Bank of Canada
adjusts interest rates to influence the economy — in terms of borrowing, spending, and price
stability. In 1993, Taylor proposed that central banks set interest rates in response to inflation
deviations from the target rate. In 1999, Dion stated that the OMMR is a key tool in influencing
inflation used by policymakers in Canada. We include the OMMR to study impacts on inflation
trends.
2.8 Household Savings Rate
Savings behavior affects aggregate demand (Mankiw, 2019). Higher savings rates can dampen
consumption and produce deflationary pressures, while a decline in savings may boost spending,
causing inflationary pressures. Mankiw’s textbook discusses the relationship between savings
and economic growth, and the resulting fluctuations in inflation dynamics. Households’ savings
rate is included to assess its influence on price movements.
2.9 Energy Prices
6
Energy prices in Canada directly impact inflation due to the necessity of energy to complete any
type of economic activity, in other words, produce any sort of goods or services. It has been
found that fluctuations in energy costs influence CPI movements in Canada (Tsimiklis, 2022).
Further, in 1999, Dion also found that energy price shocks influence inflationary cycles. We
include the Energy-CPI sub basket as an explanatory variable for our model.
2.10 Contributions
The aim is to contribute to the economic literature by developing a unified regression model with
the aforementioned economic variables and indicators. The hope is to provide new empirical
evidence on the statistical significance, or lack thereof, on the combination of these variables.
Ultimately, the contribution goal is that this model can help guide policymakers, investors or
individuals to make better informed decisions pertaining to inflation expectations and
predictions.
3. Data
The data set and data collection process was entirely novel, with all data being sourced
specifically for this study. The data was primarily sourced from secondary sources, with tertiary
sources filling some minor gaps in data ranges. To be as robust as possible, the time frame for
the data spans from Jan-1-1982 up to Sep-1-2024. Total observation size was 513, with 11 total
variables (1 dependent, 10 independent). Stats Canada, Bank of Canada, and the Federal Reserve
of St. Louis constituted most of the secondary data. Stock market data was accessed through a
combination of the related exchange website and Investing.com. The vast majority was from
reliable and accurate government or institutional sources, with the gaps filled by tertiary sources.
Research terms to find relevant academic literature are as follows: "CPI," "Inflation," "CPI
Predictions,” "Friedman," "Phillips," "Taylor," "Econometrics,” “Time Series Inflation Model,"
"Economics," "Econometric Inflation Forecasting."
The data collected was sourced in either a monthly or quarterly basis. CPI is reported monthly,
and in a year-over-year percentage change format. To keep the data consistent, every variable
was transformed into monthly year-over-year percentage format. Real GDP and the Household
7
savings rate were reported quarterly. To convert these to monthly, we took a simple average and
allocated one-third of the original value equally to each month in the quarter. Table 1
summarizes the variable and data source. Note: all variables are monthly in year-over-year
percentage change format. Variable name is stated followed by abbreviation.
Table 1: Variables and Source
Variable
CPI (CPI)
M2++ Money Supply (M2)
TSX (TSX)
S&P 500 (SP)
USD/CAD Exchange Rate (FX)
New Housing Price Index (HPI)
RGDP Growth (RGDP)
Overnight Money Market Rate (OR)
Energy Sub-CPI (NRG)
Unemployment Rate (UR)
Household Savings Rate (HSR)
Source
Statistics Canada
Bank of Canada
Toronto Stock Exchange
S&P Global
Bank of Canada
Statistics Canada
IMF
Bank of Canada
Statistics Canada
Statistics Canada
Bank of Canada
Table 2: Descriptive Statistics
Variable Description
Mean
SD
Median
Min
Max
Kurtosis
ΔCPI Consumer Price Index
ΔM2 M2++ Money Supply
2.80
2.04
2.20
-0.90
11.90
4.06
7.43
2.52
7.10
1.70
14.54
-0.09
ΔTSX TSX Returns
ΔSP S&P500 Returns
6.96
17.12
7.23
-42.11
79.03
1.17
10.30
16.20
11.91
-44.75
53.71
0.61
ΔFX USD/CAD
ΔHPI New Housing Price Index
0.52
6.78
0.62
-19.10
26.20
1.47
2.79
4.53
1.83
-9.71
16.50
0.75
ΔOR Overnight Money Market Rate
ΔNRG Energy CPI
39.51
247.15
0.07
-92.01
2515.68
61.38
3.91
8.96
3.34
-23.72
38.81
0.90
ΔUR Unemployment Rate
ΔHSR Househoulds Savings Rate
1.03
19.98
-3.23
-41.26
160.00
15.86
-4.49
55.84
-2.73
-562.22
212.50
59.24
ΔRGDP Real Gross Domestic Product
0.76
0.87
0.84
-4.08
4.30
6.25
8
# of Obs
513
Independent variables are lagged T-1 to account for endogeneity issues between variables, and CPI
was kept at T=0.
3.1 Stationarity Test
Table 3: ADF Test for Stationary Root
ADF Test Variable
pDecision
value
H0: Time series has a unit root
0.01
Reject H0
ΔOR
ΔNRG
0.02
0.01
0.01
0.01
0.01
0.01
0.01
Reject H0
Reject H0
Reject H0
Reject H0
Reject H0
Reject H0
Reject H0
ΔUR
0.01
Reject H0
ΔHSR
ΔRGDP
0.01
0.01
Reject H0
Reject H0
ΔCPI
ΔM2
ΔTSX
ΔSP
ΔFX
ΔHPI
All variables are non-stationary, rejecting H0 at the .05 significance level, due to the year-overyear structure of the data.
3.2 Dividing the Sample
To prepare for preliminary OLS estimation results and forecasting, the sample will be divided 8020. 80 percent of the samples will represent the in-sample training data set and 20 percent will be
the pseudo out-of-sample data. Jan-1, 1982 – Feb 1, 2016, will be the in-sample training data, and
then March 1 – 2016 – Sep. 1, 2024, will constitute the pseudo out-of-sample training data.
9
4. Model
The model and the variables are justified as stated in the literature review section. The variables
have been selected based on empirical evidence that they are related to or influence inflation
measured by the Consumer Price Index. As mentioned, all independent variables were lagged T-1
to account for endogeneity. The model is as follows:
ΔCPIt= β1(ΔM2t−1) + β2(ΔTSXt−1) + β3(ΔSPt−1) + β4(ΔFXt−1) + β5(ΔHPIt−1) +
β6(ΔORt−1) + β7(ΔNRGt−1) + β8(ΔURt−1) + β9(ΔHSRt−1) + β10(ΔRGDPt−1) + ϵt
4.1 Model Selection
An F-test for joint significant was conducted based off the preliminary OLS estimation results in
Table 5. All coefficients were statistically significant at the .01 level, except for the change in
household savings rate: β9(ΔHSRt−1), and the change in the house price index: β5(ΔHPIt−1). The
hypothesis test concluded that the variables tested are not significant to the model and therefore
were omitted.
Table 4: Joint Significance Test
F Test for β5, β9
p-value
Decision
H0: β5 = β9
0.543
Fail to Reject H0
Final Model:
ΔCPIt= β1(ΔM2t−1) + β2(ΔTSXt−1) + β3(ΔSPt−1) + β4(ΔFXt−1) +
β6(ΔORt−1) + β7(ΔNRGt−1) + β8(ΔURt−1) + β10(ΔRGDPt−1) + ϵt
10
5. Preliminary Estimation
Table 5: Preliminary OLS Estimation Results
Dependent Variable =
CPI
Constant
Coefficient
-1.814 ***
(0.2219)
ΔM2_L1
ΔTSX_L1
ΔSP_L1
ΔFX_L1
0.498
(0.03)
-0.030
(0.005)
0.034
(0.0051)
-0.026
***
***
***
***
0.01
ΔHPI_L1
ΔOR_L1
ΔNRG_L1
ΔUR_L1
ΔHSR_L1
ΔRGDP_L1
# of Obs
Adjusted R2
-0.010
(0.0182)
0.004
(0.001)
0.126
(0.0079)
0.057
(0.0083)
0.001
(0.0017)
0.295
(0.1386)
409
0.7409
***
***
***
***
A correlation matrix was used to analyze and investigate the potential relationships between
independent variables. Two relationships had correlation coefficients above |.70| suggesting a
very strong relationship. Firstly, the change in TSX and change in the S&P500 had a correlation
of .76 – both being North American stock exchanges, these results were not surprising. Secondly,
a correlation of -.83 was present between the change in real GDP and the change in
unemployment rate. This is expected, due to the widely studied and empirically significant force
that is Okun’s Law. These will be explored further in the VIF test in Residual Diagnostics.
11
6. Residual Diagnostics
6.1 Multicollinearity
Table 6: VIF Test Results
Variable
ΔUR_L1
ΔRGDP_L1
ΔTSX_L1
ΔSP_L1
ΔFX_L1
ΔNRG_L1
ΔOR_L1
ΔM2_L1
VIF
3.94
3.92
3.16
2.61
1.46
1.4
1.33
1.09
All independent variables included in the model have VIF > 5, meaning there is no significant
issue with multicollinearity that needs to be addressed.
6.2 Heteroskedasticity
To test for heteroskedasticity in our model we use the Breusch-Pagan Test, where the null
hypothesis is constant variance of the error terms, and the alternative hypothesis is
heteroskedasticity of the error terms. We reject H0 and conclude a heteroskedasticity issue in our
model.
Table 7: Breusch-Pagan Test for Heteroskedasticity
Heteroskedasticity Test
p-value
Decision
H0 : Constant Variance vs. HA : not H0
0.0015
Reject H0
6.3 Autocorrelation
Table 8: Breusch-Godfrey Test for Autocorrelation
Autocorrelation Test
H0 : No autocorrelation vs. HA : not H0
Lag order
p-value
Decision
q=2
0.00
Reject H0
12
The null hypothesis is no autocorrelation of the residuals in the model. Using a lag order of 2, we
reject H0, meaning there is serial correlation between the residuals. Other lag orders were tested,
all yielding the same results. The error’s lag structure is at least εt = ρ1εt−1 +ρ2εt−2 + μt.
6.4 Linearity
In Figure 1, the residuals are plotted against the fitted values. We observe non-linearity,
especially in the lower fitted values of CPI. However, the independent variables were selected
based on established economic theory and the corresponding coefficients are statistically
significant, reinforcing the model structure and their relevance. Thus, despite signs of nonlinearity, we maintain the current functional form.
6.5 Remedial Measures
To address the autocorrelation and heteroskedasticity violations in our preliminary estimation
results , we will us HAC. HAC corrects the model’s coefficient estimates’ standard errors, t-values,
and p-values, which will provide us with more reliable hypothesis testing and inference. This
makes our model more credible, and the approach is empirically backed by Newey, W. K., & West,
K. D. (1987). While these issues still exist, the OLS estimated coefficients have stayed the same,
and HAC provides us with insurance in terms of a robust model.
Table 9: HAC Estimation Results
Dependent
Variable =
CPI
Constant
ΔM2_L1
ΔTSX_L1
ΔSP_L1
ΔFX_L1
ΔOR_L1
Coefficient
-1.814
(0.63)
0.498
(0.07)
-0.03
(0.01)
0.034
(0.01)
-0.026
(0.02)
0.004
(0.001)
***
***
***
***
***
13
ΔNRG_L1
ΔUR_L1
ΔRGDP_L1
0.126 ***
(0.02)
0.057 ***
(0.008)
0.295
(0.33)
# of Obs
Adjusted R2
409
0.7409
When using HAC to correct for autocorrelation and heteroscedasticity, the following estimation
results showed that real GDP and the USD/CAD exchange rate became insignificant at the 0.05
level. When these two variables were excluded from the forecasting model, the RMFSE and
RMAFE results improved marginally from 2.89 to 2.77 and 1.91 to 1.89 respectively. While the
impact of inclusion or exclusion is marginal, the variables were excluded to provide simpler and
slightly improved forecast accuracy. Interpreting the results, the change in real GDP may not
explain the variation in CPI at one month lag. The change in real output may not have such an
immediate effect on CPI, and may also be captured in other variables, like unemployment,
energy prices, and the money supply. Furthermore, the change in the USD/CAD exchange rate,
while has been proven to have pass-though effects, may not be as significant, unless there are
large swings. There is not a 1 to 1 relationship (Benati, 2009). Most statistically significant
variables have relatively small coefficients. This may be puzzling, however, if you think about
the rate of change at which, for example, the overnight rate can change from year to year, the
0.004 coefficient gets multiplied many times. For example, a 1% change in the overnight rate
leads to a 0.004 percent change in CPI. In context, given the kurtosis, and the minimum value of
-92 and max value of 2515, you can see the outsized effect this variable could have from year to
year.
7. Forecasting
Table 10: Forecast Evaluation
Model
Final Model
RMSFE RMAFE
2.77
1.89
14
Benchmark (Historical Mean)
1.88
1.45
Our final model out of sample’s root means squared forecast error (RMSFE) and the root means
absolute forecast error (RMAFE) is larger than the benchmark model. The final model does not
meaningfully improve predicting CPI values when compared to using historical mean. This
outcome, combined with MLR assumption violations, suggests that the model needs further
researching and refining. A 2.77 RMSFE and a 1.89 RMAFE average residual forecast error is
large and unhelpful in terms of forecasting CPI. If a policymaker was to use this model, their job
may be in question.
8. Conclusion
This study set out to evaluate some of the primary macroeconomic determinants of inflation in
Canada, measured by CPI. A multiple linear regression model using OLS estimation was applied
to year-over-year monthly data from 1982 to 2024.
The final model held strong explanatory power with an adjusted R2 of .74. The money supply,
the TSX and S&P500 indices, the overnight policy rate, the unemployment rate, sub-CPI energy
was determined to be statistically significant in the explanation of CPI in Canada. However,
previously thought meaningful variables like USD/CAD exchange rate, real GDP, the New
Housing Price Index, and the Household Saving Rate, were not significant in this model. We
cannot conclude that these variables have no impact on CPI, but based on the structure of our
model, they did not contribute to our findings at this time. Different functional forms, lag
structures, or variables would be needed to explore their significance in a different context.
Despite moderate success in terms of explanatory power, the model’s predictive performance fell
short in our forecast evaluation. However, we can learn from this. The best way to predict
inflation may be to understand CPI and its determinants. A more solid forecasting methodology
may lie in an autoregressive model, using pure lagged CPI as the independent variable to predict
future values of CPI. This would be like looking into a black box, and offer no economic
significance, but may help policy makers predict and address inflation and its expectations. Table
15
3 displays the predictive power of such a model.
Indeed, one of the models’ largest limitations was its inability to accurately and actively account
for structural shocks in CPI from one month to the next. Looking at the graph in Table 1, you can
see the model was reasonable when CPI was around target range of 2 to 3%. However, any large
deviations away from the target range led to huge forecast errors. As a result, the model failed to
address systematic changes in the underlying economic conditions.
This paper aimed at contributing to the literature on inflation by bridging the classical monetary
theory with contemporary macroeconomic indicators within a Canadian context. This paper can
serve as validation of widely cited inflation determinants and present a framework that can serve
as a starting point for future forecast models. Future studies should explore functional form of
these variables which may better capture major shifts in inflationary events, incorporating
dummy variables to capture time periods of economic shocks, like the Covid-19 pandemic, or the
2008 Global Financial Crisis, among others. Lastly, inflation expectations should be included,
this may bridge the gap between the large outliers and forecasting errors we observed in our
results.
In conclusion, while the model developed meaningful explanations of CPI in Canada, it requires
further refinement, as suggested above, to reliable make any meaningful policy contributions.
Nevertheless, this paper provides a valuable foundation for understanding the interconnectedness
and complexities of CPI in Canada and underscores the need for models that can better assess
rapidly changing economic environments.
16
9. Bibliography
Bank of Canada. (2020). Mandate and planning. Bank of Canada.
https://www.bankofcanada.ca/publications/annual-reports-quarterly-financialreports/annual-report-2020/mandate-and-planning/
Bank of Canada. (2021). Understanding consumer price index. Bank of Canada.
https://www.bankofcanada.ca/2021/05/understanding-consumer-price-index/
Mankiw, N. G. (2019). Macroeconomics (10th ed., Ch. 2, 4, 5, 7). Worth Publishers.
Dornbusch, R. (1976). Expectations and exchange rate dynamics. Journal of Political Economy,
84(6), 1161-1176. https://doi.org/10.1086/26050
Goodhart, C., & Hofmann, B. (2000). Do asset prices help to predict consumer price inflation?
The Manchester School, 68(S1), 122-140. https://doi.org/10.1111/1467-9957.68.s1.7
Friedman, M. (1968). The role of monetary policy. American Economic Review, 58(1), 1-17.
https://www.aeaweb.org/aer/top20/58.1.1-17.pdf
Dion, R. (1999). Indicator models of core inflation for Canada. Bank of Canada Working Paper
99-8. Bank of Canada.
Nyoni, T. (2021). Money supply and inflation in Canada: An empirical analysis. Journal
of Macroeconomic Policy, 12(3), 45-67.
Phillips, A. W. (1958). The relationship between unemployment and the rate of change of money
wages in the United Kingdom, 1861–1957. Economica, 25(100), 283-299.
https://doi.org/10.2307/2550759
Tsimiklis, V. (2009). The connection between commodity prices and the consumer price index in
Canada (Master’s thesis). John Molson School of Business, Concordia University.
Taylor, J. B. (1993). Discretion versus policy rules in practice. Carnegie-Rochester Conference
Series on Public Policy, 39, 195-214. https://doi.org/10.1016/0167-2231(93)90009-L
Benati, L. (2009). Long-run evidence on money growth and inflation (ECB Working Paper No.
1027). European Central Bank.
https://www.ecb.europa.eu/pub/pdf/scpwps/ecbwp1027.pdf
Newey, W. K., & West, K. D. (1987). A simple, positive-definite, heteroskedasticity and
autocorrelation consistent covariance matrix. Econometrica, 55, 703-708
17
10. Appendix
Figure 1: Final Model Predicted vs Actual CPI
Figure 2: Forecast Residuals
Figure 3: CPIt-1 lagged to Predict CPIt=0
18
Data tables:
Household Savings Rate: Statistics Canada. Table 36-10-0112-01 Current and capital accounts Households, Canada, quarterly
Unemployment: Statistics Canada. Table 14-10-0287-01 Labour force characteristics, monthly,
seasonally adjusted and trend-cycle
CPI and Energy CPI: Statistics Canada. Table 18-10-0004-01 Consumer Price Index, monthly,
not seasonally adjusted
Overnight Rate: Statistics Canada. Table 10-10-0139-01 Bank of Canada, money market and
other interest rates
Real GDP Canada: International Monetary Fund, Real Gross Domestic Product for Canada
[NGDPRSAXDCCAQ], retrieved from FRED, Federal Reserve Bank of St. Louis;
https://fred.stlouisfed.org/series/NGDPRSAXDCCAQ, February 28, 2025.
New Housing Price Index: Statistics Canada. Table 18-10-0205-01 New housing price index,
monthly
USD/CAD Foreign Exchange Rate:
Statistics Canada. Table 10-10-0009-01 Foreign exchange rates in Canadian dollars, Bank of
Canada, monthly
Monthly exchange rates - Bank of Canada
CPI: Stats Canada Price trends: 1914 to today
M2++: Selected monetary aggregates and their components (formerly E1) - Bank of Canada
SP500: S&P 500 Historical Data (SPX) - Investing.com
S&P 500 Historical Prices by Month - Multpl
TSX: Statistics Canada. Table 10-10-0125-01 Toronto Stock Exchange statistics
S&P/TSX Composite Historical Rates - Investing.com Canada
19
11. R or Stata Code
##########################################################################
# Initial loading of data
##########################################################################
library(readr)
library(dplyr)
library(psych)
library(tseries)
library(broom)
# Load the raw YoY % change data
inflationdata <- read_csv("C:/Users/Owner/OneDrive - Saint Marys University/1.SMU Winter
2025/Econometrics/Project/RModel1.csv")
#############################################################################
# Summary statistics
#############################################################################
summarystatistics <- describe(inflationdata[,-1]) # Exclude Date column
View(as.matrix(summarystatistics))
##########################################################################
# ADF Tests on Full Dataset (raw YoY % data, no lagging)
##########################################################################
raw_data <- inflationdata %>% select(-Date)
adf_results <- lapply(raw_data, function(x) {
test <- adf.test(x, alternative = "stationary")
c("ADF Statistic" = round(test$statistic, 4),
"p-value" = round(test$p.value, 4))
})
adf_df <- do.call(rbind, adf_results)
adf_df <- as.data.frame(adf_df)
adf_df$Variable <- rownames(adf_df)
rownames(adf_df) <- NULL
adf_df <- adf_df %>% select(Variable, everything())
print(adf_df)
20
#############################################################################
# Create lagged variables (DO NOT overwrite original data)
#############################################################################
inflationdata_lagged <- inflationdata %>%
mutate(
M2_L1 = lag(M2, 1),
TSX_L1 = lag(TSX, 1),
SP_L1 = lag(SP, 1),
FX_L1 = lag(FX, 1),
HPI_L1 = lag(HPI, 1),
OR_L1 = lag(OR, 1),
NRG_L1 = lag(NRG, 1),
UR_L1 = lag(UR, 1),
HSR_L1 = lag(HSR, 1),
RGDP_L1 = lag(RGDP, 1)
)
inflationdata_lagged <- inflationdata_lagged %>%
select(CPI, ends_with("_L1"))
inflationdata_lagged <- na.omit(inflationdata_lagged)
#############################################################################
# Train-test split (80/20)
#############################################################################
in_sample_size <- floor(nrow(inflationdata_lagged) * 0.8)
training_data <- inflationdata_lagged[1:in_sample_size, ]
test_data <- inflationdata_lagged[(in_sample_size + 1):nrow(inflationdata_lagged), ]
#############################################################################
# OLS Estimation on training data
#############################################################################
model <- lm(CPI ~ ., data = training_data)
summary(model)
ols_table <- tidy(model) %>%
mutate(across(where(is.numeric), round, digits = 4))
print(ols_table)
#############################################################################
# F-Test: Joint Significance of HPI_L1 and HSR_L1
#############################################################################
21
full_model <- lm(CPI ~ ., data = training_data)
restricted_model <- lm(CPI ~ . -HPI_L1 -HSR_L1, data = training_data)
anova_results <- anova(restricted_model, full_model)
anova_tidy <- tidy(anova_results) %>%
mutate(across(where(is.numeric), round, digits = 4))
print(anova_tidy)
#############################################################################
# Final Model: Excludes HPI_L1 and HSR_L1 based on F-test
#############################################################################
final_model <- lm(CPI ~ . -HPI_L1 -HSR_L1, data = training_data)
summary(final_model)
final_model_tidy <- tidy(final_model) %>%
mutate(across(where(is.numeric), round, digits = 4))
print(final_model_tidy)
##############################################################################
#Correlation Table#
##############################################################################
##########################################################################
# Correlation Matrix for Final Model Predictors
##########################################################################
correlation_data <- training_data %>%
select(-CPI, -HPI_L1, -HSR_L1) # just to be safe
cor_matrix <- cor(correlation_data, use = "complete.obs")
cor_matrix_rounded <- round(cor_matrix, 3)
22
print(cor_matrix_rounded)
##############################################################################
#
#VIF
##############################################################################
#
##########################################################################
# VIF Check for Multicollinearity in Final Model
##########################################################################
library(car)
# Calculate VIFs for the final model
vif_values <- vif(final_model)
vif_table <- as.data.frame(vif_values)
vif_table$Variable <- rownames(vif_table)
colnames(vif_table)[1] <- "VIF"
vif_table <- vif_table %>%
select(Variable, VIF) %>%
mutate(VIF = round(VIF, 3)) %>%
arrange(desc(VIF))
print(vif_table)
##############################################################################
#
#BP test for heteroskedasticity
##############################################################################
#
library(lmtest)
# Run Breusch-Pagan test
bp_test <- bptest(final_model)
print(bp_test)
##############################################################################
#
#BG test for auto-correlation
23
##############################################################################
#
# Breusch-Godfrey LM test (lag order = 2)
bg_test <- bgtest(final_model, order = 2)
print(bg_test)
###############################HAC##########################################
####
library(sandwich)
hac_se <- vcovHAC(final_model)
hac_results <- coeftest(final_model, vcov. = hac_se)
hac_table <- tidy(hac_results) %>%
mutate(across(where(is.numeric), round, 4))
print(hac_table)
test_data$predicted_CPI <- predict(final_model, newdata = test_data)
View(test_data[, c("CPI", "predicted_CPI")])
library(ggplot2)
ggplot(test_data, aes(x = CPI, y = predicted_CPI)) +
geom_point(color = "dodgerblue", alpha = 0.7) +
geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "darkred") +
labs(
title = "Actual vs Predicted CPI (Test Set)",
x = "Actual CPI",
y = "Predicted CPI"
24
)+
theme_minimal()
test_data$residuals <- test_data$CPI - test_data$predicted_CPI
hist(test_data$residuals,
breaks = 20,
col = "lightgray",
border = "white",
main = "Histogram of Forecast Residuals",
xlab = "Residuals")
### RMSE and MAE for final_model ###
rmse_final <- sqrt(mean(test_data$residuals^2))
mae_final <- mean(abs(test_data$residuals))
cat("Final Model RMSE:", round(rmse_final, 4), "\n")
cat("Final Model MAE :", round(mae_final, 4), "\n")
### Benchmark (mean-based naive forecast) ###
cpi_benchmark <- mean(training_data$CPI)
test_data$benchmark_CPI <- cpi_benchmark
test_data$benchmark_residuals <- test_data$CPI - test_data$benchmark_CPI
rmse_benchmark <- sqrt(mean(test_data$benchmark_residuals^2))
mae_benchmark <- mean(abs(test_data$benchmark_residuals))
cat("Benchmark RMSE:", round(rmse_benchmark, 4), "\n")
cat("Benchmark MAE :", round(mae_benchmark, 4), "\n")
##############TEST W/o RGDP and FX due to HAC results##########################
# Refit the model without FX_L1 and RGDP_L1
model_trimmed <- lm(CPI ~ . - HPI_L1 - HSR_L1 - FX_L1 - RGDP_L1, data = training_data)
test_data$predicted_CPI <- predict(model_trimmed, newdata = test_data)
View(test_data[, c("CPI", "predicted_CPI")])
25
ggplot(test_data, aes(x = CPI, y = predicted_CPI)) +
geom_point(color = "dodgerblue", alpha = 0.7) +
geom_abline(intercept = 0, slope = 1, linetype = "dashed", color = "darkred") +
labs(
title = "Actual vs Predicted CPI (Trimmed Model)",
x = "Actual CPI",
y = "Predicted CPI"
)+
theme_minimal()
test_data$residuals <- test_data$CPI - test_data$predicted_CPI
hist(test_data$residuals,
breaks = 20,
col = "lightgray",
border = "white",
main = "Histogram of Forecast Residuals",
xlab = "Residuals")
rmse_trimmed <- sqrt(mean(test_data$residuals^2))
mae_trimmed <- mean(abs(test_data$residuals))
cat("Trimmed Model RMSE:", round(rmse_trimmed, 4), "\n")
cat("Trimmed Model MAE :", round(mae_trimmed, 4), "\n")
cpi_benchmark <- mean(training_data$CPI)
test_data$benchmark_CPI <- cpi_benchmark
test_data$benchmark_residuals <- test_data$CPI - test_data$benchmark_CPI
rmse_benchmark <- sqrt(mean(test_data$benchmark_residuals^2))
mae_benchmark <- mean(abs(test_data$benchmark_residuals))
cat("Benchmark RMSE:", round(rmse_benchmark, 4), "\n")
cat("Benchmark MAE :", round(mae_benchmark, 4), "\n")
##############################################################################
##
# Simple Autoregressive Model: CPI_t ~ CPI_{t-1}
##############################################################################
##
26
inflationdata_lagged_cpi <- inflationdata %>%
mutate(CPI_L1 = lag(CPI, 1)) %>%
select(CPI, CPI_L1)
inflationdata_lagged_cpi <- na.omit(inflationdata_lagged_cpi)
in_sample_size_cpi <- floor(nrow(inflationdata_lagged_cpi) * 0.8)
training_cpi <- inflationdata_lagged_cpi[1:in_sample_size_cpi, ]
test_cpi <- inflationdata_lagged_cpi[(in_sample_size_cpi + 1):nrow(inflationdata_lagged_cpi), ]
model_cpi_ar1 <- lm(CPI ~ CPI_L1, data = training_cpi)
summary(model_cpi_ar1)
test_cpi$predicted_CPI <- predict(model_cpi_ar1, newdata = test_cpi)
rmse_cpi_ar1 <- sqrt(mean((test_cpi$CPI - test_cpi$predicted_CPI)^2))
mae_cpi_ar1 <- mean(abs(test_cpi$CPI - test_cpi$predicted_CPI))
cat("CPI Lagged AR(1) RMSE:", round(rmse_cpi_ar1, 4), "\n")
cat("CPI Lagged AR(1) MAE :", round(mae_cpi_ar1, 4), "\n")
ggplot(test_cpi, aes(x = CPI, y = predicted_CPI)) +
geom_point(color = "darkorange", alpha = 0.6) +
geom_abline(slope = 1, intercept = 0, linetype = "dashed") +
labs(
title = "Actual vs Predicted CPI using Lagged CPI (AR1)",
x = "Actual CPI",
y = "Predicted CPI"
)+
theme_minimal()
27
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )