Commit f9a462bf authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Added option nonlinear_filter_initialization.

Default value is 1 (initialization with the ergodic variance of the reduced
form solution of the model approximated at order one).

If the model has unit roots, the user must use `nonlinear_filter_initialization=3`,
which select an identity matrix for the initial covariance matrix of the state variables.

A side effect of this option is to temporarily change the value of options_.qz_criterium to
a value above one (ie 1+1e-6) so that the unit roots are not rejected. If the
model has unit roots and if the and if the option
nonlinear_filter_initialization has a value less than 3, the evaluation of the
likelihood will fail, because by default the unit root is counted as an
unstable root.
parent 97e185bc
......@@ -3480,6 +3480,7 @@ end;
 
@deffn Command check ;
@deffnx Command check (solve_algo = @var{INTEGER}) ;
@anchor{check}
 
@descriptionhead
 
......@@ -6345,6 +6346,22 @@ Sets the method for approximating the particle distribution. Possible values for
@item cpf_weights = @var{OPTION}
@anchor{cpf_weights} Controls the method used to update the weights in conditional particle filter, possible values are @code{amisanotristani} (@cite{Amisano et al (2010)}) or @code{murrayjonesparslow} (@cite{Murray et al. (2013)}). Default value is @code{amisanotristani}.
 
@item nonlinear_filter_initialization = @var{INTEGER}
@anchor{nonlinear_filter_initialization} Sets the initial condition of the
nonlinear filters. By default the nonlinear filters are initialized with the
unconditional covariance matrix of the state variables, computed with the
reduced form solution of the first order approximation of the model. If
@code{nonlinear_filter_initialization=2}, the nonlinear filter is instead
initialized with a covariance matrix estimated with a stochastic simulation of
the reduced form solution of the second order approximation of the model. Both
these initializations assume that the model is stationary, and cannot be used
if the model has unit roots (which can be seen with the @ref{check} command
prior to estimation). If the model has stochastic trends, user must use
@code{nonlinear_filter_initialization=3}, the filters are then initialized with
an identity matrix for the covariance matrix of the state variables. Default
value is @code{nonlinear_filter_initialization=1} (initialization based on the
first order approximation of the model).
@end table
 
 
......
......@@ -316,7 +316,8 @@ switch DynareOptions.particle.initialization
StateVectorVariance = cov(y_');
DynareOptions.periods = old_DynareOptionsperiods;
clear('old_DynareOptionsperiods','y_');
case 3% Initial state vector covariance is a diagonal matrix.
case 3% Initial state vector covariance is a diagonal matrix (to be used
% if model has stochastic trends).
StateVectorMean = ReducedForm.constant(mf0);
StateVectorVariance = DynareOptions.particle.initial_state_prior_std*eye(number_of_state_variables);
otherwise
......
......@@ -36,21 +36,36 @@ function options_=select_qz_criterium_value(options_)
% set by default options_.qz_criterium to 1+1e-6
stack = dbstack;
if isequal(options_.lik_init,1)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1-1e-6;
elseif options_.qz_criterium > 1-eps
error([stack(2).file ': option qz_criterium is too large for estimating/smoothing ' ...
'a stationary model. If your model contains unit roots, use ' ...
'option diffuse_filter'])
if options_.particle.status
% Non linear filter
if isequal(options_.particle.initialization, 3)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
else
if options_.qz_criterium <= 1
fprintf('\n%s:: You set nonlinear_filter_initialization equal to 3, it is assumed that you try to estimate a non stationary model. Resetting it to 1+1e-6.\n', stack(2).file)
options_.qz_criterium = 1+1e-6;
end
end
end
else
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
% Linear filter
if isequal(options_.lik_init,1)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1-1e-6;
elseif options_.qz_criterium > 1-eps
error([stack(2).file ': option qz_criterium is too large for estimating/smoothing ' ...
'a stationary model. If your model contains unit roots, use ' ...
'option diffuse_filter'])
end
else
if options_.qz_criterium <= 1
fprintf('\n%s:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n',stack(2).file)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
else
if options_.qz_criterium <= 1
fprintf('\n%s:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n',stack(2).file)
options_.qz_criterium = 1+1e-6;
end
end
end
end
end
\ No newline at end of file
......@@ -111,7 +111,7 @@ class ParsingDriver;
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW
%token FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
%token <string_val> NAME
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
......@@ -1818,6 +1818,7 @@ estimation_options : o_datafile
| o_resampling_threshold
| o_resampling_method
| o_filter_algorithm
| o_nonlinear_filter_initialization
| o_cpf_weights
| o_proposal_approximation
| o_distribution_approximation
......@@ -3085,6 +3086,7 @@ o_resampling_method : RESAMPLING_METHOD EQUAL KITAGAWA {driver.option_num("parti
o_cpf_weights : CPF_WEIGHTS EQUAL AMISANOTRISTANI {driver.option_num("particle.cpf_weights_method.amisanotristani", "1"); driver.option_num("particle.cpf_weights_method.murrayjonesparslow", "0"); }
| CPF_WEIGHTS EQUAL MURRAYJONESPARSLOW {driver.option_num("particle.cpf_weights_method.amisanotristani", "0"); driver.option_num("particle.cpf_weights_method.murrayjonesparslow", "1"); };
o_filter_algorithm : FILTER_ALGORITHM EQUAL symbol { driver.option_str("particle.filter_algorithm", $3); };
o_nonlinear_filter_initialization : NONLINEAR_FILTER_INITIALIZATION EQUAL INT_NUMBER { driver.option_num("particle.initialization", $3); };
o_proposal_approximation : PROPOSAL_APPROXIMATION EQUAL CUBATURE {driver.option_num("particle.proposal_approximation.cubature", "1"); driver.option_num("particle.proposal_approximation.unscented", "0"); driver.option_num("particle.proposal_approximation.montecarlo", "0");}
| PROPOSAL_APPROXIMATION EQUAL UNSCENTED {driver.option_num("particle.proposal_approximation.cubature", "0"); driver.option_num("particle.proposal_approximation.unscented", "1"); driver.option_num("particle.proposal_approximation.montecarlo", "0");}
| PROPOSAL_APPROXIMATION EQUAL MONTECARLO {driver.option_num("particle.proposal_approximation.cubature", "0"); driver.option_num("particle.proposal_approximation.unscented", "0"); driver.option_num("particle.proposal_approximation.montecarlo", "1");} ;
......
......@@ -398,6 +398,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>amisanotristani {return token::AMISANOTRISTANI;}
<DYNARE_STATEMENT>murrayjonesparslow {return token::MURRAYJONESPARSLOW;}
<DYNARE_STATEMENT>filter_algorithm {return token::FILTER_ALGORITHM;}
<DYNARE_STATEMENT>nonlinear_filter_initialization {return token::NONLINEAR_FILTER_INITIALIZATION;}
<DYNARE_STATEMENT>proposal_approximation {return token::PROPOSAL_APPROXIMATION;}
<DYNARE_STATEMENT>cubature {return token::CUBATURE;}
<DYNARE_STATEMENT>unscented {return token::UNSCENTED;}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment