Fix shock_decomposition when selected_variables_only is specified
The option selected_variables_only
is currently incompatible with shock_decomposition
as can be seen in the mod-file
var y ${y}$ (long_name='output')
y_nat ${y^{nat}}$ (long_name='natural output')
y_gap ${\tilde y}$ (long_name='output gap')
pi ${\pi}$ (long_name='inflation')
c ${c}$ (long_name='consumption')
lam ${\lambda}$ (long_name='Lagrange multiplier')
n ${n}$ (long_name='hours worked')
w ${w}$ (long_name='real wage')
r ${r}$ (long_name='nominal interest rate')
mc ${\tau}$ (long_name='Marginal cost')
e ${e}$ (long_name='demand elasticty')
x ${x}$ (long_name='Preference shock')
a ${a}$ (long_name='AR(1) technology shock process')
nu ${\nu}$ (long_name='monetary shock process')
y_fd ${\varepsilon_e}$ (long_name='markup shock')
w_fd ${\varepsilon_e}$ (long_name='markup shock')
r_obs ${\varepsilon_e}$ (long_name='markup shock')
pi_obs ${\varepsilon_e}$ (long_name='markup shock')
;
varexo eps_a ${\varepsilon_a}$ (long_name='technology shock')
eps_nu ${\varepsilon_\nu}$ (long_name='monetary policy shock')
eps_x ${\varepsilon_x}$ (long_name='preference shock')
eps_e ${\varepsilon_e}$ (long_name='markup shock')
;
parameters
alppha ${\alpha}$ (long_name='capital share')
betta ${\beta}$ (long_name='discount factor')
h ${h}$ (long_name='Parameter habit consumption')
phi ${\phi}$ (long_name='unitary Frisch elasticity')
chix ${\chi}$ (long_name='price indexation')
rho_pi ${\phi_{\pi}}$ (long_name='inflation feedback Taylor Rule')
rho_y ${\phi_{y}}$ (long_name='output feedback Taylor Rule')
rho_r ${\phi_{y}}$ (long_name='degree of smoothing Taylor rule')
epsilon ${\epsilon}$ (long_name='steady state demand elasticity')
theta ${\theta}$ (long_name='Calvo parameter')
rho_a ${\rho_{x}}$ (long_name='autocorrelation technology shock')
rho_x ${\rho_{x}}$ (long_name='autocorrelation preference shock')
rho_nu ${\rho_{x}}$ (long_name='autocorrelation monetary shock')
;
%---------------------------------------------------------------
% Parametrization, p. 52
%---------------------------------------------------------------
alppha = 0.3;
betta = 0.99;
h = 0.7;
phi = 1;
chix = 0.6;
rho_pi = 1.5;
rho_y = 0.2;
rho_r = 0.8;
epsilon = 6;
theta = 0.6;
rho_a = 0.8;
rho_x = 0.5;
rho_nu = 0.4;
%---------------------------------------------------------------
% First Order Conditions
%---------------------------------------------------------------
model(linear);
//1. F.O.C. consumption for Households
lam*(1-(h*betta)) = x-((c-(h*c(-1)))*(1/(1-h)))-(h*betta*x(+1))+((c(+1)-(h*c))*((h*betta)/(1-h)));
//2. F.O.C. leisure for Households
phi*n=lam+w;
//3. F.O.C. bonds for Households
0=lam(+1)-lam+r-pi(+1);
//4. Average marginal cost
mc=w+(y*(alppha/(1-alppha)))-(a*(1/(1-alppha)));
//5. First auxiliary variable
pi=((betta/(1+(betta*chix)))*pi(+1))+((chix/(1+(betta*chix)))*pi(-1))+((mc-(e*(1/(epsilon-1))))*(((1-theta*betta)*(1-theta)*(1-alppha))/((1+betta*chix)*(1-alppha+alppha*epsilon)*theta)));
//8. Natural output
alppha*y_nat=a-((1-alppha)*w)+(((1-alppha)/(epsilon-1))*e);
//9. Taylor Rule
r=(r(-1)*rho_r)+((1-rho_r)*((rho_pi*pi)+(rho_y*y_gap)))+nu;
//10. Definition output gap
y_gap = y-y_nat;
//12. Equilibrium
y=c;
//13. Production function
y=(n*(1-alppha))+a;
//14. TFP shock
a=(rho_a*a(-1))+eps_a;
//15. Preference shock
x=(rho_x*x(-1))+eps_x;
//16. Markup shock
e=((1-epsilon)/epsilon)*eps_e;
//17. Monetary shock
nu=(rho_nu*nu(-1))+eps_nu;
//// Observation equations
//18. Output
y_fd = y;
//19. Wage
w_fd = w;
//20. Interes Rate
r_obs=r;
//21. Inflation
pi_obs=pi;
end;
shocks;
var eps_a= 0.02^2 ;
var eps_nu= 0.04^2;
var eps_x= 0.02^2;
var eps_e= 0.2^2;
end;
stoch_simul(order=1,periods=200,irf=0) y_fd w_fd r_obs pi_obs;
datatomfile('observables_gali2_filt_119',char('y_fd','w_fd','r_obs','pi_obs'));
varobs y_fd w_fd r_obs pi_obs;
estimated_params;
alppha, 0.3, 0, 1,beta_pdf, 0.3, 0.05;
h, 0.7, 0, 1,beta_pdf, 0.33, 0.15;
phi, 1, , ,gamma_pdf, 1.17, 0.351;
chix, 0.6, 0, 1, beta_pdf, 0.61, 0.112;
rho_pi, 1.5, 0, 10, normal_pdf, 1.5, 0.2;
rho_y, 0.2, 0, 10, normal_pdf, 0.2, 0.1;
theta, 0.6, 0, 1, beta_pdf, 0.61, 0.112;
rho_a, 0.7, 0, 1, beta_pdf, 0.61, 0.112;
rho_x, 0.5, 0, 1, beta_pdf, 0.61, 0.112;
rho_nu, 0.4, 0, 1, beta_pdf, 0.61, 0.112;
stderr eps_a, inv_gamma_pdf, 0.1, 2;
stderr eps_nu, inv_gamma_pdf, 0.1, 2;
stderr eps_x, inv_gamma_pdf, 0.1, 2;
stderr eps_e, inv_gamma_pdf, 0.1, 2;
end;
estimated_params_init;
alppha, 0.3;
h, 0.7;
phi, 1;
chix, 0.6;
rho_pi, 1.5;
rho_y, 0.2;
theta, 0.6;
rho_a, 0.7;
rho_x, 0.5;
rho_nu, 0.4;
stderr eps_a, 0.02;
stderr eps_nu, 0.04;
stderr eps_x, 0.02;
stderr eps_e, 0.2;
end;
%identification;
estimation(datafile=observables_gali2_filt_119,mh_replic=2000,mh_nblocks=1, mode_compute=4) y_fd w_fd y;
save temp;
// options_.selected_variables_only=0;
shock_decomposition(parameter_set=posterior_mean) y y_fd;
The best solution seems to be making the options_
structure local to evaluate_smoother
(related to #1197 (closed) ) and then set options_.selected_variables_only=0
in shock_decomposition.m