Shock Decomposition with calibrated Parameters

Dear all,

I want to decompose a historical time series with my DSGE model using calibrated parameters. But I always get the following error:

[quote]…
Loading 84 observations from Data2012GER.mat

??? Attempt to reference field of non-structure array.

Error in ==> evaluate_smoother at 117
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)

Error in ==> shock_decomposition at 60
oo = evaluate_smoother(parameter_set);

Error in ==> l_model at 527
oo_ = shock_decomposition(M_,oo_,options_,var_list_);

Error in ==> dynare at 120
evalin(‘base’,fname) ;[/quote]

My code line is the following, maybe there is something wrong??


var Z Qd Qm C I Pd Pm K L Px RK W e Qx B Y Rstar RD A ZL Pstar Zstar G ZC ExPr Ex Im Pxx risk lam lamplus AZ;
varexo eps_A eps_ZL eps_G eps_Zstar eps_ZC eps_Pxx eps_r eps_AZ; 

parameters kappa alphad vartheta alpha eta nu delta psi beta gamma Phi phiPx phiPd A0
Lss Zss Css Kss Iss RDss Rstarss Qdss Qxss Qmss Pmss Pdss Pxss Pstarss Zstarss Yss ess Wss Rss kss
Gss b 
rhoZL rhoA rhoG rhoZstar rhoZC
sigmaZL sigmaA sigmaG sigmaZstar sigmaZC
phiPm
corrZP alphax sigmaPxx rhoPxx
rhoE
rhoZ
rhoD
rhoV
kappae
sigmar 
rhor
rhoEr
rhoZr
rhoF
rhoS
rhoDr
phiL
bL
sigmaAZ
rhoAZ
; 

%----------------------------------------------------------------
% 2. P a r a m e t e r s
%----------------------------------------------------------------
sigmaA =
   0.008416666584714;
sigmaZL =
   0.001001342353004;
sigmaZstar =
   0.015917168370728;
sigmaZC =
   0.034143136170861;
rhoA =
   0.623188359221053;
rhoZL =
   0.500360625286618;
rhoZstar =
     0;
rhoZC =
   0.500003173707171;
gamma =
   0.164390203197104;
kappa =
   0.001000034216665;
Phi =
   6.494467804536654;
eta =
   2.969863210704255;
vartheta =
   0.300006842703822;
alphad =
   0.680000000000000;
psi =
   4.540717591968817;
b =
     4.682749673000000e-06;
phiPd =
     5.408003330600000e-05;
phiPx =
     7.783879062100001e-05;
sigmaG =
   0.008081053294322;
rhoG =
   0.521900000000000;
alpha =
   0.330000000000000;
Gss =
   0.250005357897742;
nu =
   5.500000000000000;
beta =
   0.990000000000000;
phiPm =
     6.753043553900001e-05;
delta =
   0.044999357069038;
sigmaPxx =
   0.001008385638963;
rhoPxx =
     0;
corrZP =
     0;
alphax =
   0.543608486859921;
rhoE =
   0.500090080068226;
rhoZ =
     0;
rhoD =
     0;
rhoV =
   0.505223825864200;
kappae =
   0.342469317014898;
rhor =
     0;
sigmar =
     0;
rhoEr =
     0;
rhoZr =
     0;
rhoF =
     0;
rhoS =
     0;
rhoDr =
     0;
phiL =
     4.280186705500000e-05;
bL =
   0.059537331525254;
sigmaAZ =
   0.002626502126124;
rhoAZ =
   0.848531027221002;
A0          = 1;
Zstarss     = 1;

paramsaux = [alphad,alpha,gamma,delta,Phi,vartheta,eta,psi,beta,kappa,Zstarss,Gss,nu,A0,b,alphax,bL];
ss = steadystateRSOE(paramsaux);

Qdss = ss(1); 
Rss = ss(2);
Qmss = ss(3);
Zss  = ss(4);
Qxss = ss(5);
Pdss = ss(6);
Pmss = ss(7);
ess  = ss(8);
Pxss = ss(9);
kss  = ss(10);
Lss  = ss(11);
Kss  = ss(12);
Iss  = ss(13);
Css  = ss(14); 
Wss  = ss(15);
Pstarss = ss(16);
Yss = Zss;

RDss    = 1/beta - 1;
Rstarss = RDss;

Bss     = 0;


%--------------------------------------------------------------------------
% 3. M o d e l
%--------------------------------------------------------------------------

model(linear);         

...

end;

