Problems running a DNK model with investments costs & fiscal

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Problems running a DNK model with investments costs & fiscal

Postby allan » Wed Sep 10, 2014 6:54 pm

// Dynamic New Keynesian Model with investment adjustment costs, open economy, monetary and fiscal policies

close all;

var y c k h r w x g n a mc pai i q xhb m mh mf tau b z yf dep prh pih rer cf ch;

// definition of variables:
// y // Output
// c // Consumption
// cf // Foreign Consumption
// ch // Home Consumption
// x // Investment
// g // Government expenditure
// n // Transfers
// r // Rate of return on capital
// w // Wage rate
// a // Technology
// k // Capital
// h // Labor
// q // Price of installed capital
// mc // Marginal cost
// pai // CPI inflation
// pih // Home Price Goods
// i // Nominal interest rate
// m // seignorage
// tau // taxation
// gbar // government steady state
// nbar // transfer steady state
// b // bond
// dep // depreciation of exchange rate
// z // Transitory shock
// yf // Foreign shock

varexo lamr lamg lamn lama lamz lamyf;

parameters sigma upsilon phih phitau alpha alphac gamma gamman bet theh thehp del rhoi gammapai gammay mcss rhoa rhog rhon rhoz rhoyf rhotau rhor tauh tauk gy gbar nbar yk gk xk ck cy xy eta_f eta_c eta_m;

gamma = 5; // Elasticity of marginal utility of consumption (minus)
sigma = 1/gamma; // Elasticity of intertemporal substitution
mcss = 1/1.2; // Steady-state marginal cost: inverse of the SS mark-up
phih = 4; // Elasticty of price of capital with respect to investment-capital ratio
phitau = 2;
alpha = 0.65; // Share of labor in the production function
alphac = 0.35; // Share of capital in production function
gamman = (1 + 1/3); // Elasticity of marginal disutility of labor
bet = 0.99; // Discount factor
eta_f = 1; // Degree of foreign input smoothing
eta_c = 1; // Degree of consumption smoothing
eta_m = 1; // Degree of seignorage smoothin
theh = 0.75; // Probability of not adjusting prices
thehp = 0.75; // Probability of not adjusting foreign prices
del = 0.025; // Capital depreciation rate
rhoi = 0.9; // Degree of nominal interest rate smoothing
gammapai = 1.5; // Taylor rule coefficient on inflation
gammay = 0.5; // Taylor rule coefficient on output
rhoa = 1; // AR(1) technology
rhor =1; // AR (1) Return on Capital
rhog = 0.95; // AR(1) government expenditure
rhon = 0.85; // AR(1) transfers
rhotau = 0.85; // AR (1) taxes
rhoz = 0.70; // AR (1) Monetary
rhoyf = 0.85; // AR(1) Foreign Output
tauk = 0.15; //taxation on capital
tauh = 0.20; // taxation on labour
gy = 0.30; // Steady-state government-output ratio
gbar = 0.10; // steady state government expenditure
nbar = 0.05; // Steady state transfers
yk = ((1/bet)-1+del)/((1-alpha)*mcss); // Steady-state output-capital ratio
gk = gy*yk; // Steady-state government-capital ratio
xk = del; // Steady-state investment-capital ratio
ck = yk - xk - gk; // Steady-state consumption-capital ratio
cy = ck/yk; // Steady-state consumption-output ratio
xy = xk/yk; // Steady-state investment-output ratio
upsilon = (1-del)/((1-alpha)*mcss*yk + (1-del)); // from rate of return on capital log-linearization

model(linear);
y = cy*c + xy*x + gy*g; // Aggregate resource constraint
ch = c - eta_c*prh; // Consumption Home
cf = c - eta_c*rer; // Foreign Consumption
0 = (1-alphac)*prh + alphac*rer;
c = -sigma*r(+1) + c(+1)+ sigma*g*(1-rhog); // Consumption Euler equation
r = (1-upsilon)*(y + mc - k(-1)) + upsilon*q - q(-1); // Rate of return on capital
//r(+1) = (1-upsilon)*(y(+1) + mc(+1) - k) + upsilon*q(+1) - q; // Rate of return on capital expected this requires Fisher i = r + pai(+1)
q(+1) = phih*(xhb - k); // Investment demand with one period delay
x = xhb(-1); // Investment auxilary variable for investment delay
w = gamma*c + (gamman - 1)*h; // Labor supply
w = y + mc - h; // Labor demand
mc = w + h - y; // marginal cost
y = alpha*(a + h) + (1-alpha)*k(-1)*(yf-eta_f*(prh-rer)); // Aggregate production function
k = del*x + (1-del)*k(-1); // Law of motion for capital
pih = bet*pih(+1) + (1-thehp)*(1-thehp*bet)/thehp*(mc-prh); // Price Home Goods
pai = bet*pai(+1) + ((1-theh)*(1-bet*theh)/theh)*mc*(rer-rer(-1))+ pih; // Phillips curve
i = rhoi*i(-1) + (1-rhoi)*gammay*(y - y(-1)) + (1-rhoi)*gammapai*pai - lamr; // Monetary policy rule
//i = rhoi*i(-1) + gammapai*pai(-1) - lamr; // Monetary policy rule in BGG with gammapai = 0.11
i = r(+1) + pai(+1); // Fisher equation
g - gbar = rhog*(g(-1)- gbar) + lamg; // Government spending process
n - nbar = rhon*(n(-1) - nbar) + lamn; // transfer process
tau = k*(tauk*(rhoi*i - rhoa*a - q*del))+ tauh*h*w + phitau; // taxation process
mh + mf = m - eta_m*pai; // Government issues money in real terms
m = eta_m*pai + m(-1); // seignorage growth
//tau = g - bstar + b(-1) - ( m - m(-1))*pai; // taxation
//bstar = b(-1)*i ; // bond steady state
g + n - tau = b - (i(-1)/pai)*b(-1)+ m - m(-1)/pai; // budget constraint of government
//g = rhog*g(-1) + lamg; // Government spending process
a = rhoa*a(-1) + lama; // Technology process
z = rhoz*z(-1) + lamz; // Transitory process
yf = rhoyf*yf(-1) + lamyf; // Foreign Output
dep = rer-rer(-1) + pai; // Depreciation of Exchange rate
rer = (1/sigma)*(c-yf)- g; // Real exchange rate
end;

steady;

check;

shocks;
var lamr; stderr 0.025;
var lamg; stderr 1;
var lamn; stderr 1;
var lama; stderr 0.01;
var lamz; stderr 0.01;
var lamyf; stderr 0.01;
//var lamtau; stderr 0.01;
end;

stoch_simul(periods=20000,irf=12);

varobs y rer pai i;

estimated_params;

rhoa, 0.7902, , , beta_pdf, 0.7, 0.1;
rhog, 0.7243, , , beta_pdf, 0.7, 0.1;
rhoz, 0.9639, , , beta_pdf, 0.7, 0.1;
rhoyf, 0.7662, , , beta_pdf, 0.7, 0.1;
rhon, 0.9639, , , beta_pdf, 0.7, 0.1;
rhor, 0.7662, , , beta_pdf, 0.7, 0.1;
rhotau, 0.7662, , , beta_pdf, 0.7, 0.1;

//stderr eps_a, inv_gamma_pdf , .1 , 2;
//stderr eps_g, inv_gamma_pdf , 0.1 , 2;
//stderr eps_z, inv_gamma_pdf , .1 , 2;
//stderr eps_yf, inv_gamma_pdf , .1 , 2;

end;

steady;

check;

estimation(datafile=datos_open_economy, xls_sheet=data, xls_range=b1:e25, order=1,mode_compute = 6,mh_replic=100000,mh_drop=0.5, mh_jscale=0.15, mh_nblocks=2,smoother, bayesian_irf, irf = 24);

I am experiencing problems and getting NaN Not a Number results in my equations.. Can someone please tell me how to correct this..
See issues below..

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 28 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.

STEADY: numerical initial values or parameters incompatible with the following equations
23

Check whether your model in truly linear




Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : -0.005
Equation number 19 : -0.0075
Equation number 20 : -2.0075
Equation number 21 : -0.005
Equation number 22 : 0
Equation number 23 : NaN
Equation number 24 : 0
Equation number 25 : 0
Equation number 26 : 0
Equation number 27 : NaN
Equation number 28 : 0


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 monetary_fiscal_open_model (line 382)
steady;

Error in dynare (line 180)
evalin('base',fname) ;

>>
Attachments
monetary_fiscal_open_model.mod
(8.48 KiB) Downloaded 96 times
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Thu Sep 11, 2014 5:02 am

The equation
Code: Select all
g + n - tau = b - (i(-1)/pai)*b(-1)+ m - m(-1)/pai; // budget constraint of government

is clearly not linear. You divide by pai.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 1:59 pm

thanks
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 2:03 pm

hi J..
I adjusted the equation and it still not running getting the same error.. could you help me
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Thu Sep 11, 2014 3:56 pm

First of all, always post the updated file. Second, just check the equations for which residuals are non-zero. They must contain mistakes.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 4:01 pm

kool thks again.. J
I actually did check the eqns with NaN but could see my error.. I was hoping you could help further.. I am also attaching the latest file.. if you could look to help me from this..
thanks
Attachments
monetary_fiscal_open_model.mod
(8.48 KiB) Downloaded 89 times
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Thu Sep 11, 2014 4:06 pm

Your new equation 23 still is not linear. You divide by pai.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 4:12 pm

okay J.
is government spending equation, transfers equation, taxation eqn and seignorage eqn along with the depreciation rate eqn also seem off .. plus eqn 23 ( the budget constraint eqn ...) can you say specifically please how i can adjust this file.. or even sending me the adjusted file which runs.. so that my eqn are not NaN..thanks

my email is awright13@gmail.com or you could please use dynare forum
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Thu Sep 11, 2014 4:44 pm

Sorry, but this is not my job. You did not correctly linearize the budget constraint so that the model is not linear. You need to fix this yourself. Sit down and do the linearization.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 4:51 pm

J..
let me be clear i wasnt asking for handouts.. I only recognised that the BC, govt spending, transfers, taxation, seignorage and depreciation eqns were all the source of my problem and not just the BC ( and the division by pai or inflation)..hence i asked how would you correct the others, as i am still getting NaN when i fix only the BC..
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Thu Sep 11, 2014 5:34 pm

g - gbar = rhog*(g(-1)- gbar) + shock_mat; // Government spending process
n - nbar = rhon*(n(-1) - nbar) + lamn; // transfer process
tau = k*(tauk*(rhoi*i - rhoa*a - q*del))+ tauh*h*w + phitau; // taxation process

The steady states for g and n are given by nbar and gbar. You need to put this into the initval block. But then you get a problem in the last equation. My guess is your linearization here is also wrong
The last one contains a constant phitau that also leads to problems.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Thu Sep 11, 2014 6:37 pm

J.
I adjusted the eqns.. (g, tau, and n) plus change the phitau to lamtau (as a shock).. Please see.. results are closer to 0 for eqns but not there yet.. if i remove the (/pai) in the BC eqn all my results fall to NaN..
Please see latest file..dont know what additional help you could give..please
Attachments
monetary_fiscal_open_model_2.mod
(8.61 KiB) Downloaded 137 times
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm

Re: Problems running a DNK model with investments costs & fi

Postby jpfeifer » Sat Sep 13, 2014 7:37 am

Go about it more systematically. Put
Code: Select all
resid(1);

before steady. Dynare will then show you the residuals of equations given your steady state values of 0. Check every equation that does not have 0 residual. In particular, check the linearization of those equations. You still have a /pai there.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Problems running a DNK model with investments costs & fi

Postby allan » Sat Sep 13, 2014 1:07 pm

ok thks
allan
 
Posts: 8
Joined: Wed Sep 10, 2014 6:48 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 4 guests

cron