I’m a beginner of Dynare and I’m trying to modify a given DSGE model with sticky prices and wages. In particular I have to suppose that there are adjustment costs of capital, sticky prices and flexible wages; then I have to simulate a negative preference discount factor shock with an exogenous process.
The problem is that when i execute Dynare the output give me a lot of theoretical moments equal to NaN, no matrix of correlations and (of course) wrong graphs.
How can I fix the problem?

Running model_diagnostics(M_,options_,oo_) reveals that there is 1 colinear relationships between the variables and the equations. Thus, your model has collinear equations.

Also, it seems that xi does not appear in any of the equations either than being an AR(1) process, that is a little strange to me. What does xi do in the model?

Check Understanding DSGE models by Celso Jose Costa Junior for a better implementation (chaper 4). Here is his model, same as the one you are implementing…

//NK model with wage stickiness -
//Chapter 4 (UNDERSTANDING DSGE MODELS)
var Y I C R K W L PIW P PI A CM;
varexo e;
parameters sigma phi alpha beta delta rhoa psi theta thetaW psiW;
sigma = 2;
phi = 1.5;
alpha = 0.35;
beta = 0.985;
delta = 0.025;
rhoa = 0.95;
psi = 8;
theta = 0.75;
thetaW = 0.75;
psiW = 21;
model(linear);
#Pss = 1;
#Rss = Pss*((1/beta)-(1-delta));
#CMss = ((psi-1)/psi)*(1-beta*theta)*Pss;
#Wss = (1-alpha)*(CMss^(1/(1-alpha)))*((alpha/Rss)^(alpha/(1-alpha)));
#Yss = ((Rss/(Rss-delta*alpha*CMss))^(sigma/(sigma+phi)))*((1-beta*thetaW)
*((psiW-1)/psiW)*(Wss/Pss)*(Wss/((1-alpha)*CMss))^phi)^(1/(sigma+phi));
#Kss = alpha*CMss*(Yss/Rss);
#Iss = delta*Kss;
#Css = Yss - Iss;
#Lss = (1-alpha)*CMss*(Yss/Wss);
//1-Phillips equation for wages
PIW = beta*PIW(+1)+((1-thetaW)*(1-beta*thetaW)/thetaW)*(sigma*C+phi*L-(W-P));
//2-Gross wage inflation rate
PIW = W - W(-1);
//3-Euler equation
(sigma/beta)*(C(+1)-C)=(Rss/Pss)*(R(+1)-P(+1));
//4-Law of motion of capital
K = (1-delta)*K(-1) + delta*I;
//5-Production function
Y = A + alpha*K(-1) + (1-alpha)*L;
//6-Demand for capital
K(-1) = Y - R;
//7-Demand for labor
L = Y - W;
//8-Marginal cost
CM = ((1-alpha)*W + alpha*R - A);
//9-Phillips equation
PI = beta*PI(+1)+((1-theta)*(1-beta*theta)/theta)*(CM-P);
//10-Gross inflation rate
PI = P - P(-1);
//11-Equilibrium condition
Yss*Y = Css*C + Iss*I;
//12-Productivity shock
A = rhoa*A(-1) + e;
end;
model_diagnostics;
steady;
check (qz_zero_threshold=1e-20);
shocks;
var e;
stderr 0.01;
end;
stoch_simul(qz_zero_threshold=1e-20) Y I C R K W L PI A;

I’m checking again all the derivation of the model. It’s possible that I have committed some mistakes because I had to modify the capital law motion, the households’ F.O.C. wrto capital and investments and then loglinearize them again (as my assignment sayd).
I think that if nominal interest rate is in “wrong place” the problem is between equations 1 to 7; I didn’t touched the other equations.

Thanks for your reply and suggestions, I’ll give a look to Celso Jose Costa Junior!

I don’t know how to fix the collinear equations’ problem, is the first time that I match this error (just because I’m a beginner!!). So I’m checking all the analytical derivation of the model, maybe I committed some errors.
About xi, given the exogenous process of the preference discount factor shock, I have loglinearized it to obtain the equation number 14. I follow other examples from my MsC course, maybe it’s wrong?

Yeah, you can log linearize xi, but it does not appear any where else again in the model. Thus, it does not affect the model and it is not useful. It does not do anything, so the shock (epsxi) does not affect the model. Maybe it should appear in the FOC for households.

I did a full revision of the model’s analytical derivation. As you said I committed a mistake: I forgot to evaluate the impact of the shock (espxi) on the Households’ FOC. Infact It affects the equation number 2 and now the model works! Thank you!!

I have to evaluate the IRFs with two different values of the capital adjustment cost parameter (phik), and I have another error:

if I set a value greater than 0 everything is ok

if I set a value equal to 0 dynare tells me “” One of the eigenvalues is close to 0/0 (the absolute value of numerator and denominator is smaller than 0.0000! If you believe that the model has a unique solution you can try to reduce the value of qz_zero_threshold. “”

I also tried to modify by hand the model but Dynare gave me the same error.

So this seems like a parameter issue. Since when solving a DSGE model, we take the inverse of a matrix which its elements are made up of parameters and functions of the parameters of the model, it is expected that choosing some parameter values may sometimes make the matrix singular, which seems to be the issue here, I guess. Try playing with the values of the other parameters while keeping phik at 0.

Also as dynare says, try reducing the qz_zero threshold. Default is 1e-6. So try decreasing that to may be 1e-30.

According to dynare documentation, qz_zero threshold is used to test if a generalized eigenvalue is 0/0 in the generalized Schur decomposition (in which case the model does not admit a unique solution).

Schur decomposition is used to decompose a matrix if it is singular, so that we are are able to find eigen values for the matrix. This is part of the process of determining whether the Blanchard khan conditions of a DSGE model are satisfied. I suggest you read it or anything about solving a system of rational expectation equations.

So of course we don’t want eigen value to be 0/0 which is not defined. qz_zero_threshold is a way to test it, and also one way to get around this error is by decreasing it.

While decreasing qz_zero_threshold might solve the problem in some cases, this is not always the solution as prof. Pfeifer says in this post How can I reduce manually qz_zero_threshold

If the costs are exactly 0, some variables will not appear in the model and cannot be computed. Thus, simply setting a parameter to 0 will not work. You need to remove that part from the model.