-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
look into HD coding #47
Comments
Hello Adam and Thomasz, I was working on my historical decomposition and realized that after computing it with the compute_historical_decomposition() function, I lost two observations from the dataset. The problem is that I don´t know if those lost observations belong to the beginning or the end of the dataset. Maybe the possible problem you pointed out to me last time has something to do with this? Best regards, Alejandro |
Would you please share with us your analysis script? It would be useful bc often HDs don't work due to the model specification needing improvements. I would go through your code and make certain all the setup is as it should. The data file or plot would be useful as well. Greetings, T |
Hello Mr. Wozniak, thank you so much for the reply and for the help that you offered. As requested, I copy and paste my R script and attach the excel database I´m using. BVAR Brazilian Economy for historical decomposition of inflation (ipca_free_3mc)library(tidyverse) setwd('C:/Users/acruceno/OneDrive - Fosun Brasil/Documentos/Baysiana/Bases de Dados') dados <- read_excel('Baysiana/Bases de Dados/dados_projeto_alejandro.xlsx', Visualizing the datadados %>% Collecting the variables of interest in levels and differeces/growth ratesvariables <- dados[,c('ic_br_3mma', 'scp_3mma', 'output_gap_bcb', 'ipca_free_3mc' Checking staionarity of variables in differences/growth rates with the KPSS testcheck_stationarity <- function(base) { for (col in names(base)[-1]) {
} return(list(stationary = stationary_vars, non_stationary = non_stationary_vars)) results1 <- check_stationarity(variables) cat("Variáveis Estacionárias:\n", results1$stationary, "\n") Estimating the model with BVAR Signs Packagesr3 <- matrix(rep(NA), ncol = 7, nrow = 7) sr3[1,] <- c(1,NA,NA,NA,NA,NA,NA) sign_irf <- sr3 prior2 <- specify_bsvarSIGN$new(as.matrix(stat_variables), Estimating the hyperparametershyper_pams <- prior2$prior$estimate_hyper(S = 20000, burn_in = 5000, hp_df <- as.data.frame(t(hyper_pams)) trace_plot <- hp_df %>% Estimating the model:posterior2 <- estimate(prior2, S = 100) Computing impulse responsesimpulse2 <- compute_impulse_responses(posterior2, horizon = 10) irfs_4th_var <- impulse2[4, , , ] median_irf_4th_var <- apply(irfs_4th_var, c(1,2), median) irf_df <- as.data.frame(t(median_irf_4th_var)) %>% Computing the historical decompositionhd <- compute_historical_decompositions(posterior = posterior2, show_progress = TRUE) Getting only impact on inflationcontrib_shocks_4th_var <- hd[4, , , ] median_contrib_shocks_4th_var <- apply(contrib_shocks_4th_var, c(1, 2), median) contrib_df <- as.data.frame(t(median_contrib_shocks_4th_var)) contrib_long <- tidyr::gather(contrib_df, key = "Shock", value = "Contribution", -Time) Plotting the entire series of the historical decompositionggplot(contrib_long, aes(x = Time, y = Contribution, color = Shock)) + Line graphs of HD since 2019-12-01 forwardhd_graph <- contrib_long %>% Historical decomposition as bar graphs stacked on top of each other from 2019-01-01 forward:hd_bar_graph <- contrib_long %>% |
I just wanted to let you know that we're still revising the C++ code for historical decompositions. It takes time, but we're actively working on this. Greetings, Tomasz |
Hi everyone, I have been using the compute_historical_decompositions() function and have encountered some issues. I manage to get the IRFs from this posterior, but when running:
The R session crashes, sometimes right after achieving 100%, some other times immediately upon execution: Do you know what may be happenning? Thanks in advance for your kind help. |
compute_historical_decompositions()
is based on the textbook Kilian, L., & Lütkepohl, H. (2017), check if the code is correctThe text was updated successfully, but these errors were encountered: