knitr::opts_chunk$set(echo = FALSE, error = FALSE, message = FALSE, warning = FALSE)
devtools::load_all() library(tidyverse) library(sn)
raw_df = import_from_fame_template( paste0( file.path(Sys.getenv("USERPROFILE")), "\\OneDrive - Bank Of Israel\\Data\\BoI\\GaR_Data\\Working_data\\data_fame.csv" ) ) df = raw_df %>% preprocess_df(vars_to_yoy = c( "gdp", "private_consumption", "public_consumption", "investment", "oecd_imp", "exports", "imports", "sp500", "eurostoxx600", "oil_p", "non_energy_p", "credit", "house_price", "ta125_close" ), vars_to_diff = c("unemployment", "boi_rate", "rate_euro", "rate_us"), vars_to_4_ma = c("gdp_us", "gdp_euro") )
partitions_list = list( dom_macro = c( "private_consumption", "public_consumption", "investment", "unemployment"), ext_macro = c( "oecd_imp", "exports", "imports" ), dom_fin = c( "credit", "house_price", "ta125_close", "boi_rate" ), ext_fin = c( "rate_euro", "rate_us", "sp500", "eurostoxx600", "oil_p", "non_energy_p" ) ) horizon_list=c(1,4,8,12) quantile_vec=c(0.05,0.25,0.5,0.75,0.95)
gar_analysis = run_GaR_analysis( partitions_list = partitions_list, vars_df = df, target_var_name = "gdp", horizon_list = horizon_list, quantile_vec = quantile_vec)
gar_analysis$gar_fitted_df %>% filter(quantile == "0.05") %>% filter(horizon %in% c(1,4)) %>% ggplot(aes(x = date, y = gar_fitted, color = horizon)) + geom_line()
t_skew_params = gar_analysis$gar_fitted_df %>% filter(date == max(date)) %>% filter(horizon == 1) %>% select(quantile, values = gar_fitted) %>% fit_t_skew()
dst(seq(-33, 68) / 1000, dp = t_skew_params) %>% as_tibble() %>% mutate(x = seq(-33, 68) / 1000) %>% mutate(mark = "no") %>% bind_rows(tibble( x = qst(p = c(0.05), dp = t_skew_params), value = dst(qst(p = c(0.05), dp = t_skew_params), dp = t_skew_params), mark = "yes" )) %>% ggplot(aes(x = x, y = value, color = as_factor(mark),size = mark)) + geom_point() + scale_color_manual(values = c("no" = "black", "yes" = "red")) + scale_size_manual(values = c("no" = 1, "yes" = 2.5)) + scale_x_continuous(labels = scales::percent_format()) + xlab(NULL) + ylab(NULL) + theme( axis.ticks.y = element_blank(), axis.text.y = element_blank(), legend.position = "none" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.