I am estimating a DSGE model. According to the way in which I calibrate parameters and calculate steady state, certain regions of some parameters will deliver unreasonable (out-of-bound or complex) steady state values. Also, certain regions of the parameter space imply model indeterminacy. Unfortunately, there is no closed-form for these boundaries of the parameter space. So, during the searching of the posterior mode and Metropolis-Hastings MCMC, I need to check whether a candidate draw is valid in every iteration. I have an external files solely for solving the steady state and checking for validity. I am wondering if this kind of checking can be embedded in Dynare. How can I be sure Dynare implement this kind of checking all the time?
Thanks a lot for any hints or suggestions!
Is there anyone who could provide me some hints? Maybe my previous post is not clear enough. Let me describe my question more clearly as follows:
Right now I am estimating a standard DSGE model similar to Smets and Wouters (2007). The steady state and some calibrated parameters are nonlinear functions of the parameters to be estimated. According to the way in which I calculate steady state values, certain regions of the parameter space deliver unreasonable parameter values and steady state values. For example, some calculated parameters may be out of bound, such as the depreciate rate being larger than one or smaller than zero. Sometimes, the steady state values turn out to be complex numbers. Also, certain regions of the parameter space imply model indeterminacy. Obviously, I would like to discard any draw from these regions during the estimation. Unfortunately, there is no closed-form for these boundaries of the parameter space. So, when searching for the posterior mode and doing Metropolis-Hastings MCMC, I check whether a candidate draw is valid in every iteration. I have external files solely for solving the steady state and checking for parameter validity. Right now, I use my own codes. I am thinking of transiting to Dynare and benefit from the sophisticated functionality of Dynare. But I am not sure if Dynare is flexible enough to embed these kinds of checking into the toolbox.
I guess Dynare has already guaranteed model determinacy during model estimation, right? If so, how is it realized? There must be some kind of checking somewhere in the source code. What I need is just to add some additional checking to the code. I just don’t know if it is possible and how it could be done.
Thank you very much!
Dynare always checks for
- Blanchard Kahn conditions (unstable and indeterminate solutions)
- existence of steady state
- complex steady states
- violation or prior bounds
- positive definite covariance matrices
You don’t have to take care of this yourself. Your example of depreciation would be solved by imposing a beta prior. One way to impose checks yourself is using a steady state file and setting the check indicator to 1 in case of failure. See the NK_baseline.mod in the Dynare examples folder to the recent snapshot.
Thank you so much, jpfeifer! Your hints are very useful!
As you suggested, I took a look at NK_baseline.mod in the Dynare examples folder to the recent snapshot. The situation described in that file shown as below is quite similar to my case.
“The following parameters are set in the steady state file as they depend on other deep parameters that were estimated in the original study. Setting them in the steady state file means they are updated for every parameter draw in the MCMC algorithm,…”
From my experience, for some draws in the MCMC algorithm, either the updated parameters are out of bounds such as the depreciation rate being less than zero or some steady state values are complex. In this case, imposing prior on the updated parameters does not seem to work as they are not estimated parameters from the first place.
Therefore, imposing checks seems to be the right way to go. You suggested “One way to impose checks yourself is using a steady state file and setting the check indicator to 1 in case of failure.” Right now, I do have a steady state file and I do have indicators, in which 1 implies failure. With all these files, is Dynare able to take care of the failure draw automatically by discarding the draw and searching for a new candidate draw? If not, what kind of additional programming do we need?
Dear jpfeifer, I am not very familiar with the fundamental programming of Dynare. And I am not sure if the Dynare group is just working on this kind of problems right now. I just hope to get more of your hints and suggestions. I really appreciate your time and attention!!!
Tomorrow’s snapshot will have an updated version of the file that shows how to do this. To see it immediately, go to github.com/JohannesPfeifer/dynare/blob/1b5641575f0f3e6f22c5d62f386446bdc774b491/examples/NK_baseline_steadystate.m
Thanks so much for your kind reply, jpfeifer! The updated steady state file is much more clear and instructive. And my problem is nearly solvable with what the latest version provides.
To better understand the mechanism of Dynare, I have three related follow-up questions:
During the search for posterior mode and MH-MCMC, the steady state file will be called every time a new candidate draw is obtained. Suppose a draw is invalid and the check indicator in the steady state file is set to 1. This would stop the steady state function immediately and return to the invoking function. At this time, does Dynare stop with error message or just ignore the previous invalid draw and try another draw? In fact, what we need is the latter one and don’t want Dynare to stop. In my own code, this could be simply done with a while loop. But I am not sure how this is done in Dynare?
In most .mod files, there is a line “check;” after “steady;”. Is this line of “check” solely for checking BK condition for determinacy? Or is it related to the check indicator from the steady-state function?
Yesterday, you mentioned that “Dynare always checks for Blanchard Kahn conditions (unstable and indeterminate solutions), existence of steady state, complex steady states, violation or prior bounds and positive definite covariance matrices”. When any of these is violated during MCMC or mode search, would Dynare stop immediately or discard the current draw and try another draw? If the latter one, why are there so many error messages in the forum saying that “BK condition not satisfied”? Is that because those are for stochastic simulation based on a given set of parameters instead of estimation?
The questions may look naive to the Dynare experts. But I am just a new beginner and want to transit to Dynare. Again, I really appreciate your time, attention and patience!
Great! Thanks so much for your answers, jpfeifer! I will try to code it up soon and see how it works.