%--------------------------------------------------------------------------
% 4. C o m p u t a t i o n
%--------------------------------------------------------------------------

initval;
Pd = 0;
Px = 0; 
Pm = 0;
Z  = 0;
Qd = 0;
Qm = 0;
Qx = 0;
RD = 0;
Rstar = 0;
K = 0;
I = 0;
L = 0;
W = 0;
RK = 0;
C = 0;
e = 0;
Y = 0;
B = 0;
ExPr = 0;
Ex   = 0;
A = 0;
ZL = 0;
G = 0;
Zstar = 0;
Pstar = 0;
ZC = 0;
Pxx = 0;
risk = 0;
AZ = 0;
end;

steady;
check;

shocks;
 var eps_ZL = (sigmaZL)^2;
 var eps_A = (sigmaA)^2;
 var eps_G = (sigmaG)^2;
 var eps_Zstar = (sigmaZstar)^2;
 var eps_ZC = (sigmaZC)^2;
 corr eps_Pxx, eps_Zstar = corrZP;
 var eps_Pxx = (sigmaPxx)^2;
 var eps_r = (sigmar)^2;
 var eps_AZ = (sigmaAZ)^2;
end;


stoch_simul(order = 1, irf=0, drop=0, periods = 0);
varobs Y L Ex Im ExPr Pm L I C;
shock_decomposition(parameter_set=calibration,datafile='Data2012GER.mat') Y L Ex Im ExPr Pm L I C;

It is a known bug that has been fixed in the unstable version.

Okay. it works now. But how do I have to read the pictures.

And why are the decompositions changing of the same variable (say GDP) when I add more observable variables as exports etc.??

Perhaps I should specify my question more : are the presented shocks the epsilson (the innovations) of the shock processes?

The second question still remains:
And why are the decompositions changing when I add more observable variables?

Here the description of the plot for your first question:

Shock decomposition plot generated by the shock_decomposition-command. It is stored in the main folder. The black line depicts the
deviation of the smoothed value of the corresponding endogenous variable from its steady state at the specified parameter_set. By default, the parameter_set is the posterior_mean if Bayesian estimation has been used and the posterior_mode otherwise. The colored bars correspond to the contribution of the the respective smoothed shocks to the deviation of the smoothed endogenous variable from its steady state, i.e. our “best guess” of which shocks lead to our “best guess” for our unobserved variables. “Initial values” in the graphs refers to the part of the deviations from steady state not explained by the smoothed shocks, but rather by the unknown initial value of the state variables. This influence of the starting values usually dies out relatively quickly.

For the second question, we will get back to you.

If you mean that the results change if you observe more variables in the varobs-statement, this is normal. Those observable contain information about the shocks. If you observe all variables in the model, all shocks can be perfectly recovered.

If you mean that the results change when you add variables after the decomposition command, please send me a mod file to check.

okay. thank you. but obseravtion errors are not included?

And i also do not understand why the eps have different values when looking at different time series? I thought that the kalman filter estimates the unknown values of the shocks innvoations and these values are the same for all observable time series. The decomposition is then just the experiment, how would have the variable (say BIP) look if we shut off all shocks except one (like in the Ireland paper fmwww.bc.edu/ec-p/wp735.pdf).

what does dynare do?

Before going on, let’s get the facts straight.

If you change the observables in the varobs-command, you change the observation equation of the Kalman smoother and thus the results will change. You use a different set of observations to estimate the shocks. If you e.g. suddenly observe TFP you can better estimate TFP shocks than inferring them from just observing consumption and output.

If you mean that you only change e.g.

to

and the results for c and y change, there must be something wrong. In this case, the observation equation is the same and the estimated shocks must be the same so that results should not change. If this is what you observe, please send me the mod-file.

no this does not happen.

but what about the rest of my question?

does the graph perhaps show (for example when i look at y) the different y when switching only one shock on??

Sorry, but I still do not get the question. The graphs do not show the smoothed shocks, but

Why should a TFP shock at time 1 have the same effect on output and inflation? The former usually goes up while the second one goes down.

Okay. I understand.

Does Dynare uses observation errors? So that I can use more observable variables than shocks in the model?

Yes, you can introduce measurement error on an endogenous variable by specifying the variance of this endogenous variable in the shocks block. Let yobs be such a variable, then use

shocks; stderr yobs... end;

Alternatively, just explicitly add a structural shock in the obseration equation in the model:

yobs=y + eps_meas_y;

Done correctly, this is perfectly equivalent.