Dear all,
I have provided the dynare code for Iran economy, and i exactly want tow or more shocks in IRFs at the same time.
How can i do that?
please guide me
Best regard
fhossein
Use the simult_-function, e.g. github.com/JohannesPfeifer/DSGE_mod/blob/master/RBC_news_shock_model/RBC_news_shock_model.mod
thanks a lot!1 i want to know whether i have to change in the part of model , indeed the exogenous process of model must be changed??
You need to use the part from line 130 onwards for your model
//initialize IRF generation
initial_condition_states = repmat(oo_.dr.ys,1,M_.maximum_lag);
shock_matrix = zeros(options_.irf,M_.exo_nbr); %create shock matrix with number of time periods in colums
// set shocks for pure news
shock_matrix(1,strmatch('eps_z_news',M_.exo_names,'exact')) = 1; %set news shock to 1 (use any shock size you want)
shock_matrix(1+8,strmatch('eps_z_surprise',M_.exo_names,'exact')) = -1; %8 periods later use counteracting shock of -1
y2 = simult_(initial_condition_states,oo_.dr,shock_matrix,1);
y_IRF = y2(:,M_.maximum_lag+1:end)-repmat(oo_.dr.ys,1,options_.irf); %deviation from steady state
and adjust the shock_matrix to what you want.
Thanks for your feedback! I have changed the “shock_matrix” but i could not see to change on the results! Indeed, i don’t know what thing of this function must be changed?!
What do you mean? did you plot the results from
y_IRF
?
yes I mean y_IRF!! I changed your code but i could not distinguish when we want to compute IRFs for two shocks “eps_z_surprise” and " eps_z_news", which the function or command in your code must be changed?
How can we recognize that the endogenous variables what response to two shocks at same time and different time?
Thanks for replay
example1.mod (2.07 KB)
The only thing you were supposed to change was the setting of the shock matrix. You can only set one shock at a time. In your case, you should have used
shock_matrix(1:2,strmatch('e',M_.exo_names,'exact')) = 2; %set news shock to 1 (use any shock size you want)
shock_matrix(1:2,strmatch('a',M_.exo_names,'exact')) = 2
shock_matrix(1,strmatch('a',M_.exo_names,'exact')) = 1; %8 periods later use counteracting shock of -1
This sets e for the first two period to 2, a for the first two periods to 2 and then resets e in the first period to 1. In contrast, your
shock_matrix(1:2,strmatch('e',M_.exo_names,'exact'),strmatch('a',M_.exo_names,'exact')) = 2;
was creating a three-dimensional array. You should have used something along the lines of
var y c k l z r w i;
varexo e a;
parameters beta psi sigma delta alpha rhoz gammax n x i_y k_y;
% set parameter values
sigma=1; % risk aversion
alpha= 0.33; % capital share
i_y=0.25; % investment-output ration
k_y=10.4; % capital-output ratio
x=0.0055; % technology growth (per capita output growth)
n=0.0027; % population growth
rhoz=0.97; %technology autocorrelation base on linearly detrended Solow residual
model;
exp(c)^(-sigma)=beta/gammax*exp(c(+1))^(-sigma)* (alpha*exp(z(+1))*(exp(k)/exp(l(+1)))^(alpha-1)+(1-delta));
psi*exp(c)^sigma*1/(1-exp(l))=exp(w);
gammax*exp(k)=(1-delta)*exp(k(-1))+exp(i);
exp(y)=exp(i)+exp(c);
exp(y)=exp(z)*exp(k(-1))^alpha*exp(l)^(1-alpha);
exp(w)=(1-alpha)*exp(y)/exp(l);
r=4*alpha*exp(y)/exp(k(-1));
z=rhoz*z(-1)+e + a;
end;
steady_state_model;
gammax=(1+n)*(1+x);
delta=i_y/k_y-x-n-n*x;
beta=gammax/(alpha/k_y+(1-delta));
l_ss=0.33;
k_ss=((1/beta*gammax-(1-delta))/alpha)^(1/(alpha-1))*l_ss;
i_ss=(x+n+delta+n*x)*k_ss;
y_ss=k_ss^alpha*l_ss^(1-alpha);
c_ss=y_ss-i_ss;
psi=(1-alpha)*(k_ss/l_ss)^alpha*(1-l_ss)/c_ss^sigma;
i=log(i_ss);
w=log((1-alpha)*y_ss/l_ss);
r=4*alpha*y_ss/k_ss;
y=log(y_ss);
k=log(k_ss);
c=log(c_ss);
l=log(l_ss);
z=0;
end;
shocks;
var e=1;
var a=1;
end;
steady;
check;
stoch_simul(order=1,irf=20)y z;
initial_condition_states = repmat(oo_.dr.ys,1,M_.maximum_lag);
shock_matrix = zeros(options_.irf,M_.exo_nbr); %create shock matrix with number of time periods in columns
shock_matrix(1:2,strmatch('e',M_.exo_names,'exact')) = 2;
shock_matrix(1:2,strmatch('a',M_.exo_names,'exact')) = 2
shock_matrix(1,strmatch('a',M_.exo_names,'exact')) = 1;
y2 = simult_(initial_condition_states,oo_.dr,shock_matrix,1);
y_IRF = y2(:,M_.maximum_lag+1:end)-repmat(oo_.dr.ys,1,options_.irf);
But given that your two shocks in the mod-file are observationally equivalent, you cannot distinguish them in any case.
thanks a lot for your explain!