Choosing initial values for simult_

Hi

How does Dynare choose the initial values when oo_.SmoothedVariables is calculated?

I want to use simult_ to replicate the results in oo_.SmoothedVariables and then see the effect of specific changes to either the decision rules or the shocks. I have tried to use the steady state, but that have not worked.

Thanks in advance for any help.

PS: With the two shocks ea and eb in my model ‘simmodel’ what I have tried is:

dynare simmodel;
a = [oo_.SmoothedShocks.ea oo_.SmoothedShocks.eb];
y_=simult_(oo_.dr.ys,oo_.dr,a,1);

The results are not the samme as in oo_.SmoothedVariables.

Hi, I have the same problem as Jeppe. How to replicate the data in oo_.Smoothed Variables?

Best,
Alex

The Smoothed Variables are derived from the Kalman smoother, which works backwards in time after a forward iteration with the Kalman filter (See Hamilton 1994 for details). Thus, the initial value is estimated. simult_ should start at the first smoothed value for the states, not at the steady state.

Thanks for your reply. I was actually using the first values of the variables oo_.SmoothedVariables. However the behavior over time of the series is completely different.

Some variables match well, others not. It looks to me that discrepancies arise mostly for the predetermined variables.

Any thought about this?

Alex

Might have to do with the variable ordering. Have you tried starting at the initial smoothed values and not providing any shocks, i.e. a matrix of zeros? This should show whether the variables are initially close to steady state or whether you mixed up variables and there is a lot of movement to get to their actual steady states.

solved thanks a lot!

Alex

So what is the solution?

First, to check that the ordering of the variables was correct, as you suggested I inputed in simult_ a series of shocks set to zero and as initial condition, the steady state values. Simulated variables stayed at their ss values over the simulation, so this confirmed that the ordering was correct.

Then I inputed as initial condition for simult_ the first observations of the series included in oo_.SmoothedVariables, and the sequence of shocks included in oo_.SmoothedShocks. To solve the issue:

  • I had to trim the first observation of the sequences of shocks to make sure that the initial conditions would match.
  • To compare the series output of simult_ with those in oo_.SmoothedVariables I had to put back the steady-state levels in the oo_.SmoothedVariables series, as apparently these series are log-deviations from their steady-state levels.

Results perfectly match!

Alex

[quote=“alex”]First, to check that the ordering of the variables was correct, as you suggested I inputed in simult_ a series of shocks set to zero and as initial condition, the steady state values. Simulated variables stayed at their ss values over the simulation, so this confirmed that the ordering was correct.

Then I inputed as initial condition for simult_ the first observations of the series included in oo_.SmoothedVariables, and the sequence of shocks included in oo_.SmoothedShocks. To solve the issue:

  • I had to trim the first observation of the sequences of shocks to make sure that the initial conditions would match.
  • To compare the series output of simult_ with those in oo_.SmoothedVariables I had to put back the steady-state levels in the oo_.SmoothedVariables series, as apparently these series are log-deviations from their steady-state levels.

Results perfectly match!

Alex[/quote]

Dear all,

I was trying to back out observables using simult_(). I followed the steps in Alex’s post but it didn’t work out for me.

If my understanding is correct, I should use the first observations in oo_.SmoothedVariables instead of the steady-state values as the initial condition and discard the first row the estimated shocks. Then, I use the function simult_() to obtain the simulated observables. As Alex wrote, the steady-state levels in the oo_.SmoothedVariables series need to be put back. In my case, there is nothing to be put back, since my data are detrended and demeaned before estimation. So, my simulated observables are supposed to match the data very well. However, that turns out not to be the case.

Anybody knows what’s going on here? Thank you very much.

Aaron

Are you using 4.4.3? Have you checked whether the variable ordering matches?

Yes, 4.4.3. The variable ordering is consistent.

You must be doing something wrong. For observed variables, the simulated smoothed variables must be identical to the observed series. Have compared your simulated series to the Dynare oo_.SmoothedVariables?

The Dynare oo_.SmoothedVariables match the data perfectly. I don’t have any problem with that. But how can I back out the data from oo_.SmoothedShocks by using the command simult_()? Thank you.

Dear Dr. Pfeifer,

I haven’t found the solution to my problem yet. Here, I am using the mod file from Iacoviello and Neri (2010) as an example. The only change I made is that I got rid of the linear trends in the model and cleaned the data using HP filter before estimation. The series in oo_.SmoothedVariables match the data very well, however I couldn’t back out the data from the estimated oo_.SmoothedShocks using the command simult_().

Your help is highly appreciated. Thanks in advance.

Aaron
rideaej1.m (2.88 KB)
jules1_steadystate.m (4.92 KB)
jules1.mod (17.4 KB)
US_data_65Q106Q4HP.m (17.5 KB)

Please try

clear; close all; clc 

dynare jules1.mod

%set shocks
ex_=];
for shock_iter=1:M_.exo_nbr
ex_=[ex_ oo_.SmoothedShocks.Mean.(deblank(M_.exo_names(shock_iter,:)))];
end

%use shocks only starting at t=2 due to t=1 being initial condition
ex_ = ex_(2:end,:);

%set starting values
y0=];
for endo_iter=1:M_.endo_nbr
y0 = [y0;
oo_.SmoothedVariables.Mean.(deblank(M_.endo_names(endo_iter,:)))(1)];
end;

%make sure decision rules were updated
[oo_.dr,info,M_,options_] = resol(0,M_,options_,oo_);

dr = oo_.dr;
iorder=1;

y_=simult_(y0,dr,ex_,iorder);

US_data_65Q106Q4HP

figure
plot(data_CC)
hold on
plot(y_(strmatch('data_CC',M_.endo_names,'exact'),:),'r--')

That works for me. The series are only different where you allow for measurement error.

Note finally that some small differences are expected. The steady state values of your model variables are nonlinear functions of the parameters. Thus, the steady state used is at the mean of the parameters, but you would actually need the mean of the steady states.

[quote=“jpfeifer”]Please try

[code]clear; close all; clc

dynare jules1.mod

%set shocks
ex_=];
for shock_iter=1:M_.exo_nbr
ex_=[ex_ oo_.SmoothedShocks.Mean.(deblank(M_.exo_names(shock_iter,:)))];
end

%use shocks only starting at t=2 due to t=1 being initial condition
ex_ = ex_(2:end,:);

%set starting values
y0=];
for endo_iter=1:M_.endo_nbr
y0 = [y0;
oo_.SmoothedVariables.Mean.(deblank(M_.endo_names(endo_iter,:)))(1)];
end;

%make sure decision rules were updated
[oo_.dr,info,M_,options_] = resol(0,M_,options_,oo_);

dr = oo_.dr;
iorder=1;

y_=simult_(y0,dr,ex_,iorder);

US_data_65Q106Q4HP

figure
plot(data_CC)
hold on
plot(y_(strmatch(‘data_CC’,M_.endo_names,‘exact’),:),‘r–’)[/code]
That works for me. The series are only different where you allow for measurement error.

Note finally that some small differences are expected. The steady state values of your model variables are nonlinear functions of the parameters. Thus, the steady state used is at the mean of the parameters, but you would actually need the mean of the steady states.[/quote]

Great help. It works perfectly! I really appreciate your help. – Aaron