Modifications for online estimation of linearly-solved models

time-shift
Frédéric Karamé 2014-08-29 15:36:07 +02:00
parent 788833d874
commit b06b6a6161
4 changed files with 51 additions and 19 deletions

View File

@ -73,7 +73,12 @@ end
% Evaluate the likelihood.
ana_deriv = DynareOptions.analytic_derivation;
DynareOptions.analytic_derivation=0;
[fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
if ~isequal(DynareOptions.mode_compute,11)
[fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
else
b=0;
fval = 0;
end
DynareOptions.analytic_derivation=ana_deriv;
if DynareOptions.dsge_var || strcmp(func2str(objective_function),'non_linear_dsge_likelihood')
@ -104,4 +109,6 @@ if any(abs(DynareResults.steady_state(BayesInfo.mfys))>1e-9) && (DynareOptions.p
error('You should change something in your mod file...')
end
disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
if ~isequal(DynareOptions.mode_compute,11)
disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
end

View File

@ -85,8 +85,8 @@ small_a = sqrt(1-h_square) ;
% Initialization of parameter 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)/50 ;
%stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/100 ;
stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/10 ;
i = 1 ;
while i<=number_of_particles
%candidate = start_param + .001*liu_west_chol_sigma_bar*randn(number_of_parameters,1) ;
@ -110,7 +110,10 @@ std_xparam = zeros(number_of_parameters,sample_size) ;
lb95_xparam = zeros(number_of_parameters,sample_size) ;
ub95_xparam = zeros(number_of_parameters,sample_size) ;
%% The Online filter
disp(0)
disp(start_param)
%% The Online filter
for t=1:sample_size
disp(t)
% Moments of parameters particles distribution

View File

@ -307,11 +307,18 @@ end
ReducedForm.ghx = dr.ghx(restrict_variables_idx,:);
ReducedForm.ghu = dr.ghu(restrict_variables_idx,:);
ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
ReducedForm.ghuu = dr.ghuu(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);
if DynareOptions.order>1
ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:);
ReducedForm.ghxu = dr.ghxu(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.Q = Q;
ReducedForm.H = H;

View File

@ -35,26 +35,39 @@ steady;
//disp(oo_.mean) ;
estimated_params;
alp, uniform_pdf,,, 0.0001, 0.5;
alp, uniform_pdf,,, 0.0001, 0.99;
bet, uniform_pdf,,, 0.0001, 0.99;
tet, uniform_pdf,,, 0.0001, 1;
tau, uniform_pdf,,, 0.0001, 100;
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 y, uniform_pdf,,, 0.00001, 0.1;
stderr l, uniform_pdf,,, 0.00001, 0.1;
stderr i, uniform_pdf,,, 0.00001, 0.1;
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;
alp, 0.4;
bet, 0.97;
tet, 0.357 ;
tau, 50;
delt, 0.02;
rho, 0.9 ;
stderr e_a, .035;
bet, 0.98;
tet, 0.3;
tau, 30;
delt, 0.01;
rho, 0.85;
stderr e_a, .03;
stderr y, .0175;//.00158;
stderr l, .00312;//.0011;
stderr i, .00465;//.000866;
@ -98,8 +111,10 @@ options_.particle.IS_approximation_method = 'cubature' ;
//options_.particle.approximation_method = 'unscented' ;
//options_.particle.approximation_method = 'MonteCarlo' ;
//options_.mh_posterior_mode_estimation=1 ;
options_.mh_posterior_mode_estimation=0 ;
// online
options_.particle.liu_west_delta = 0.99 ;
options_.mode_check_node_number = 250 ;
estimation(datafile=data_risky_perturb3,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);