Good morning I am a total newbie with Dynare, and I am trying to buid a simple model of debt dynamics.
I defined the equations in the model block, and one of these is the government reaction function, that determines spending according to its debt target.
I’d like to have an if statement. Something like:
This is what I’d do in a matlab code, but of course it did not work within dynare!
Is there any possibility to do it? In genera, is it possible to say the model to use certain equations at certain moments, and others at other moments?
Can I for example set some parameters at different values with if statements? (say if the central bank is conservative then the inflation parameter is such, if the central bank is not, then the inflation parameter is something else
I post an update:
I found that if statements can be included with @#if and so on. But it also seems to me that this can only work for parameter values, not for values taken by the endogenous variables.
In other words, I could solve the “monetary policy” question (if cb conservative do x, if cb loose, do y). But I cannot do what to me was more important, i.e. tell the model to change dynamic equation past a debt threshold.
I am afraid that the latter problem is unsolvable…
Hi,
I am wondering if you could solve the problem? I am facing something similar… I need to set an if statement which depends on a variable, but Dynare does not give me the solution! I get the error that FEx is unknown…
Sorry, but this is not possible within the context the stochastic simulations in Dynare. The reason is that your policy function will have a kink and be non-differentiable. This is inconsistent with perturbation solution techniques that rely on Taylor approximations.
I have different specifications of investment adjustment costs and want to use @# to choose between them in the model block. In the preambel, the marker has to be defined, e.g., @# define cee = 0
However, I want to choose the specification in an external parameter file, where I set all my parameters. I thought, I could then pass on the parameter value to cee, however, that does not work:
Thank you for your answer. However, I don’t entirely get it what you suggested. What do you specify in the .mod file as parameter, cee or cee_indicator?
So right now, I’m working with two files which I do not modify: a .mod file and an .m file containing the baseline calibration. The parameters specified in benchmarkcalibration.m and stored in parameterfile_comparison.mat are loaded into the Dynare file by using the command (inside the .mod file): load parameterfile_comparison;
I’m working with two specifications of investment adjustment costs, so my model block contains, for example, an equation
And cee is the parameter indicating which adjustment costs I’m using.
Now, when I want to plot IR for the two specifications of investment ajustment costs I have a third file which “dynares” my .mod file and contains the following lines:
run benchmarkcalibration_comparison;
cee = 1;
save parameterfile_comparison cee -append;
dynare investmentNK.mod noclearall;
......
cee = 0;
save parameterfile_comparison cee -append;
dynare investmentNK.mod noclearall;
.....
Works fine, however, now I want to look at a third version of inv. adj. costs and for that I need the if statement in the .mod file. Can I do it analogously to how I did it before?
I am working on the code of Basu and Bundick (2017) and I saw they have an external steady state file along with the earlier mentioned code. It works fine but I put my own guess for steady-state in the same file (does not want to use external SS file). Then how it will work?
I’m sorry it is a general question.
Thanks for this answer, but I share the confusion of jojokre. What is the declared parameter here, cee or cee_indicator?
I’m trying to run the same model multiple times from a Matlab code, and I was trying to select different equations in the model block according to a global-kind-of variable that I set in Matlab. In this case: I’d declare the global variable opt = 1 in Matlab, then run the .mod file with option “noclearall” not to delete it, and within the .mod file define “@#define op = opt”
This is the model block’s if statement:
@#if op = 1
tn = 0; % Lump sum
@#elseif op = 2
tn = tn_ss + (0.5*(apport - gy_ss))/((1-alpha)*y); % Current labor tax
@#elseif op = 3
tn = tn_ss + (0.5*(apport(-3) - gy_ss))/((1-alpha)*y); % Delayed labor tax
@#endif