Skip to content
Snippets Groups Projects
Commit fc3e1b21 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Merge remote-tracking branch 'fred@github/master'

Conflicts:
	matlab/initial_estimation_checks.m
	matlab/utilities/tests
parents 41e05391 b06b6a61
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,12 @@ test_for_deep_parameters_calibration(Model); ...@@ -75,7 +75,12 @@ test_for_deep_parameters_calibration(Model);
% Evaluate the likelihood. % Evaluate the likelihood.
ana_deriv = DynareOptions.analytic_derivation; ana_deriv = DynareOptions.analytic_derivation;
DynareOptions.analytic_derivation=0; DynareOptions.analytic_derivation=0;
if ~isequal(DynareOptions.mode_compute,11)
[fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults); [fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
else
b=0;
fval = 0;
end
DynareOptions.analytic_derivation=ana_deriv; DynareOptions.analytic_derivation=ana_deriv;
if DynareOptions.dsge_var || strcmp(func2str(objective_function),'non_linear_dsge_likelihood') if DynareOptions.dsge_var || strcmp(func2str(objective_function),'non_linear_dsge_likelihood')
...@@ -106,4 +111,6 @@ if any(abs(DynareResults.steady_state(BayesInfo.mfys))>1e-9) && (DynareOptions.p ...@@ -106,4 +111,6 @@ if any(abs(DynareResults.steady_state(BayesInfo.mfys))>1e-9) && (DynareOptions.p
error('You should change something in your mod file...') error('You should change something in your mod file...')
end end
if ~isequal(DynareOptions.mode_compute,11)
disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]); disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
end
...@@ -85,8 +85,8 @@ small_a = sqrt(1-h_square) ; ...@@ -85,8 +85,8 @@ small_a = sqrt(1-h_square) ;
% Initialization of parameter particles % Initialization of parameter particles
xparam = zeros(number_of_parameters,number_of_particles) ; xparam = zeros(number_of_parameters,number_of_particles) ;
stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/100 ; %stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/100 ;
stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/50 ; stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/10 ;
i = 1 ; i = 1 ;
while i<=number_of_particles while i<=number_of_particles
%candidate = start_param + .001*liu_west_chol_sigma_bar*randn(number_of_parameters,1) ; %candidate = start_param + .001*liu_west_chol_sigma_bar*randn(number_of_parameters,1) ;
...@@ -110,6 +110,9 @@ std_xparam = zeros(number_of_parameters,sample_size) ; ...@@ -110,6 +110,9 @@ std_xparam = zeros(number_of_parameters,sample_size) ;
lb95_xparam = zeros(number_of_parameters,sample_size) ; lb95_xparam = zeros(number_of_parameters,sample_size) ;
ub95_xparam = zeros(number_of_parameters,sample_size) ; ub95_xparam = zeros(number_of_parameters,sample_size) ;
disp(0)
disp(start_param)
%% The Online filter %% The Online filter
for t=1:sample_size for t=1:sample_size
disp(t) disp(t)
......
...@@ -307,11 +307,18 @@ end ...@@ -307,11 +307,18 @@ end
ReducedForm.ghx = dr.ghx(restrict_variables_idx,:); ReducedForm.ghx = dr.ghx(restrict_variables_idx,:);
ReducedForm.ghu = dr.ghu(restrict_variables_idx,:); ReducedForm.ghu = dr.ghu(restrict_variables_idx,:);
ReducedForm.steadystate = dr.ys(dr.order_var(restrict_variables_idx));
if DynareOptions.order>1
ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:); ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:); ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:);
ReducedForm.ghxu = dr.ghxu(restrict_variables_idx,:); ReducedForm.ghxu = dr.ghxu(restrict_variables_idx,:);
ReducedForm.steadystate = dr.ys(dr.order_var(restrict_variables_idx));
ReducedForm.constant = ReducedForm.steadystate + .5*dr.ghs2(restrict_variables_idx); ReducedForm.constant = ReducedForm.steadystate + .5*dr.ghs2(restrict_variables_idx);
else
ReducedForm.ghxx = zeros(size(restrict_variables_idx,1),size(dr.kstate,2));
ReducedForm.ghuu = zeros(size(restrict_variables_idx,1),size(dr.ghu,2));
ReducedForm.ghxu = zeros(size(restrict_variables_idx,1),size(dr.ghx,2));
ReducedForm.constant = ReducedForm.steadystate ;
end
ReducedForm.state_variables_steady_state = dr.ys(dr.order_var(state_variables_idx)); ReducedForm.state_variables_steady_state = dr.ys(dr.order_var(state_variables_idx));
ReducedForm.Q = Q; ReducedForm.Q = Q;
ReducedForm.H = H; ReducedForm.H = H;
......
...@@ -35,26 +35,39 @@ steady; ...@@ -35,26 +35,39 @@ steady;
//disp(oo_.mean) ; //disp(oo_.mean) ;
estimated_params; estimated_params;
alp, uniform_pdf,,, 0.0001, 0.5; alp, uniform_pdf,,, 0.0001, 0.99;
bet, uniform_pdf,,, 0.0001, 0.99; bet, uniform_pdf,,, 0.0001, 0.99;
tet, uniform_pdf,,, 0.0001, 1; tet, uniform_pdf,,, 0.0001, 1;
tau, uniform_pdf,,, 0.0001, 100; tau, uniform_pdf,,, 0.0001, 100;
delt, uniform_pdf,,, 0.0001, 0.05; delt, uniform_pdf,,, 0.0001, 0.05;
rho, uniform_pdf,,, 0.8, 0.99; rho, uniform_pdf,,, 0.0001, 0.99;
stderr e_a, uniform_pdf,,, 0.00001, 0.1; stderr e_a, uniform_pdf,,, 0.00001, 0.1;
stderr y, uniform_pdf,,, 0.00001, 0.1; stderr y, uniform_pdf,,, 0.00001, 0.1;
stderr l, uniform_pdf,,, 0.00001, 0.1; stderr l, uniform_pdf,,, 0.00001, 0.1;
stderr i, uniform_pdf,,, 0.00001, 0.1; stderr i, uniform_pdf,,, 0.00001, 0.1;
end; end;
//estimated_params_init;
//alp, 0.4;
//bet, 0.99;
//tet, 0.357 ;
//tau, 50;
//delt, 0.02;
//rho, 0.95 ;
//stderr e_a, .035;
//stderr y, .0175;//.00158;
//stderr l, .00312;//.0011;
//stderr i, .00465;//.000866;
//end;
estimated_params_init; estimated_params_init;
alp, 0.4; alp, 0.4;
bet, 0.97; bet, 0.98;
tet, 0.357 ; tet, 0.3;
tau, 50; tau, 30;
delt, 0.02; delt, 0.01;
rho, 0.9 ; rho, 0.85;
stderr e_a, .035; stderr e_a, .03;
stderr y, .0175;//.00158; stderr y, .0175;//.00158;
stderr l, .00312;//.0011; stderr l, .00312;//.0011;
stderr i, .00465;//.000866; stderr i, .00465;//.000866;
...@@ -68,20 +81,20 @@ varobs y l i ; ...@@ -68,20 +81,20 @@ varobs y l i ;
options_.particle.status = 1; options_.particle.status = 1;
options_.particle.initialization = 1; options_.particle.initialization = 1;
options_.particle.pruning = 0; options_.particle.pruning = 0;
options_.particle.number_of_particles = 1000 ; options_.particle.number_of_particles = 5000 ;
options_.particle.resampling.status = 'systematic'; options_.particle.resampling.status = 'systematic';
//options_.particle.resampling.method1 = 'traditional' ; options_.particle.resampling.method1 = 'traditional' ;
//options_.particle.resampling.method1 = 'residual' ; //options_.particle.resampling.method1 = 'residual' ;
options_.particle.resampling.method1 = 'smooth' ; //options_.particle.resampling.method1 = 'smooth' ;
options_.particle.reampling.method2 = 'kitagawa' ; options_.particle.reampling.method2 = 'kitagawa' ;//'stratified' ;
//options_.particle.resampling.method2 = 'stratified' ;
options_.particle.resampling.number_of_partitions = 1;
options_.particle.resampling.neff_threshold = .5; options_.particle.resampling.neff_threshold = .5;
options_.mode_check.neighbourhood_size = .2 ;
options_.mode_check.number_of_points = 250;
set_dynare_threads('local_state_space_iteration_2',3); //set_dynare_threads('local_state_space_iteration_2',3);
options_.particle.algorithm = 'sequential_importance_particle_filter'; options_.particle.algorithm = 'sequential_importance_particle_filter';
//options_.particle.algorithm = 'auxiliary_particle_filter'; //options_.particle.algorithm = 'auxiliary_particle_filter';
...@@ -94,14 +107,14 @@ options_.particle.IS_approximation_method = 'cubature' ; ...@@ -94,14 +107,14 @@ options_.particle.IS_approximation_method = 'cubature' ;
//options_.particle.IS_approximation_method = 'unscented' ; //options_.particle.IS_approximation_method = 'unscented' ;
//options_.particle.approximation_method = 'quadrature' ; //options_.particle.approximation_method = 'quadrature' ;
options_.particle.approximation_method = 'cubature' ; //options_.particle.approximation_method = 'cubature' ;
//options_.particle.approximation_method = 'unscented' ; //options_.particle.approximation_method = 'unscented' ;
//options_.particle.approximation_method = 'MonteCarlo' ; //options_.particle.approximation_method = 'MonteCarlo' ;
//options_.mh_posterior_mode_estimation=1 ; options_.mh_posterior_mode_estimation=0 ;
// online // online
options_.particle.liu_west_delta = 0.9 ; options_.particle.liu_west_delta = 0.99 ;
options_.mode_check_node_number = 250 ; options_.mode_check_node_number = 250 ;
estimation(datafile=data_risky_perturb2,nograph,order=2,nobs=100,mh_replic=0,mode_compute=7,mode_check); estimation(datafile=data_risky_perturb3,order=1,nograph,nobs=100,mh_replic=0,mode_compute=11);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment