// 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) ;
>>