adding new option 'fast_kalman_filter' implementing Ed Herbst 2012 approach

time-shift
Michel Juillard 2015-11-28 17:36:51 +01:00
parent 105100c7fe
commit c373d1e1be
7 changed files with 39 additions and 3 deletions

View File

@ -5527,6 +5527,12 @@ from the likelihood computations (for details see @cite{Durbin and Koopman (2012
singularity is encountered, Dynare by default automatically switches to the univariate Kalman filter for this parameter draw. This behavior can be changed via the singularity is encountered, Dynare by default automatically switches to the univariate Kalman filter for this parameter draw. This behavior can be changed via the
@ref{use_univariate_filters_if_singularity_is_detected} option. @ref{use_univariate_filters_if_singularity_is_detected} option.
@item fast_kalman_filter
@anchor{fast_kalman_filter} Select the fast Kalman filter using Chandrasekhar
recursions as described by @cite{Herbst, 2012}. This setting is only used with
@code{kalman_algo=1} or @code{kalman_algo=3}. It is not yet compatible with
@code{analytical_derivation}.
@item kalman_tol = @var{DOUBLE} @item kalman_tol = @var{DOUBLE}
@anchor{kalman_tol} Numerical tolerance for determining the singularity of the covariance matrix of the prediction errors during the Kalman filter (minimum allowed reciprocal of the matrix condition number). Default value is @code{1e-10} @anchor{kalman_tol} Numerical tolerance for determining the singularity of the covariance matrix of the prediction errors during the Kalman filter (minimum allowed reciprocal of the matrix condition number). Default value is @code{1e-10}
@ -13099,6 +13105,11 @@ Hansen, Nikolaus and Stefan Kern (2004): ``Evaluating the CMA Evolution Strategy
on Multimodal Test Functions''. In: @i{Eighth International Conference on Parallel on Multimodal Test Functions''. In: @i{Eighth International Conference on Parallel
Problem Solving from Nature PPSN VIII, Proceedings}, Berlin: Springer, 282--291 Problem Solving from Nature PPSN VIII, Proceedings}, Berlin: Springer, 282--291
@item
Edward Herbst (2015):
``Using the “Chandrasekhar Recursions” for Likelihood Evaluation of DSGE
Models,'' @i{Computational Economics}, 45(4), 693--705.
@item @item
Ireland, Peter (2004): ``A Method for Taking Models to the Data,'' Ireland, Peter (2004): ``A Method for Taking Models to the Data,''
@i{Journal of Economic Dynamics and Control}, 28, 1205--26 @i{Journal of Economic Dynamics and Control}, 28, 1205--26

View File

@ -659,6 +659,13 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
if DynareOptions.block if DynareOptions.block
[err, LIK] = block_kalman_filter(T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar); [err, LIK] = block_kalman_filter(T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar);
mexErrCheck('block_kalman_filter', err); mexErrCheck('block_kalman_filter', err);
elseif DynareOptions.fast_kalman_filter
[LIK,lik] = kalman_filter_fast(Y,diffuse_periods+1,size(Y,2), ...
a,Pstar, ...
kalman_tol, riccati_tol, ...
DynareOptions.presample, ...
T,Q,R,H,Z,mm,pp,rr,Zflag,diffuse_periods, ...
analytic_deriv_info{:});
else else
[LIK,lik] = kalman_filter(Y,diffuse_periods+1,size(Y,2), ... [LIK,lik] = kalman_filter(Y,diffuse_periods+1,size(Y,2), ...
a,Pstar, ... a,Pstar, ...

View File

@ -206,7 +206,21 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && options_.m
return return
end end
% Estimation of the posterior mode or likelihood mode %% Estimation of the posterior mode or likelihood mode
% analytical derivation is not yet available for kalman_filter_fast
if options_.analytic_derivation && options_.fast_kalman_filter
error(['estimation option conflict: analytic_derivation isn''t available ' ...
'for fast_kalman_filter'])
end
% fast kalman filter is only available with kalman_algo == 1,3
if options_.fast_kalman_filter && ...
(options_.kalman_algo == 1 || options_.kalman_algo == 3)
error(['estimation option conflict: fast_kalman_filter is only available ' ...
'with kalman_algo = 1 or kalman_algo = 3'])
end
if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
%prepare settings for newrat %prepare settings for newrat
if options_.mode_compute==5 if options_.mode_compute==5

View File

@ -407,7 +407,7 @@ options_.filtered_vars = 0;
options_.first_obs = NaN; options_.first_obs = NaN;
options_.nobs = NaN; options_.nobs = NaN;
options_.kalman_algo = 0; options_.kalman_algo = 0;
options_.fast_kalman = 0; options_.fast_kalman_filter = 0;
options_.kalman_tol = 1e-10; options_.kalman_tol = 1e-10;
options_.diffuse_kalman_tol = 1e-6; options_.diffuse_kalman_tol = 1e-6;
options_.use_univariate_filters_if_singularity_is_detected = 1; options_.use_univariate_filters_if_singularity_is_detected = 1;

View File

@ -101,7 +101,7 @@ class ParsingDriver;
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS %token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
%token <string_val> INT_NUMBER %token <string_val> INT_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION %token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
%token KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF %token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION %token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT %token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS %token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
@ -1698,6 +1698,7 @@ estimation_options : o_datafile
| o_moments_varendo | o_moments_varendo
| o_contemporaneous_correlation | o_contemporaneous_correlation
| o_filtered_vars | o_filtered_vars
| o_fast_kalman_filter
| o_kalman_algo | o_kalman_algo
| o_kalman_tol | o_kalman_tol
| o_diffuse_kalman_tol | o_diffuse_kalman_tol
@ -2746,6 +2747,7 @@ o_moments_varendo : MOMENTS_VARENDO { driver.option_num("moments_varendo", "1");
o_contemporaneous_correlation : CONTEMPORANEOUS_CORRELATION { driver.option_num("contemporaneous_correlation", "1"); }; o_contemporaneous_correlation : CONTEMPORANEOUS_CORRELATION { driver.option_num("contemporaneous_correlation", "1"); };
o_filtered_vars : FILTERED_VARS { driver.option_num("filtered_vars", "1"); }; o_filtered_vars : FILTERED_VARS { driver.option_num("filtered_vars", "1"); };
o_relative_irf : RELATIVE_IRF { driver.option_num("relative_irf", "1"); }; o_relative_irf : RELATIVE_IRF { driver.option_num("relative_irf", "1"); };
o_fast_kalman_filter : FAST_KALMAN_FILTER { driver.option_num("fast_kalman_filter", "1"); };
o_kalman_algo : KALMAN_ALGO EQUAL INT_NUMBER { driver.option_num("kalman_algo", $3); }; o_kalman_algo : KALMAN_ALGO EQUAL INT_NUMBER { driver.option_num("kalman_algo", $3); };
o_kalman_tol : KALMAN_TOL EQUAL non_negative_number { driver.option_num("kalman_tol", $3); }; o_kalman_tol : KALMAN_TOL EQUAL non_negative_number { driver.option_num("kalman_tol", $3); };
o_diffuse_kalman_tol : DIFFUSE_KALMAN_TOL EQUAL non_negative_number { driver.option_num("diffuse_kalman_tol", $3); }; o_diffuse_kalman_tol : DIFFUSE_KALMAN_TOL EQUAL non_negative_number { driver.option_num("diffuse_kalman_tol", $3); };

View File

@ -295,6 +295,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>logdata {return token::LOGDATA;} <DYNARE_STATEMENT>logdata {return token::LOGDATA;}
<DYNARE_STATEMENT>nodiagnostic {return token::NODIAGNOSTIC;} <DYNARE_STATEMENT>nodiagnostic {return token::NODIAGNOSTIC;}
<DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;} <DYNARE_STATEMENT>kalman_algo {return token::KALMAN_ALGO;}
<DYNARE_STATEMENT>fast_kalman_filter {return token::FAST_KALMAN_FILTER;}
<DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;} <DYNARE_STATEMENT>kalman_tol {return token::KALMAN_TOL;}
<DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;} <DYNARE_STATEMENT>diffuse_kalman_tol {return token::DIFFUSE_KALMAN_TOL;}
<DYNARE_STATEMENT>forecast {return token::FORECAST;} <DYNARE_STATEMENT>forecast {return token::FORECAST;}

View File

@ -4,6 +4,7 @@ MODFILES = \
estimation/fs2000_initialize_from_calib.mod \ estimation/fs2000_initialize_from_calib.mod \
estimation/fs2000_calibrated_covariance.mod \ estimation/fs2000_calibrated_covariance.mod \
estimation/fs2000_model_comparison.mod \ estimation/fs2000_model_comparison.mod \
estimation/fs2000_fast.mod \
estimation/MH_recover/fs2000_recover.mod \ estimation/MH_recover/fs2000_recover.mod \
estimation/t_proposal/fs2000_student.mod \ estimation/t_proposal/fs2000_student.mod \
estimation/TaRB/fs2000_tarb.mod \ estimation/TaRB/fs2000_tarb.mod \