# Creating uncertainty bands around IRFs of perfect foresight solver

I have employed Bayesian estimation to estimate several parameters of my DSGE model. Afterwards, I am employing the perfect foresight solver to study the dynamics in response to an exogenous shock, as my model can display nonlinear behavior depending on the size of this shock.

Under a stochastic simulation, it is easy to create uncertainty bands through the command “oo_.PosteriorIRF.dsge.HPDinf” and “oo_.PosteriorIRF.dsge.HPDsup”. My broader question is how these uncertainty bands are created exactly under the hood.

I know that dynare saves all the draws from the Metropolis Hastings in the “metropolis” folder under [model name] _mh1_blck*, where * refers to the chain number. I also know that dynare saves the 1200 draws that have been used to compute the Bayesian statistics under [model name]posterior_draws1. My first question is whether the draws from [model name]posterior_draws1 are used to create oo.PosteriorIRF.dsge.HPDinf and oo.PosteriorIRF.dsge.HPDsup, or whether draws from [model name]_mh1_blck* are used.

My second question is how to create HPDinf and HPDsup from a posterior distribution myself. I would say that I first take N draws from the posterior distribution, pass the resulting parameter values for each draw to my model, and calculate the impulse response functions using the perfect foresight solver in response to the same exogenous shock. This would generate at each point in time a distribution with N values for each endogenous variable. I would say that I then sort the N values at each point in time from low to high or vice versa, and calculate the 90% HPD interval. This way I get at each point in time the HPDinf and HPDsup for each endogenous variable. I would like to know i) whether this is the way Dynare generates HPDinf and HPDsup for a stochastic simulation, ii) whether this would be the correct way to manually do it for the perfect foresight solver, and iii) whether I should take the 1200 draws from [model name]_posterior_draws1 or take draws from [model name]_mh1_blck*.

As a side note I calculated the mean for each parameter of [model name]posterior_draws1, and I found that the resulting means were very close to the posterior means saved in "oo.posterior_mean.parameters", but not exactly the same (difference starting at 2 decimals). I was surprised to see they were not exactly the same, as I understand that [model name] posterior_draws1 contains the draws from which the summary statistics saved under "oo.posterior" are saved. Is my interpretation wrong?

I would be grateful for your thoughts and/or help

1. The posterior parameter statistics like `oo.posterior_mean` are based on all posterior draws in the `_mh*_blck*.mat`-files saved on the disk.
2. The `bayesian_irfs` stored in `oo.PosteriorIRF.dsge` are only based on the `sub_draws` saved in the `_ posterior_draws*.mat`-files.
3. What you describe is exactly the way to proceed. Loop over the different draws, run the simulation, and then compute the desired quantiles.

Thank you so much, professor Pfeifer! I am glad I have understood it correctly. Your work here is very much appreciated!

p.s. I see that you responded to me 6 days ago (many thanks for the quick response!), but Iast time I checked (Thursday, March 16) I could not see your response.