Page 1 of 2
Choosing initial values for simult_
Posted:
Fri Feb 17, 2012 2:41 pm
by Jeppe Druedahl
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.
Re: Choosing initial values for simult_
Posted:
Mon Nov 04, 2013 10:01 pm
by alex
Hi, I have the same problem as Jeppe. How to replicate the data in oo_.Smoothed Variables?
Best,
Alex
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 9:58 am
by jpfeifer
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.
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 10:16 am
by alex
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
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 12:24 pm
by jpfeifer
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.
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 2:49 pm
by alex
solved thanks a lot!
Alex
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 3:03 pm
by jpfeifer
So what is the solution?
Re: Choosing initial values for simult_
Posted:
Tue Nov 05, 2013 3:15 pm
by 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
Re: Choosing initial values for simult_
Posted:
Thu Feb 19, 2015 9:04 pm
by aaronsun
alex wrote: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
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
Re: Choosing initial values for simult_
Posted:
Fri Feb 20, 2015 6:53 am
by jpfeifer
Are you using 4.4.3? Have you checked whether the variable ordering matches?
Re: Choosing initial values for simult_
Posted:
Fri Feb 20, 2015 3:45 pm
by aaronsun
jpfeifer wrote:Are you using 4.4.3? Have you checked whether the variable ordering matches?
Yes, 4.4.3. The variable ordering is consistent.
Re: Choosing initial values for simult_
Posted:
Mon Feb 23, 2015 10:46 am
by jpfeifer
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?
Re: Choosing initial values for simult_
Posted:
Mon Feb 23, 2015 5:22 pm
by aaronsun
jpfeifer wrote: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.
Re: Choosing initial values for simult_
Posted:
Mon Mar 02, 2015 1:46 am
by aaronsun
jpfeifer wrote: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?
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
Re: Choosing initial values for simult_
Posted:
Sat Mar 07, 2015 2:12 pm
by jpfeifer
Please try
- Code: Select all
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.