Question: Multi-Country-Model

Dear all,

I have a question regarding the coding for a multi-country model. Suppose I have 4 countries with the following declarations for my countries and variables

@#define countries = “a”, “b”, “c”, “d” ]

@#for co in countries
var w_@{co} c_@{co};

For the model declaration, I would like to include a set of equations that has the following structure:

c_a(+1) - c_b(+1)) = c_a - c_b
c_a(+1) - c_c(+1)) = c_a - c_c
c_a(+1) - c_d(+1)) = c_a - c_d

and in addition:

w_b + w_c + w_d = c_a - c_b
w_b + w_c + w_d = c_a - c_c
w_b + w_c + w_d = c_a - c_d

I would be very happy to get a hint how a structure like this can be coded up in Dynare.


I had the same problem and couldn’t find anyway to do it in loops,
you can separate independent equations from interrelated ones. do independent ones in loops and bring the rest at the end after your loop.

Thanks for your message!

I found a way for the first three equations by defining a second group of countries:

@#define group = “b”, “c”, “d” ]

and then write a loop:

@#for gr in group
c_a(+1) - c_@{gr}(+1)) = c_a - c_@{gr}


I am trying to convert a two country model into a three country model. I already can run the former model despite both countries are not in autarky.

The uncovered interest rate parity condition for the two country version is: :

exp(c2lambdaq_pot(+1))/exp(c2lambdaq_pot)exp(c2rpcpd_pot(+1))/exp(c2rpcpd_pot) =(exp(

So, I supposed that for a third country would be :

exp.(c2lambdaq_pot(+1))/exp(c2lambdaq_pot)exp(c2rpcpd_pot(+1))/exp(c2rpcpd_pot) =(exp(

Nevertheless, I still have a few equations with residues different from zero mainly associated with the international links blocs .

I must confess my lack of knowledge in this matter.
Could someone, please, give me a help or send me some references about the subject. (602 KB)

I know this is a rather complex issue but I would highly appreciate any help in this matter, please!

If all countries are symmetric, you should get the same steady state values for each country. Thus, going from the running two country to the three country version should be straightforward. If this is not the case and you encounter residuals, there must be a mistake in your model equations.

Yes, all countries are symmetric. In my view the problem arises from equations such as the clearing oil market… Actually I put these equations all together at the end of my model bloc, so they are quite easy to identify. I understand, however, that Professors have other things to do than to resolve students’ s problems.
In any case I am sincerely grateful for the reply.

Actually, that’s not completely true. It is the job of professors to help resolve their own students’ problems. So if you have a supervisor, ask him for help. He may have more time for you than I have.

It seens you uploaded the wrong code. It looks like a two country model. One thing that is definitely wrong is the incorrect accounting for parameter dependence. See e.g. [Question about IRFs)