I am trying to replicate “Optimal monetary and ﬁscal policy in a currency union” by Gali and Monacelli (2008). I am new to Dynare and I do not know how to solve my problem.

I get this error message:

Error using print_info (line 80)
The steady state contains NaN or Inf
Error in steady (line 92)
print_info(info,options_.noprint, options_);
Error in gali_monacelli_2008 (line 240)
steady;
Error in dynare (line 180)
evalin(‘base’,fname) ;

Attached you find my code.

It would be great if somebody could help me. Many thanks in advance for your help.

I still have problems with my mod file. I divided the model into two separate mod files, one for the country and one for the currency union, in order to see what is going wrong.

The currency model is now running, but I cannot figure out my mistake in case of the country model. I tried to use the mod file of Prof. Pfeifer for the Gali and Monacelli (2005) model as a guidance.

Attached you find both mod files.

Some advice would be very helpful. Many thanks in advance.

I tried to simplify the linking equation in order to avoid that problem. Of course, there might be a mistake.

Unfortunately, I still have not managed to get the complete model running. I got rid of some equations, but there is still an error in the system of equations such that dynare cannot find the steady states for the equations 1. - 16. (except 10.).

before steady to see the residuals of the equations. The problem with Gali’s papers is that some of his linearized equations still contain constant terms and you need to make this consistent. For example,

rr_star=rho_a+(y_bar_star(+1)-y_bar_star); //9. Union's natural level of interest rate, p.126
implies that rr_star has steady state rho_a.
You will need something like

initval;
rr_star=rho_a;
r_star=rho_a;
g_bar_star = log(BigChi);
f_gap_star = -log(BigChi);
end;
But this alone will not be sufficient, because I think there is still something wrong with some equations.

Would you be so kind to explain me the meaning of the residuals here? What problems do the constant terms in the linearized equations cause? Is it that I am dividing by zero or something like this?

Unfortunately, I think you are right, there is something wrong with the equations as well…

The residuals are the difference between the left and the right side of your equations, given the 0 starting values you provide. They show that some variables are not mean 0. This is per se not a problem in linear models, but you need to take care of this constant term in every equation that is affected.

Thank you Mr.Pfeifer. I think, I adjusted my mod file for the constant equations you mnetioned but it is still not working. Can you help me to find the mistake in my equations? I really do not know how to start finding the problem…

i rewrite your code after reading the article you referred. And the consequence of code simulation is same as the article.excuse my bad english untitled3.mod (2.22 KB)

Dear chowshangyao, thank you very much for your help.

If I understand it correctly, you implemented the equations describing the optimal policy, right? My problem is, that if I manage to get the baisc model working, I want to add some government debt policies to the model. Thus, I think, I would have to recalculate the optimality conditions, right? In order to avoid that problem, I would like to base my mod-file on the equations describing the economy, and not on the optimality conditions. Does that make sense to you?

Do you have (or anybody else) any suggestions to get my model running? I think, I need to include the monetary union, don’t I ? I would really appreciate any hints or suggestions!

i see what you mean.Some variables like nominal interest_rate and government expenditure are exogenous, optimal condition just determine the unique path for them.So giving any specific path to these exogenous variables can make the basic model working.

back to the topic , i guess some equations like p - p(-1) = ppi make the code cannot work.So i add the risk sharing condition (c = c_star + (1- alpha*s) )into the model for solving the path of domestic consumption c and terms of trade s (As the equilibrium of union is independent to country i ,and the path of y_gap and f_gap ppi can be derived only by using equation(1) phillips curve and (2) Is curve. so the path of y_star c_ star y is known , and we can derive the c and s by using country i’s market clearing and risk sharing condition).

Dropping some equations can make it works.But even if i add one equation like p - p(-1) = ppi will also make it unworkable .It troubles me a lot.
There also has another thing troubles me that the steady value of some variables which should equal to zero are just close to 0 but not 0. g_m_2008.mod (6.52 KB)

i had wrote a polite reply before ，but i forget to login …And it’s already 03:00 am in my country .If there are any inappropriate words ,please forgive me .

Dear chowshangyao, thank you very much for working so much on my code. You really helped me a lot as the code is running now.

Nonetheless, I do not really understand why these equations cause so much trouble. Does anybody understand this? Unfortunately, I think, the simulations based on your code do not produce the correct impulse response functions, do they? The output gap and the fiscal gap behave in the opposite way…

Of course the simulation will be different . Because we define the government expenditure as g_star = BigChi*a_star , but the original(gali(2008) is g_star = log(BigChi) + a_star.
From the original we can see g_gap_star = 0 for all period ,and the fiscal gap will satisfy f_gap_star = - y_gap_star(which can be regarded as the optimal fiscal policy).
But our code’s fiscal gap is f_gap_star = (g_star - y_star ) - log(BigChi) = (BigChi-1)*a_star - log(BigChi) - y_gap_star.On the other hand , the exogenous shocks may be badly defined,thus the irf works weirdly.
From above, it’s obvious to see the reason why the consequence of our simulation is different from gali(2008).But i haven’t test it and cannot make sure whether it can be fixed only by modifying the path of government expenditure.

I adjusted the path for government expenditure to g = log(BigChi)+a (where in the paper do you find this?), and I get g_gap = 0 and f_gap= -y_gap. Thus, I think, this is working now.
But looking at the impulse response functions pictured in the paper, this does not seem to hold. There, y_gap initially drops to -0.2 whereas f_gap rises to 2… Is the related to how the shock is specified? The paper simulates a 1 percent rise in productivity. Do you know how to model that?

I have an additional question on modifying the model. Do you think it is possible to implement a debt target and a government spending path to reduce the outstandig debt to that level in order to model a government debt policy (spending cut)?

Thank you very much for your help. I am new to dynare and to this kind of models, so I am really greatful for your support.

@chowshangyao What is the problem when you add p - p(-1) = ppi @xyz There is no reason to suppose you cannot add a particular fiscal sector to the model.

when I add the equation you mentioned, I get the following error message again:

Error using print_info (line 80)
The steady state contains NaN or Inf
Error in steady (line 92)
print_info(info,options_.noprint, options_);
Error in g_m_2008_2 (line 218)
steady;
Error in dynare (line 180)
evalin(‘base’,fname) ;

I am quite confused about this as I have seen equations like this in other models. Do you why it causes this error in my model?

Moreover, do you know why my impulse response functions differ from the ones presented in the paper? How do I model a 1% shock to technology?

Nonetheless, I do not really understand why these equations cause so much trouble. Does anybody understand this? Unfortunately I think, the simulations based on your code do not produce the correct impulse response functions, do they? The output gap and the fiscal gap behave in the opposite way.…

As I said, you cannot try to compute something endogenously from the model when it is not uniquely determined. Only inflation is unique, but not the underlying price level.