Save posterior moments even if the distribution is degenerate

Closes #1024
time-shift
Johannes Pfeifer 2015-10-13 11:47:35 +02:00
parent d3eca9338b
commit 1043a019c2
3 changed files with 37 additions and 85 deletions

View File

@ -90,46 +90,26 @@ for file = 1:length(ListOfFiles)
i1 = i2+1;
end
name = [ var1 '.' var2 ];
if ~isconst(tmp)
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
else
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
if isfield(oo_,[ TYPE 'TheoreticalMoments'])
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']);
if isfield(temporary_structure,'dsge')
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']).dsge;
if isfield(temporary_structure,'correlation')
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Mean',nar,p_mean);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Median',nar,p_median);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Variance',nar,p_var);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDinf',nar,hpd_interval(1));
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDsup',nar,hpd_interval(2));
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'deciles',nar,p_deciles);
if options_.estimation.moments_posterior_density.indicator
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'density',nar,density);
end
end
end
end
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
else
if isfield(oo_,'PosteriorTheoreticalMoments')
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']);
if isfield(temporary_structure,'dsge')
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']).dsge;
if isfield(temporary_structure,'correlation')
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Mean',nar,NaN);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Median',nar,NaN);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Variance',nar,NaN);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDinf',nar,NaN);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDsup',nar,NaN);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'deciles',nar,NaN);
if options_.estimation.moments_posterior_density.indicator
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'density',nar,NaN);
end
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
if isfield(oo_,[ TYPE 'TheoreticalMoments'])
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']);
if isfield(temporary_structure,'dsge')
temporary_structure = oo_.([TYPE, 'TheoreticalMoments']).dsge;
if isfield(temporary_structure,'correlation')
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Mean',nar,p_mean);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Median',nar,p_median);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'Variance',nar,p_var);
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDinf',nar,hpd_interval(1));
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'HPDsup',nar,hpd_interval(2));
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'deciles',nar,p_deciles);
if options_.estimation.moments_posterior_density.indicator
oo_ = fill_output_structure(var1,var2,TYPE,oo_,'density',nar,density);
end
end
end

View File

@ -105,32 +105,20 @@ for file = 1:length(ListOfFiles)
i1 = i2+1;
end
if ~isconst(tmp)
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.density.(var1).(var2) = density;
else
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Mean.(var1).(var2) = p_mean;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Median.(var1).(var2) = p_median;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Variance.(var1).(var2) = p_var;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDinf.(var1).(var2) = hpd_interval(1);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDsup.(var1).(var2) = hpd_interval(2);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.deciles.(var1).(var2) = p_deciles;
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.density.(var1).(var2) = density;
else
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Mean.(var1).(var2) = NaN;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Median.(var1).(var2) = NaN;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Variance.(var1).(var2) = NaN;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDinf.(var1).(var2) = NaN;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDsup.(var1).(var2) = NaN;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.deciles.(var1).(var2) = NaN;
if options_.estimation.moments_posterior_density.indicator
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.density.(var1).(var2) = NaN;
end
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Mean.(var1).(var2) = p_mean;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Median.(var1).(var2) = p_median;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.Variance.(var1).(var2) = p_var;
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDinf.(var1).(var2) = hpd_interval(1);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.HPDsup.(var1).(var2) = hpd_interval(2);
oo_.([TYPE, 'TheoreticalMoments']).dsge.covariance.deciles.(var1).(var2) = p_deciles;
if options_.contemporaneous_correlation
if options_.estimation.moments_posterior_density.indicator

View File

@ -86,30 +86,14 @@ for file = 1:length(ListOfFiles)
i1 = i2+1;
end
t1 = min(tmp); t2 = max(tmp);
t3 = t2-t1;% How to normalize ? t1 and t2 may be zero...
if t3<1.0e-12
if t1<1.0e-12
t1 = 0;
end
if abs(t1-1)<1.0e-12
t1 = 1;
end
p_mean = t1;
p_median = t1;
p_var = 0;
hpd_interval = NaN(2,1);
p_deciles = NaN(9,1);
density = NaN;
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
else
if options_.estimation.moments_posterior_density.indicator
[p_mean, p_median, p_var, hpd_interval, p_deciles, density] = ...
posterior_moments(tmp,1,mh_conf_sig);
else
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
[p_mean, p_median, p_var, hpd_interval, p_deciles] = ...
posterior_moments(tmp,0,mh_conf_sig);
end
oo_.([TYPE, 'TheoreticalMoments']).dsge.VarianceDecomposition.Mean.(var).(exo) = p_mean;
oo_.([TYPE, 'TheoreticalMoments']).dsge.VarianceDecomposition.Median.(var).(exo) = p_median;
oo_.([TYPE, 'TheoreticalMoments']).dsge.VarianceDecomposition.Variance.(var).(exo) = p_var;