Page 1 of 1

Plotting and naming IRF's

PostPosted: Sat Jun 14, 2014 12:14 pm
by Ned
Hello everyone.

I'm new to Dynare and I've started programming only recently. For practice, I tried to run a version of a simple Keynesian model
with a NK Phillips curve. First of all, I would be grateful if someone could look at my code and spot any mistakes. My main concerns
however are:

1) I've seen in other codes that for the steady state values, people usually choose values of zeros for their variables. Is that for simplicity
and for the sake of the example? If for instance, I was to set steady state values for a ZLB situation, how would I change those?

2) The basic command for irf plotting is "stoch_simul" but this gives me the output with the names I've already set, which are the abreviations
of the normal variables in question. I know that I can change those through the figure window but is there a more "elegant" way to set the names
of my variables, the x and y axis names etc? The only thing I've found so far but it doesn't work is:

Code: Select all
figure(1);
subplot(2,2,1);
plot(jj,xgap_t_ eps_i,’-’);
title(’ouput gap’);
xlabel(’Quarters’);
ylabel(’%-deviation’);


I am providing my code for anyone to have a look. Any help would be really appreciated. Thank you in advance.

Re: Plotting and naming IRF's

PostPosted: Sun Jun 15, 2014 12:03 pm
by jpfeifer
1) People of loglinearize their models and express variables in deviations from steady state. Those deviations have always steady state 0. Essentially, you subtract the steady state on both sides of the equations.
For the zero lower bound, you would not demean the net interest rate. It would have steady state log(1/cbeta). The mod-file then is

Code: Select all
// Simple New Keynesian Model

/* Enbdogenous Variables
pi_t: inflation
xgap_t: output gap
int_t: nominal interest rate
e_t: autoregressive process linked with interest rate
u_t: autoregressive process linked with the output gap
*/

var pi_t xgap_t int_t e_t u_t;


/* Exogenous Variables
eps_i: normally distributed error of the e_t autoregressive process
eps_u: normally distributed error of the u_t autoregressive process
*/

varexo eps_i eps_u;


/* Parameters
csigma: sigma found in the Output Gap
row_i: parameter of the autoregressive process e_t
row_u: parameter of the autoregressive process u_t
phi_p: parameter linked with inflation in Taylor Rule
phi_x: parameter linked with the output gap in Taylor Rule
cbeta: discount factor beta
ckappa: parameter kappa in the Phillips Curve
comega: parameter linked with kappa and linked with Calvo Contracting
ita_LL: parameter linked with cgamma
ita_CC: parameter linked with cgamma
ctheta: parameter linked with cgamma
*/

parameters csigma row_i row_u phi_p phi_x cbeta ckappa comega cgamma ita_LL ita_CC ctheta;


// Initiating parameter values
csigma = 1;  // from literature
row_i = .70;  // persistence is considered high for the autoregressive process e_t
row_u = .70;  // percistence is considered high for the autoregressive process u_t
phi_p = 1.5;  // phi_p must be > 1 to follow the Taylor Rule incorporated in the model
phi_x = .50;  // phi_x must be > 0 to follow the Taylor Rule incorporated in the model
cbeta = .99;  // from literature
comega = .75;  // from literature
ita_LL = .45;  // from literature
ita_CC = 1;  // from literature
ctheta = 6;  // from literature
ckappa = (1 - comega) * (1 - (cbeta * comega)) / comega;  // specified from the model
cgamma = (ita_LL + ita_CC) / (1 + (ctheta * ita_LL));  // specified from the model

// Specifying the model
model;
pi_t = cbeta * pi_t(+1) + (ckappa * cgamma * xgap_t);  // New Keynesian Phillips Curve
xgap_t = xgap_t(+1) - (1/csigma) * (int_t-log(1/cbeta) - pi_t(+1)) + u_t;  // Output Gap
int_t =log(1/cbeta) + (phi_p * pi_t) + (phi_x * xgap_t) + e_t;  // Interest rates following the Taylor Rule
e_t = (row_i * e_t(-1)) + eps_i;  // Autoregresive process e_t linked with the Taylor Rule
u_t = (row_u * u_t(-1)) + eps_u;  // Autoregresive process u_t linked with the Output Gap
end;


// Initializing Steady State Values
initval;
pi_t = 0;
xgap_t = 0;
int_t = log(1/cbeta);
end;


// Calculating the Steady State
steady;


// Introducing Shocks
shocks;
var eps_i;
stderr 1;  // Standard error assumed 1
var eps_u;
stderr 0;  // Standard error assumed 0
end;


/* Stochastic Simulation
Order: Order is set to 1 to denote the linear order of our taylor series approximation
irf: Impulse Response Functions 40 periods ahead
*/
stoch_simul(order=1, irf=40);


2) All IRFs are stored in oo_.irfs. Simply plot them by hand with all the labels and titles you want.

Re: Plotting and naming IRF's

PostPosted: Sun Jun 15, 2014 12:29 pm
by Ned
Thank you so much for your help. Much appreciated.

Re: Plotting and naming IRF's

PostPosted: Mon Jun 16, 2014 2:04 pm
by Ned
I found a way to configure the IRFs through code and I'm posting in case someone else had the same question.

Code: Select all
stoch_simul (order=1, irf=40);

subplot(2,2,1);
plot(pi_t_eps_i, 'r', 'LineWidth', 2.5);
title('Inflation', 'fontweight', 'bold');

subplot(2,2,2);
plot(xgap_t_eps_i, 'r', 'LineWidth', 2.5);
title('Output Gap', 'fontweight', 'bold');

subplot(2,2,3);
plot(int_t_eps_i, 'r', 'LineWidth', 2.5);
title('Nominal Interest Rate', 'fontweight', 'bold');

subplot(2,2,4);
plot(e_t_eps_i, 'r', 'LineWidth', 2.5);
title('Policy Shock', 'fontweight', 'bold');


Where pi_t, xgap_t, int_t, e_t are the endogenous variables and eps_i is the exogenous variable in question.