kalman filter estimate

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.

kalman filter estimate

Postby marco_dp » Mon Jul 03, 2017 4:28 pm

Dear dynare community,

I have estimated a DSGE model in dynare by using bayesian techniques.
I would like to obtain the Kalman filter estimate of an endogenous variable used in the model at the posterior mode, in order to compare its evolution (i.e., the path of the variable generated by the model) against its observed evolution (the observed time series).
Essentially, I would like to replicate figure 5, pag 116, of the paper I attached to this message.
How does this can be accomplished into dynare?

thanks in advance for the help
Attachments
justiniano-primicieri-tambalotti.pdf
(362.11 KiB) Downloaded 107 times
marco_dp
 
Posts: 24
Joined: Wed May 15, 2013 3:07 pm

Re: kalman filter estimate

Postby jpfeifer » Tue Jul 04, 2017 12:19 pm

1. For observed variables, the smoothed variables from the Kalman filter will always be equal to the observed ones. JPT compare the smoothed variable to outside evidence not used for the model estimation
2. To generate the smoothed variables at the mode, use estimation with
Code: Select all
mh_replic=0

Or alternatively, if you run estimation with MCMC, use the
Code: Select all
calib_smoother

command with
Code: Select all
parameter_set=posterior_mode
------------
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: kalman filter estimate

Postby marco_dp » Wed Jul 05, 2017 9:50 am

Dear jpfeifer,

thanks for the reply. I run the estimation with MCMC, after the estimation command I added this line

Code: Select all
calib_smoother(datafile=dataset1) var1;


but after the estimation it gives me the following error:

Code: Select all
??? Attempted to access xparam1(1); index out of bounds because
numel(xparam1)=0.

Error in ==> set_all_parameters at 68
        Sigma_e(k,k) = xparam1(i)^2;

Error in ==> DsgeSmoother at 65
M_ = set_all_parameters(xparam1,estim_params_,M_);

Error in ==> evaluate_smoother at 90
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp]
= ...

Error in ==> final_model at 587
evaluate_smoother('calibration',var_list_);

Error in ==> dynare at 180
evalin('base',fname) ;


Moreover, if I add into parenthesis in the calib_smoother command
Code: Select all
parameter_set=posterior_mode


I get an error.

How can I solve this?
thanks
marco_dp
 
Posts: 24
Joined: Wed May 15, 2013 3:07 pm

Re: kalman filter estimate

Postby jpfeifer » Wed Jul 05, 2017 9:54 am

I would need to see the files.
------------
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: kalman filter estimate

Postby marco_dp » Wed Jul 05, 2017 12:18 pm

Dear jpfeifer,

thanks for the help

I attached the .mod file
Attachments
final_model.mod
(12.57 KiB) Downloaded 91 times
marco_dp
 
Posts: 24
Joined: Wed May 15, 2013 3:07 pm

Re: kalman filter estimate

Postby jpfeifer » Fri Jul 07, 2017 3:55 pm

You are missing the data file.

I was wrong. calib_smoother does not support the parameter_set option yet, see https://github.com/DynareTeam/dynare/issues/1477

Instead use the following code
Code: Select all
verbatim;
options_.datafile = 'data_80_16_hp';
var_list_ = char('q');
options_.smoother = 1;
options_.order = 1;
[oo_,M_,options_,bayestopt_]=evaluate_smoother('calibration',var_list_,M_,oo_,options_,bayestopt_,estim_params_);
end;
------------
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: kalman filter estimate

Postby marco_dp » Sat Jul 08, 2017 10:36 am

Dear Johannes Pfeifer,

thanks a lot for deserving me your time.

However, the solution you proposed me does not work, I get the following error:

??? Error using ==> evaluate_smoother
Too many input arguments.

Error in ==> final_model at 586
[oo_,M_,options_,bayestopt_]=evaluate_smoother('calibration',var_list_,M_,oo_,options_,bayestopt_,estim_params_);

Error in ==> dynare at 180
evalin('base',fname) ;


I attach you both the .mod file and the .xls data

thanks for your attention
Attachments
data_80_16_hp.rar
(23.96 KiB) Downloaded 84 times
final_model.mod
(12.81 KiB) Downloaded 90 times
marco_dp
 
Posts: 24
Joined: Wed May 15, 2013 3:07 pm

Re: kalman filter estimate

Postby jpfeifer » Mon Jul 10, 2017 2:14 pm

The mode-file is missing. But from the error message I infer that you are not using Dynare 4.5
------------
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: kalman filter estimate

Postby marco_dp » Tue Jul 11, 2017 10:26 am

Thanks for the help, the problem was the dynare version

Thanks again for your kindness
marco_dp
 
Posts: 24
Joined: Wed May 15, 2013 3:07 pm


Return to Dynare help

Who is online

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