Block decomposition and the pound sign


#1

Hi,

I’ve written a multiple country large scale DSGE model (over 400 equations). To write the code, I rely on local variables to cut down on the number of equations and also use the macro processor very intensively. The code runs fine and I get the deterministic solution within one minute. Now I am trying to solve it faster so that I can add more countries. I wanted to use a block decomposition of the model and the bytecode option but get the following error:

ERROR: In ‘model’ block, ‘block’ or ‘bytecode’ options are not yet compatible with pound expressions

Is there any way around this? I really don’t want to write the model line by line.

Thanks for any suggestions!


#2

Hi, you can replace the pound variables with macro variables and it will work. This approach is in general safer, but you will have to use @{} in the model block. It should be possible to write a matlab code to transform the mod file this way, but I do not think it worth the effort for one model.

Best,
Stéphane.


#3

Thanks for your quick response! I should have been more clear. I’m using @#for and @#if statements in the model block so even if I change the local variables to macros, I still have pound signs in the model block and get the same error. It looks like maybe the fix isn’t worth the return for this problem. Thanks again for replying.


#4

Sorry but I do not understand… Suppose you have one local variable declared at the top of your model

#beta = bla*bla*bla

If you remove this line and add

@#define beta = bla*bla*bla

at the top of the mod file and replace any occurrence of beta by @{beta} in the model block, it should work since the pound variable beta is no more present. You can eliminate all the pound variables using the same approach.

Best,
Stéphane.


#5

Sorry, maybe I’m not being clear enough. You are right about the local variables. I could change them to macro variables and that would solve the problem for those variables.

The other problem I have is that I’m writing the model equations with for loops in the macro processor. It’s a multi region model with trade. Instead of writing a separate equation for trade between each region (y_12 y_13 y_14,…,y_21, y_23, …), I’m using the macro processor to write for loops for these equations and others. The pound sign inside the syntax for the @#for loop also seems to cause a problem for the block option. This is the one that I’m having a problem with as I don’t want to write all of these equations separately. Is that more clear?


#6

Either there is something wrong with your code or a bug in Dynare. A possible workaround (if the bug is in Dynare, but I tend to believe that the problem is in your mod file) is to use the savemacro, onlymacro and/or nolinemacro options of the dynare command (see the reference manual) to generate the expanded model block. Do this without the block and bytecode options, then add these options in the generated mod file (where the macro directives will have disappeared) and it should work as with a standard mod file.

It would help us (if there is a bug we need to fix it) if you post (or send us) the code.

Best,
Stéphane.