library(fpp2)
## Loading required package: ggplot2
## Loading required package: forecast
## Loading required package: fma
## Loading required package: expsmooth
library(data.table)
indicators <- read.csv("Supervisory Severely Adverse Domestic.csv")
colnames(indicators) <- tolower(colnames(indicators))
indicators$log_house.price.index..level. <- log(indicators$house.price.index..level.)
indicators$log_unemployment.rate <- log(indicators$unemployment.rate)
indicators$log_mortgage.rate <- log(indicators$mortgage.rate)
indicators$log_DJ.index <- log(indicators$dow.jones.total.stock.market.index..level.)
indicators$log_10treasury.yield <- log(indicators$x10.year.treasury.yield)
indicators$log_5treasury.yield <- log(indicators$x5.year.treasury.yield)
indicators$log_3treasury.yield <- log(indicators$x3.month.treasury.rate)
indicators$log_bbb <- log(indicators$bbb.corporate.yield)
indicators_ts <- ts(indicators, start = c(1976,1), frequency = 4)
par(mfrow = c(1,3))
autoplot(indicators_ts [,"x10.year.treasury.yield"]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("10 Year Treasury Yield ") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

autoplot(indicators_ts [,"house.price.index..level."]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("House Price Index Level ") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

autoplot(indicators_ts [,"mortgage.rate"]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("Mortgage Rate") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

autoplot(indicators_ts [,"dow.jones.total.stock.market.index..level."]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("Dow Jones Level") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

autoplot(indicators_ts [,"real.gdp.growth"]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("Real GDP Growth") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

autoplot(indicators_ts [,"bbb.corporate.yield"]) +
scale_x_continuous(limits = c(2010, 2019)) +
ggtitle("BBB Corperate Yield") +
annotate(
"rect",
xmin=2016,xmax=2019,ymin=-Inf,ymax=Inf,
fill="lightblue",alpha = 0.3
)
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.

scenario.ts <- window(indicators_ts, start = c(2017,2), end = c(2019,1))
scenario <- as.data.table(scenario.ts)
scenario[1,9] = 0.1
scenario$log_5treasury.yield = log(scenario$x5.year.treasury.yield)