Choosing initial values for simult_

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Choosing initial values for simult_

Postby Jeppe Druedahl » Fri Feb 17, 2012 2:41 pm

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.
Jeppe Druedahl
 
Posts: 2
Joined: Fri Feb 17, 2012 2:18 pm

Re: Choosing initial values for simult_

Postby alex » Mon Nov 04, 2013 10:01 pm

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

Best,
Alex
alex
 
Posts: 10
Joined: Sun Sep 15, 2013 3:41 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Tue Nov 05, 2013 9:58 am

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Choosing initial values for simult_

Postby alex » Tue Nov 05, 2013 10:16 am

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
alex
 
Posts: 10
Joined: Sun Sep 15, 2013 3:41 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Tue Nov 05, 2013 12:24 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Choosing initial values for simult_

Postby alex » Tue Nov 05, 2013 2:49 pm

solved thanks a lot!

Alex
alex
 
Posts: 10
Joined: Sun Sep 15, 2013 3:41 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Tue Nov 05, 2013 3:03 pm

So what is the solution?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Choosing initial values for simult_

Postby alex » Tue Nov 05, 2013 3:15 pm

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
alex
 
Posts: 10
Joined: Sun Sep 15, 2013 3:41 pm

Re: Choosing initial values for simult_

Postby aaronsun » Thu Feb 19, 2015 9:04 pm

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
aaronsun
 
Posts: 13
Joined: Mon Mar 17, 2014 7:39 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Fri Feb 20, 2015 6:53 am

Are you using 4.4.3? Have you checked whether the variable ordering matches?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Choosing initial values for simult_

Postby aaronsun » Fri Feb 20, 2015 3:45 pm

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.
aaronsun
 
Posts: 13
Joined: Mon Mar 17, 2014 7:39 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Mon Feb 23, 2015 10:46 am

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?
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Choosing initial values for simult_

Postby aaronsun » Mon Feb 23, 2015 5:22 pm

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.
aaronsun
 
Posts: 13
Joined: Mon Mar 17, 2014 7:39 pm

Re: Choosing initial values for simult_

Postby aaronsun » Mon Mar 02, 2015 1:46 am

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
Attachments
rideaej1.m
main script
(2.88 KiB) Downloaded 98 times
jules1_steadystate.m
steady state file
(4.92 KiB) Downloaded 88 times
jules1.mod
mod file
(17.39 KiB) Downloaded 122 times
US_data_65Q106Q4HP.m
data (hp filtered)
(17.51 KiB) Downloaded 92 times
aaronsun
 
Posts: 13
Joined: Mon Mar 17, 2014 7:39 pm

Re: Choosing initial values for simult_

Postby jpfeifer » Sat Mar 07, 2015 2:12 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Next

Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 6 guests