Page 2 of 2

Re: Impulse response graph about news shocks

PostPosted: Fri Dec 19, 2014 4:32 pm
by Grant
Dear Jpfeifer,

Many thanks for your help. Your answer makes me know that it's not my model's problem, which I have worried about several days. As for the unanticipated shocks, the IRF should be the graph of IRF to a_c directly generated by dynare in my code, right?

Re: Impulse response graph about news shocks

PostPosted: Fri Dec 19, 2014 4:41 pm
by jpfeifer
Yes.

Re: Impulse response graph about news shocks

PostPosted: Sun Dec 21, 2014 11:03 am
by Grant
Dear Jpfeifer,

Many thanks for your instant help. Since I am not good at Matlab programming, I am a bit confused about the code in the replication file from your homepage.
Code: Select all
/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


// manually select variables for figure
figure
subplot(2,1,1)
plot(y_IRF(strmatch('y',M_.endo_names,'exact'),:)); % use strmatch to select values
title('Output');
subplot(2,1,2)
plot(y_IRF(strmatch('z',M_.endo_names,'exact'),:));
title('TFP');

// Automatically loop over variables for figure (may require different setting for subplots in larger models)
figure
for ii=1:M_.orig_endo_nbr
    subplot(3,3,ii)
    if max(abs(y_IRF(ii,:)))>1e-12 %get rid of numerical inaccuracies
        plot(y_IRF(ii,:));
    else
        plot(zeros(options_.irf,1));
    end
    title(deblank(M_.endo_names(ii,:)));
end

I think I need to modify some code to apply my model. How can I draw the IRF of the unrealized news shock to y,n,p_dc,c in my model? Besides, as your JEDC paper, I introduce both 4 period and 8 period news components, how can I set pure news? Moreover, I just generate Bayesian estimated IRF in my code, but it seems that your code file generates simulated IRF. Is it possible to generate Bayesian estimated IRF of unrealized shocks?

Re: Impulse response graph about news shocks

PostPosted: Sun Dec 28, 2014 10:21 am
by jpfeifer
At the current stage, generating pure news shocks Bayesian IRFs in estimation is not easily possible. You need to rely on simulation. Regarding my code, I think it is well-documented and you need to put more effort into understanding it. If you have specific questions, I am happy to answer them.