commit
40ef192e37
22
license.txt
22
license.txt
|
@ -171,17 +171,13 @@ Comment: Written by Jessica Cariboni and Francesca Campolongo
|
|||
|
||||
Files: matlab/gsa/cumplot.m
|
||||
matlab/gsa/filt_mc_.m
|
||||
matlab/gsa/gsa_plotmatrix.m
|
||||
matlab/gsa/gsa_skewness.m
|
||||
matlab/gsa/gsa_speed.m
|
||||
matlab/gsa/log_trans_.m
|
||||
matlab/gsa/map_calibration.m
|
||||
matlab/gsa/map_ident_.m
|
||||
matlab/gsa/mcf_analysis.m
|
||||
matlab/gsa/myboxplot.m
|
||||
matlab/gsa/myprctilecol.m
|
||||
matlab/gsa/prior_draw_gsa.m
|
||||
matlab/gsa/read_data.m
|
||||
matlab/gsa/redform_map.m
|
||||
matlab/gsa/redform_screen.m
|
||||
matlab/gsa/scatter_mcf.m
|
||||
|
@ -192,26 +188,10 @@ Files: matlab/gsa/cumplot.m
|
|||
matlab/gsa/stand_.m
|
||||
matlab/gsa/tcrit.m
|
||||
matlab/gsa/teff.m
|
||||
matlab/gsa/trank.m
|
||||
Copyright: 2011-2018 European Commission
|
||||
2011-2018 Dynare Team
|
||||
2011-2023 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/gsa/pick.m
|
||||
Copyright: none
|
||||
License: public-domain-jrc
|
||||
This software has been developed at the Joint Research Centre of European Commission
|
||||
by officers in the course of their official duties. This software is not subject to copyright
|
||||
protection and is in the public domain. It is an experimental system. The Joint Research Centre
|
||||
of European Commission assumes no responsibility whatsoever for its use by other parties
|
||||
and makes no guarantees, expressed or implied, about its quality, reliability, or any other
|
||||
characteristic. We would appreciate acknowledgement if the software is used.
|
||||
Comment: This file is part of GLUEWIN.
|
||||
The program has been developed by M. Ratto, European Commission, Joint Research Centre,
|
||||
Institute for the Protection and Security of The Citizen, Technological and Economic Risk Management,
|
||||
Applied Statistics, as a deliverable of the IMPACT project
|
||||
(EC Fifth Framework Programme, SCA Project, IST-1999-11313, DG-INFSO).
|
||||
|
||||
Files: matlab/optimization/simpsa.m matlab/optimization/simpsaget.m matlab/optimization/simpsaset.m
|
||||
Copyright: 2005 Henning Schmidt, FCC, henning@fcc.chalmers.se
|
||||
2006 Brecht Donckels, BIOMATH, brecht.donckels@ugent.be
|
||||
|
|
|
@ -62,7 +62,7 @@ if strcmp(options_mom_.mom.mom_method,'GMM') && options_mom_.mom.analytic_standa
|
|||
idx_nan = find(any(isnan(D)));
|
||||
if any(idx_nan)
|
||||
for i = idx_nan
|
||||
fprintf('No standard errors available for parameter %s\n',get_the_name(i,options_mom_.TeX, M_, estim_params_, options_mom_))
|
||||
fprintf('No standard errors available for parameter %s\n',get_the_name(i,options_mom_.TeX, M_, estim_params_, options_mom_.varobs))
|
||||
end
|
||||
warning('There are NaN in the analytical Jacobian of Moments. Check your bounds and/or priors, or use a different optimizer.')
|
||||
Asympt_Var = NaN(length(xparam),length(xparam));
|
||||
|
@ -86,7 +86,7 @@ else
|
|||
if nnz(info_p)==0 && nnz(info_m)==0
|
||||
D(:,i) = (oo__p.mom.model_moments - oo__m.mom.model_moments)/(2*eps_value);
|
||||
else
|
||||
problpar = get_the_name(i,options_mom_.TeX, M_, estim_params_, options_mom_);
|
||||
problpar = get_the_name(i,options_mom_.TeX, M_, estim_params_, options_mom_.varobs);
|
||||
if info_p(1)==42
|
||||
warning('method_of_moments:info','Cannot compute the Jacobian using finite differences for parameter %s due to hitting the upper bound - no standard errors available.\n',problpar)
|
||||
else
|
||||
|
|
|
@ -98,7 +98,7 @@ TeX = options_.TeX;
|
|||
|
||||
str = sprintf(' Param. \t Lower Bound (95%%) \t Mean \t Upper Bound (95%%)');
|
||||
for l=1:npar
|
||||
[name,~] = get_the_name(l,TeX,M_,estim_params_,options_);
|
||||
[name,~] = get_the_name(l,TeX,M_,estim_params_,options_.varobs);
|
||||
str = sprintf('%s\n %s \t\t %5.4f \t\t %7.5f \t\t %5.4f', str, name, lb95_xparam(l), mean_xparam(l), ub95_xparam(l));
|
||||
end
|
||||
disp([str])
|
||||
|
@ -129,7 +129,7 @@ hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
|
|||
for k=1:npar %min(nstar,npar-(plt-1)*nstar)
|
||||
subplot(ceil(sqrt(npar)),floor(sqrt(npar)),k)
|
||||
%kk = (plt-1)*nstar+k;
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
optimal_bandwidth = mh_optimal_bandwidth(distrib_param(k,:)',options_.posterior_sampler_options.dsmh.nparticles,bandwidth,kernel_function);
|
||||
[density(:,1),density(:,2)] = kernel_density_estimate(distrib_param(k,:)',number_of_grid_points,...
|
||||
options_.posterior_sampler_options.dsmh.nparticles,optimal_bandwidth,kernel_function);
|
||||
|
|
|
@ -126,7 +126,7 @@ TeX = options_.TeX;
|
|||
|
||||
str = sprintf(' Param. \t Lower Bound (95%%) \t Mean \t Upper Bound (95%%)');
|
||||
for l=1:npar
|
||||
[name,~] = get_the_name(l,TeX,M_,estim_params_,options_);
|
||||
[name,~] = get_the_name(l,TeX,M_,estim_params_,options_.varobs);
|
||||
str = sprintf('%s\n %s \t\t %5.4f \t\t %7.5f \t\t %5.4f', str, name, lb95_xparam(l), mean_xparam(l), ub95_xparam(l));
|
||||
end
|
||||
disp([str])
|
||||
|
@ -156,7 +156,7 @@ hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
|
|||
for k=1:npar %min(nstar,npar-(plt-1)*nstar)
|
||||
subplot(ceil(sqrt(npar)),floor(sqrt(npar)),k)
|
||||
%kk = (plt-1)*nstar+k;
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
optimal_bandwidth = mh_optimal_bandwidth(distrib_param(k,:)',options_.posterior_sampler_options.HSsmc.nparticles,bandwidth,kernel_function);
|
||||
[density(:,1),density(:,2)] = kernel_density_estimate(distrib_param(k,:)',number_of_grid_points,...
|
||||
options_.posterior_sampler_options.HSsmc.nparticles,optimal_bandwidth,kernel_function);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_)
|
||||
|
||||
% function PlotPosteriorDistributions()
|
||||
% oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_)
|
||||
% plots posterior distributions
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -36,7 +35,6 @@ latexDirectoryName = CheckPath('latex',M_.dname);
|
|||
graphDirectoryName = CheckPath('graphs',M_.dname);
|
||||
|
||||
TeX = options_.TeX;
|
||||
nblck = options_.mh_nblck;
|
||||
nvx = estim_params_.nvx;
|
||||
nvn = estim_params_.nvn;
|
||||
ncx = estim_params_.ncx;
|
||||
|
@ -65,8 +63,8 @@ for i=1:npar
|
|||
figunumber = figunumber+1;
|
||||
hh_fig=dyn_figure(options_.nodisplay, 'Name', figurename);
|
||||
end
|
||||
[nam,texnam] = get_the_name(i, TeX, M_, estim_params_, options_);
|
||||
[x2, f2, abscissa, dens, binf2, bsup2] = draw_prior_density(i, bayestopt_);
|
||||
[nam,texnam] = get_the_name(i, TeX, M_, estim_params_, options_.varobs);
|
||||
[x2, f2, ~, ~, binf2, bsup2] = draw_prior_density(i, bayestopt_);
|
||||
top2 = max(f2);
|
||||
if i <= nvx
|
||||
name = M_.exo_names{estim_params_.var_exo(i,1)};
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
function check_prior_bounds(xparam1,bounds,M_,estim_params_,options_,bayestopt_)
|
||||
% function check_prior_bounds(xparam1,bounds,M_,estim_params_,options_)
|
||||
% function check_prior_bounds(xparam1,bounds,M_,estim_params_,options_,bayestopt_)
|
||||
% checks the parameter vector of violations of the prior bounds
|
||||
% Inputs:
|
||||
% -xparam1 [double] vector of parameters to be estimated (initial values)
|
||||
% -bounds [vector] vector containing the lower and upper
|
||||
% bounds
|
||||
% -bounds [vector] vector containing the lower and upper bounds
|
||||
% -M_ [structure] characterizing the model.
|
||||
% -estim_params_ [structure] characterizing parameters to be estimated
|
||||
% -options_ [structure] characterizing the options
|
||||
|
@ -30,7 +29,7 @@ function check_prior_bounds(xparam1,bounds,M_,estim_params_,options_,bayestopt_)
|
|||
outside_bound_pars=find(xparam1 < bounds.lb | xparam1 > bounds.ub);
|
||||
if ~isempty(outside_bound_pars)
|
||||
for ii=1:length(outside_bound_pars)
|
||||
outside_bound_par_names{ii,1}=get_the_name(outside_bound_pars(ii),0,M_,estim_params_,options_);
|
||||
outside_bound_par_names{ii,1}=get_the_name(outside_bound_pars(ii),0,M_,estim_params_,options_.varobs);
|
||||
end
|
||||
disp_string=[outside_bound_par_names{1,:}];
|
||||
for ii=2:size(outside_bound_par_names,1)
|
||||
|
@ -41,7 +40,7 @@ end
|
|||
inadmissible_inverse_gamma_values=find(bayestopt_.pshape==4 & xparam1 == 0);
|
||||
if ~isempty(inadmissible_inverse_gamma_values)
|
||||
for ii=1:length(inadmissible_inverse_gamma_values)
|
||||
inadmissible_inverse_gamma_par_names{ii,1}=get_the_name(inadmissible_inverse_gamma_values(ii),0,M_,estim_params_,options_);
|
||||
inadmissible_inverse_gamma_par_names{ii,1}=get_the_name(inadmissible_inverse_gamma_values(ii),0,M_,estim_params_,options_.varobs);
|
||||
end
|
||||
disp_string=[inadmissible_inverse_gamma_par_names{1,:}];
|
||||
for ii=2:size(inadmissible_inverse_gamma_par_names,1)
|
||||
|
|
|
@ -71,12 +71,12 @@ param_name_tex = {};
|
|||
Ifac=NaN(nblck,npar);
|
||||
for jj = 1:npar
|
||||
if options_.TeX
|
||||
[par_name_temp, par_name_tex_temp] = get_the_name(jj, options_.TeX, M_,estim_params_, options_);
|
||||
[par_name_temp, par_name_tex_temp] = get_the_name(jj, options_.TeX, M_,estim_params_, options_.varobs);
|
||||
param_name = vertcat(param_name, par_name_temp);
|
||||
par_name_tex_temp = strrep(par_name_tex_temp,'$','');
|
||||
param_name_tex = vertcat(param_name_tex, par_name_tex_temp);
|
||||
else
|
||||
par_name_temp = get_the_name(jj, options_.TeX, M_, estim_params_, options_);
|
||||
par_name_temp = get_the_name(jj, options_.TeX, M_, estim_params_, options_.varobs);
|
||||
param_name = vertcat(param_name, par_name_temp);
|
||||
end
|
||||
Draws = GetAllPosteriorDraws(M_.dname, M_.fname, jj, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck);
|
||||
|
@ -130,11 +130,11 @@ if options_.TeX
|
|||
end
|
||||
for jj=1:npar
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp] = get_the_name(jj, options_.TeX, M_, estim_params_, options_);
|
||||
[param_name_temp, param_name_tex_temp] = get_the_name(jj, options_.TeX, M_, estim_params_, options_.varobs);
|
||||
param_name_tex = vertcat(param_name_tex, strrep(param_name_tex_temp, '$',''));
|
||||
param_name = vertcat(param_name, param_name_temp);
|
||||
else
|
||||
param_name_temp = get_the_name(jj, options_.TeX, M_,estim_params_, options_);
|
||||
param_name_temp = get_the_name(jj, options_.TeX, M_,estim_params_, options_.varobs);
|
||||
param_name = vertcat(param_name, param_name_temp);
|
||||
end
|
||||
end
|
||||
|
@ -290,7 +290,7 @@ for i = 1:pages
|
|||
boxplot = 1;
|
||||
for j = 1:npardisp % Loop over parameters %npardisp instead of 3
|
||||
k = k+1;
|
||||
[nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
for crit = 1:3% Loop over criteria
|
||||
if crit == 1
|
||||
plt1 = UDIAG(:,1,k);
|
||||
|
@ -346,7 +346,7 @@ if reste
|
|||
boxplot = 1;
|
||||
for j = 1:reste
|
||||
k = k+1;
|
||||
[nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
for crit = 1:3
|
||||
if crit == 1
|
||||
plt1 = UDIAG(:,1,k);
|
||||
|
|
|
@ -28,6 +28,25 @@ end
|
|||
|
||||
OutputDirectoryName = CheckPath('latex',M_.dname);
|
||||
|
||||
%delete dollars in label as they will be added automatically below
|
||||
begin_dollar = cellfun (@(x)startsWith(x,'$'),labels,'UniformOutput',1);
|
||||
end_dollar = cellfun (@(x)endsWith(x,'$'),labels,'UniformOutput',1);
|
||||
|
||||
if all(begin_dollar) && all(end_dollar)
|
||||
labels = cellfun(@(x)delete_dollar(x,'begin'),labels,'UniformOutput',0);
|
||||
labels = cellfun(@(x)delete_dollar(x,'end'),labels,'UniformOutput',0);
|
||||
end
|
||||
|
||||
|
||||
%delete dollars in headers as they will be added automatically below
|
||||
begin_dollar = cellfun (@(x)startsWith(x,'$'),headers,'UniformOutput',1);
|
||||
end_dollar = cellfun (@(x)endsWith(x,'$'),headers,'UniformOutput',1);
|
||||
|
||||
if all(begin_dollar) && all(end_dollar)
|
||||
headers = cellfun(@(x)delete_dollar(x,'begin'),headers,'UniformOutput',0);
|
||||
headers = cellfun(@(x)delete_dollar(x,'end'),headers,'UniformOutput',0);
|
||||
end
|
||||
|
||||
% Set width of label column
|
||||
if isempty(label_width)
|
||||
label_width = cellofchararraymaxlength(vertcat(headers{1}, labels))+2;
|
||||
|
@ -102,4 +121,12 @@ end
|
|||
fprintf(fidTeX, '\\end{longtable}\n ');
|
||||
fprintf(fidTeX, '\\end{center}\n');
|
||||
fprintf(fidTeX, '%% End of TeX file.\n');
|
||||
fclose(fidTeX);
|
||||
fclose(fidTeX);
|
||||
|
||||
function x=delete_dollar(x,position_string)
|
||||
if strcmp(position_string,'begin')
|
||||
x(1)=[];
|
||||
elseif strcmp(position_string,'end')
|
||||
x(end)=[];
|
||||
end
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ assert(size(data, 1) == length(rows), 'must have the same number of rows')
|
|||
assert(size(data, 2) == length(cols), 'must have the same number of columns')
|
||||
assert(isint(indent), 'indent must be an integer')
|
||||
|
||||
skipline(3)
|
||||
skipline(2)
|
||||
|
||||
%% Print Output
|
||||
rowstrlens = cellfun(@length, rows);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, STO_si_dREDUCEDFORM, STO_si_dMOMENTS, STO_dSPECTRUM, STO_dMINIMAL] = dynare_identification(options_ident, pdraws0)
|
||||
%function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, STO_si_dREDUCEDFORM, STO_si_dMOMENTS, STO_dSPECTRUM, STO_dMINIMAL] = dynare_identification(options_ident, pdraws0)
|
||||
function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, STO_si_dREDUCEDFORM, STO_si_dMOMENTS, STO_dSPECTRUM, STO_dMINIMAL] = dynare_identification(M_,oo_,options_,bayestopt_,estim_params_,options_ident, pdraws0)
|
||||
% [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, STO_si_dREDUCEDFORM, STO_si_dMOMENTS, STO_dSPECTRUM, STO_dMINIMAL] = dynare_identification(options_ident, pdraws0)
|
||||
% -------------------------------------------------------------------------
|
||||
% This function is called, when the user specifies identification(...); in the mod file. It prepares all identification analysis:
|
||||
% (1) set options, local and persistent variables for a new identification
|
||||
|
@ -11,6 +11,11 @@ function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, ST
|
|||
% to put identification in your mod file, otherwise the preprocessor won't provide all necessary objects
|
||||
% =========================================================================
|
||||
% INPUTS
|
||||
% * M_ [structure] Matlab's structure describing the model
|
||||
% * oo_ [structure] Matlab's structure describing the results
|
||||
% * options_ [structure] Matlab's structure describing the current options
|
||||
% * bayestopt_ [structure] describing the priors
|
||||
% * estim_params_ [structure] characterizing parameters to be estimated
|
||||
% * options_ident [structure] identification options
|
||||
% * pdraws0 [SampleSize by totparam_nbr] optional: matrix of MC sample of model parameters
|
||||
% -------------------------------------------------------------------------
|
||||
|
@ -65,9 +70,6 @@ function [pdraws, STO_REDUCEDFORM, STO_MOMENTS, STO_DYNAMIC, STO_si_dDYNAMIC, ST
|
|||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
|
||||
global M_ options_ oo_ bayestopt_ estim_params_
|
||||
|
||||
store_options_ = options_; % store options to restore them at the end
|
||||
fname = M_.fname; %model name
|
||||
dname = M_.dname; %model name
|
||||
|
||||
|
@ -255,11 +257,11 @@ if options_ident.gsa_sample_file
|
|||
end
|
||||
pdraws0 = [lpmatx lpmat(istable,:)];
|
||||
clear lpmat lpmat0 istable;
|
||||
elseif nargin==1
|
||||
elseif nargin==6
|
||||
pdraws0=[];
|
||||
end
|
||||
external_sample=0;
|
||||
if nargin==2 || ~isempty(pdraws0)
|
||||
if nargin==7 || ~isempty(pdraws0)
|
||||
% change settings if there is an external sample provided as input argument
|
||||
options_ident.prior_mc = size(pdraws0,1);
|
||||
options_ident.load_ident_files = 0;
|
||||
|
@ -361,11 +363,11 @@ if prior_exist % use estimated_params block
|
|||
name_tex = cell(totparam_nbr,1); %initialize cell for TeX parameter names
|
||||
for jj=1:totparam_nbr
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name_tex{jj,1} =param_name_tex_temp;
|
||||
name{jj,1} = param_name_temp; %ordering corresponds to estimated_params
|
||||
else
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name{jj,1} = param_name_temp; %ordering corresponds to estimated_params
|
||||
end
|
||||
end
|
||||
|
@ -469,7 +471,7 @@ if iload <=0
|
|||
options_ident.tittxt = parameters; %title text for graphs and figures
|
||||
% perform identification analysis for single point
|
||||
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, derivatives_info_point, info, error_indicator_point] = ...
|
||||
identification_analysis(params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end implies initialization of persistent variables
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end implies initialization of persistent variables
|
||||
if info(1)~=0
|
||||
% there are errors in the solution algorithm
|
||||
message = get_error_message(info,options_);
|
||||
|
@ -486,7 +488,7 @@ if iload <=0
|
|||
options_ident.tittxt = 'Random_prior_params'; %title text for graphs and figures
|
||||
% perform identification analysis
|
||||
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, derivatives_info_point, info, error_indicator_point] = ...
|
||||
identification_analysis(params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1);
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1);
|
||||
end
|
||||
end
|
||||
if info(1)
|
||||
|
@ -514,7 +516,8 @@ if iload <=0
|
|||
disp_identification(params, ide_reducedform_point, ide_moments_point, ide_spectrum_point, ide_minimal_point, name, options_ident);
|
||||
if ~options_ident.no_identification_strength && ~options_.nograph && ~error_indicator_point.identification_strength && ~error_indicator_point.identification_moments
|
||||
% plot (i) identification strength and sensitivity measure based on the moment information matrix and (ii) plot advanced analysis graphs
|
||||
plot_identification(params, ide_moments_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, options_ident.advanced, parameters, name, IdentifDirectoryName, parameters_TeX, name_tex);
|
||||
plot_identification(M_,params, ide_moments_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, options_ident.advanced, parameters, name, ...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, parameters_TeX, name_tex);
|
||||
end
|
||||
|
||||
if SampleSize > 1
|
||||
|
@ -540,7 +543,7 @@ if iload <=0
|
|||
options_ident.tittxt = []; % clear title text for graphs and figures
|
||||
% run identification analysis
|
||||
[ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, ide_derivatives_info, info, error_indicator] = ...
|
||||
identification_analysis(params, indpmodel, indpstderr, indpcorr, options_MC, dataset_info, prior_exist, 0); % the 0 implies that we do not initialize persistent variables anymore
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_MC, dataset_info, prior_exist, 0); % the 0 implies that we do not initialize persistent variables anymore
|
||||
|
||||
if iteration==0 && info(1)==0 % preallocate storage in the first admissable run
|
||||
delete([IdentifDirectoryName '/' fname '_identif_*.mat']) % delete previously saved results
|
||||
|
@ -783,6 +786,19 @@ if iload <=0
|
|||
else
|
||||
maxrun_dMINIMAL = 0;
|
||||
end
|
||||
si_dDYNAMICnorm=NaN(max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL]),size(STO_si_dDYNAMIC,2));
|
||||
if ~options_MC.no_identification_reducedform
|
||||
si_dREDUCEDFORMnorm=NaN(max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL]),size(STO_si_dREDUCEDFORM,2));
|
||||
end
|
||||
if ~options_MC.no_identification_moments
|
||||
si_dMOMENTSnorm=NaN(max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL]),size(STO_si_dMOMENTS,2));
|
||||
end
|
||||
if ~options_MC.no_identification_spectrum
|
||||
dSPECTRUMnorm=NaN(max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL]),size(STO_dSPECTRUM,2));
|
||||
end
|
||||
if ~options_MC.no_identification_minimal
|
||||
dMINIMALnorm=NaN(max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL]),size(STO_dMINIMAL,2));
|
||||
end
|
||||
for irun=1:max([maxrun_dDYNAMIC, maxrun_dREDUCEDFORM, maxrun_dMOMENTS, maxrun_dSPECTRUM, maxrun_dMINIMAL])
|
||||
iter=iter+1;
|
||||
% note that this is not the same si_dDYNAMICnorm as computed in identification_analysis
|
||||
|
@ -863,7 +879,8 @@ if iload
|
|||
disp_identification(ide_hess_point.params, ide_reducedform_point, ide_moments_point, ide_spectrum_point, ide_minimal_point, name, options_ident);
|
||||
if ~options_.nograph && ~error_indicator_point.identification_strength && ~error_indicator_point.identification_moments
|
||||
% plot (i) identification strength and sensitivity measure based on the sample information matrix and (ii) advanced analysis graphs
|
||||
plot_identification(ide_hess_point.params, ide_moments_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, options_ident.advanced, parameters, name, IdentifDirectoryName, [], name_tex);
|
||||
plot_identification(M_,ide_hess_point.params, ide_moments_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, options_ident.advanced, parameters, name, ...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, [], name_tex);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -877,7 +894,8 @@ if SampleSize > 1
|
|||
options_ident.advanced = advanced0; % reset advanced setting
|
||||
if ~options_.nograph && isfield(ide_hess_point,'ide_strength_dMOMENTS')
|
||||
% plot (i) identification strength and sensitivity measure based on the sample information matrix and (ii) advanced analysis graphs
|
||||
plot_identification(pdraws, IDE_MOMENTS, ide_hess_point, IDE_REDUCEDFORM, IDE_DYNAMIC, options_ident.advanced, 'MC sample ', name, IdentifDirectoryName, [], name_tex);
|
||||
plot_identification(M_, pdraws, IDE_MOMENTS, ide_hess_point, IDE_REDUCEDFORM, IDE_DYNAMIC, options_ident.advanced, 'MC sample ', name, ...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, [], name_tex);
|
||||
end
|
||||
%advanced display and plots for MC Sample, i.e. look at draws with highest/lowest condition number
|
||||
if options_ident.advanced
|
||||
|
@ -894,7 +912,7 @@ if SampleSize > 1
|
|||
if ~iload
|
||||
options_ident.tittxt = tittxt; %title text for graphs and figures
|
||||
[ide_moments_max, ide_spectrum_max, ide_minimal_max, ide_hess_max, ide_reducedform_max, ide_dynamic_max, derivatives_info_max, info_max, error_indicator_max] = ...
|
||||
identification_analysis(pdraws(jmax,:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end initializes some persistent variables
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,pdraws(jmax,:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end initializes some persistent variables
|
||||
save([IdentifDirectoryName '/' fname '_identif.mat'], 'ide_hess_max', 'ide_moments_max', 'ide_spectrum_max', 'ide_minimal_max','ide_reducedform_max', 'ide_dynamic_max', 'jmax', '-append');
|
||||
end
|
||||
advanced0 = options_ident.advanced; options_ident.advanced = 1; % make sure advanced setting is on
|
||||
|
@ -902,7 +920,8 @@ if SampleSize > 1
|
|||
options_ident.advanced = advanced0; %reset advanced setting
|
||||
if ~options_.nograph && ~error_indicator_max.identification_strength && ~error_indicator_max.identification_moments
|
||||
% plot (i) identification strength and sensitivity measure based on the sample information matrix and (ii) advanced analysis graphs
|
||||
plot_identification(pdraws(jmax,:), ide_moments_max, ide_hess_max, ide_reducedform_max, ide_dynamic_max, 1, tittxt, name, IdentifDirectoryName, tittxt, name_tex);
|
||||
plot_identification(M_, pdraws(jmax,:), ide_moments_max, ide_hess_max, ide_reducedform_max, ide_dynamic_max, 1, tittxt, name, ...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, tittxt, name_tex);
|
||||
end
|
||||
|
||||
% SMALLEST condition number
|
||||
|
@ -911,8 +930,8 @@ if SampleSize > 1
|
|||
fprintf('Testing %s.\n',tittxt);
|
||||
if ~iload
|
||||
options_ident.tittxt = tittxt; %title text for graphs and figures
|
||||
[ide_moments_min, ide_spectrum_min, ide_minimal_min, ide_hess_min, ide_reducedform_min, ide_dynamic_min, derivatives_info_min, info_min, error_indicator_min] = ...
|
||||
identification_analysis(pdraws(jmin,:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end initializes persistent variables
|
||||
[ide_moments_min, ide_spectrum_min, ide_minimal_min, ide_hess_min, ide_reducedform_min, ide_dynamic_min, ~, ~, error_indicator_min] = ...
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,pdraws(jmin,:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end initializes persistent variables
|
||||
save([IdentifDirectoryName '/' fname '_identif.mat'], 'ide_hess_min', 'ide_moments_min','ide_spectrum_min','ide_minimal_min','ide_reducedform_min', 'ide_dynamic_min', 'jmin', '-append');
|
||||
end
|
||||
advanced0 = options_ident.advanced; options_ident.advanced = 1; % make sure advanced setting is on
|
||||
|
@ -920,7 +939,8 @@ if SampleSize > 1
|
|||
options_ident.advanced = advanced0; %reset advanced setting
|
||||
if ~options_.nograph && ~error_indicator_min.identification_strength && ~error_indicator_min.identification_moments
|
||||
% plot (i) identification strength and sensitivity measure based on the sample information matrix and (ii) advanced analysis graphs
|
||||
plot_identification(pdraws(jmin,:),ide_moments_min,ide_hess_min,ide_reducedform_min,ide_dynamic_min,1,tittxt,name,IdentifDirectoryName,tittxt,name_tex);
|
||||
plot_identification(M_, pdraws(jmin,:),ide_moments_min,ide_hess_min,ide_reducedform_min,ide_dynamic_min,1,tittxt,name,...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, tittxt,name_tex);
|
||||
end
|
||||
% reset nodisplay option
|
||||
options_.nodisplay = store_nodisplay;
|
||||
|
@ -934,14 +954,15 @@ if SampleSize > 1
|
|||
if ~iload
|
||||
options_ident.tittxt = tittxt; %title text for graphs and figures
|
||||
[ide_moments_(j), ide_spectrum_(j), ide_minimal_(j), ide_hess_(j), ide_reducedform_(j), ide_dynamic_(j), derivatives_info_(j), info_resolve, error_indicator_j] = ...
|
||||
identification_analysis(pdraws(jcrit(j),:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1);
|
||||
identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,pdraws(jcrit(j),:), indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1);
|
||||
end
|
||||
advanced0 = options_ident.advanced; options_ident.advanced = 1; %make sure advanced setting is on
|
||||
disp_identification(pdraws(jcrit(j),:), ide_reducedform_(j), ide_moments_(j), ide_spectrum_(j), ide_minimal_(j), name, options_ident);
|
||||
options_ident.advanced = advanced0; % reset advanced
|
||||
if ~options_.nograph && ~error_indicator_j.identification_strength && ~error_indicator_j.identification_moments
|
||||
% plot (i) identification strength and sensitivity measure based on the sample information matrix and (ii) advanced analysis graphs
|
||||
plot_identification(pdraws(jcrit(j),:), ide_moments_(j), ide_hess_(j), ide_reducedform_(j), ide_dynamic_(j), 1, tittxt, name, IdentifDirectoryName, tittxt, name_tex);
|
||||
plot_identification(M_, pdraws(jcrit(j),:), ide_moments_(j), ide_hess_(j), ide_reducedform_(j), ide_dynamic_(j), 1, tittxt, name, ...
|
||||
IdentifDirectoryName, M_.fname, options_, estim_params_, bayestopt_, tittxt, name_tex);
|
||||
end
|
||||
end
|
||||
if ~iload
|
||||
|
@ -957,6 +978,4 @@ end
|
|||
%reset warning state
|
||||
warning_config;
|
||||
|
||||
fprintf('\n==== Identification analysis completed ====\n\n')
|
||||
|
||||
options_ = store_options_; %restore options set
|
||||
fprintf('\n==== Identification analysis completed ====\n\n')
|
|
@ -1,10 +1,19 @@
|
|||
function x0=dynare_sensitivity(options_gsa)
|
||||
function x0=dynare_sensitivity(M_,oo_,options_,bayestopt_,estim_params_,options_gsa)
|
||||
% x0=dynare_sensitivity(M_,oo_,options_,bayestopt_,estim_params_,options_gsa)
|
||||
% Frontend to the Sensitivity Analysis Toolbox for DYNARE
|
||||
% Inputs:
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
% - oo_ [structure] Matlab's structure describing the results
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - options_gsa [structure] Matlab's structure describing the GSA options
|
||||
%
|
||||
% Reference:
|
||||
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
|
||||
% M. Ratto (2008), Analysing DSGE Models with Global Sensitivity Analysis,
|
||||
% Computational Economics (2008), 31, pp. 115–139
|
||||
|
||||
% Copyright © 2008-2018 Dynare Team
|
||||
% Copyright © 2008-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -21,14 +30,11 @@ function x0=dynare_sensitivity(options_gsa)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ options_ oo_ bayestopt_ estim_params_
|
||||
|
||||
if options_.dsge_var
|
||||
error('Identification does not support DSGE-VARs at the current stage')
|
||||
end
|
||||
|
||||
fname_ = M_.fname;
|
||||
lgy_ = M_.endo_names;
|
||||
x0=[];
|
||||
|
||||
% check user defined options
|
||||
|
@ -43,7 +49,6 @@ end
|
|||
|
||||
if isfield(options_gsa,'morris') && options_gsa.morris==1
|
||||
if isfield(options_gsa,'identification') && options_gsa.identification==0
|
||||
% options_gsa.redform=1;
|
||||
end
|
||||
if isfield(options_gsa,'ppost') && options_gsa.ppost
|
||||
error('sensitivity:: Morris is incompatible with posterior sampling')
|
||||
|
@ -89,9 +94,6 @@ if options_.order~=1
|
|||
options_.order = 1;
|
||||
end
|
||||
|
||||
original_prior_trunc = options_.prior_trunc;
|
||||
original_qz_criterium = options_.qz_criterium;
|
||||
|
||||
if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse
|
||||
if isempty(options_gsa.datafile) && options_gsa.rmse
|
||||
disp('The data file and all relevant estimation options ')
|
||||
|
@ -130,7 +132,7 @@ if ~isempty(options_gsa.datafile) || isempty(bayestopt_) || options_gsa.rmse
|
|||
options_.mode_compute = 0;
|
||||
options_.filtered_vars = 1;
|
||||
options_.plot_priors = 0;
|
||||
[dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_, bayestopt_] = ...
|
||||
[dataset_,dataset_info,~,~, M_, options_, oo_, estim_params_, bayestopt_] = ...
|
||||
dynare_estimation_init(M_.endo_names, fname_, 1, M_, options_, oo_, estim_params_, bayestopt_);
|
||||
% computes a first linear solution to set up various variables
|
||||
else
|
||||
|
@ -146,7 +148,7 @@ if M_.exo_nbr==0
|
|||
error('dynare_sensitivity does not support having no varexo in the model. As a workaround you could define a dummy exogenous variable.')
|
||||
end
|
||||
|
||||
[make,my,day,punk,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
[~,~,~,~,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
|
||||
options_gsa = set_default_option(options_gsa,'identification',0);
|
||||
if options_gsa.identification
|
||||
|
@ -166,7 +168,6 @@ if options_gsa.identification
|
|||
options_.options_ident.load_ident_files = options_gsa.load_ident_files;
|
||||
options_.options_ident.useautocorr = options_gsa.useautocorr;
|
||||
options_.options_ident.ar = options_gsa.ar;
|
||||
options_ident=options_.options_ident;
|
||||
else
|
||||
options_ident=[];
|
||||
options_ident = set_default_option(options_ident,'load_ident_files',options_gsa.load_ident_files);
|
||||
|
@ -193,7 +194,6 @@ options_gsa = set_default_option(options_gsa,'load_stab',0);
|
|||
options_gsa = set_default_option(options_gsa,'alpha2_stab',0);
|
||||
options_gsa = set_default_option(options_gsa,'pvalue_ks',0.001);
|
||||
options_gsa = set_default_option(options_gsa,'pvalue_corr',1.e-5);
|
||||
%options_gsa = set_default_option(options_gsa,'load_mh',0);
|
||||
% REDFORM mapping
|
||||
options_gsa = set_default_option(options_gsa,'redform',0);
|
||||
options_gsa = set_default_option(options_gsa,'load_redform',0);
|
||||
|
@ -202,8 +202,29 @@ options_gsa = set_default_option(options_gsa,'threshold_redform',[]);
|
|||
options_gsa = set_default_option(options_gsa,'ksstat_redform',0.001);
|
||||
options_gsa = set_default_option(options_gsa,'alpha2_redform',1.e-5);
|
||||
options_gsa = set_default_option(options_gsa,'namendo',{});
|
||||
options_gsa = set_default_option(options_gsa,'namlagendo',[]);
|
||||
options_gsa = set_default_option(options_gsa,'namlagendo',{});
|
||||
options_gsa = set_default_option(options_gsa,'namexo',{});
|
||||
options_gsa = set_default_option(options_gsa,'namendo_tex',{});
|
||||
options_gsa = set_default_option(options_gsa,'namlagendo_tex',{});
|
||||
options_gsa = set_default_option(options_gsa,'namexo_tex',{});
|
||||
if strmatch(':',options_gsa.namendo,'exact')
|
||||
options_gsa.namendo = M_.endo_names(1:M_.orig_endo_nbr);
|
||||
end
|
||||
if strmatch(':',options_gsa.namexo,'exact')
|
||||
options_gsa.namexo = M_.exo_names;
|
||||
end
|
||||
if strmatch(':',options_gsa.namlagendo,'exact')
|
||||
options_gsa.namlagendo = M_.endo_names(1:M_.orig_endo_nbr);
|
||||
end
|
||||
|
||||
if options_.TeX
|
||||
[~,Locb]=ismember(options_gsa.namendo,M_.endo_names);
|
||||
options_gsa.namendo_tex=cellfun(@(x) horzcat('$', x, '$'), M_.endo_names_tex(Locb), 'UniformOutput', false);
|
||||
[~,Locb]=ismember(options_gsa.namlagendo,M_.endo_names);
|
||||
options_gsa.namlagendo_tex=cellfun(@(x) horzcat('$', x, '$'), M_.endo_names_tex(Locb), 'UniformOutput', false);
|
||||
[~,Locb]=ismember(options_gsa.namexo,M_.exo_names);
|
||||
options_gsa.namexo_tex=cellfun(@(x) horzcat('$', x, '$'), M_.exo_names_tex(Locb), 'UniformOutput', false);
|
||||
end
|
||||
% RMSE mapping
|
||||
options_gsa = set_default_option(options_gsa,'load_rmse',0);
|
||||
options_gsa = set_default_option(options_gsa,'lik_only',0);
|
||||
|
@ -212,8 +233,9 @@ options_gsa = set_default_option(options_gsa,'var_rmse', options_.varobs);
|
|||
options_gsa.var_rmse_tex={};
|
||||
for ii=1:length(options_gsa.var_rmse)
|
||||
temp_name = M_.endo_names_tex{strmatch(options_gsa.var_rmse{ii}, M_.endo_names, 'exact')};
|
||||
options_gsa.var_rmse_tex = vertcat(options_gsa.var_rmse_tex, temp_name);
|
||||
options_gsa.var_rmse_tex = vertcat(options_gsa.var_rmse_tex, ['$' temp_name '$']);
|
||||
end
|
||||
options_gsa.varobs_tex = cellfun(@(x) horzcat('$', x, '$'), M_.endo_names_tex(options_.varobs_id), 'UniformOutput', false);
|
||||
options_gsa = set_default_option(options_gsa,'pfilt_rmse', 0.1);
|
||||
options_gsa = set_default_option(options_gsa,'istart_rmse', options_.presample+1);
|
||||
options_gsa = set_default_option(options_gsa,'alpha_rmse', 0.001);
|
||||
|
@ -245,31 +267,22 @@ if options_gsa.morris==1
|
|||
options_gsa.pprior=1;
|
||||
end
|
||||
options_gsa.ppost=0;
|
||||
%options_gsa.stab=1;
|
||||
options_gsa.glue=0;
|
||||
options_gsa.rmse=0;
|
||||
options_gsa.load_rmse=0;
|
||||
options_gsa.alpha2_stab=1;
|
||||
options_gsa.pvalue_ks=0;
|
||||
options_gsa.pvalue_corr=0;
|
||||
% if options_gsa.morris==3,
|
||||
% options_gsa = set_default_option(options_gsa,'Nsam',256);
|
||||
% OutputDirectoryName = CheckPath('gsa/identif',M_.dname);
|
||||
% else
|
||||
OutputDirectoryName = CheckPath('gsa/screen',M_.dname);
|
||||
% end
|
||||
else
|
||||
OutputDirectoryName = CheckPath('gsa',M_.dname);
|
||||
end
|
||||
|
||||
% options_.opt_gsa = options_gsa;
|
||||
|
||||
if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform) && options_gsa.pprior
|
||||
filetoload=[OutputDirectoryName '/' fname_ '_prior.mat'];
|
||||
if ~exist(filetoload,'file')
|
||||
disp([filetoload,' not found!'])
|
||||
disp(['You asked to load a non existent analysis'])
|
||||
%options_gsa.load_stab=0;
|
||||
disp('You asked to load a non existent analysis')
|
||||
return
|
||||
else
|
||||
if isempty(strmatch('bkpprior',who('-file', filetoload),'exact'))
|
||||
|
@ -293,7 +306,7 @@ if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform)
|
|||
end
|
||||
|
||||
if options_gsa.stab && ~options_gsa.ppost
|
||||
x0 = stab_map_(OutputDirectoryName,options_gsa);
|
||||
x0 = stab_map_(OutputDirectoryName,options_gsa,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
if isempty(x0)
|
||||
skipline()
|
||||
disp('Sensitivity computations stopped: no parameter set provided a unique solution')
|
||||
|
@ -301,16 +314,13 @@ if options_gsa.stab && ~options_gsa.ppost
|
|||
end
|
||||
end
|
||||
|
||||
% reduced form
|
||||
% redform_map(namendo, namlagendo, namexo, icomp, pprior, ilog, threshold)
|
||||
|
||||
options_.opt_gsa = options_gsa;
|
||||
if ~isempty(options_gsa.moment_calibration) || ~isempty(options_gsa.irf_calibration)
|
||||
map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_,bayestopt_);
|
||||
end
|
||||
|
||||
if options_gsa.identification
|
||||
map_ident_(OutputDirectoryName,options_gsa);
|
||||
map_ident_(OutputDirectoryName,options_gsa,M_,oo_,options_,estim_params_,bayestopt_);
|
||||
end
|
||||
|
||||
if options_gsa.redform && ~isempty(options_gsa.namendo)
|
||||
|
@ -318,7 +328,7 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
|
|||
filnam = dir([M_.dname filesep 'metropolis' filesep '*param_irf*.mat']);
|
||||
lpmat=[];
|
||||
for j=1:length(filnam)
|
||||
load ([M_.dname filesep 'metropolis' filesep M_.fname '_param_irf' int2str(j) '.mat'])
|
||||
load ([M_.dname filesep 'metropolis' filesep M_.fname '_param_irf' int2str(j) '.mat'],'stock')
|
||||
lpmat=[lpmat; stock];
|
||||
end
|
||||
clear stock
|
||||
|
@ -336,20 +346,10 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
|
|||
save([OutputDirectoryName filesep M_.fname '_mc.mat'],'lpmat','lpmat0','istable','iunstable','iwrong','iindeterm')
|
||||
options_gsa.load_stab=1;
|
||||
|
||||
x0 = stab_map_(OutputDirectoryName,options_gsa);
|
||||
x0 = stab_map_(OutputDirectoryName,options_gsa,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
end
|
||||
if strmatch(':',options_gsa.namendo,'exact')
|
||||
options_gsa.namendo = M_.endo_names(1:M_.orig_endo_nbr);
|
||||
end
|
||||
if strmatch(':',options_gsa.namexo,'exact')
|
||||
options_gsa.namexo = M_.exo_names;
|
||||
end
|
||||
if strmatch(':',options_gsa.namlagendo,'exact')
|
||||
options_gsa.namlagendo = M_.endo_names(1:M_.orig_endo_nbr);
|
||||
end
|
||||
% options_.opt_gsa = options_gsa;
|
||||
if options_gsa.morris==1
|
||||
redform_screen(OutputDirectoryName,options_gsa);
|
||||
redform_screen(OutputDirectoryName,options_gsa, estim_params_, M_, oo_.dr, options_, bayestopt_);
|
||||
else
|
||||
% check existence of the SS_ANOVA toolbox
|
||||
if isempty(options_gsa.threshold_redform) && ~(exist('gsa_sdp','file')==6 || exist('gsa_sdp','file')==2)
|
||||
|
@ -360,11 +360,10 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
|
|||
fprintf('After obtaining the files, you need to unpack them and set a Matlab Path to those files.\n')
|
||||
error('SS-ANOVA-R Toolbox missing!')
|
||||
end
|
||||
redform_map(OutputDirectoryName,options_gsa);
|
||||
redform_map(OutputDirectoryName,options_gsa,M_,estim_params_,options_,bayestopt_,oo_);
|
||||
end
|
||||
end
|
||||
% RMSE mapping
|
||||
% function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2)
|
||||
options_.opt_gsa = options_gsa;
|
||||
if options_gsa.rmse
|
||||
if ~options_gsa.ppost
|
||||
|
@ -391,7 +390,6 @@ if options_gsa.rmse
|
|||
options_.forecast=0;
|
||||
options_.filtered_vars=0;
|
||||
end
|
||||
% dynare_MC([],OutputDirectoryName,data,rawdata,data_info);
|
||||
if options_gsa.pprior
|
||||
TmpDirectoryName = ([M_.dname filesep 'gsa' filesep 'prior']);
|
||||
else
|
||||
|
@ -408,37 +406,18 @@ if options_gsa.rmse
|
|||
delete([TmpDirectoryName filesep filparam(j).name]);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
oo_=prior_posterior_statistics('gsa',dataset_, dataset_info,M_,oo_,options_,estim_params_,bayestopt_,'gsa::mcmc');
|
||||
if options_.bayesian_irf
|
||||
oo_=PosteriorIRF('gsa',options_,estim_params_,oo_,M_,bayestopt_,dataset_,dataset_info,'gsa::mcmc');
|
||||
end
|
||||
options_gsa.load_rmse=0;
|
||||
% else
|
||||
% if options_gsa.load_rmse==0,
|
||||
% disp('You already saved a MC filter/smoother analysis ')
|
||||
% disp('Do you want to overwrite ?')
|
||||
% pause;
|
||||
% if options_gsa.pprior
|
||||
% delete([OutputDirectoryName,'/',fname_,'_prior_*.mat'])
|
||||
% else
|
||||
% delete([OutputDirectoryName,'/',fname_,'_mc_*.mat'])
|
||||
% end
|
||||
% dynare_MC([],OutputDirectoryName);
|
||||
% options_gsa.load_rmse=0;
|
||||
% end
|
||||
|
||||
end
|
||||
end
|
||||
clear a;
|
||||
% filt_mc_(OutputDirectoryName,data_info);
|
||||
filt_mc_(OutputDirectoryName,options_gsa,dataset_,dataset_info);
|
||||
filt_mc_(OutputDirectoryName,options_gsa,dataset_,dataset_info,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
end
|
||||
options_.opt_gsa = options_gsa;
|
||||
options_.prior_trunc=original_prior_trunc;
|
||||
options_.qz_criterium=original_qz_criterium ;
|
||||
|
||||
|
||||
if options_gsa.glue
|
||||
dr_ = oo_.dr;
|
||||
|
@ -453,11 +432,10 @@ if options_gsa.glue
|
|||
end
|
||||
end
|
||||
if ~exist('x','var')
|
||||
disp(['No RMSE analysis is available for current options'])
|
||||
disp(['No GLUE file prepared'])
|
||||
disp('No RMSE analysis is available for current options')
|
||||
disp('No GLUE file prepared')
|
||||
return,
|
||||
end
|
||||
nruns=size(x,1);
|
||||
gend = options_.nobs;
|
||||
rawdata = read_variables(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
|
||||
rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
|
||||
|
@ -465,28 +443,20 @@ if options_gsa.glue
|
|||
rawdata = log(rawdata);
|
||||
end
|
||||
if options_.prefilter == 1
|
||||
%data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
|
||||
data = transpose(rawdata-ones(gend,1)*mean(rawdata,1));
|
||||
else
|
||||
data = transpose(rawdata);
|
||||
end
|
||||
|
||||
Obs.data = data;
|
||||
Obs.time = [1:gend];
|
||||
Obs.time = 1:gend;
|
||||
Obs.num = gend;
|
||||
for j=1:length(options_.varobs)
|
||||
Obs.name{j} = options_.varobs{j};
|
||||
vj = options_.varobs{j};
|
||||
|
||||
jxj = strmatch(vj,lgy_(dr_.order_var),'exact');
|
||||
js = strmatch(vj,lgy_,'exact');
|
||||
jxj = strmatch(vj,M_.endo_names(dr_.order_var),'exact');
|
||||
if ~options_gsa.ppost
|
||||
% y0=zeros(gend+1,nruns);
|
||||
% nb = size(stock_filter,3);
|
||||
% y0 = squeeze(stock_filter(:,jxj,:)) + ...
|
||||
% kron(stock_ys(js,:),ones(size(stock_filter,1),1));
|
||||
% Out(j).data = y0';
|
||||
% Out(j).time = [1:size(y0,1)];
|
||||
Out(j).data = jxj;
|
||||
Out(j).time = [pwd,'/',OutputDirectoryName];
|
||||
else
|
||||
|
@ -500,17 +470,7 @@ if options_gsa.glue
|
|||
Lik(j).isam = 1;
|
||||
Lik(j).data = rmse_MC(:,j)';
|
||||
|
||||
if ~options_gsa.ppost
|
||||
% y0 = squeeze(stock_smooth(:,jxj,:)) + ...
|
||||
% kron(stock_ys(js,:),ones(size(stock_smooth,1),1));
|
||||
% Out1(j).name = vj;
|
||||
% Out1(j).ini = 'yes';
|
||||
% Out1(j).time = [1:size(y0,1)];
|
||||
% Out1(j).data = y0';
|
||||
Out1=Out;
|
||||
else
|
||||
Out1=Out;
|
||||
end
|
||||
Out1=Out;
|
||||
ismoo(j)=jxj;
|
||||
|
||||
end
|
||||
|
@ -520,10 +480,6 @@ if options_gsa.glue
|
|||
jsmoo=jsmoo+1;
|
||||
vj = M_.endo_names{dr_.order_var(j)};
|
||||
if ~options_gsa.ppost
|
||||
% y0 = squeeze(stock_smooth(:,j,:)) + ...
|
||||
% kron(stock_ys(j,:),ones(size(stock_smooth,1),1));
|
||||
% Out1(jsmoo).time = [1:size(y0,1)];
|
||||
% Out1(jsmoo).data = y0';
|
||||
Out1(jsmoo).data = j;
|
||||
Out1(jsmoo).time = [pwd,'/',OutputDirectoryName];
|
||||
else
|
||||
|
@ -546,36 +502,24 @@ if options_gsa.glue
|
|||
end
|
||||
Sam.name = bayestopt_.name;
|
||||
Sam.dim = [size(x) 0];
|
||||
Sam.data = [x];
|
||||
Sam.data = x;
|
||||
|
||||
Rem.id = 'Original';
|
||||
Rem.ind= [1:size(x,1)];
|
||||
Rem.ind= 1:size(x,1);
|
||||
|
||||
Info.dynare=M_.fname;
|
||||
Info.order_var=dr_.order_var;
|
||||
Out=Out1;
|
||||
if options_gsa.ppost
|
||||
% Info.dynare=M_.fname;
|
||||
% Info.order_var=dr_.order_var;
|
||||
% Out=Out1;
|
||||
Info.TypeofSample='post';
|
||||
save([OutputDirectoryName,'/',fname_,'_glue_post.mat'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem','Info', 'Exo')
|
||||
%save([fname_,'_post_glue_smooth'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem','Info')
|
||||
|
||||
else
|
||||
if options_gsa.pprior
|
||||
Info.TypeofSample='prior';
|
||||
save([OutputDirectoryName,'/',fname_,'_glue_prior.mat'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem','Info', 'Exo')
|
||||
% save([OutputDirectoryName,'/',fname_,'_prior_glue'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem')
|
||||
% Out=Out1;
|
||||
% save([OutputDirectoryName,'/',fname_,'_prior_glue_smooth'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem')
|
||||
else
|
||||
Info.TypeofSample='mc';
|
||||
save([OutputDirectoryName,'/',fname_,'_glue_mc.mat'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem','Info', 'Exo')
|
||||
% save([OutputDirectoryName,'/',fname_,'_mc_glue'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem')
|
||||
% Out=Out1;
|
||||
% save([OutputDirectoryName,'/',fname_,'_mc_glue_smooth'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function fjac = fjaco(f,x,varargin)
|
||||
|
||||
% fjac = fjaco(f,x,varargin)
|
||||
% FJACO Computes two-sided finite difference Jacobian
|
||||
% USAGE
|
||||
% fjac = fjaco(f,x,P1,P2,...)
|
||||
|
@ -57,7 +57,7 @@ feval(f,x,varargin{:});
|
|||
%Auxiliary functions
|
||||
function disp_info_error_identification_perturbation(info,j)
|
||||
% there are errors in the solution algorithm
|
||||
probl_par = get_the_name(j,varargin{4}.TeX,varargin{3},varargin{2},varargin{4});
|
||||
probl_par = get_the_name(j,varargin{4}.TeX,varargin{3},varargin{2},varargin{4}.varobs);
|
||||
skipline()
|
||||
message = get_error_message(info,varargin{4});
|
||||
fprintf('Parameter error in numerical two-sided difference method:\n')
|
||||
|
|
|
@ -1,46 +1,26 @@
|
|||
function [nam, texnam] = get_the_name(k, TeX, M_, estim_params_, options_)
|
||||
function [nam, texnam] = get_the_name(k, TeX, M_, estim_params_, varobs)
|
||||
% [nam, texnam] = get_the_name(k, TeX, M_, estim_params_, varobs)
|
||||
% Returns name of estimated parameter number k, following the internal ordering of
|
||||
% the estimated parameters.
|
||||
% Inputs:
|
||||
% - k [integer] parameter number.
|
||||
% - TeX [bool] if false, texnam is not returned (empty matrix)
|
||||
% - M_ [structure] model
|
||||
% - estim_params_ [structure] describing the estimated parameters
|
||||
% - varobs [cell] name of observed variables
|
||||
%
|
||||
% Outputs
|
||||
% - nam [char] internal name of the variable
|
||||
% - texnam [char] TeX name of the same variable (if defined in the mod file)
|
||||
%
|
||||
% This function is called by:
|
||||
% get_prior_info, mcmc_diagnostics, mode_check, PlotPosteriorDistributions, plot_priors
|
||||
%
|
||||
% This function calls:
|
||||
% None.
|
||||
%
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {[@var{nam},@var{texnam}] =} get_the_name (@var{k},@var{TeX},@var{M_},@var{estim_params_},@var{options_})
|
||||
%! @anchor{get_the_name}
|
||||
%! @sp 1
|
||||
%! Returns the name of the estimated parameter number @var{k}, following the internal ordering of the estimated parameters.
|
||||
%! @sp 2
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item k
|
||||
%! Integer scalar, parameter number.
|
||||
%! @item TeX
|
||||
%! Integer scalar, if @var{TeX}==0 then @var{texnam} is not returned (empty matrix).
|
||||
%! @item M_
|
||||
%! Matlab's structure describing the model (initialized by @code{dynare}).
|
||||
%! @item estim_params_
|
||||
%! Matlab's structure describing the estimated parameters (initialized by @code{dynare}).
|
||||
%! @item options_
|
||||
%! Matlab's structure describing the options (initialized by @code{dynare}).
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item nam
|
||||
%! String, internal name of the variable
|
||||
%! @item texnam
|
||||
%! String, TeX name of the same variable (if defined in the mod file).
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{This function is called by:}
|
||||
%! @sp 1
|
||||
%! @ref{get_prior_info}, @ref{mcmc_diagnostics}, @ref{mode_check}, @ref{PlotPosteriorDistributions}, @ref{plot_priors}
|
||||
%! @sp 2
|
||||
%! @strong{This function calls:}
|
||||
%! @sp 1
|
||||
%! None.
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright © 2004-2018 Dynare Team
|
||||
% Copyright © 2004-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -57,7 +37,6 @@ function [nam, texnam] = get_the_name(k, TeX, M_, estim_params_, options_)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
nam = [];
|
||||
texnam = [];
|
||||
|
||||
nvx = estim_params_.nvx;
|
||||
|
@ -73,7 +52,7 @@ if k <= nvx
|
|||
texnam = sprintf('$ \\sigma_{%s} $', tname);
|
||||
end
|
||||
elseif k <= (nvx+nvn)
|
||||
vname = options_.varobs{estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1)};
|
||||
vname = varobs{estim_params_.nvn_observable_correspondence(k-estim_params_.nvx,1)};
|
||||
nam = sprintf('SE_EOBS_%s', vname);
|
||||
if TeX
|
||||
tname = M_.endo_names_tex{estim_params_.var_endo(k-estim_params_.nvx,1)};
|
||||
|
|
|
@ -6,20 +6,20 @@ function [SAmeas, OutMatrix] = Morris_Measure_Groups(NumFact, Sample, Output, p,
|
|||
% INPUTS
|
||||
% -------------------------------------------------------------------------
|
||||
% Group [NumFactor, NumGroups] := Matrix describing the groups.
|
||||
% Each column represents one group.
|
||||
% The element of each column are zero if the factor is not in the
|
||||
% group. Otherwise it is 1.
|
||||
% Each column represents one group.
|
||||
% The element of each column are zero if the factor is not in the
|
||||
% group. Otherwise it is 1.
|
||||
%
|
||||
% Sample := Matrix of the Morris sampled trajectories
|
||||
%
|
||||
% Output := Matrix of the output(s) values in correspondence of each point
|
||||
% of each trajectory
|
||||
% of each trajectory
|
||||
%
|
||||
% k = Number of factors
|
||||
% -------------------------------------------------------------------------
|
||||
% OUTPUTS
|
||||
% OutMatrix (NumFactor*NumOutputs, 3)= [Mu*, Mu, StDev]
|
||||
% for each output it gives the three measures of each factor
|
||||
% for each output it gives the three measures of each factor
|
||||
% -------------------------------------------------------------------------
|
||||
%
|
||||
% Written by Jessica Cariboni and Francesca Campolongo
|
||||
|
@ -27,7 +27,7 @@ function [SAmeas, OutMatrix] = Morris_Measure_Groups(NumFact, Sample, Output, p,
|
|||
%
|
||||
|
||||
% Copyright © 2005 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -50,32 +50,34 @@ if nargin==0
|
|||
return
|
||||
end
|
||||
|
||||
OutMatrix=[];
|
||||
if nargin < 5, Group=[]; end
|
||||
|
||||
NumGroups = size(Group,2);
|
||||
if nargin < 4 | isempty(p)
|
||||
|
||||
if nargin < 4 || isempty(p)
|
||||
p = 4;
|
||||
end
|
||||
Delt = p/(2*p-2);
|
||||
|
||||
if NumGroups ~ 0
|
||||
if NumGroups ~= 0
|
||||
sizea = NumGroups; % Number of groups
|
||||
GroupMat=Group;
|
||||
GroupMat = GroupMat';
|
||||
else
|
||||
sizea = NumFact;
|
||||
end
|
||||
|
||||
r=size(Sample,1)/(sizea+1); % Number of trajectories
|
||||
if NumGroups > 0
|
||||
OutMatrix = NaN(sizea*size(Output,2),1);
|
||||
else
|
||||
OutMatrix = NaN(sizea*size(Output,2),3);
|
||||
end
|
||||
|
||||
% For Each Output
|
||||
for k=1:size(Output,2)
|
||||
|
||||
OutValues=Output(:,k);
|
||||
|
||||
% For each r trajectory
|
||||
for i=1:r
|
||||
|
||||
% For each step j in the trajectory
|
||||
% Read the orientation matrix fact for the r-th sampling
|
||||
% Read the corresponding output values
|
||||
|
@ -86,13 +88,11 @@ for k=1:size(Output,2)
|
|||
|
||||
% For each point of the fixed trajectory compute the values of the Morris function. The function
|
||||
% is partitioned in four parts, from order zero to order 4th.
|
||||
% SAmeas=NaN();
|
||||
for j=1:sizea % For each point in the trajectory i.e for each factor
|
||||
% matrix of factor which changes
|
||||
if NumGroups ~ 0
|
||||
if NumGroups ~= 0
|
||||
AuxFind (:,1) = A(:,j);
|
||||
% AuxFind(find(A(:,j)),1)=1;
|
||||
% Pippo = sum((Group - repmat(AuxFind,1,NumGroups)),1);
|
||||
% Change_factor(j,i) = find(Pippo==0);
|
||||
Change_factor = find(abs(AuxFind)>1e-010);
|
||||
% If we deal with groups we can only estimate the new mu*
|
||||
% measure since factors in the same groups can move in
|
||||
|
@ -100,7 +100,6 @@ for k=1:size(Output,2)
|
|||
% Morris mu cannopt be applied.
|
||||
% In the new version the elementary effect is defined with
|
||||
% the absolute value.
|
||||
%SAmeas(find(GroupMat(Change_factor(j,i),:)),i) = abs((Single_OutValues(j) - Single_OutValues(j+1) )/Delt); %(2/3));
|
||||
SAmeas(i,Change_factor') = abs((Single_OutValues(j) - Single_OutValues(j+1) )/Delt);
|
||||
else
|
||||
Change_factor(j,i) = find(Single_Sample(j+1,:)-Single_Sample(j,:));
|
||||
|
@ -116,12 +115,17 @@ for k=1:size(Output,2)
|
|||
|
||||
end %for i=1:r
|
||||
|
||||
if NumGroups ~ 0
|
||||
if NumGroups ~= 0
|
||||
SAmeas = SAmeas';
|
||||
end
|
||||
|
||||
% Compute Mu AbsMu and StDev
|
||||
if any(any(isnan(SAmeas)))
|
||||
AbsMu=NaN(NumFact,1);
|
||||
if NumGroups == 0
|
||||
Mu=NaN(NumFact,1);
|
||||
StDev=NaN(NumFact,1);
|
||||
end
|
||||
for j=1:NumFact
|
||||
SAm = SAmeas(j,:);
|
||||
SAm = SAm(find(~isnan(SAm)));
|
||||
|
@ -143,8 +147,8 @@ for k=1:size(Output,2)
|
|||
% Define the output Matrix - if we have groups we cannot define the old
|
||||
% measure mu, only mu* makes sense
|
||||
if NumGroups > 0
|
||||
OutMatrix = [OutMatrix; AbsMu];
|
||||
OutMatrix((k-1)*sizea+1:k*sizea,:) = AbsMu;
|
||||
else
|
||||
OutMatrix = [OutMatrix; AbsMu, Mu, StDev];
|
||||
OutMatrix((k-1)*sizea+1:k*sizea,:) = [AbsMu, Mu, StDev];
|
||||
end
|
||||
end % For Each Output
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
function [Outmatrix, OutFact] = Sampling_Function_2(p, k, r, UB, LB, GroupMat)
|
||||
%[Outmatrix, OutFact] = Sampling_Function_2(p, k, r, UB, LB, GroupMat)
|
||||
% Inputs: k (1,1) := number of factors examined or number of groups examined.
|
||||
% Inputs:
|
||||
% k (1,1) := number of factors examined or number of groups examined.
|
||||
% In case the groups are chosen the number of factors is stores in NumFact and
|
||||
% sizea becomes the number of created groups.
|
||||
% NumFact (1,1) := number of factors examined in the case when groups are chosen
|
||||
|
@ -13,7 +14,7 @@ function [Outmatrix, OutFact] = Sampling_Function_2(p, k, r, UB, LB, GroupMat)
|
|||
% are set to 1 in correspondence of the factors that belong to the fixed group. All
|
||||
% the other elements are zero.
|
||||
% Local Variables:
|
||||
% sizeb (1,1) := sizea+1
|
||||
% sizeb (1,1) := sizea+1
|
||||
% sizec (1,1) := 1
|
||||
% randmult (sizea,1) := vector of random +1 and -1
|
||||
% perm_e(1,sizea) := vector of sizea random permutated indeces
|
||||
|
@ -34,7 +35,8 @@ function [Outmatrix, OutFact] = Sampling_Function_2(p, k, r, UB, LB, GroupMat)
|
|||
% AuxMat(sizeb,sizea) := Delta*0.5*((2*B - A) * DD0 + A) in Morris, 1991. The AuxMat is used as in Morris design
|
||||
% for single factor analysis, while it constitutes an intermediate step for the group analysis.
|
||||
%
|
||||
% Output: Outmatrix(sizeb*r, sizea) := for the entire sample size computed In(i,j) matrices
|
||||
% Outputs:
|
||||
% Outmatrix(sizeb*r, sizea) := for the entire sample size computed In(i,j) matrices
|
||||
% OutFact(sizea*r,1) := for the entire sample size computed Fact(i,1) vectors
|
||||
%
|
||||
% Note: B0 is constructed as in Morris design when groups are not considered. When groups are considered the routine
|
||||
|
@ -56,7 +58,7 @@ function [Outmatrix, OutFact] = Sampling_Function_2(p, k, r, UB, LB, GroupMat)
|
|||
%
|
||||
|
||||
% Copyright © 2005 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -80,25 +82,23 @@ Delta = p/(2*p-2);
|
|||
NumFact = sizea;
|
||||
GroupNumber = size(GroupMat,2);
|
||||
|
||||
if GroupNumber ~ 0;
|
||||
if GroupNumber ~= 0
|
||||
sizea = size(GroupMat,2);
|
||||
end
|
||||
|
||||
sizeb = sizea + 1;
|
||||
sizec = 1;
|
||||
Outmatrix = [];
|
||||
OutFact = [];
|
||||
|
||||
% For each i generate a trajectory
|
||||
for i=1:r
|
||||
|
||||
% Construct DD0 - OLD VERSION - it does not need communication toolbox
|
||||
% RAND(N,M) is an NXM matrix with random entries, chosen from a uniform distribution on the interval (0.0,1.0).
|
||||
% Note that DD0 tells if the factor have to be increased or ddecreased
|
||||
% by Delta.
|
||||
randmult = ones(k,1);
|
||||
v = rand(k,1);
|
||||
randmult (find(v < 0.5))=-1;
|
||||
randmult (v < 0.5)=-1;
|
||||
randmult = repmat(randmult,1,k);
|
||||
DD0 = randmult .* eye(k);
|
||||
|
||||
|
@ -133,7 +133,7 @@ for i=1:r
|
|||
|
||||
% When groups are present the random permutation is done only on B. The effect is the same since
|
||||
% the added part (A0*x0') is completely random.
|
||||
if GroupNumber ~ 0
|
||||
if GroupNumber ~= 0
|
||||
B = B * (GroupMat*P0')';
|
||||
end
|
||||
|
||||
|
@ -158,9 +158,9 @@ for i=1:r
|
|||
% 3) check in which interval the random numbers fall
|
||||
% 4) generate the corresponding integer
|
||||
v = repmat(rand(NumFact,1),1,size(MyInt,2)+1); % 1)
|
||||
IntUsed = repmat([0:1/size(MyInt,2):1],NumFact,1); % 2)
|
||||
IntUsed = repmat(0:1/size(MyInt,2):1,NumFact,1); % 2)
|
||||
DiffAuxVec = IntUsed - v; % 3)
|
||||
|
||||
w=NaN(1,size(DiffAuxVec,1));
|
||||
for ii = 1:size(DiffAuxVec,1)
|
||||
w(1,ii) = max(find(DiffAuxVec(ii,:)<0)); % 4)
|
||||
end
|
||||
|
@ -168,7 +168,7 @@ for i=1:r
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% b --> Compute the matrix B*, here indicated as B0. Each row in B0 is a
|
||||
% trajectory for Morris Calculations. The dimension of B0 is (Numfactors+1,Numfactors)
|
||||
if GroupNumber ~ 0
|
||||
if GroupNumber ~= 0
|
||||
B0 = (A0*x0' + AuxMat);
|
||||
else
|
||||
B0 = (A0*x0' + AuxMat)*P0;
|
||||
|
@ -183,6 +183,7 @@ for i=1:r
|
|||
|
||||
% Create the Factor vector. Each component of this vector indicate which factor or group of factor
|
||||
% has been changed in each step of the trajectory.
|
||||
Fact=NaN(1,sizea);
|
||||
for j=1:sizea
|
||||
Fact(1,j) = find(P0(j,:));
|
||||
end
|
||||
|
@ -190,5 +191,4 @@ for i=1:r
|
|||
|
||||
Outmatrix = [Outmatrix; In];
|
||||
OutFact = [OutFact; Fact'];
|
||||
|
||||
end
|
|
@ -1,5 +1,10 @@
|
|||
function h = cumplot(x)
|
||||
%function h =cumplot(x)
|
||||
% Inputs:
|
||||
% - x [double] data series
|
||||
%
|
||||
% Outputs:
|
||||
% - h [handle] figure handle
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -26,9 +31,5 @@ function h = cumplot(x)
|
|||
n=length(x);
|
||||
x=[-inf; sort(x); Inf];
|
||||
y=[0:n n]./n;
|
||||
h0 = stairs(x,y);
|
||||
grid on,
|
||||
|
||||
if nargout
|
||||
h=h0;
|
||||
end
|
||||
h = stairs(x,y);
|
||||
grid on
|
|
@ -1,5 +1,25 @@
|
|||
function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info)
|
||||
% function [rmse_MC, ixx] = filt_mc_(OutDir)
|
||||
function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info,M_,oo_,options_,bayestopt_,estim_params_)
|
||||
% [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info,M_,oo_,options_,bayestopt_,estim_params_
|
||||
% Inputs:
|
||||
% - OutputDirectoryName [string] name of the output directory
|
||||
% - options_gsa_ [structure] GSA options
|
||||
% - dataset_ [dseries] object storing the dataset
|
||||
% - dataset_info [structure] storing informations about the sample.
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
% - oo_ [structure] storing the results
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
%
|
||||
% Outputs:
|
||||
% - rmse_MC [double] RMSE by nvar matrix of the RMSEs
|
||||
% - ixx [double] RMSE by nvar matrix of sorting
|
||||
% indices (descending order of RMSEs)
|
||||
%
|
||||
% Notes: the R^2 definition is 1-var(ymodel-ydata)/var(ydata). It ranges
|
||||
% bewteen (-inf, 1], with negative values indicating that themodel is a worse
|
||||
% predictor than the sample mean of the data
|
||||
|
||||
% inputs (from opt_gsa structure)
|
||||
% vvarvecm = options_gsa_.var_rmse;
|
||||
% loadSA = options_gsa_.load_rmse;
|
||||
|
@ -7,7 +27,6 @@ function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info)
|
|||
% alpha = options_gsa_.alpha_rmse;
|
||||
% alpha2 = options_gsa_.alpha2_rmse;
|
||||
% istart = options_gsa_.istart_rmse;
|
||||
% alphaPC = 0.5;
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -31,9 +50,6 @@ function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global bayestopt_ estim_params_ M_ options_ oo_
|
||||
|
||||
% options_gsa_=options_.opt_gsa;
|
||||
vvarvecm = options_gsa_.var_rmse;
|
||||
if options_.TeX
|
||||
vvarvecm_tex = options_gsa_.var_rmse_tex;
|
||||
|
@ -46,13 +62,10 @@ alpha = options_gsa_.alpha_rmse;
|
|||
alpha2 = 0;
|
||||
pvalue = options_gsa_.alpha2_rmse;
|
||||
istart = max(2,options_gsa_.istart_rmse);
|
||||
alphaPC = 0.5;
|
||||
|
||||
fname_ = M_.fname;
|
||||
lgy_ = M_.endo_names;
|
||||
dr_ = oo_.dr;
|
||||
|
||||
skipline(2)
|
||||
skipline(1)
|
||||
disp('Starting sensitivity analysis')
|
||||
disp('for the fit of EACH observed series ...')
|
||||
skipline()
|
||||
|
@ -61,12 +74,12 @@ if ~options_.nograph
|
|||
a=dir([OutDir,filesep,'*.*']);
|
||||
tmp1='0';
|
||||
if options_.opt_gsa.ppost
|
||||
tmp=['_rmse_post'];
|
||||
tmp='_rmse_post';
|
||||
else
|
||||
if options_.opt_gsa.pprior
|
||||
tmp=['_rmse_prior'];
|
||||
tmp='_rmse_prior';
|
||||
else
|
||||
tmp=['_rmse_mc'];
|
||||
tmp='_rmse_mc';
|
||||
end
|
||||
if options_gsa_.lik_only
|
||||
tmp1 = [tmp,'_post_SA'];
|
||||
|
@ -75,17 +88,23 @@ if ~options_.nograph
|
|||
end
|
||||
for j=1:length(a)
|
||||
if strmatch([fname_,tmp],a(j).name)
|
||||
disp(a(j).name)
|
||||
if options_.debug
|
||||
disp(a(j).name)
|
||||
end
|
||||
delete([OutDir,filesep,a(j).name])
|
||||
end
|
||||
if strmatch([fname_,tmp1],a(j).name)
|
||||
disp(a(j).name)
|
||||
if options_.debug
|
||||
disp(a(j).name)
|
||||
end
|
||||
delete([OutDir,filesep,a(j).name])
|
||||
end
|
||||
end
|
||||
disp('done !')
|
||||
end
|
||||
|
||||
[param_names,param_names_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
|
||||
|
||||
nshock=estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn;
|
||||
npar=estim_params_.np;
|
||||
if ~isempty(options_.mode_file)
|
||||
|
@ -94,10 +113,12 @@ end
|
|||
if options_.opt_gsa.ppost
|
||||
c=load([M_.dname filesep 'Output' filesep fname_,'_mean.mat'],'xparam1');
|
||||
xparam1_mean=c.xparam1;
|
||||
xparam1=c.xparam1;
|
||||
clear c
|
||||
elseif ~isempty(options_.mode_file) && exist([M_.dname filesep 'Output' filesep fname_,'_mean.mat'])==2
|
||||
elseif ~isempty(options_.mode_file) && exist([M_.dname filesep 'Output' filesep fname_,'_mean.mat'],'file')==2
|
||||
c=load([M_.dname filesep 'Output' filesep fname_,'_mean.mat'],'xparam1');
|
||||
xparam1_mean=c.xparam1;
|
||||
xparam1=c.xparam1;
|
||||
clear c
|
||||
end
|
||||
|
||||
|
@ -124,31 +145,11 @@ if loadSA
|
|||
end
|
||||
end
|
||||
if ~loadSA
|
||||
if exist('xparam1','var')
|
||||
M_ = set_all_parameters(xparam1,estim_params_,M_);
|
||||
ys_mode=evaluate_steady_state(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_,options_,~options_.steadystate.nocheck);
|
||||
end
|
||||
if exist('xparam1_mean','var')
|
||||
M_ = set_all_parameters(xparam1_mean,estim_params_,M_);
|
||||
ys_mean=evaluate_steady_state(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_,options_,~options_.steadystate.nocheck);
|
||||
end
|
||||
Y = transpose(dataset_.data);
|
||||
gend = dataset_.nobs;
|
||||
data_index = dataset_info.missing.aindex;
|
||||
missing_value = dataset_info.missing.state;
|
||||
for jx=1:gend
|
||||
data_indx(jx,data_index{jx})=true;
|
||||
end
|
||||
load([DirectoryName filesep M_.fname '_data.mat']);
|
||||
filfilt = dir([DirectoryName filesep M_.fname '_filter_step_ahead*.mat']);
|
||||
temp_smooth_file_list = dir([DirectoryName filesep M_.fname '_smooth*.mat']);
|
||||
jfile=0;
|
||||
for j=1:length(temp_smooth_file_list)
|
||||
if isempty(strfind(temp_smooth_file_list(j).name,'smoothed')),
|
||||
jfile=jfile+1;
|
||||
filsmooth(jfile)=temp_smooth_file_list(j);
|
||||
end
|
||||
end
|
||||
filupdate = dir([DirectoryName filesep M_.fname '_update*.mat']);
|
||||
filparam = dir([DirectoryName filesep M_.fname '_param*.mat']);
|
||||
x=[];
|
||||
|
@ -156,11 +157,11 @@ if ~loadSA
|
|||
sto_ys=[];
|
||||
for j=1:length(filparam)
|
||||
if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name))
|
||||
load([DirectoryName filesep filparam(j).name]);
|
||||
x=[x; stock];
|
||||
logpo2=[logpo2; stock_logpo];
|
||||
sto_ys=[sto_ys; stock_ys];
|
||||
clear stock stock_logpo stock_ys;
|
||||
temp=load([DirectoryName filesep filparam(j).name]); % from prior_posterior_statistics_core
|
||||
x=[x; temp.stock];
|
||||
logpo2=[logpo2; temp.stock_logpo];
|
||||
sto_ys=[sto_ys; temp.stock_ys];
|
||||
clear temp;
|
||||
end
|
||||
end
|
||||
nruns=size(x,1);
|
||||
|
@ -168,38 +169,41 @@ if ~loadSA
|
|||
if options_.opt_gsa.ppost || (options_.opt_gsa.ppost==0 && options_.opt_gsa.lik_only==0)
|
||||
skipline()
|
||||
disp('Computing RMSE''s...')
|
||||
jxj=NaN(length(vvarvecm),1);
|
||||
js=NaN(length(vvarvecm),1);
|
||||
yss=NaN(length(vvarvecm),gend,size(sto_ys,1));
|
||||
for i = 1:length(vvarvecm)
|
||||
vj = vvarvecm{i};
|
||||
jxj(i) = strmatch(vj, lgy_(dr_.order_var), 'exact');
|
||||
js(i) = strmatch(vj, lgy_, 'exact');
|
||||
jxj(i) = strmatch(vj, M_.endo_names(oo_.dr.order_var), 'exact');
|
||||
js(i) = strmatch(vj, M_.endo_names, 'exact');
|
||||
yss(i,:,:)=repmat(sto_ys(:,js(i))',[gend,1]);
|
||||
end
|
||||
if exist('xparam1','var')
|
||||
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);% + kron(ys_mode(js),ones(1,gend)));
|
||||
yobs = transpose( ahat(jxj,:));% + kron(ys_mode(js),ones(1,gend)));
|
||||
[~,~,~,ahat,~,~,aK] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);
|
||||
yobs = transpose( ahat(jxj,:));
|
||||
rmse_mode = sqrt(mean((yobs(istart:end,:)-y0(istart:end,:)).^2));
|
||||
r2_mode = 1-sum((yobs(istart:end,:)-y0(istart:end,:)).^2)./sum(yobs(istart:end,:).^2);
|
||||
end
|
||||
y0=-yss;
|
||||
|
||||
y0=-yss; %demean everything using the theoretical mean, i.e. steady state
|
||||
nbb=0;
|
||||
for j=1:length(filfilt)
|
||||
load([DirectoryName filesep M_.fname '_filter_step_ahead',num2str(j),'.mat']);
|
||||
nb = size(stock,4);
|
||||
y0(:,:,nbb+1:nbb+nb)=y0(:,:,nbb+1:nbb+nb)+reshape(stock(1,js,1:gend,:),[length(js) gend nb]);
|
||||
temp=load([DirectoryName filesep M_.fname '_filter_step_ahead',num2str(j),'.mat']);
|
||||
nb = size(temp.stock,4);
|
||||
y0(:,:,nbb+1:nbb+nb)=y0(:,:,nbb+1:nbb+nb)+reshape(temp.stock(1,js,1:gend,:),[length(js) gend nb]);
|
||||
nbb=nbb+nb;
|
||||
clear stock;
|
||||
clear temp;
|
||||
end
|
||||
yobs=-yss;
|
||||
nbb=0;
|
||||
for j=1:length(filupdate)
|
||||
load([DirectoryName filesep M_.fname '_update',num2str(j),'.mat']);
|
||||
nb = size(stock,3);
|
||||
yobs(:,:,nbb+1:nbb+nb)=yobs(:,:,nbb+1:nbb+nb)+reshape(stock(js,1:gend,:),[length(js) gend nb]);
|
||||
temp=load([DirectoryName filesep M_.fname '_update',num2str(j),'.mat']);
|
||||
nb = size(temp.stock,3);
|
||||
yobs(:,:,nbb+1:nbb+nb)=yobs(:,:,nbb+1:nbb+nb)+reshape(temp.stock(js,1:gend,:),[length(js) gend nb]);
|
||||
nbb=nbb+nb;
|
||||
clear stock;
|
||||
clear temp;
|
||||
end
|
||||
y0M=mean(y0,2);
|
||||
rmse_MC=zeros(nruns,length(js));
|
||||
r2_MC=zeros(nruns,length(js));
|
||||
for j=1:nruns
|
||||
|
@ -207,14 +211,15 @@ if ~loadSA
|
|||
r2_MC(j,:) = 1-mean((yobs(:,istart:end,j)'-y0(:,istart:end,j)').^2)./mean((yobs(:,istart:end,j)').^2);
|
||||
end
|
||||
if exist('xparam1_mean','var')
|
||||
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1_mean,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);% + kron(ys_mean(js),ones(1,gend)));
|
||||
yobs = transpose( ahat(jxj,:));% + kron(ys_mean(js),ones(1,gend)));
|
||||
[~,~,~,ahat,~,~,aK] = DsgeSmoother(xparam1_mean,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
y0 = reshape( squeeze(aK(1,jxj,1:gend)),[gend length(jxj)]);
|
||||
yobs = transpose( ahat(jxj,:));
|
||||
rmse_pmean = sqrt(mean((yobs(istart:end,:)-y0(istart:end,:)).^2));
|
||||
r2_pmean = 1-mean((yobs(istart:end,:)-y0(istart:end,:)).^2)./mean(yobs(istart:end,:).^2);
|
||||
end
|
||||
clear stock_filter;
|
||||
end
|
||||
lnprior=NaN(nruns,1);
|
||||
for j=1:nruns
|
||||
lnprior(j,1) = priordens(x(j,:)',bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
||||
end
|
||||
|
@ -242,7 +247,7 @@ if ~loadSA
|
|||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
else % loadSA
|
||||
if options_.opt_gsa.lik_only && options_.opt_gsa.ppost==0
|
||||
load([OutDir,filesep,fnamtmp, '.mat'],'x','logpo2','likelihood');
|
||||
else
|
||||
|
@ -252,27 +257,27 @@ else
|
|||
nruns=size(x,1);
|
||||
nfilt=floor(pfilt*nruns);
|
||||
end
|
||||
% smirnov tests
|
||||
% Smirnov tests
|
||||
nfilt0 = nfilt*ones(length(vvarvecm), 1);
|
||||
logpo2=logpo2(:);
|
||||
if ~options_.opt_gsa.ppost
|
||||
[dum, ipost]=sort(-logpo2);
|
||||
[dum, ilik]=sort(-likelihood);
|
||||
[~, ipost]=sort(-logpo2);
|
||||
[~, ilik]=sort(-likelihood);
|
||||
end
|
||||
|
||||
% visual scatter analysis!
|
||||
if options_.opt_gsa.ppost
|
||||
tmp_title='R2 Posterior:';
|
||||
atitle='R2 Posterior:';
|
||||
tmp_title='R2 Scatter plot: Posterior';
|
||||
atitle='R2 Scatter plot: Posterior';
|
||||
asname='r2_post';
|
||||
else
|
||||
if options_.opt_gsa.pprior
|
||||
tmp_title='R2 Prior:';
|
||||
atitle='R2 Prior:';
|
||||
tmp_title='R2 Scatter plot: Prior';
|
||||
atitle='R2 Scatter plot: Prior';
|
||||
asname='r2_prior';
|
||||
else
|
||||
tmp_title='R2 MC:';
|
||||
atitle='R2 MC:';
|
||||
tmp_title='R2 Scatter plot: MC';
|
||||
atitle='R2 Scatter plot: MC';
|
||||
asname='r2_mc';
|
||||
end
|
||||
end
|
||||
|
@ -297,13 +302,10 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
|
|||
options_mcf.pvalue_ks = alpha;
|
||||
options_mcf.pvalue_corr = pvalue;
|
||||
options_mcf.alpha2 = alpha2;
|
||||
options_mcf.param_names = param_names;
|
||||
if options_.TeX
|
||||
[pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
|
||||
options_mcf.param_names = pnames;
|
||||
options_mcf.param_names_tex = pnames_tex;
|
||||
options_mcf.param_names_tex = param_names_tex;
|
||||
else
|
||||
[pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
|
||||
options_mcf.param_names = pnames;
|
||||
options_mcf.param_names_tex = {};
|
||||
end
|
||||
options_mcf.fname_ = fname_;
|
||||
|
@ -313,7 +315,12 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
|
|||
options_mcf.title = atitle;
|
||||
options_mcf.beha_title = 'better posterior kernel';
|
||||
options_mcf.nobeha_title = 'worse posterior kernel';
|
||||
mcf_analysis(x, ipost(1:nfilt), ipost(nfilt+1:end), options_mcf, options_);
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'better posterior kernel';
|
||||
options_mcf.nobeha_title_latex = 'worse posterior kernel';
|
||||
end
|
||||
|
||||
mcf_analysis(x, ipost(1:nfilt), ipost(nfilt+1:end), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
if options_.opt_gsa.pprior
|
||||
anam = 'rmse_prior_lik';
|
||||
atitle = 'RMSE prior: Log Likelihood Kernel';
|
||||
|
@ -326,15 +333,20 @@ if ~options_.opt_gsa.ppost && options_.opt_gsa.lik_only
|
|||
options_mcf.title = atitle;
|
||||
options_mcf.beha_title = 'better likelihood';
|
||||
options_mcf.nobeha_title = 'worse likelihood';
|
||||
mcf_analysis(x, ilik(1:nfilt), ilik(nfilt+1:end), options_mcf, options_);
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'better likelihood';
|
||||
options_mcf.nobeha_title_latex = 'worse likelihood';
|
||||
end
|
||||
|
||||
mcf_analysis(x, ilik(1:nfilt), ilik(nfilt+1:end), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
|
||||
else
|
||||
if options_.opt_gsa.ppost
|
||||
rmse_txt=rmse_pmean;
|
||||
r2_txt=r2_pmean;
|
||||
else
|
||||
if options_.opt_gsa.pprior || ~exist('rmse_pmean')
|
||||
if exist('rmse_mode')
|
||||
if options_.opt_gsa.pprior || ~exist('rmse_pmean','var')
|
||||
if exist('rmse_mode','var')
|
||||
rmse_txt=rmse_mode;
|
||||
r2_txt=r2_mode;
|
||||
else
|
||||
|
@ -346,18 +358,19 @@ else
|
|||
r2_txt=r2_pmean;
|
||||
end
|
||||
end
|
||||
ixx=NaN(size(rmse_MC,1),length(vvarvecm));
|
||||
for i = 1:length(vvarvecm)
|
||||
[dum, ixx(:,i)] = sort(rmse_MC(:,i));
|
||||
[~, ixx(:,i)] = sort(rmse_MC(:,i));
|
||||
end
|
||||
PP = ones(npar+nshock, length(vvarvecm));
|
||||
PPV = ones(length(vvarvecm), length(vvarvecm), npar+nshock);
|
||||
SS = zeros(npar+nshock, length(vvarvecm));
|
||||
for j = 1:npar+nshock
|
||||
for i = 1:length(vvarvecm)
|
||||
[H, P, KSSTAT] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
|
||||
[H1, P1, KSSTAT1] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
|
||||
[H2, P2, KSSTAT2] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
|
||||
if H1 & H2==0
|
||||
[~, P] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
|
||||
[H1] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
|
||||
[H2] = smirnov(x(ixx(nfilt0(i)+1:end,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
|
||||
if H1==0 && H2==0
|
||||
SS(j,i)=1;
|
||||
elseif H1==0
|
||||
SS(j,i)=-1;
|
||||
|
@ -369,7 +382,7 @@ else
|
|||
for i = 1:length(vvarvecm)
|
||||
for l = 1:length(vvarvecm)
|
||||
if l~=i && PP(j,i)<alpha && PP(j,l)<alpha
|
||||
[H,P,KSSTAT] = smirnov(x(ixx(1:nfilt0(i),i),j),x(ixx(1:nfilt0(l),l),j), alpha);
|
||||
[~,P] = smirnov(x(ixx(1:nfilt0(i),i),j),x(ixx(1:nfilt0(l),l),j), alpha);
|
||||
PPV(i,l,j) = P;
|
||||
elseif l==i
|
||||
PPV(i,l,j) = PP(j,i);
|
||||
|
@ -400,7 +413,11 @@ else
|
|||
set(h,'color','k','linewidth',1)
|
||||
h=cumplot(lnprior(ixx(nfilt0(i)+1:end,i)));
|
||||
set(h,'color','red','linewidth',2)
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
if options_.TeX
|
||||
title(vvarvecm_tex{i},'interpreter','latex')
|
||||
else
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
end
|
||||
if mod(i,9)==0 || i==length(vvarvecm)
|
||||
if ~isoctave
|
||||
annotation('textbox', [0.1,0,0.35,0.05],'String', 'Log-prior for BETTER R2','Color','Blue','horizontalalignment','center');
|
||||
|
@ -448,7 +465,11 @@ else
|
|||
set(h,'color','k','linewidth',1)
|
||||
h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i)));
|
||||
set(h,'color','red','linewidth',2)
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
if options_.TeX
|
||||
title(vvarvecm_tex{i},'interpreter','latex')
|
||||
else
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
end
|
||||
if options_.opt_gsa.ppost==0
|
||||
set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )])
|
||||
end
|
||||
|
@ -499,7 +520,11 @@ else
|
|||
set(h,'color','k','linewidth',1)
|
||||
h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i)));
|
||||
set(h,'color','red','linewidth',2)
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
if options_.TeX
|
||||
title(vvarvecm_tex{i},'interpreter','latex')
|
||||
else
|
||||
title(vvarvecm{i},'interpreter','none')
|
||||
end
|
||||
if options_.opt_gsa.ppost==0
|
||||
set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )])
|
||||
end
|
||||
|
@ -529,15 +554,6 @@ else
|
|||
end
|
||||
end
|
||||
end
|
||||
if options_.TeX
|
||||
[pnames,pnames_tex]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
|
||||
param_names = pnames;
|
||||
param_names_tex = pnames_tex;
|
||||
else
|
||||
[pnames]=get_LaTeX_parameter_names(M_,options_,estim_params_,bayestopt_);
|
||||
param_names = pnames;
|
||||
param_names_tex = {};
|
||||
end
|
||||
skipline()
|
||||
title_string='RMSE over the MC sample:';
|
||||
data_mat=[min(rmse_MC)' max(rmse_MC)'];
|
||||
|
@ -549,7 +565,7 @@ else
|
|||
end
|
||||
invar = find( std(rmse_MC)./mean(rmse_MC)<=0.0001 );
|
||||
if ~isempty(invar)
|
||||
skipline(2)
|
||||
skipline(1)
|
||||
disp('RMSE is not varying significantly over the MC sample for the following variables:')
|
||||
disp(vvarvecm{invar})
|
||||
disp('These variables are excluded from SA')
|
||||
|
@ -561,8 +577,7 @@ else
|
|||
rmse_MC = rmse_MC(:,ivar);
|
||||
skipline()
|
||||
disp(['Sample filtered the ',num2str(pfilt*100),'% best RMSE''s for each observed series ...' ])
|
||||
skipline(2)
|
||||
disp('RMSE ranges after filtering:')
|
||||
skipline(1)
|
||||
title_string='RMSE ranges after filtering:';
|
||||
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
|
||||
headers = {'Variable'; 'min'; 'max'; 'min'; 'max'; 'posterior mode'};
|
||||
|
@ -589,7 +604,7 @@ else
|
|||
else
|
||||
values_length = max(ceil(max(max(log10(abs(data_mat(isfinite(data_mat))))))),1)+val_precis+1;
|
||||
end
|
||||
if any(data_mat) < 0 %add one character for minus sign
|
||||
if any(data_mat < 0) %add one character for minus sign
|
||||
values_length = values_length+1;
|
||||
end
|
||||
headers_length = cellofchararraymaxlength(headers(2:end));
|
||||
|
@ -598,7 +613,6 @@ else
|
|||
else
|
||||
val_width = max(headers_length, values_length)+2;
|
||||
end
|
||||
value_format = sprintf('%%%d.%df',val_width,val_precis);
|
||||
header_string_format = sprintf('%%%ds',val_width);
|
||||
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
|
||||
optional_header=sprintf([label_format_leftbound,header_string_format,header_string_format,header_string_format,header_string_format],'','',['best ',num2str(pfilt*100),'% filtered'],'','remaining 90%');
|
||||
|
@ -610,7 +624,7 @@ else
|
|||
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
|
||||
optional_header={[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
|
||||
else
|
||||
optional_header={[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
|
||||
optional_header={' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\'};
|
||||
end
|
||||
dyn_latex_table(M_, options_, title_string, 'RMSE_ranges_after_filtering', headers_tex, vvarvecm_tex, data_mat, 0, val_width, val_precis, optional_header);
|
||||
end
|
||||
|
@ -657,7 +671,7 @@ else
|
|||
else
|
||||
values_length = max(ceil(max(max(log10(abs(data_mat(isfinite(data_mat))))))),1)+val_precis+1;
|
||||
end
|
||||
if any(data_mat) < 0 %add one character for minus sign
|
||||
if any(data_mat < 0) %add one character for minus sign
|
||||
values_length = values_length+1;
|
||||
end
|
||||
headers_length = cellofchararraymaxlength(headers(2:end));
|
||||
|
@ -666,7 +680,6 @@ else
|
|||
else
|
||||
val_width = max(headers_length, values_length)+2;
|
||||
end
|
||||
value_format = sprintf('%%%d.%df',val_width,val_precis);
|
||||
header_string_format = sprintf('%%%ds',val_width);
|
||||
|
||||
if options_.opt_gsa.ppost==0 && options_.opt_gsa.pprior
|
||||
|
@ -679,7 +692,7 @@ else
|
|||
if ~options_.opt_gsa.ppost && options_.opt_gsa.pprior
|
||||
optional_header = {[' & \multicolumn{2}{c}{best ',num2str(pfilt*100),' filtered} & \multicolumn{2}{c}{remaining 90\%}\\']};
|
||||
else
|
||||
optional_header = {[' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\']};
|
||||
optional_header = {' & \multicolumn{2}{c}{best filtered} & \multicolumn{2}{c}{remaining}\\'};
|
||||
end
|
||||
dyn_latex_table(M_, options_, title_string, 'R2_ranges_after_filtering', headers_tex, vvarvecm_tex, data_mat, 0, val_width, val_precis, optional_header);
|
||||
end
|
||||
|
@ -690,16 +703,15 @@ else
|
|||
SP(ns,j)=ones(size(ns));
|
||||
SS(:,j)=SS(:,j).*SP(:,j);
|
||||
end
|
||||
|
||||
for j=1:npar+nshock %estim_params_.np,
|
||||
nsp=NaN(npar+nshock,1);
|
||||
for j=1:npar+nshock
|
||||
nsp(j)=length(find(SP(j,:)));
|
||||
end
|
||||
snam0=param_names(find(nsp==0));
|
||||
snam1=param_names(find(nsp==1));
|
||||
snam2=param_names(find(nsp>1));
|
||||
snam=param_names(find(nsp>0));
|
||||
snam0=param_names(nsp==0);
|
||||
snam1=param_names(nsp==1);
|
||||
snam2=param_names(nsp>1);
|
||||
nsnam=(find(nsp>1));
|
||||
skipline(2)
|
||||
skipline(1)
|
||||
disp('These parameters do not affect significantly the fit of ANY observed series:')
|
||||
disp(char(snam0))
|
||||
skipline()
|
||||
|
@ -708,7 +720,6 @@ else
|
|||
skipline()
|
||||
disp('These parameters affect MORE THAN ONE observed series: trade off exists!')
|
||||
disp(char(snam2))
|
||||
pnam=bayestopt_.name;
|
||||
% plot trade-offs
|
||||
if ~options_.nograph
|
||||
a00=jet(length(vvarvecm));
|
||||
|
@ -740,8 +751,12 @@ else
|
|||
options_mcf.amcf_title = [atitle ' ' vvarvecm{iy}];
|
||||
options_mcf.beha_title = ['better fit of ' vvarvecm{iy}];
|
||||
options_mcf.nobeha_title = ['worse fit of ' vvarvecm{iy}];
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = ['better fit of ' vvarvecm_tex{iy}];
|
||||
options_mcf.nobeha_title_latex = ['worse fit of ' vvarvecm_tex{iy}];
|
||||
end
|
||||
options_mcf.title = ['the fit of ' vvarvecm{iy}];
|
||||
mcf_analysis(x, ixx(1:nfilt0(iy),iy), ixx(nfilt0(iy)+1:end,iy), options_mcf, options_);
|
||||
mcf_analysis(x, ixx(1:nfilt0(iy),iy), ixx(nfilt0(iy)+1:end,iy), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
for iy = 1:length(vvarvecm)
|
||||
ipar = find(any(squeeze(PPV(iy,:,:))<alpha));
|
||||
|
@ -767,35 +782,43 @@ else
|
|||
set(h0,'color',a00(i,:),'linewidth',2)
|
||||
end
|
||||
ydum=get(gca,'ylim');
|
||||
if exist('xparam1')
|
||||
if exist('xparam1','var')
|
||||
xdum=xparam1(ipar(j));
|
||||
h1=plot([xdum xdum],ydum);
|
||||
set(h1,'color',[0.85 0.85 0.85],'linewidth',2)
|
||||
end
|
||||
xlabel('')
|
||||
title([pnam{ipar(j)}],'interpreter','none')
|
||||
if options_.TeX
|
||||
title([param_names_tex{ipar(j)}],'interpreter','latex')
|
||||
else
|
||||
title([param_names{ipar(j)}],'interpreter','none')
|
||||
end
|
||||
end
|
||||
if isoctave
|
||||
legend(vertcat('base',vvarvecm),'location','eastoutside');
|
||||
else
|
||||
h0=legend(vertcat('base',vvarvecm));
|
||||
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
|
||||
if options_.TeX
|
||||
h0=legend(vertcat('base',vvarvecm_tex),'interpreter','latex');
|
||||
else
|
||||
h0=legend(vertcat('base',vvarvecm),'interpreter','none');
|
||||
end
|
||||
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3]);
|
||||
end
|
||||
if options_.opt_gsa.ppost
|
||||
dyn_saveas(hh_fig,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX
|
||||
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_post_' vvarvecm{iy}],1)
|
||||
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable ',vvarvecm_tex{iy} ],['rmse_post_' vvarvecm{iy}],1)
|
||||
end
|
||||
else
|
||||
if options_.opt_gsa.pprior
|
||||
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX
|
||||
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_prior_' vvarvecm{iy}],1)
|
||||
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' vvarvecm{iy} '_' int2str(ix) ],ix,[temp_name,' observed variable ',vvarvecm_tex{iy}],['rmse_prior_' vvarvecm{iy}],1)
|
||||
end
|
||||
else
|
||||
dyn_saveas(hh_fig,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX
|
||||
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable $',vvarvecm_tex{iy} '$'],['rmse_mc_' vvarvecm{iy}],1)
|
||||
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' vvarvecm{iy} '_' int2str(ix)],ix,[temp_name,' observed variable ',vvarvecm_tex{iy}],['rmse_mc_' vvarvecm{iy}],1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -824,20 +847,28 @@ else
|
|||
set(h0,'color',a00(i,:),'linewidth',2)
|
||||
end
|
||||
ydum=get(gca,'ylim');
|
||||
if exist('xparam1')
|
||||
if exist('xparam1','var')
|
||||
xdum=xparam1(nsnam(j));
|
||||
h1=plot([xdum xdum],ydum);
|
||||
set(h1,'color',[0.85 0.85 0.85],'linewidth',2)
|
||||
end
|
||||
xlabel('')
|
||||
title([pnam{nsnam(j)}],'interpreter','none')
|
||||
if options_.TeX
|
||||
title([param_names_tex{nsnam(j)}],'interpreter','latex')
|
||||
else
|
||||
title([param_names{nsnam(j)}],'interpreter','none')
|
||||
end
|
||||
end
|
||||
%subplot(3,2,6)
|
||||
if isoctave
|
||||
legend(vertcat('base',vvarvecm),'location','eastoutside');
|
||||
else
|
||||
h0=legend(vertcat('base',vvarvecm));
|
||||
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
|
||||
if options_.TeX
|
||||
h0=legend(vertcat('base',vvarvecm_tex),'interpreter','latex');
|
||||
else
|
||||
h0=legend(vertcat('base',vvarvecm),'interpreter','none');
|
||||
end
|
||||
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3]);
|
||||
end
|
||||
if options_.opt_gsa.ppost
|
||||
dyn_saveas(hh_fig,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
|
||||
|
@ -885,11 +916,11 @@ pnames=cell(np,1);
|
|||
pnames_tex=cell(np,1);
|
||||
for ii=1:length(bayestopt_.name)
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(ii,options_.TeX,M_,estim_params_,options_);
|
||||
pnames_tex{ii,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(ii,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
pnames_tex{ii,1} = param_name_tex_temp;
|
||||
pnames{ii,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(ii,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(ii,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
pnames{ii,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
function gsa_plotmatrix(type,varargin)
|
||||
% function gsa_plotmatrix(type,varargin)
|
||||
% extended version of the standard MATLAB plotmatrix
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2011-2012 European Commission
|
||||
% Copyright © 2011-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global bayestopt_ options_ M_
|
||||
|
||||
RootDirectoryName = CheckPath('gsa',M_.dname);
|
||||
|
||||
if options_.opt_gsa.pprior
|
||||
load([ RootDirectoryName filesep M_.fname '_prior.mat'],'lpmat0','lpmat','istable','iunstable','iindeterm','iwrong')
|
||||
else
|
||||
load([ RootDirectoryName filesep M_.fname '_mc.mat'],'lpmat0','lpmat','istable','iunstable','iindeterm','iwrong')
|
||||
eval(['load ' options_.mode_file ' xparam1;']');
|
||||
end
|
||||
|
||||
iexplosive = iunstable(~ismember(iunstable,[iindeterm;iwrong]));
|
||||
|
||||
switch type
|
||||
case 'all'
|
||||
x=[lpmat0 lpmat];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
case 'stable'
|
||||
x=[lpmat0(istable,:) lpmat(istable,:)];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
case 'nosolution'
|
||||
x=[lpmat0(iunstable,:) lpmat(iunstable,:)];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
case 'unstable'
|
||||
x=[lpmat0(iexplosive,:) lpmat(iexplosive,:)];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
case 'indeterm'
|
||||
x=[lpmat0(iindeterm,:) lpmat(iindeterm,:)];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
case 'wrong'
|
||||
x=[lpmat0(iwrong,:) lpmat(iwrong,:)];
|
||||
NumberOfDraws=size(x,1);
|
||||
B=NumberOfDraws;
|
||||
|
||||
end
|
||||
|
||||
if isempty(x)
|
||||
disp('Empty parameter set!')
|
||||
return
|
||||
end
|
||||
|
||||
for j=1:length(varargin)
|
||||
jcol(j)=strmatch(varargin{j},bayestopt_.name,'exact');
|
||||
end
|
||||
|
||||
[H,AX,BigA,P,PAx]=plotmatrix(x(:,jcol));
|
||||
|
||||
for j=1:length(varargin)
|
||||
% axes(AX(1,j)), title(varargin{j})
|
||||
% axes(AX(j,1)), ylabel(varargin{j})
|
||||
% set(AX(1,j),'title',varargin{j}),
|
||||
set(get(AX(j,1),'ylabel'),'string',varargin{j})
|
||||
set(get(AX(end,j),'xlabel'),'string',varargin{j})
|
||||
end
|
||||
|
||||
if options_.opt_gsa.pprior==0
|
||||
xparam1=xparam1(jcol);
|
||||
for j=1:length(varargin)
|
||||
for i=1:j-1
|
||||
axes(AX(j,i))
|
||||
hold on, plot(xparam1(i),xparam1(j),'*r')
|
||||
end
|
||||
for i=j+1:length(varargin)
|
||||
axes(AX(j,i))
|
||||
hold on, plot(xparam1(i),xparam1(j),'*r')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +1,17 @@
|
|||
function s=gsa_skewness(y)
|
||||
% s=gsa_skewness(y)
|
||||
% Compute normalized skewness of y
|
||||
% Inputs:
|
||||
% - y [double] input vector
|
||||
% Outputs:
|
||||
% - s [double] standardized skewness
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -22,8 +28,6 @@ function s=gsa_skewness(y)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
% y=stand_(y);
|
||||
% s=mean(y.^3);
|
||||
m2=mean((y-mean(y)).^2);
|
||||
m3=mean((y-mean(y)).^3);
|
||||
s=m3/m2^1.5;
|
|
@ -1,58 +0,0 @@
|
|||
function [tadj, iff] = gsa_speed(A,B,mf,p)
|
||||
% [tadj, iff] = gsa_speed(A,B,mf,p),
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
nvar=length(mf);
|
||||
nstate= size(A,1);
|
||||
nshock = size(B,2);
|
||||
nrun=size(B,3);
|
||||
|
||||
iff=zeros(nvar,nshock,nrun);
|
||||
tadj=iff;
|
||||
disp('Computing speed of adjustement ...')
|
||||
h = dyn_waitbar(0,'Speed of adjustement...');
|
||||
|
||||
for i=1:nrun
|
||||
irf=zeros(nvar,nshock);
|
||||
a=squeeze(A(:,:,i));
|
||||
b=squeeze(B(:,:,i));
|
||||
IFF=inv(eye(nstate)-a)*b;
|
||||
iff(:,:,i)=IFF(mf,:);
|
||||
IF=IFF-b;
|
||||
|
||||
t=0;
|
||||
while any(any(irf<0.5))
|
||||
t=t+1;
|
||||
IFT=((eye(nstate)-a^(t+1))*inv(eye(nstate)-a))*b-b;
|
||||
irf=IFT(mf,:)./(IF(mf,:)+eps);
|
||||
irf = irf.*(abs(IF(mf,:))>1.e-7)+(abs(IF(mf,:))<=1.e-7);
|
||||
%irf=ft(mf,:);
|
||||
tt=(irf>0.5).*t;
|
||||
tadj(:,:,i)=((tt-tadj(:,:,i))==tt).*tt+tadj(:,:,i);
|
||||
end
|
||||
dyn_waitbar(i/nrun,h)
|
||||
end
|
||||
skipline()
|
||||
disp('.. done !')
|
||||
dyn_waitbar_close(h)
|
|
@ -1,4 +1,29 @@
|
|||
function [yy, xdir, isig, lam]=log_trans_(y0,xdir0,isig,lam)
|
||||
% [yy, xdir, isig, lam]=log_trans_(y0,xdir0,isig,lam)
|
||||
% Conduct automatic log transformation lam(yy/isig+lam)
|
||||
% Inputs:
|
||||
% - y0 [double] series to transform
|
||||
% - xdir [char] string indating the type of transformation:
|
||||
% - log: standard log transformation
|
||||
% - minuslog: log of minus (y0)
|
||||
% - logsquared: log of y0^2
|
||||
% - logskew: log of y0 shifted by lam
|
||||
% - isig [double] scaling factor for y0
|
||||
% - lam [double] shifting for y0
|
||||
%
|
||||
% Outputs:
|
||||
% - yy [double] transformed series
|
||||
% - xdir [char] string indating the type of transformation:
|
||||
% - log: standard log transformation
|
||||
% - minuslog: log of minus (y0)
|
||||
% - logsquared: log of y0^2
|
||||
% - logskew: log of y0 shifted by lam
|
||||
% - isig [double] scaling factor for y0
|
||||
% - lam [double] shifting for y0
|
||||
%
|
||||
% Notes: takes either one or four arguments. For one argument, the log
|
||||
% transformation is conducted. For four arguments, the inverse
|
||||
% transformation is applied.
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -33,12 +58,16 @@ if nargin==1
|
|||
end
|
||||
f=@(lam,y)gsa_skewness(log(y+lam));
|
||||
isig=1;
|
||||
if ~(max(y0)<0 | min(y0)>0)
|
||||
if gsa_skewness(y0)<0,
|
||||
if ~(max(y0)<0 || min(y0)>0)
|
||||
if gsa_skewness(y0)<0
|
||||
isig=-1;
|
||||
y0=-y0;
|
||||
end
|
||||
n=hist(y0,10);
|
||||
if isoctave
|
||||
n=hist(y0,10);
|
||||
else
|
||||
n=histcounts(y0,10);
|
||||
end
|
||||
if n(1)>20*n(end)
|
||||
try
|
||||
lam=fzero(f,[-min(y0)+10*eps -min(y0)+abs(median(y0))],[],y0);
|
||||
|
@ -48,7 +77,7 @@ if ~(max(y0)<0 | min(y0)>0)
|
|||
if abs(yl(1))<abs(yl(2))
|
||||
lam=-min(y0)+eps;
|
||||
else
|
||||
lam = -min(y0)+abs(median(y0)); %abs(100*(1+min(y0)));
|
||||
lam = -min(y0)+abs(median(y0));
|
||||
end
|
||||
end
|
||||
yy = log(y0+lam);
|
||||
|
@ -63,10 +92,8 @@ else
|
|||
if max(y0)<0
|
||||
isig=-1;
|
||||
y0=-y0;
|
||||
%yy=log(-y0);
|
||||
xdir=[xdir0,'_minuslog'];
|
||||
elseif min(y0)>0
|
||||
%yy=log(y0);
|
||||
xdir=[xdir0,'_log'];
|
||||
end
|
||||
try
|
||||
|
@ -77,7 +104,7 @@ else
|
|||
if abs(yl(1))<abs(yl(2))
|
||||
lam=-min(y0)+eps;
|
||||
else
|
||||
lam = -min(y0)+abs(median(y0)); %abs(100*(1+min(y0)));
|
||||
lam = -min(y0)+abs(median(y0));
|
||||
end
|
||||
end
|
||||
lam = max(lam,0);
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
function map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_, bayestopt_)
|
||||
% map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_, bayestopt_)
|
||||
|
||||
|
||||
% Inputs:
|
||||
% - OutputDirectoryName [string] name of the output directory
|
||||
% - M_ [structure] describing the model
|
||||
% - options_ [structure] describing the options
|
||||
% - oo_ [structure] storing the results
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
@ -32,16 +38,15 @@ pnames=cell(np,1);
|
|||
pnames_tex=cell(np,1);
|
||||
for jj=1:np
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj, options_.TeX, M_, estim_params_, options_);
|
||||
pnames_tex{jj,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj, options_.TeX, M_, estim_params_, options_.varobs);
|
||||
pnames_tex{jj,1} = param_name_tex_temp;
|
||||
pnames{jj,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(nshock+jj, options_.TeX, M_, estim_params_, options_);
|
||||
param_name_temp = get_the_name(nshock+jj, options_.TeX, M_, estim_params_, options_.varobs);
|
||||
pnames{jj,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
||||
pvalue_ks = options_.opt_gsa.pvalue_ks;
|
||||
indx_irf = [];
|
||||
indx_moment = [];
|
||||
init = ~options_.opt_gsa.load_stab;
|
||||
|
@ -63,7 +68,7 @@ if options_.opt_gsa.ppost
|
|||
filetoload=dir([M_.dname filesep 'metropolis' filesep fname_ '_param_irf*.mat']);
|
||||
lpmat=[];
|
||||
for j=1:length(filetoload)
|
||||
load([M_.dname filesep 'metropolis' filesep fname_ '_param_irf',int2str(j),'.mat'])
|
||||
load([M_.dname filesep 'metropolis' filesep fname_ '_param_irf',int2str(j),'.mat'],'stock')
|
||||
lpmat = [lpmat; stock];
|
||||
clear stock
|
||||
end
|
||||
|
@ -71,12 +76,12 @@ if options_.opt_gsa.ppost
|
|||
else
|
||||
if options_.opt_gsa.pprior
|
||||
filetoload=[OutputDirectoryName '/' fname_ '_prior'];
|
||||
load(filetoload,'lpmat','lpmat0','istable','iunstable','iindeterm','iwrong' ,'infox')
|
||||
load(filetoload,'lpmat','lpmat0')
|
||||
lpmat = [lpmat0 lpmat];
|
||||
type = 'prior';
|
||||
else
|
||||
filetoload=[OutputDirectoryName '/' fname_ '_mc'];
|
||||
load(filetoload,'lpmat','lpmat0','istable','iunstable','iindeterm','iwrong' ,'infox')
|
||||
load(filetoload,'lpmat','lpmat0')
|
||||
lpmat = [lpmat0 lpmat];
|
||||
type = 'mc';
|
||||
end
|
||||
|
@ -99,17 +104,17 @@ if init
|
|||
mat_moment{ij}=NaN(Nsam,length(options_.endogenous_prior_restrictions.moment{ij,3}));
|
||||
end
|
||||
|
||||
irestrictions = [1:Nsam];
|
||||
irestrictions = 1:Nsam;
|
||||
h = dyn_waitbar(0,'Please wait...');
|
||||
for j=1:Nsam
|
||||
M_ = set_all_parameters(lpmat(j,:)',estim_params_,M_);
|
||||
if nbr_moment_restrictions
|
||||
[Tt,Rr,SteadyState,info,oo_.dr, M_.params] = dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
[Tt,Rr,~,info,oo_.dr, M_.params] = dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
else
|
||||
[Tt,Rr,SteadyState,info,oo_.dr, M_.params] = dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state,'restrict');
|
||||
[Tt,Rr,~,info,oo_.dr, M_.params] = dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state,'restrict');
|
||||
end
|
||||
if info(1)==0
|
||||
[info, info_irf, info_moment, data_irf, data_moment]=endogenous_prior_restrictions(Tt,Rr,M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
[~, info_irf, info_moment, data_irf, data_moment]=endogenous_prior_restrictions(Tt,Rr,M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
if ~isempty(info_irf)
|
||||
for ij=1:nbr_irf_restrictions
|
||||
mat_irf{ij}(j,:)=data_irf{ij}(:,2)';
|
||||
|
@ -125,7 +130,9 @@ if init
|
|||
else
|
||||
irestrictions(j)=0;
|
||||
end
|
||||
dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
|
||||
if mod(j,3)==0
|
||||
dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
|
||||
end
|
||||
end
|
||||
dyn_waitbar_close(h);
|
||||
|
||||
|
@ -183,7 +190,7 @@ if ~isempty(indx_irf)
|
|||
maxijv=0;
|
||||
for ij=1:nbr_irf_restrictions
|
||||
if length(endo_prior_restrictions.irf{ij,3})>maxijv
|
||||
maxij=ij;maxijv=length(endo_prior_restrictions.irf{ij,3});
|
||||
maxijv=length(endo_prior_restrictions.irf{ij,3});
|
||||
end
|
||||
plot_indx(ij) = find(strcmp(irf_couples,all_irf_couples(ij,:)));
|
||||
time_matrix{plot_indx(ij)} = [time_matrix{plot_indx(ij)} endo_prior_restrictions.irf{ij,3}];
|
||||
|
@ -235,38 +242,25 @@ if ~isempty(indx_irf)
|
|||
hold off,
|
||||
% hold off,
|
||||
title([endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'],'interpreter','none'),
|
||||
%set(legend_h,'Xlim',[0 1]);
|
||||
% if ij==maxij
|
||||
% leg1 = num2str(endo_prior_restrictions.irf{ij,3}(:));
|
||||
% [legend_h,object_h,plot_h,text_strings]=legend(leg1);
|
||||
% Position=get(legend_h,'Position');Position(1:2)=[-0.055 0.95-Position(4)];
|
||||
% set(legend_h,'Position',Position);
|
||||
% end
|
||||
end
|
||||
% hc = get(h,'Children');
|
||||
%for i=2:2:length(hc)
|
||||
%end
|
||||
indx1 = find(indx_irf(:,ij)==0);
|
||||
indx2 = find(indx_irf(:,ij)~=0);
|
||||
atitle0=[endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'];
|
||||
fprintf(['%4.1f%% of the ',type,' support matches IRF ',atitle0,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,endo_prior_restrictions.irf{ij,4})
|
||||
% aname=[type '_irf_calib_',int2str(ij)];
|
||||
aname=[type '_irf_calib_',endo_prior_restrictions.irf{ij,1},'_vs_',endo_prior_restrictions.irf{ij,2},'_',aleg];
|
||||
atitle=[type ' IRF Calib: Parameter(s) driving ',endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'];
|
||||
options_mcf.amcf_name = aname;
|
||||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'IRF restriction';
|
||||
options_mcf.nobeha_title = 'NO IRF restriction';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'IRF restriction';
|
||||
options_mcf.nobeha_title_latex = 'NO IRF restriction';
|
||||
end
|
||||
options_mcf.title = atitle0;
|
||||
if ~isempty(indx1) && ~isempty(indx2)
|
||||
mcf_analysis(xmat(:,nshock+1:end), indx1, indx2, options_mcf, options_);
|
||||
mcf_analysis(xmat(:,nshock+1:end), indx1, indx2, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
|
||||
% [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
|
||||
% indplot=find(proba<pvalue_ks);
|
||||
% if ~isempty(indplot)
|
||||
% stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
|
||||
% end
|
||||
end
|
||||
for ij=1:nbr_irf_couples
|
||||
if length(time_matrix{ij})>1
|
||||
|
@ -284,7 +278,6 @@ if ~isempty(indx_irf)
|
|||
tmp(temp_index,:) = endo_prior_restrictions.irf{itmp(ir),4};
|
||||
end
|
||||
end
|
||||
% tmp = cell2mat(endo_prior_restrictions.irf(itmp,4));
|
||||
tmp(isinf(tmp(:,1)),1)=a(3);
|
||||
tmp(isinf(tmp(:,2)),2)=a(4);
|
||||
hp = patch([time_matrix{ij} time_matrix{ij}(end:-1:1)],[tmp(:,1); tmp(end:-1:1,2)],'c');
|
||||
|
@ -297,7 +290,6 @@ if ~isempty(indx_irf)
|
|||
hold off
|
||||
axis([max(1,a(1)) a(2:4)])
|
||||
box on
|
||||
%set(gca,'xtick',sort(time_matrix{ij}))
|
||||
itmp = min(itmp);
|
||||
title([endo_prior_restrictions.irf{itmp,1},' vs ',endo_prior_restrictions.irf{itmp,2}],'interpreter','none'),
|
||||
end
|
||||
|
@ -311,16 +303,20 @@ if ~isempty(indx_irf)
|
|||
aleg = 'ALL';
|
||||
atitle0=[endo_prior_restrictions.irf{itmp,1},' vs ',endo_prior_restrictions.irf{itmp,2}, '(', leg,')'];
|
||||
fprintf(['%4.1f%% of the ',type,' support matches IRF restrictions ',atitle0,'\n'],length(indx1)/length(irestrictions)*100)
|
||||
% aname=[type '_irf_calib_',int2str(ij)];
|
||||
aname=[type '_irf_calib_',endo_prior_restrictions.irf{itmp,1},'_vs_',endo_prior_restrictions.irf{itmp,2},'_',aleg];
|
||||
atitle=[type ' IRF Calib: Parameter(s) driving ',endo_prior_restrictions.irf{itmp,1},' vs ',endo_prior_restrictions.irf{itmp,2}, '(', leg,')'];
|
||||
options_mcf.amcf_name = aname;
|
||||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'IRF restriction';
|
||||
options_mcf.nobeha_title = 'NO IRF restriction';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'IRF restriction';
|
||||
options_mcf.nobeha_title_latex = 'NO IRF restriction';
|
||||
end
|
||||
|
||||
options_mcf.title = atitle0;
|
||||
if ~isempty(indx1) && ~isempty(indx2)
|
||||
mcf_analysis(xmat(:,nshock+1:end), indx1, indx2, options_mcf, options_);
|
||||
mcf_analysis(xmat(:,nshock+1:end), indx1, indx2, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -368,11 +364,11 @@ if ~isempty(indx_moment)
|
|||
name_tex=cell(np,1);
|
||||
for jj=1:np
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
name_tex{jj,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name_tex{jj,1} = param_name_tex_temp;
|
||||
name{jj,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name{jj,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
@ -398,7 +394,7 @@ if ~isempty(indx_moment)
|
|||
for ij=1:nbr_moment_restrictions
|
||||
endo_prior_restrictions.moment{ij,3} = sort(endo_prior_restrictions.moment{ij,3});
|
||||
if length(endo_prior_restrictions.moment{ij,3})>maxijv
|
||||
maxij=ij;maxijv=length(endo_prior_restrictions.moment{ij,3});
|
||||
maxijv=length(endo_prior_restrictions.moment{ij,3});
|
||||
end
|
||||
plot_indx(ij) = find(strcmp(moment_couples,all_moment_couples(ij,:)));
|
||||
time_matrix{plot_indx(ij)} = [time_matrix{plot_indx(ij)} endo_prior_restrictions.moment{ij,3}];
|
||||
|
@ -450,34 +446,25 @@ if ~isempty(indx_moment)
|
|||
set(hc,'color','k','linewidth',2)
|
||||
hold off
|
||||
title([endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2},'(',leg,')'],'interpreter','none'),
|
||||
% if ij==maxij
|
||||
% leg1 = num2str(endo_prior_restrictions.moment{ij,3}(:));
|
||||
% [legend_h,object_h,plot_h,text_strings]=legend(leg1);
|
||||
% Position=get(legend_h,'Position');Position(1:2)=[-0.055 0.95-Position(4)];
|
||||
% set(legend_h,'Position',Position);
|
||||
% end
|
||||
end
|
||||
indx1 = find(indx_moment(:,ij)==0);
|
||||
indx2 = find(indx_moment(:,ij)~=0);
|
||||
atitle0=[endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2}, '(', leg,')'];
|
||||
fprintf(['%4.1f%% of the ',type,' support matches MOMENT ',atitle0,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,endo_prior_restrictions.moment{ij,4})
|
||||
% aname=[type '_moment_calib_',int2str(ij)];
|
||||
aname=[type '_moment_calib_',endo_prior_restrictions.moment{ij,1},'_vs_',endo_prior_restrictions.moment{ij,2},'_',aleg];
|
||||
atitle=[type ' MOMENT Calib: Parameter(s) driving ',endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2}, '(', leg,')'];
|
||||
options_mcf.amcf_name = aname;
|
||||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'moment restriction';
|
||||
options_mcf.nobeha_title = 'NO moment restriction';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'moment restriction';
|
||||
options_mcf.nobeha_title_latex = 'NO moment restriction';
|
||||
end
|
||||
options_mcf.title = atitle0;
|
||||
if ~isempty(indx1) && ~isempty(indx2)
|
||||
mcf_analysis(xmat, indx1, indx2, options_mcf, options_);
|
||||
mcf_analysis(xmat, indx1, indx2, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
|
||||
% [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
|
||||
% indplot=find(proba<pvalue_ks);
|
||||
% if ~isempty(indplot)
|
||||
% stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
|
||||
% end
|
||||
end
|
||||
for ij=1:nbr_moment_couples
|
||||
time_matrix{ij} = sort(time_matrix{ij});
|
||||
|
@ -496,7 +483,6 @@ if ~isempty(indx_moment)
|
|||
tmp(temp_index,:) = endo_prior_restrictions.moment{itmp(ir),4};
|
||||
end
|
||||
end
|
||||
% tmp = cell2mat(endo_prior_restrictions.moment(itmp,4));
|
||||
tmp(isinf(tmp(:,1)),1)=a(3);
|
||||
tmp(isinf(tmp(:,2)),2)=a(4);
|
||||
hp = patch([time_matrix{ij} time_matrix{ij}(end:-1:1)],[tmp(:,1); tmp(end:-1:1,2)],'b');
|
||||
|
@ -509,7 +495,6 @@ if ~isempty(indx_moment)
|
|||
hold off
|
||||
axis(a)
|
||||
box on
|
||||
% set(gca,'xtick',sort(time_matrix{ij}))
|
||||
itmp = min(itmp);
|
||||
title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
|
||||
end
|
||||
|
@ -523,16 +508,19 @@ if ~isempty(indx_moment)
|
|||
aleg = 'ALL';
|
||||
atitle0=[endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}, '(', leg,')'];
|
||||
fprintf(['%4.1f%% of the ',type,' support matches MOMENT restrictions ',atitle0,'\n'],length(indx1)/length(irestrictions)*100)
|
||||
% aname=[type '_moment_calib_',int2str(ij)];
|
||||
aname=[type '_moment_calib_',endo_prior_restrictions.moment{itmp,1},'_vs_',endo_prior_restrictions.moment{itmp,2},'_',aleg];
|
||||
atitle=[type ' MOMENT Calib: Parameter(s) driving ',endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}, '(', leg,')'];
|
||||
options_mcf.amcf_name = aname;
|
||||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'moment restriction';
|
||||
options_mcf.nobeha_title = 'NO moment restriction';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'moment restriction';
|
||||
options_mcf.nobeha_title_latex = 'NO moment restriction';
|
||||
end
|
||||
options_mcf.title = atitle0;
|
||||
if ~isempty(indx1) && ~isempty(indx2)
|
||||
mcf_analysis(xmat, indx1, indx2, options_mcf, options_);
|
||||
mcf_analysis(xmat, indx1, indx2, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,19 @@
|
|||
function [vdec, cc, ac] = mc_moments(mm, ss, dr)
|
||||
function [vdec, cc, ac] = mc_moments(mm, ss, dr, M_, options_, estim_params_)
|
||||
% [vdec, cc, ac] = mc_moments(mm, ss, dr, M_, options_,estim_params_)
|
||||
% Conduct Monte Carlo simulation of second moments for GSA
|
||||
% Inputs:
|
||||
% - dr [structure] decision rules
|
||||
% - M_ [structure] model structure
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
%
|
||||
% Outputs:
|
||||
% - vdec [double] variance decomposition matrix
|
||||
% - cc [double] vector of unique elements of cross correlation matrix
|
||||
% - ac [cell] autocorrelation matrix
|
||||
|
||||
% Copyright © 2012-2018 Dynare Team
|
||||
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -17,30 +30,30 @@ function [vdec, cc, ac] = mc_moments(mm, ss, dr)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global options_ M_ estim_params_ oo_
|
||||
|
||||
[nr1, nc1, nsam] = size(mm);
|
||||
[~, nc1, nsam] = size(mm);
|
||||
nobs=length(options_.varobs);
|
||||
disp('Computing theoretical moments ...')
|
||||
disp('mc_moments: Computing theoretical moments ...')
|
||||
h = dyn_waitbar(0,'Theoretical moments ...');
|
||||
vdec = zeros(nobs,M_.exo_nbr,nsam);
|
||||
cc = zeros(nobs,nobs,nsam);
|
||||
ac = zeros(nobs,nobs*options_.ar,nsam);
|
||||
|
||||
for j=1:nsam
|
||||
oo_.dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j);
|
||||
oo_.dr.ghu = mm(:, [(nc1-M_.exo_nbr+1):end], j);
|
||||
dr.ghx = mm(:, 1:(nc1-M_.exo_nbr),j);
|
||||
dr.ghu = mm(:, (nc1-M_.exo_nbr+1):end, j);
|
||||
if ~isempty(ss)
|
||||
set_shocks_param(ss(j,:));
|
||||
M_=set_shocks_param(M_,estim_params_,ss(j,:));
|
||||
end
|
||||
[vdec(:,:,j), corr, autocorr, z, zz] = th_moments(oo_.dr,options_.varobs);
|
||||
[vdec(:,:,j), corr, autocorr] = th_moments(dr,options_,M_);
|
||||
cc(:,:,j)=triu(corr);
|
||||
dum=[];
|
||||
dum=NaN(nobs,nobs*options_.ar);
|
||||
for i=1:options_.ar
|
||||
dum=[dum, autocorr{i}];
|
||||
dum(:,(i-1)*nobs+1:i*nobs)=autocorr{i};
|
||||
end
|
||||
ac(:,:,j)=dum;
|
||||
dyn_waitbar(j/nsam,h)
|
||||
if mod(j,3)==0
|
||||
dyn_waitbar(j/nsam,h)
|
||||
end
|
||||
end
|
||||
dyn_waitbar_close(h)
|
||||
skipline()
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
function indmcf = mcf_analysis(lpmat, ibeha, inobeha, options_mcf, options_)
|
||||
% indmcf = mcf_analysis(lpmat, ibeha, inobeha, options_mcf, options_)
|
||||
function indmcf = mcf_analysis(lpmat, ibeha, inobeha, options_mcf, M_, options_, bayestopt_, estim_params_)
|
||||
% indmcf = mcf_analysis(lpmat, ibeha, inobeha, options_mcf, M_, options_, bayestopt_, estim_params_)
|
||||
% Inputs:
|
||||
% - lpmat [double] Monte Carlo matrix
|
||||
% - ibeha [integer] index of behavioural runs
|
||||
% - inobeha [integer] index of non-behavioural runs
|
||||
% - options_gsa_ [structure] GSA options_
|
||||
% - M_ [structure] describing the model
|
||||
% - options_ [structure] describing the options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
%
|
||||
% Outputs:
|
||||
% - indmcf [double] results of matrix
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -42,6 +54,10 @@ amcf_name = options_mcf.amcf_name;
|
|||
amcf_title = options_mcf.amcf_title;
|
||||
beha_title = options_mcf.beha_title;
|
||||
nobeha_title = options_mcf.nobeha_title;
|
||||
if options_.TeX
|
||||
beha_title_latex = options_mcf.beha_title_latex;
|
||||
nobeha_title_latex = options_mcf.nobeha_title_latex;
|
||||
end
|
||||
title = options_mcf.title;
|
||||
fname_ = options_mcf.fname_;
|
||||
xparam1=[];
|
||||
|
@ -50,15 +66,15 @@ if isfield(options_mcf,'xparam1')
|
|||
end
|
||||
OutputDirectoryName = options_mcf.OutputDirectoryName;
|
||||
|
||||
[proba, dproba] = stab_map_1(lpmat, ibeha, inobeha, [],0);
|
||||
[proba, dproba] = stab_map_1(lpmat, ibeha, inobeha, [],fname_, options_, bayestopt_.name, estim_params_,0);
|
||||
indmcf=find(proba<pvalue_ks);
|
||||
[tmp,jtmp] = sort(proba(indmcf),2,'ascend');
|
||||
[~,jtmp] = sort(proba(indmcf),1,'ascend');
|
||||
indmcf = indmcf(jtmp);
|
||||
if ~isempty(indmcf)
|
||||
skipline()
|
||||
headers = {'Parameter','d-stat','p-value'};
|
||||
labels = param_names(indmcf);
|
||||
data_mat=[dproba(indmcf)' proba(indmcf)'];
|
||||
data_mat=[dproba(indmcf) proba(indmcf)];
|
||||
options_temp.noprint=0;
|
||||
dyntable(options_temp,['Smirnov statistics in driving ', title],headers,labels,data_mat,size(labels,2)+2,16,3);
|
||||
if options_.TeX
|
||||
|
@ -69,10 +85,14 @@ if ~isempty(indmcf)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
if length(ibeha)>10 && length(inobeha)>10
|
||||
indcorr1 = stab_map_2(lpmat(ibeha,:),alpha2, pvalue_corr, beha_title);
|
||||
indcorr2 = stab_map_2(lpmat(inobeha,:),alpha2, pvalue_corr, nobeha_title);
|
||||
if options_.TeX
|
||||
indcorr1 = stab_map_2(lpmat(ibeha,:),alpha2, pvalue_corr, M_, options_, bayestopt_, estim_params_, beha_title, beha_title_latex);
|
||||
indcorr2 = stab_map_2(lpmat(inobeha,:),alpha2, pvalue_corr, M_, options_, bayestopt_, estim_params_, nobeha_title, nobeha_title_latex);
|
||||
else
|
||||
indcorr1 = stab_map_2(lpmat(ibeha,:),alpha2, pvalue_corr, M_, options_, bayestopt_, estim_params_, beha_title);
|
||||
indcorr2 = stab_map_2(lpmat(inobeha,:),alpha2, pvalue_corr, M_, options_, bayestopt_, estim_params_, nobeha_title);
|
||||
end
|
||||
indcorr = union(indcorr1(:), indcorr2(:));
|
||||
indcorr = indcorr(~ismember(indcorr(:),indmcf));
|
||||
indmcf = [indmcf(:); indcorr(:)];
|
||||
|
@ -80,8 +100,16 @@ end
|
|||
if ~isempty(indmcf) && ~options_.nograph
|
||||
skipline()
|
||||
xx=[];
|
||||
if ~ isempty(xparam1), xx=xparam1(indmcf); end
|
||||
scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names_tex(indmcf), ...
|
||||
'.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, options_, ...
|
||||
beha_title, nobeha_title)
|
||||
if ~ isempty(xparam1)
|
||||
xx=xparam1(indmcf);
|
||||
end
|
||||
if options_.TeX
|
||||
scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names_tex(indmcf), ...
|
||||
'.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, options_, ...
|
||||
beha_title, nobeha_title, beha_title_latex, nobeha_title_latex)
|
||||
else
|
||||
scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names_tex(indmcf), ...
|
||||
'.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,xx, options_, ...
|
||||
beha_title, nobeha_title)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
function sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
||||
% sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
||||
% sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
||||
% Creates a box plot
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
% Copyright © 2010-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -23,18 +19,17 @@ function sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
% % % % endif
|
||||
if nargin < 5 | isempty(maxwhisker), maxwhisker = 1.5; end
|
||||
if nargin < 4 | isempty(vertical), vertical = 1; end
|
||||
if nargin < 3 | isempty(symbol), symbol = ['+','o']; end
|
||||
if nargin < 2 | isempty(notched), notched = 0; end
|
||||
if nargin < 5 || isempty(maxwhisker), maxwhisker = 1.5; end
|
||||
if nargin < 4 || isempty(vertical), vertical = 1; end
|
||||
if nargin < 3 || isempty(symbol), symbol = ['+','o']; end
|
||||
if nargin < 2 || isempty(notched), notched = 0; end
|
||||
|
||||
if length(symbol)==1, symbol(2)=symbol(1); end
|
||||
|
||||
if notched==1, notched=0.25; end
|
||||
a=1-notched;
|
||||
|
||||
% ## figure out how many data sets we have
|
||||
% % figure out how many data sets we have
|
||||
if iscell(data)
|
||||
nc = length(data);
|
||||
else
|
||||
|
@ -42,11 +37,11 @@ else
|
|||
nc = size(data,2);
|
||||
end
|
||||
|
||||
% ## compute statistics
|
||||
% ## s will contain
|
||||
% ## 1,5 min and max
|
||||
% ## 2,3,4 1st, 2nd and 3rd quartile
|
||||
% ## 6,7 lower and upper confidence intervals for median
|
||||
% compute statistics
|
||||
% s will contain
|
||||
% 1,5 min and max
|
||||
% 2,3,4 1st, 2nd and 3rd quartile
|
||||
% 6,7 lower and upper confidence intervals for median
|
||||
s = zeros(7,nc);
|
||||
box = zeros(1,nc);
|
||||
whisker_x = ones(2,1)*[1:nc,1:nc];
|
||||
|
@ -57,44 +52,36 @@ outliers2_x = [];
|
|||
outliers2_y = [];
|
||||
|
||||
for i=1:nc
|
||||
% ## Get the next data set from the array or cell array
|
||||
% Get the next data set from the array or cell array
|
||||
if iscell(data)
|
||||
col = data{i}(:);
|
||||
else
|
||||
col = data(:,i);
|
||||
end
|
||||
% ## Skip missing data
|
||||
% Skip missing data
|
||||
% % % % % % % col(isnan(col) | isna (col)) = [];
|
||||
col(isnan(col)) = [];
|
||||
|
||||
% ## Remember the data length
|
||||
% Remember the data length
|
||||
nd = length(col);
|
||||
box(i) = nd;
|
||||
if (nd > 1)
|
||||
% ## min,max and quartiles
|
||||
% s(1:5,i) = statistics(col)(1:5);
|
||||
% min,max and quartiles
|
||||
s(1,i)=min(col);
|
||||
s(5,i)=max(col);
|
||||
s(2,i)=myprctilecol(col,25);
|
||||
s(3,i)=myprctilecol(col,50);
|
||||
s(4,i)=myprctilecol(col,75);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% ## confidence interval for the median
|
||||
% confidence interval for the median
|
||||
est = 1.57*(s(4,i)-s(2,i))/sqrt(nd);
|
||||
s(6,i) = max([s(3,i)-est, s(2,i)]);
|
||||
s(7,i) = min([s(3,i)+est, s(4,i)]);
|
||||
% ## whiskers out to the last point within the desired inter-quartile range
|
||||
% whiskers out to the last point within the desired inter-quartile range
|
||||
IQR = maxwhisker*(s(4,i)-s(2,i));
|
||||
whisker_y(:,i) = [min(col(col >= s(2,i)-IQR)); s(2,i)];
|
||||
whisker_y(:,nc+i) = [max(col(col <= s(4,i)+IQR)); s(4,i)];
|
||||
% ## outliers beyond 1 and 2 inter-quartile ranges
|
||||
% outliers beyond 1 and 2 inter-quartile ranges
|
||||
outliers = col((col < s(2,i)-IQR & col >= s(2,i)-2*IQR) | (col > s(4,i)+IQR & col <= s(4,i)+2*IQR));
|
||||
outliers2 = col(col < s(2,i)-2*IQR | col > s(4,i)+2*IQR);
|
||||
outliers_x = [outliers_x; i*ones(size(outliers))];
|
||||
|
@ -102,41 +89,37 @@ for i=1:nc
|
|||
outliers2_x = [outliers2_x; i*ones(size(outliers2))];
|
||||
outliers2_y = [outliers2_y; outliers2];
|
||||
elseif (nd == 1)
|
||||
% ## all statistics collapse to the value of the point
|
||||
% all statistics collapse to the value of the point
|
||||
s(:,i) = col;
|
||||
% ## single point data sets are plotted as outliers.
|
||||
% single point data sets are plotted as outliers.
|
||||
outliers_x = [outliers_x; i];
|
||||
outliers_y = [outliers_y; col];
|
||||
else
|
||||
% ## no statistics if no points
|
||||
% no statistics if no points
|
||||
s(:,i) = NaN;
|
||||
end
|
||||
end
|
||||
% % % % if isempty(outliers2_y)
|
||||
% % % % outliers2_y=
|
||||
% ## Note which boxes don't have enough stats
|
||||
% Note which boxes don't have enough stats
|
||||
chop = find(box <= 1);
|
||||
|
||||
% ## Draw a box around the quartiles, with width proportional to the number of
|
||||
% ## items in the box. Draw notches if desired.
|
||||
% Draw a box around the quartiles, with width proportional to the number of
|
||||
% items in the box. Draw notches if desired.
|
||||
box = box*0.23/max(box);
|
||||
quartile_x = ones(11,1)*[1:nc] + [-a;-1;-1;1;1;a;1;1;-1;-1;-a]*box;
|
||||
quartile_y = s([3,7,4,4,7,3,6,2,2,6,3],:);
|
||||
|
||||
% ## Draw a line through the median
|
||||
% Draw a line through the median
|
||||
median_x = ones(2,1)*[1:nc] + [-a;+a]*box;
|
||||
% median_x=median(col);
|
||||
median_y = s([3,3],:);
|
||||
|
||||
% ## Chop all boxes which don't have enough stats
|
||||
% Chop all boxes which don't have enough stats
|
||||
quartile_x(:,chop) = [];
|
||||
quartile_y(:,chop) = [];
|
||||
whisker_x(:,[chop,chop+nc]) = [];
|
||||
whisker_y(:,[chop,chop+nc]) = [];
|
||||
median_x(:,chop) = [];
|
||||
median_y(:,chop) = [];
|
||||
% % % %
|
||||
% ## Add caps to the remaining whiskers
|
||||
% Add caps to the remaining whiskers
|
||||
cap_x = whisker_x;
|
||||
cap_x(1,:) =cap_x(1,:)- 0.05;
|
||||
cap_x(2,:) =cap_x(2,:)+ 0.05;
|
||||
|
@ -146,11 +129,14 @@ cap_y = whisker_y([1,1],:);
|
|||
% #whisker_x,whisker_y
|
||||
% #median_x,median_y
|
||||
% #cap_x,cap_y
|
||||
%
|
||||
% ## Do the plot
|
||||
|
||||
% Do the plot
|
||||
mm=min(min(data));
|
||||
MM=max(max(data));
|
||||
if isnan(mm)
|
||||
mm=0;
|
||||
MM=0;
|
||||
end
|
||||
|
||||
if vertical
|
||||
plot (quartile_x, quartile_y, 'b', ...
|
||||
|
@ -162,17 +148,30 @@ if vertical
|
|||
set(gca,'XTick',1:nc);
|
||||
set(gca, 'XLim', [0.5, nc+0.5]);
|
||||
set(gca, 'YLim', [mm-(MM-mm)*0.05-eps, MM+(MM-mm)*0.05+eps]);
|
||||
|
||||
else
|
||||
% % % % % plot (quartile_y, quartile_x, "b;;",
|
||||
% % % % % whisker_y, whisker_x, "b;;",
|
||||
% % % % % cap_y, cap_x, "b;;",
|
||||
% % % % % median_y, median_x, "r;;",
|
||||
% % % % % outliers_y, outliers_x, [symbol(1),"r;;"],
|
||||
% % % % % outliers2_y, outliers2_x, [symbol(2),"r;;"]);
|
||||
end
|
||||
|
||||
if nargout
|
||||
sout=s;
|
||||
end
|
||||
% % % endfunction
|
||||
|
||||
function y = myprctilecol(x,p)
|
||||
|
||||
xx = sort(x);
|
||||
[m,n] = size(x);
|
||||
|
||||
if m==1 | n==1
|
||||
m = max(m,n);
|
||||
if m == 1
|
||||
y = x*ones(length(p),1);
|
||||
return
|
||||
end
|
||||
n = 1;
|
||||
q = 100*(0.5:m - 0.5)./m;
|
||||
xx = [min(x); xx(:); max(x)];
|
||||
else
|
||||
q = 100*(0.5:m - 0.5)./m;
|
||||
xx = [min(x); xx; max(x)];
|
||||
end
|
||||
|
||||
q = [0 q 100];
|
||||
y = interp1(q,xx,p);
|
|
@ -1,43 +0,0 @@
|
|||
function y = myprctilecol(x,p)
|
||||
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
xx = sort(x);
|
||||
[m,n] = size(x);
|
||||
|
||||
if m==1 | n==1
|
||||
m = max(m,n);
|
||||
if m == 1
|
||||
y = x*ones(length(p),1);
|
||||
return
|
||||
end
|
||||
n = 1;
|
||||
q = 100*(0.5:m - 0.5)./m;
|
||||
xx = [min(x); xx(:); max(x)];
|
||||
else
|
||||
q = 100*(0.5:m - 0.5)./m;
|
||||
xx = [min(x); xx; max(x)];
|
||||
end
|
||||
|
||||
q = [0 q 100];
|
||||
y = interp1(q,xx,p);
|
|
@ -1,91 +0,0 @@
|
|||
function pick
|
||||
%
|
||||
% Copyright © 2001-2017 European Commission
|
||||
% Copyright © 2017-2023 DynareTeam
|
||||
|
||||
% This file is part of GLUEWIN
|
||||
% GLUEWIN is a MATLAB code designed for analysing the output
|
||||
% of Monte Carlo runs when empirical observations of the model output are available
|
||||
% and implements the GSA-GLUE methodology by Ratto et al. [1], based on a combination
|
||||
% of GLUE (Generalised Likelihood Uncertainty Estimation) by K. Beven [2] and GSA
|
||||
% Global Sensitivity Analysis) [3].']
|
||||
% The program has been developed by M. Ratto, European Commission, Joint Research Centre,
|
||||
% Institute for the Protection and Security of The Citizen, Technological and Economic Risk Management,
|
||||
% Applied Statistics, as a deliverable of the IMPACT project
|
||||
% (EC Fifth Framework Programme, SCA Project, IST-1999-11313, DG-INFSO).
|
||||
%
|
||||
% The graphical layout of the code is inspired by the freeware GLUE package by K. Beven,
|
||||
% vailable at the Lancaster University web site on the page [4]:
|
||||
% http://www.es.lancs.ac.uk/hfdg/glue.html
|
||||
% to which the GLUEWIN code introduces several extensions and additional options.
|
||||
% Thanks are due to R. Girardi, A. Rossi, A. Saltelli, S. Tarantola and U. Callies for numerous
|
||||
% comments and suggestions.
|
||||
% For more information, please contact marco.ratto@ec.europa.eu
|
||||
%
|
||||
% Disclaimer: This software has been developed at the Joint Research Centre of European Commission
|
||||
% by officers in the course of their official duties. This software is not subject to copyright
|
||||
% protection and is in the public domain. It is an experimental system. The Joint Research Centre
|
||||
% of European Commission assumes no responsibility whatsoever for its use by other parties
|
||||
% and makes no guarantees, expressed or implied, about its quality, reliability, or any other
|
||||
% characteristic. We would appreciate acknowledgement if the software is used.
|
||||
%
|
||||
% [1] Ratto, M., Tarantola, S., A. Saltelli, Sensitivity analysis in model calibration: GSA-GLUE approach.
|
||||
% 'Computer Physics Communications, 136, 2001, 212-224
|
||||
% [2] Beven K.J., Binley A., The Future of Distributed Models: Model Calibration and Uncertainty
|
||||
% 'Prediction, Hydrological Processes, 6, 279-298, 1992
|
||||
% [3] Saltelli, A., K. Chan, M. Scott, Editors, (2000), Sensitivity analysis, John Wiley & Sons
|
||||
% 'publishers, Probability and Statistics series.
|
||||
% [4] Beven K., GLUE for Windows User manual, 1998.
|
||||
|
||||
|
||||
|
||||
pmenu=findobj(gcf,'type','uicontextmenu','Tag','Run viewer');
|
||||
button1=findobj(gcf,'type','uimenu','Tag','save params');
|
||||
button2=findobj(gcf,'type','uimenu','Tag','eval params');
|
||||
%button=get(pmenu,'children');
|
||||
gg=gco;
|
||||
ax0=gca;
|
||||
set(gg,'buttondownfcn',[]);
|
||||
c=get(gca,'currentpoint');
|
||||
x=c(1,1);
|
||||
y=c(1,2);
|
||||
X=get(gco,'xdata');
|
||||
Y=get(gco,'ydata');
|
||||
dx=get(gca,'xlim');
|
||||
dy=get(gca,'ylim');
|
||||
pos=get(gca,'position');
|
||||
scalex=dx(2)-dx(1);
|
||||
scaley=dy(2)-dy(1);
|
||||
if length(X)>1
|
||||
K = dsearchn([(Y./scaley)' (X./scalex)'],[y/scaley x/scalex]);
|
||||
else
|
||||
az=get(gca,'children');
|
||||
T =get(az(end),'ydata');
|
||||
[dum K]=max(T);
|
||||
end
|
||||
|
||||
KK=K;
|
||||
|
||||
set(button1,'Label',['Save ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''save'')']);
|
||||
set(button2,'Label',['Eval ',num2str(K)],'Callback',['scatter_callback(',num2str(KK),',''eval'')']);
|
||||
hh_obj=findobj(gcf,'type','axes','Tag','scatter');
|
||||
for k=1:length(hh_obj)
|
||||
axes(hh_obj(k));
|
||||
dum=get(gca,'children');
|
||||
dumx=get(dum(end),'xdata');
|
||||
dumy=get(dum(end),'ydata');
|
||||
xmid=min(dumx) + 0.5*(max(dumx)-min(dumx));
|
||||
hold on
|
||||
plot(dumx(KK),dumy(KK),'or');
|
||||
if dumx(KK) < xmid
|
||||
text(dumx(KK),dumy(KK),[' ',num2str(K)], ...
|
||||
'FontWeight','Bold',...
|
||||
'Color','r');
|
||||
else
|
||||
text(dumx(KK),dumy(KK),[num2str(K),' '], ...
|
||||
'HorizontalAlignment','right', ...
|
||||
'FontWeight','Bold',...
|
||||
'Color','r');
|
||||
end
|
||||
hold off
|
||||
end
|
|
@ -1,9 +1,13 @@
|
|||
function pdraw = prior_draw_gsa(init,rdraw)
|
||||
function pdraw = prior_draw_gsa(M_,bayestopt_,options_,estim_params_,init,rdraw)
|
||||
% Draws from the prior distributions for use with Sensitivity Toolbox for DYNARE
|
||||
%
|
||||
% INPUTS
|
||||
% o init [integer] scalar equal to 1 (first call) or 0.
|
||||
% o rdraw
|
||||
% - M_ [structure] describing the model
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - options_ [structure] describing the options
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - init [integer] scalar equal to 1 (first call) or 0.
|
||||
% - rdraw
|
||||
%
|
||||
% OUTPUTS
|
||||
% o pdraw [double] draw from the joint prior density.
|
||||
|
@ -35,8 +39,7 @@ function pdraw = prior_draw_gsa(init,rdraw)
|
|||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global bayestopt_ options_ estim_params_ M_
|
||||
|
||||
persistent npar pshape p6 p7 p3 p4 lbcum ubcum
|
||||
|
||||
if init
|
||||
|
@ -49,7 +52,7 @@ if init
|
|||
pdraw = zeros(npar,1);
|
||||
lbcum = zeros(npar,1);
|
||||
ubcum = ones(npar,1);
|
||||
[~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
|
||||
[~,~,~,lb,ub] = set_prior(estim_params_,M_,options_); %Prepare bounds
|
||||
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
|
||||
% Set prior bounds
|
||||
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
||||
|
@ -64,29 +67,29 @@ if init
|
|||
% set bounds for cumulative probabilities
|
||||
for i = 1:npar
|
||||
switch pshape(i)
|
||||
case 5% Uniform prior.
|
||||
p4(i) = min(p4(i),bounds.ub(i));
|
||||
p3(i) = max(p3(i),bounds.lb(i));
|
||||
case 3% Gaussian prior.
|
||||
lbcum(i) = 0.5 * erfc(-(bounds.lb(i)-p6(i))/p7(i) ./ sqrt(2));
|
||||
ubcum(i) = 0.5 * erfc(-(bounds.ub(i)-p6(i))/p7(i) ./ sqrt(2));
|
||||
case 2% Gamma prior.
|
||||
lbcum(i) = gamcdf(bounds.lb(i)-p3(i),p6(i),p7(i));
|
||||
ubcum(i) = gamcdf(bounds.ub(i)-p3(i),p6(i),p7(i));
|
||||
case 1% Beta distribution (TODO: generalized beta distribution)
|
||||
lbcum(i) = betainc((bounds.lb(i)-p3(i))./(p4(i)-p3(i)),p6(i),p7(i));
|
||||
ubcum(i) = betainc((bounds.ub(i)-p3(i))./(p4(i)-p3(i)),p6(i),p7(i));
|
||||
case 2% Gamma prior.
|
||||
lbcum(i) = gamcdf(bounds.lb(i)-p3(i),p6(i),p7(i));
|
||||
ubcum(i) = gamcdf(bounds.ub(i)-p3(i),p6(i),p7(i));
|
||||
case 3% Gaussian prior.
|
||||
lbcum(i) = 0.5 * erfc(-(bounds.lb(i)-p6(i))/p7(i) ./ sqrt(2));
|
||||
ubcum(i) = 0.5 * erfc(-(bounds.ub(i)-p6(i))/p7(i) ./ sqrt(2));
|
||||
case 4% INV-GAMMA1 distribution
|
||||
% TO BE CHECKED
|
||||
lbcum(i) = gamcdf(1/(bounds.ub(i)-p3(i))^2,p7(i)/2,2/p6(i));
|
||||
ubcum(i) = gamcdf(1/(bounds.lb(i)-p3(i))^2,p7(i)/2,2/p6(i));
|
||||
case 5% Uniform prior.
|
||||
p4(i) = min(p4(i),bounds.ub(i));
|
||||
p3(i) = max(p3(i),bounds.lb(i));
|
||||
case 6% INV-GAMMA2 distribution
|
||||
% TO BE CHECKED
|
||||
lbcum(i) = gamcdf(1/(bounds.ub(i)-p3(i)),p7(i)/2,2/p6(i));
|
||||
ubcum(i) = gamcdf(1/(bounds.lb(i)-p3(i)),p7(i)/2,2/p6(i));
|
||||
case 8
|
||||
lbcum(i) = weibcdf(bounds.lb(i)-p3(i),p6(i),p7(i));
|
||||
ubcum(i) = weibcdf(bounds.ub(i)-p3(i),p6(i),p7(i));
|
||||
lbcum(i) = wblcdf(bounds.lb(i)-p3(i),p6(i),p7(i));
|
||||
ubcum(i) = wblcdf(bounds.ub(i)-p3(i),p6(i),p7(i));
|
||||
otherwise
|
||||
% Nothing to do here.
|
||||
end
|
||||
|
@ -94,7 +97,7 @@ if init
|
|||
return
|
||||
end
|
||||
|
||||
|
||||
pdraw=NaN(size(rdraw,1),npar);
|
||||
for i = 1:npar
|
||||
rdraw(:,i) = rdraw(:,i).*(ubcum(i)-lbcum(i))+lbcum(i);
|
||||
switch pshape(i)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function xcum = priorcdf(para, pshape, p6, p7, p3, p4)
|
||||
|
||||
% xcum = priorcdf(para, pshape, p6, p7, p3, p4)
|
||||
% This procedure transforms x vectors into cumulative values
|
||||
% pshape: 0 is point mass, both para and p2 are ignored
|
||||
% 1 is BETA(mean,stdd)
|
||||
|
@ -11,7 +11,7 @@ function xcum = priorcdf(para, pshape, p6, p7, p3, p4)
|
|||
% 8 is WEIBULL(s, k)
|
||||
% Adapted by M. Ratto from MJ priordens.m
|
||||
|
||||
% Copyright © 2012-2015 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -28,6 +28,7 @@ function xcum = priorcdf(para, pshape, p6, p7, p3, p4)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
xcum=NaN(size(para));
|
||||
for i=1:length(pshape)
|
||||
switch pshape(i)
|
||||
case 1 % (generalized) BETA Prior
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
function [gend, data] = read_data()
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012-2015 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global options_
|
||||
|
||||
rawdata = read_variables(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
|
||||
|
||||
options_ = set_default_option(options_,'nobs',size(rawdata,1)-options_.first_obs+1);
|
||||
gend = options_.nobs;
|
||||
|
||||
rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
|
||||
if options_.loglinear == 1 & ~options_.logdata
|
||||
rawdata = log(rawdata);
|
||||
end
|
||||
if options_.prefilter == 1
|
||||
data = transpose(rawdata-ones(gend,1)* mean(rawdata,1));
|
||||
else
|
||||
data = transpose(rawdata);
|
||||
end
|
||||
|
||||
if ~isreal(rawdata)
|
||||
error(['There are complex values in the data. Probably a wrong' ...
|
||||
' transformation'])
|
||||
end
|
|
@ -1,15 +1,13 @@
|
|||
function redform_map(dirname,options_gsa_)
|
||||
%function redform_map(dirname)
|
||||
% inputs (from opt_gsa structure
|
||||
% anamendo = options_gsa_.namendo;
|
||||
% anamlagendo = options_gsa_.namlagendo;
|
||||
% anamexo = options_gsa_.namexo;
|
||||
% iload = options_gsa_.load_redform;
|
||||
% pprior = options_gsa_.pprior;
|
||||
% ilog = options_gsa_.logtrans_redform;
|
||||
% threshold = options_gsa_.threshold_redform;
|
||||
% ksstat = options_gsa_.ksstat_redform;
|
||||
% alpha2 = options_gsa_.alpha2_redform;
|
||||
function redform_map(dirname,options_gsa_,M_,estim_params_,options_,bayestopt_,oo_)
|
||||
% redform_map(dirname,options_gsa_,M_,estim_params_,options_,bayestopt_,oo_)
|
||||
% Inputs:
|
||||
% - dirname [string] name of the output directory
|
||||
% - options_gsa_ [structure] GSA options_
|
||||
% - M_ [structure] describing the model
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - options_ [structure] describing the options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - oo_ [structure] storing the results
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -33,23 +31,16 @@ function redform_map(dirname,options_gsa_)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
global M_ oo_ estim_params_ options_ bayestopt_
|
||||
|
||||
% options_gsa_ = options_.opt_gsa;
|
||||
|
||||
anamendo = options_gsa_.namendo;
|
||||
anamlagendo = options_gsa_.namlagendo;
|
||||
anamexo = options_gsa_.namexo;
|
||||
anamendo_tex = options_gsa_.namendo_tex;
|
||||
anamlagendo_tex = options_gsa_.namlagendo_tex;
|
||||
anamexo_tex = options_gsa_.namexo_tex;
|
||||
iload = options_gsa_.load_redform;
|
||||
pprior = options_gsa_.pprior;
|
||||
ilog = options_gsa_.logtrans_redform;
|
||||
threshold = options_gsa_.threshold_redform;
|
||||
% ksstat = options_gsa_.ksstat_redform;
|
||||
alpha2 = options_gsa_.alpha2_redform;
|
||||
alpha2=0;
|
||||
pvalue_ks = options_gsa_.ksstat_redform;
|
||||
pvalue_corr = options_gsa_.alpha2_redform;
|
||||
|
||||
np = estim_params_.np;
|
||||
nshock = estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn;
|
||||
|
@ -57,11 +48,11 @@ pnames=cell(np,1);
|
|||
pnames_tex=cell(np,1);
|
||||
for jj=1:np
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_);
|
||||
pnames_tex{jj,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
pnames_tex{jj,1} = param_name_tex_temp;
|
||||
pnames{jj,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
pnames{jj,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
@ -93,14 +84,14 @@ end
|
|||
options_mcf.fname_ = M_.fname;
|
||||
options_mcf.OutputDirectoryName = adir;
|
||||
|
||||
if ~exist('T')
|
||||
stab_map_(dirname,options_gsa_);
|
||||
if ~exist('T','var')
|
||||
stab_map_(dirname,options_gsa_,M_,oo_,options_,bayestopt_,estim_params_);
|
||||
if pprior
|
||||
load([dirname,filesep,M_.fname,'_prior'],'T');
|
||||
else
|
||||
load([dirname,filesep,M_.fname,'_mc'],'T');
|
||||
end
|
||||
if ~exist('T')
|
||||
if ~exist('T','var')
|
||||
disp('The model is too large!')
|
||||
disp('Reduced form mapping stopped!')
|
||||
return
|
||||
|
@ -109,8 +100,6 @@ end
|
|||
if isempty(dir(adir))
|
||||
mkdir(adir)
|
||||
end
|
||||
adir0=pwd;
|
||||
%cd(adir)
|
||||
|
||||
nspred=size(T,2)-M_.exo_nbr;
|
||||
x0=lpmat(istable,:);
|
||||
|
@ -121,7 +110,7 @@ else
|
|||
xx0=lpmat0(istable,:);
|
||||
nshocks=size(xx0,2);
|
||||
end
|
||||
[kn, np]=size(x0);
|
||||
[~, np]=size(x0);
|
||||
offset = length(bayestopt_.pshape)-np;
|
||||
if options_gsa_.prior_range
|
||||
pshape=5*(ones(np,1));
|
||||
|
@ -144,23 +133,22 @@ options_map.pshape = pshape;
|
|||
options_map.pd = pd;
|
||||
|
||||
nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
|
||||
lpmat=[];
|
||||
lpmat0=[];
|
||||
js=0;
|
||||
for j = 1:length(anamendo)
|
||||
namendo = anamendo{j};
|
||||
namendo_tex = anamendo_tex{j};
|
||||
iendo = strmatch(namendo, M_.endo_names(oo_.dr.order_var), 'exact');
|
||||
ifig = 0;
|
||||
iplo = 0;
|
||||
for jx = 1:length(anamexo)
|
||||
namexo = anamexo{jx};
|
||||
namexo_tex = anamexo_tex{jx};
|
||||
iexo=strmatch(namexo, M_.exo_names, 'exact');
|
||||
skipline()
|
||||
disp(['[', namendo,' vs ',namexo,']'])
|
||||
|
||||
|
||||
if ~isempty(iexo)
|
||||
%y0=squeeze(T(iendo,iexo+nspred,istable));
|
||||
y0=squeeze(T(iendo,iexo+nspred,:));
|
||||
if (max(y0)-min(y0))>1.e-10
|
||||
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
|
||||
|
@ -196,7 +184,6 @@ for j = 1:length(anamendo)
|
|||
hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs ', namexo]);
|
||||
hc = cumplot(y0);
|
||||
a=axis; delete(hc);
|
||||
% hist(mat_moment{ij}),
|
||||
x1val=max(threshold(1),a(1));
|
||||
x2val=min(threshold(2),a(2));
|
||||
hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'b');
|
||||
|
@ -205,9 +192,13 @@ for j = 1:length(anamendo)
|
|||
hc = cumplot(y0);
|
||||
set(hc,'color','k','linewidth',2)
|
||||
hold off,
|
||||
title([namendo,' vs ', namexo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
|
||||
if options_.TeX
|
||||
title([namendo_tex,' vs ', namexo_tex ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','latex')
|
||||
else
|
||||
title([namendo,' vs ', namexo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
|
||||
end
|
||||
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],['Reduced Form Mapping (Monte Carlo Filtering): ',strrep(namendo,'_','\_'),' vs ', strrep(namexo,'_','\_')],[type '_' namendo,'_vs_', namexo])
|
||||
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],['Reduced Form Mapping (Monte Carlo Filtering): ',namendo_tex,' vs ', namexo_tex],[type '_' namendo,'_vs_', namexo])
|
||||
end
|
||||
si(:,js) = NaN(np,1);
|
||||
delete([xdir, '/*threshold*.*'])
|
||||
|
@ -219,19 +210,23 @@ for j = 1:length(anamendo)
|
|||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'inside threshold';
|
||||
options_mcf.nobeha_title = 'outside threshold';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'inside threshold';
|
||||
options_mcf.nobeha_title_latex = 'outside threshold';
|
||||
end
|
||||
options_mcf.title = atitle0;
|
||||
options_mcf.OutputDirectoryName = xdir;
|
||||
if ~isempty(iy) && ~isempty(iyc)
|
||||
fprintf(['%4.1f%% of the ',type,' support matches ',atitle0,'\n'],length(iy)/length(y0)*100)
|
||||
icheck = mcf_analysis(x0, iy, iyc, options_mcf, options_);
|
||||
icheck = mcf_analysis(x0, iy, iyc, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
|
||||
lpmat=x0(iy,:);
|
||||
if nshocks
|
||||
lpmat0=xx0(iy,:);
|
||||
end
|
||||
istable=[1:length(iy)];
|
||||
istable=1:length(iy);
|
||||
save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
|
||||
lpmat=[]; lpmat0=[]; istable=[];
|
||||
lpmat0=[];
|
||||
if length(iy)<=10 || length(iyc)<=10
|
||||
icheck = []; % do the generic plot in any case
|
||||
end
|
||||
|
@ -255,12 +250,10 @@ for j = 1:length(anamendo)
|
|||
end
|
||||
atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namexo];
|
||||
options_mcf.title = atitle0;
|
||||
indmcf = redform_mcf(y0, x0, options_mcf, options_);
|
||||
|
||||
redform_mcf(y0, x0, options_mcf, options_, M_.fname, bayestopt_.name, estim_params_);
|
||||
end
|
||||
end
|
||||
else
|
||||
[yy, xdir] = log_trans_(y0,xdir0);
|
||||
atitle0=['Reduced Form Mapping (ANOVA) for log-transformed ',namendo,' vs ', namexo];
|
||||
aname=[type '_' namendo '_vs_' namexo];
|
||||
atitle=[type ' Reduced Form Mapping (ANOVA): Parameter(s) driving ',namendo,' vs ',namexo];
|
||||
|
@ -276,24 +269,31 @@ for j = 1:length(anamendo)
|
|||
figure(hh_fig)
|
||||
subplot(3,3,iplo),
|
||||
if ilog
|
||||
[saso, iso] = sort(-silog(:,js));
|
||||
[~, iso] = sort(-silog(:,js));
|
||||
bar([silog(iso(1:min(np,10)),js)])
|
||||
logflag='log';
|
||||
else
|
||||
[saso, iso] = sort(-si(:,js));
|
||||
[~, iso] = sort(-si(:,js));
|
||||
bar(si(iso(1:min(np,10)),js))
|
||||
logflag='';
|
||||
end
|
||||
%set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
|
||||
set(gca,'xticklabel',' ','fontsize',10)
|
||||
set(gca,'xlim',[0.5 10.5])
|
||||
for ip=1:min(np,10)
|
||||
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
if options_.TeX
|
||||
text(ip,-0.02,deblank(pnames_tex(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','latex')
|
||||
else
|
||||
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
end
|
||||
if options_.TeX
|
||||
title([logflag,' ',namendo_tex,' vs ',namexo_tex],'interpreter','none')
|
||||
else
|
||||
title([logflag,' ',namendo,' vs ',namexo],'interpreter','none')
|
||||
end
|
||||
title([logflag,' ',namendo,' vs ',namexo],'interpreter','none')
|
||||
if iplo==9
|
||||
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],1)
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',namendo_tex,' vs ',namexo_tex],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -310,12 +310,12 @@ for j = 1:length(anamendo)
|
|||
iplo=0;
|
||||
for je=1:length(anamlagendo)
|
||||
namlagendo = anamlagendo{je};
|
||||
namlagendo_tex = anamlagendo_tex{je};
|
||||
ilagendo=strmatch(namlagendo, M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok)), 'exact');
|
||||
skipline()
|
||||
disp(['[', namendo,' vs lagged ',namlagendo,']'])
|
||||
|
||||
if ~isempty(ilagendo)
|
||||
%y0=squeeze(T(iendo,ilagendo,istable));
|
||||
y0=squeeze(T(iendo,ilagendo,:));
|
||||
if (max(y0)-min(y0))>1.e-10
|
||||
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph
|
||||
|
@ -331,9 +331,9 @@ for j = 1:length(anamendo)
|
|||
if isempty(dir(xdir0))
|
||||
mkdir(xdir0)
|
||||
end
|
||||
atitle0=['Reduced Form Mapping (ANOVA) for ',namendo,' vs ', namlagendo];
|
||||
aname=[type '_' namendo '_vs_' namlagendo];
|
||||
atitle=[type ' Reduced Form Mapping (ANOVA): Parameter(s) driving ',namendo,' vs ',namlagendo];
|
||||
atitle0=['Reduced Form Mapping (ANOVA) for ',namendo,' vs lagged', namlagendo];
|
||||
aname=[type '_' namendo '_vs_lag_' namlagendo];
|
||||
atitle=[type ' Reduced Form Mapping (ANOVA): Parameter(s) driving ',namendo,' vs lagged',namlagendo];
|
||||
options_map.amap_name = aname;
|
||||
options_map.amap_title = atitle;
|
||||
options_map.figtitle = atitle0;
|
||||
|
@ -351,7 +351,6 @@ for j = 1:length(anamendo)
|
|||
hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs lagged ', namlagendo]);
|
||||
hc = cumplot(y0);
|
||||
a=axis; delete(hc);
|
||||
% hist(mat_moment{ij}),
|
||||
x1val=max(threshold(1),a(1));
|
||||
x2val=min(threshold(2),a(2));
|
||||
hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'b');
|
||||
|
@ -359,10 +358,14 @@ for j = 1:length(anamendo)
|
|||
hold all,
|
||||
hc = cumplot(y0);
|
||||
set(hc,'color','k','linewidth',2)
|
||||
hold off,
|
||||
title([namendo,' vs lagged ', namlagendo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
|
||||
hold off
|
||||
if options_.TeX
|
||||
title([namendo_tex,' vs lagged ', namlagendo_tex ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','latex')
|
||||
else
|
||||
title([namendo,' vs lagged ', namlagendo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
|
||||
end
|
||||
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],['Reduced Form Mapping (Monte Carlo Filtering): ',strrep(namendo,'_','\_'),' vs lagged ', strrep(namlagendo,'_','\_')],[type '_' namendo,'_vs_', namlagendo],1)
|
||||
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],['Reduced Form Mapping (Monte Carlo Filtering): ',namendo_tex,' vs lagged ', namlagendo_tex],[type '_' namendo,'_vs_', namlagendo],1)
|
||||
end
|
||||
|
||||
delete([xdir, '/*threshold*.*'])
|
||||
|
@ -374,24 +377,28 @@ for j = 1:length(anamendo)
|
|||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'inside threshold';
|
||||
options_mcf.nobeha_title = 'outside threshold';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'inside threshold';
|
||||
options_mcf.nobeha_title_latex = 'outside threshold';
|
||||
end
|
||||
|
||||
options_mcf.title = atitle0;
|
||||
options_mcf.OutputDirectoryName = xdir;
|
||||
if ~isempty(iy) && ~isempty(iyc)
|
||||
|
||||
fprintf(['%4.1f%% of the ',type,' support matches ',atitle0,'\n'],length(iy)/length(y0)*100)
|
||||
icheck = mcf_analysis(x0, iy, iyc, options_mcf, options_);
|
||||
icheck = mcf_analysis(x0, iy, iyc, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
|
||||
lpmat=x0(iy,:);
|
||||
if nshocks
|
||||
lpmat0=xx0(iy,:);
|
||||
end
|
||||
istable=[1:length(iy)];
|
||||
istable=1:length(iy);
|
||||
save([xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo '_threshold' ],'lpmat','lpmat0','istable','y0','x0','xx0','iy','iyc')
|
||||
lpmat=[]; lpmat0=[]; istable=[];
|
||||
if length(iy)<=10 || length(iyc)<=10,
|
||||
lpmat0=[];
|
||||
if length(iy)<=10 || length(iyc)<=10
|
||||
icheck = []; % do the generic plot in any case
|
||||
end
|
||||
|
||||
else
|
||||
icheck = [];
|
||||
end
|
||||
|
@ -412,11 +419,10 @@ for j = 1:length(anamendo)
|
|||
end
|
||||
atitle0=['Monte Carlo Filtering for ',namendo,' vs ', namlagendo];
|
||||
options_mcf.title = atitle0;
|
||||
indmcf = redform_mcf(y0, x0, options_mcf, options_);
|
||||
redform_mcf(y0, x0, options_mcf, options_, M_.fname, bayestopt_.name, estim_params_);
|
||||
end
|
||||
end
|
||||
else
|
||||
[yy, xdir] = log_trans_(y0,xdir0);
|
||||
atitle0=['Reduced Form Mapping (ANOVA) for log-transformed ',namendo,' vs ', namlagendo];
|
||||
aname=[type '_' namendo '_vs_' namlagendo];
|
||||
atitle=[type ' Reduced Form Mapping (ANOVA): Parameter(s) driving ',namendo,' vs ',namlagendo];
|
||||
|
@ -432,24 +438,27 @@ for j = 1:length(anamendo)
|
|||
figure(hh_fig),
|
||||
subplot(3,3,iplo),
|
||||
if ilog
|
||||
[saso, iso] = sort(-silog(:,js));
|
||||
[~, iso] = sort(-silog(:,js));
|
||||
bar([silog(iso(1:min(np,10)),js)])
|
||||
logflag='log';
|
||||
else
|
||||
[saso, iso] = sort(-si(:,js));
|
||||
[~, iso] = sort(-si(:,js));
|
||||
bar(si(iso(1:min(np,10)),js))
|
||||
logflag='';
|
||||
end
|
||||
%set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
|
||||
set(gca,'xticklabel',' ','fontsize',10)
|
||||
set(gca,'xlim',[0.5 10.5])
|
||||
for ip=1:min(np,10)
|
||||
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
if options_.TeX
|
||||
text(ip,-0.02,deblank(pnames_tex(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','latex')
|
||||
else
|
||||
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
end
|
||||
title([logflag,' ',namendo,' vs ',namlagendo,'(-1)'],'interpreter','none')
|
||||
if iplo==9
|
||||
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],1)
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',namendo_tex,' vs ',namlagendo_tex,'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -460,48 +469,37 @@ for j = 1:length(anamendo)
|
|||
end
|
||||
if iplo<9 && iplo>0 && ifig && ~options_.nograph
|
||||
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],options_.figures.textwidth*min(iplo/3,1));
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',namendo_tex,' vs ',namlagendo_tex,'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],options_.figures.textwidth*min(iplo/3,1));
|
||||
end
|
||||
end
|
||||
|
||||
if isempty(threshold) && ~options_.nograph
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA');
|
||||
if ilog==0
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(si)
|
||||
% boxplot(si','whis',10,'symbol','r.')
|
||||
myboxplot(si',[],'.',[],10)
|
||||
xlabel(' ')
|
||||
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
|
||||
set(gca,'xlim',[0.5 np+0.5])
|
||||
set(gca,'ylim',[0 1])
|
||||
set(gca,'position',[0.13 0.2 0.775 0.7])
|
||||
for ip=1:np
|
||||
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
else
|
||||
myboxplot(silog',[],'.',[],10)
|
||||
end
|
||||
xlabel(' ')
|
||||
set(gca,'xticklabel',' ','fontsize',10,'xtick',1:np)
|
||||
set(gca,'xlim',[0.5 np+0.5])
|
||||
set(gca,'ylim',[0 1])
|
||||
set(gca,'position',[0.13 0.2 0.775 0.7])
|
||||
for ip=1:np
|
||||
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
if ilog==0
|
||||
title('Reduced form GSA')
|
||||
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_gsa'],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa'],'Reduced Form GSA','redform_gsa')
|
||||
|
||||
else
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(silog)
|
||||
% boxplot(silog','whis',10,'symbol','r.')
|
||||
myboxplot(silog',[],'.',[],10)
|
||||
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
|
||||
xlabel(' ')
|
||||
set(gca,'xlim',[0.5 np+0.5])
|
||||
set(gca,'ylim',[0 1])
|
||||
set(gca,'position',[0.13 0.2 0.775 0.7])
|
||||
for ip=1:np
|
||||
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
title('Reduced form GSA - Log-transformed elements')
|
||||
dyn_saveas(hh_fig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa_log'],'Reduced form GSA - Log-transformed elements','redform_gsa_log')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function si = redform_private(x0, y0, options_map, options_)
|
||||
|
||||
np=size(x0,2);
|
||||
x00=x0;
|
||||
ilog = options_map.log_trans;
|
||||
|
@ -531,14 +529,12 @@ if iload==0
|
|||
nest=max(50,nrun/2);
|
||||
nest=min(250,nest);
|
||||
nfit=min(1000,nrun);
|
||||
% dotheplots = (nfit<=nest);
|
||||
% gsa_ = gsa_sdp(y0(1:nest), x0(1:nest,:), 2, [],[-1 -1 -1 -1 -1 0],[],0,[fname,'_est'], pnames);
|
||||
[ys,is] = sort(y0);
|
||||
[~,is] = sort(y0);
|
||||
istep = ceil(nrun/nest);
|
||||
if istep>1
|
||||
iest = is(floor(istep/2):istep:end);
|
||||
nest = length(iest);
|
||||
irest = is(setdiff([1:nrun],[floor(istep/2):istep:nrun]));
|
||||
irest = is(setdiff(1:nrun,floor(istep/2):istep:nrun));
|
||||
istep = ceil(length(irest)/(nfit-nest));
|
||||
ifit = union(iest, irest(1:istep:end));
|
||||
else
|
||||
|
@ -550,22 +546,27 @@ if iload==0
|
|||
ifit = union(ifit, irest(end));
|
||||
end
|
||||
nfit=length(ifit);
|
||||
% ifit = union(iest, irest(randperm(nrun-nest,nfit-nest)));
|
||||
% ifit = iest;
|
||||
% nfit=nest;
|
||||
ipred = setdiff([1:nrun],ifit);
|
||||
ipred = setdiff(1:nrun,ifit);
|
||||
|
||||
if ilog
|
||||
[y1, tmp, isig, lam] = log_trans_(y0(iest));
|
||||
[~, ~, isig, lam] = log_trans_(y0(iest));
|
||||
y1 = log(y0*isig+lam);
|
||||
end
|
||||
if ~options_.nograph
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name',options_map.figtitle);
|
||||
subplot(221)
|
||||
if ilog
|
||||
hist(y1,30)
|
||||
if isoctave
|
||||
hist(y1,30)
|
||||
else
|
||||
histogram(y1,30)
|
||||
end
|
||||
else
|
||||
hist(y0,30)
|
||||
if isoctave
|
||||
hist(y0,30)
|
||||
else
|
||||
histogram(y0,30)
|
||||
end
|
||||
end
|
||||
title(options_map.title,'interpreter','none')
|
||||
subplot(222)
|
||||
|
@ -582,15 +583,7 @@ if iload==0
|
|||
if ilog
|
||||
[gsa22, gsa1, gsax] = ss_anova_log(y1(iest), x0(iest,:), isig, lam, gsa0);
|
||||
end
|
||||
% if (gsa1.out.bic-gsa0.out.bic) < 10,
|
||||
% y00=y0;
|
||||
% gsa00=gsa0;
|
||||
% gsa0=gsa1;
|
||||
% y0=y1;
|
||||
% ilog=1;
|
||||
% end
|
||||
if nfit>nest
|
||||
% gsa_ = gsa_sdp(y0(1:nfit), x0(1:nfit,:), -2, gsa_.nvr*nest^3/nfit^3,[-1 -1 -1 -1 -1 0],[],0,fname, pnames);
|
||||
nvr = gsa0.nvr*nest^3/nfit^3;
|
||||
nvr(gsa0.stat<2) = gsa0.nvr(gsa0.stat<2)*nest^5/nfit^5;
|
||||
gsa_ = ss_anova(y0(ifit), x0(ifit,:), 1, 0, 2, nvr);
|
||||
|
@ -601,33 +594,6 @@ if iload==0
|
|||
nvrx = gsax.nvr*nest^3/nfit^3;
|
||||
nvrx(gsax.stat<2) = gsax.nvr(gsax.stat<2)*nest^5/nfit^5;
|
||||
[gsa22, gsa1, gsax] = ss_anova_log(y1(ifit), x0(ifit,:), isig, lam, gsa0, [nvr1' nvrx']);
|
||||
% gsa1 = ss_anova(y1(ifit), x0(ifit,:), 1, 0, 2, nvr);
|
||||
% gsa2=gsa1;
|
||||
% gsa2.y = gsa0.y;
|
||||
% gsa2.fit = (exp(gsa1.fit)-lam)*isig;
|
||||
% gsa2.f0 = mean(gsa2.fit);
|
||||
% gsa2.out.SSE = sum((gsa2.fit-gsa2.y).^2);
|
||||
% gsa2.out.bic = gsa2.out.bic-nest*log(gsa1.out.SSE)+nest*log(gsa2.out.SSE);
|
||||
% gsa2.r2 = 1-cov(gsa2.fit-gsa2.y)/cov(gsa2.y);
|
||||
% for j=1:np,
|
||||
% gsa2.fs(:,j) = exp(gsa1.fs(:,j)).*mean(exp(gsa1.fit-gsa1.f(:,j)))*isig-lam*isig-gsa2.f0;
|
||||
% gsa2.f(:,j) = exp(gsa1.f(:,j)).*mean(exp(gsa1.fit-gsa1.f(:,j)))*isig-lam*isig-gsa2.f0;
|
||||
% gsa2.si(j) = var(gsa2.f(:,j))/var(gsa2.y);
|
||||
% end
|
||||
% nvr = gsax.nvr*nest^3/nfit^3;
|
||||
% nvr(gsax.stat<2) = gsax.nvr(gsax.stat<2)*nest^5/nfit^5;
|
||||
% gsax = ss_anova([gsa2.y-gsa2.fit], x0(ifit,:), 1, 0, 2, nvr);
|
||||
% gsa22=gsa2;
|
||||
% gsa22.fit = gsa2.fit+gsax.fit;
|
||||
% gsa22.f0 = mean(gsa22.fit);
|
||||
% gsa22.out.SSE = sum((gsa22.fit-gsa22.y).^2);
|
||||
% gsa22.out.bic = nest*log(gsa22.out.SSE/nest) + (gsax.out.df+gsa2.out.df-1)*log(nest);
|
||||
% gsa22.r2 = 1-sum((gsa22.fit-gsa22.y).^2)/sum((gsa22.y-mean(gsa22.y)).^2);
|
||||
% for j=1:np,
|
||||
% gsa22.fs(:,j) = gsa2.fs(:,j)+gsax.fs(:,j);
|
||||
% gsa22.f(:,j) = gsa2.f(:,j)+gsax.f(:,j);
|
||||
% gsa22.si(j) = var(gsa22.f(:,j))/var(gsa22.y);
|
||||
% end
|
||||
gsa_ = gsa22;
|
||||
end
|
||||
else
|
||||
|
@ -638,26 +604,18 @@ if iload==0
|
|||
end
|
||||
end
|
||||
save([fname,'_map.mat'],'gsa_')
|
||||
[sidum, iii]=sort(-gsa_.si);
|
||||
[~, iii]=sort(-gsa_.si);
|
||||
gsa_.x0=x00(ifit,:);
|
||||
if ~options_.nograph
|
||||
hmap=gsa_sdp_plot(gsa_,[fname '_map'],pnames,iii(1:min(12,np)));
|
||||
set(hmap,'name',options_map.amap_title);
|
||||
end
|
||||
gsa_.x0=x0(ifit,:);
|
||||
% copyfile([fname,'_est.mat'],[fname,'.mat'])
|
||||
if ~options_.nograph
|
||||
figure(hh_fig);
|
||||
subplot(223),
|
||||
plot(y0(ifit),[gsa_.fit y0(ifit)],'.'),
|
||||
r2 = gsa_.r2;
|
||||
% if ilog,
|
||||
% plot(y00(ifit),[log_trans_(gsa_.fit,'',isig,lam) y00(ifit)],'.'),
|
||||
% r2 = 1 - cov(log_trans_(gsa_.fit,'',isig,lam)-y00(ifit))/cov(y00(ifit));
|
||||
% else
|
||||
% plot(y0(ifit),[gsa_.fit y0(ifit)],'.'),
|
||||
% r2 = gsa_.r2;
|
||||
% end
|
||||
title(['Learning sample fit - R2=' num2str(r2,2)],'interpreter','none')
|
||||
if nfit<nrun
|
||||
if ilog
|
||||
|
@ -680,8 +638,6 @@ if iload==0
|
|||
end
|
||||
end
|
||||
else
|
||||
% gsa_ = gsa_sdp_dyn(y0, x0, 0, [],[],[],0,fname, pnames);
|
||||
% gsa_ = gsa_sdp(y0, x0, 0, [],[],[],0,fname, pnames);
|
||||
load([fname,'_map.mat'],'gsa_')
|
||||
if ~options_.nograph
|
||||
yf = ss_anova_fcast(x0, gsa_);
|
||||
|
@ -690,10 +646,8 @@ else
|
|||
title([namy,' vs ', namx,' pred'],'interpreter','none')
|
||||
dyn_saveas(hh_fig,[fname '_pred'],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[fname '_pred'],options_map.title,[namy,' vs ', namx,' pred'])
|
||||
|
||||
end
|
||||
end
|
||||
% si = gsa_.multivariate.si;
|
||||
si = gsa_.si;
|
||||
|
||||
return
|
||||
|
@ -730,6 +684,8 @@ else
|
|||
end
|
||||
gsa2 = log2level_map(gsa1, isig, lam);
|
||||
if nargin >=5 && ~isempty(gsa0)
|
||||
nvr2=NaN(np,1);
|
||||
nvr0=NaN(np,1);
|
||||
for j=1:np
|
||||
nvr2(j) = var(diff(gsa2.fs(:,j),2));
|
||||
nvr0(j) = var(diff(gsa0.fs(:,j),2));
|
||||
|
@ -760,26 +716,24 @@ end
|
|||
|
||||
return
|
||||
|
||||
function indmcf = redform_mcf(y0, x0, options_mcf, options_)
|
||||
function indmcf = redform_mcf(y0, x0, options_mcf, options_, fname, parnames, estim_params_)
|
||||
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name',options_mcf.amcf_title);
|
||||
|
||||
[post_mean, post_median, post_var, hpd_interval, post_deciles, ...
|
||||
density] = posterior_moments(y0,1,0.9);
|
||||
[~, ~, ~, ~, post_deciles] = posterior_moments(y0,1,0.9);
|
||||
post_deciles = [-inf; post_deciles; inf];
|
||||
|
||||
for jt=1:10
|
||||
indy{jt}=find( (y0>post_deciles(jt)) & (y0<=post_deciles(jt+1)));
|
||||
leg{jt}=[int2str(jt) '-dec'];
|
||||
end
|
||||
[proba, dproba] = stab_map_1(x0, indy{1}, indy{end}, [],0);
|
||||
[proba] = stab_map_1(x0, indy{1}, indy{end}, [], fname, options_, parnames, estim_params_,0);
|
||||
indmcf=find(proba<options_mcf.pvalue_ks);
|
||||
if isempty(indmcf)
|
||||
[tmp,jtmp] = sort(proba,2,'ascend');
|
||||
[~,jtmp] = sort(proba,1,'ascend');
|
||||
indmcf = jtmp(1);
|
||||
% indmcf = jtmp(1:min(2,length(proba)));
|
||||
end
|
||||
[tmp,jtmp] = sort(proba(indmcf),2,'ascend');
|
||||
[~,jtmp] = sort(proba(indmcf),1,'ascend');
|
||||
indmcf = indmcf(jtmp);
|
||||
nbr_par = length(indmcf);
|
||||
nrow=ceil(sqrt(nbr_par+1));
|
||||
|
@ -797,7 +751,11 @@ for jx=1:nbr_par
|
|||
set(h,'color', cmap(jt,:), 'linewidth', 2)
|
||||
hold all
|
||||
end
|
||||
title(options_mcf.param_names(indmcf(jx),:),'interpreter','none')
|
||||
if options_.TeX
|
||||
title(options_mcf.param_names_tex(indmcf(jx),:),'interpreter','latex')
|
||||
else
|
||||
title(options_mcf.param_names(indmcf(jx),:),'interpreter','none')
|
||||
end
|
||||
end
|
||||
hleg = legend(leg);
|
||||
aa=get(hleg,'Position');
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
function redform_screen(dirname, options_gsa_)
|
||||
%function redform_map(dirname, options_gsa_)
|
||||
% inputs (from opt_gsa structure
|
||||
% anamendo = options_gsa_.namendo;
|
||||
% anamlagendo = options_gsa_.namlagendo;
|
||||
% anamexo = options_gsa_.namexo;
|
||||
% iload = options_gsa_.load_redform;
|
||||
function redform_screen(dirname, options_gsa_, estim_params_, M_, dr, options_, bayestopt_)
|
||||
% redform_screen(dirname, options_gsa_, estim_params_, M_, dr, options_, bayestopt_)
|
||||
% Conduct reduced form screening
|
||||
% Inputs:
|
||||
% - dirname [string] name of the output directory
|
||||
% - options_gsa_ [structure] GSA options_
|
||||
% - estim_params [structure] describing the estimated parameters
|
||||
% - M_ [structure] describing the model
|
||||
% - dr [structure] decision rules
|
||||
% - options_ [structure] describing the options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -28,17 +32,21 @@ function redform_screen(dirname, options_gsa_)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ oo_ estim_params_ options_ bayestopt_
|
||||
|
||||
% options_gsa_ = options_.opt_gsa;
|
||||
|
||||
anamendo = options_gsa_.namendo;
|
||||
anamlagendo = options_gsa_.namlagendo;
|
||||
anamexo = options_gsa_.namexo;
|
||||
iload = options_gsa_.load_redform;
|
||||
anamendo_tex = options_gsa_.namendo_tex;
|
||||
anamlagendo_tex = options_gsa_.namlagendo_tex;
|
||||
anamexo_tex = options_gsa_.namexo_tex;
|
||||
|
||||
nliv = options_gsa_.morris_nliv;
|
||||
|
||||
pnames = M_.param_names(estim_params_.param_vals(:,1));
|
||||
if options_.TeX
|
||||
for par_iter=1:size(estim_params_.param_vals(:,1),1)
|
||||
[~,tex_names{par_iter,1}]=get_the_name(estim_params_.param_vals(par_iter,1),options_.TeX, M_, estim_params_, options_.varobs);
|
||||
end
|
||||
end
|
||||
if nargin==0
|
||||
dirname='';
|
||||
end
|
||||
|
@ -54,35 +62,45 @@ nsok = length(find(M_.lead_lag_incidence(M_.maximum_lag,:)));
|
|||
|
||||
js=0;
|
||||
for j=1:size(anamendo,1)
|
||||
namendo = deblank(anamendo(j,:));
|
||||
iendo = strmatch(namendo, M_.endo_names(oo_.dr.order_var), 'exact');
|
||||
namendo = anamendo{j,:};
|
||||
namendo_tex = anamendo_tex{j,:};
|
||||
iendo = strmatch(namendo, M_.endo_names(dr.order_var), 'exact');
|
||||
iplo=0;
|
||||
ifig=0;
|
||||
for jx=1:size(anamexo,1)
|
||||
namexo = deblank(anamexo(jx,:));
|
||||
namexo = anamexo{jx};
|
||||
namexo_tex = anamexo_tex{jx};
|
||||
iexo = strmatch(namexo, M_.exo_names, 'exact');
|
||||
if ~isempty(iexo)
|
||||
y0=teff(T(iendo,iexo+nspred,:), kn, istable);
|
||||
if ~isempty(y0)
|
||||
if mod(iplo,9)==0
|
||||
ifig = ifig+1;
|
||||
hh_fig = dyn_figure(options_.nodisplay, 'name', [namendo,[' vs. shocks '], int2str(ifig)]);
|
||||
hh_fig = dyn_figure(options_.nodisplay, 'name', [namendo,' vs. shocks ', int2str(ifig)]);
|
||||
iplo = 0;
|
||||
end
|
||||
iplo = iplo+1;
|
||||
js = js+1;
|
||||
subplot(3, 3, iplo)
|
||||
[SAmeas, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0, nliv);
|
||||
[~, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0, nliv);
|
||||
SAM = squeeze(SAMorris(nshock+1:end,1));
|
||||
SA(:,js) = SAM./(max(SAM)+eps);
|
||||
[saso, iso] = sort(-SA(:,js));
|
||||
[~, iso] = sort(-SA(:,js));
|
||||
bar(SA(iso(1:min(np,10)),js))
|
||||
set(gca,'xticklabel',' ','fontsize',10)
|
||||
set(gca,'xlim',[0.5 10.5])
|
||||
for ip=1:min(np,10)
|
||||
text(ip,-0.02,pnames(iso(ip)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
if options_.TeX
|
||||
text(ip,-0.02,tex_names(iso(ip)),'rotation',90,'HorizontalAlignment','right','interpreter','latex')
|
||||
else
|
||||
text(ip,-0.02,pnames(iso(ip)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
end
|
||||
if options_.TeX
|
||||
title([namendo_tex,' vs. ',namexo_tex],'interpreter','latex')
|
||||
else
|
||||
title([namendo,' vs. ',namexo],'interpreter','none')
|
||||
end
|
||||
title([namendo,' vs. ',namexo],'interpreter','none')
|
||||
if iplo==9
|
||||
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],1)
|
||||
|
@ -99,8 +117,9 @@ for j=1:size(anamendo,1)
|
|||
iplo=0;
|
||||
ifig=0;
|
||||
for je=1:size(anamlagendo,1)
|
||||
namlagendo=deblank(anamlagendo(je,:));
|
||||
ilagendo=strmatch(namlagendo, M_.endo_names(oo_.dr.order_var(M_.nstatic+1:M_.nstatic+nsok)), 'exact');
|
||||
namlagendo=anamlagendo{je};
|
||||
namlagendo_tex=anamlagendo_tex{je};
|
||||
ilagendo=strmatch(namlagendo, M_.endo_names(dr.order_var(M_.nstatic+1:M_.nstatic+nsok)), 'exact');
|
||||
|
||||
if ~isempty(ilagendo)
|
||||
y0=teff(T(iendo,ilagendo,:),kn,istable);
|
||||
|
@ -113,19 +132,26 @@ for j=1:size(anamendo,1)
|
|||
iplo=iplo+1;
|
||||
js=js+1;
|
||||
subplot(3,3,iplo),
|
||||
[SAmeas, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0,nliv);
|
||||
[~, SAMorris] = Morris_Measure_Groups(np+nshock, [lpmat0 lpmat], y0,nliv);
|
||||
SAM = squeeze(SAMorris(nshock+1:end,1));
|
||||
SA(:,js)=SAM./(max(SAM)+eps);
|
||||
[saso, iso] = sort(-SA(:,js));
|
||||
[~, iso] = sort(-SA(:,js));
|
||||
bar(SA(iso(1:min(np,10)),js))
|
||||
%set(gca,'xticklabel',pnames(iso(1:min(np,10)),:),'fontsize',8)
|
||||
set(gca,'xticklabel',' ','fontsize',10)
|
||||
set(gca,'xlim',[0.5 10.5])
|
||||
for ip=1:min(np,10)
|
||||
text(ip,-0.02,deblank(pnames(iso(ip),:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
if options_.TeX
|
||||
text(ip,-0.02,tex_names(iso(ip)),'rotation',90,'HorizontalAlignment','right','interpreter','latex')
|
||||
else
|
||||
text(ip,-0.02,pnames{iso(ip)},'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
end
|
||||
|
||||
title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none')
|
||||
if options_.TeX
|
||||
title([namendo_tex,' vs. ',namlagendo_tex,'(-1)'],'interpreter','latex')
|
||||
else
|
||||
title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none')
|
||||
end
|
||||
if iplo==9
|
||||
dyn_saveas(hh_fig,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],1)
|
||||
|
@ -140,15 +166,17 @@ for j=1:size(anamendo,1)
|
|||
end
|
||||
|
||||
hh_fig=dyn_figure(options_.nodisplay,'Name','Reduced form screening');
|
||||
%bar(SA)
|
||||
% boxplot(SA','whis',10,'symbol','r.')
|
||||
myboxplot(SA',[],'.',[],10)
|
||||
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
|
||||
set(gca,'xticklabel',' ','fontsize',10,'xtick',1:np)
|
||||
set(gca,'xlim',[0.5 np+0.5])
|
||||
set(gca,'ylim',[0 1])
|
||||
set(gca,'position',[0.13 0.2 0.775 0.7])
|
||||
for ip=1:np
|
||||
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
if options_.TeX
|
||||
text(ip,-0.02,tex_names(ip),'rotation',90,'HorizontalAlignment','right','interpreter','latex')
|
||||
else
|
||||
text(ip,-0.02,pnames{ip},'rotation',90,'HorizontalAlignment','right','interpreter','none')
|
||||
end
|
||||
end
|
||||
xlabel(' ')
|
||||
ylabel('Elementary Effects')
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
function indmcf = scatter_analysis(lpmat, xdata, options_scatter, options_)
|
||||
function scatter_analysis(lpmat, xdata, options_scatter, options_)
|
||||
% scatter_analysis(lpmat, xdata, options_scatter, options_)
|
||||
% Plot scatter plot analysis
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -6,7 +8,7 @@ function indmcf = scatter_analysis(lpmat, xdata, options_scatter, options_)
|
|||
%
|
||||
|
||||
% Copyright © 2017 European Commission
|
||||
% Copyright © 2017 Dynare Team
|
||||
% Copyright © 2017-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -34,7 +36,6 @@ if options_.TeX
|
|||
end
|
||||
amcf_name = options_scatter.amcf_name;
|
||||
amcf_title = options_scatter.amcf_title;
|
||||
title = options_scatter.title;
|
||||
fname_ = options_scatter.fname_;
|
||||
xparam1=[];
|
||||
if isfield(options_scatter,'xparam1')
|
||||
|
@ -48,5 +49,9 @@ if ~options_.nograph
|
|||
if ~isempty(xparam1)
|
||||
xx=xparam1;
|
||||
end
|
||||
scatter_plots(lpmat, xdata, param_names, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_)
|
||||
if options_.TeX
|
||||
scatter_plots(lpmat, xdata, param_names_tex, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_)
|
||||
else
|
||||
scatter_plots(lpmat, xdata, param_names, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
function scatter_callback(K, type)
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
%
|
||||
|
||||
% Copyright © 2017 European Commission
|
||||
% Copyright © 2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global oo_ M_ options_ bayestopt_ estim_params_
|
||||
|
||||
x=get(gcf,'userdata');
|
||||
r2=x{1};
|
||||
x=x{2};
|
||||
|
||||
xparam1=x(K,:)';
|
||||
|
||||
switch type
|
||||
case 'save'
|
||||
save(['my_params_' int2str(K)],'xparam1')
|
||||
case 'eval'
|
||||
disp('Evaluating smoother ...')
|
||||
[oo_, M_]=evaluate_smoother(xparam1, M_.endo_names, M_, oo_, options_, bayestopt_, estim_params_);
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_, beha_name, non_beha_name)
|
||||
% scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_, beha_name, non_beha_name)
|
||||
function scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_, beha_name, non_beha_name, beha_name_latex, non_beha_name_latex)
|
||||
% scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_, beha_name, non_beha_name, beha_name_latex, non_beha_name_latex)
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
|
@ -38,12 +38,6 @@ function scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, o
|
|||
|
||||
|
||||
Z=[X;Y];
|
||||
[n,p] = size(X);
|
||||
% X = X - ones(n,1)*min(Z);
|
||||
% X = X ./ (ones(n,1)*max(Z));
|
||||
[n,p] = size(Y);
|
||||
% Y = Y - ones(n,1)*min(Z);
|
||||
% Y = Y ./ (ones(n,1)*max(Z));
|
||||
[n,p] = size(Z);
|
||||
clear Z;
|
||||
|
||||
|
@ -53,8 +47,10 @@ if nargin >=3
|
|||
end
|
||||
|
||||
if nargin<4 || isempty(plotsymbol)
|
||||
if n*p<100, plotsymbol = 'o';
|
||||
else plotsymbol = '.';
|
||||
if n*p<100
|
||||
plotsymbol = 'o';
|
||||
else
|
||||
plotsymbol = '.';
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -83,7 +79,7 @@ end
|
|||
|
||||
figtitle_tex=strrep(figtitle,'_','\_');
|
||||
|
||||
fig_nam_=[fnam];
|
||||
fig_nam_=fnam;
|
||||
if ~nograph
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name',figtitle);
|
||||
end
|
||||
|
@ -101,7 +97,6 @@ for i = 1:p
|
|||
h = axes('position',[fL(i),fL(p+1-j),ffl,ffl]);
|
||||
if i==j
|
||||
h1=cumplot(X(:,j));
|
||||
% set(h1,'color',[0 0 1], 'linestyle','--','LineWidth',1.5)
|
||||
set(h1,'color',[0 0 1],'LineWidth',1.5)
|
||||
hold on,
|
||||
h2=cumplot(Y(:,j));
|
||||
|
@ -126,10 +121,10 @@ for i = 1:p
|
|||
plot(X(:,i),X(:,j),[plotsymbol,'b'])
|
||||
end
|
||||
if ~isempty(xparam1)
|
||||
hold on, plot(xparam1(i),xparam1(j),'s','MarkerFaceColor',[0 0.75 0],'MarkerEdgeColor',[0 0.75 0])
|
||||
hold on
|
||||
plot(xparam1(i),xparam1(j),'s','MarkerFaceColor',[0 0.75 0],'MarkerEdgeColor',[0 0.75 0])
|
||||
end
|
||||
hold off;
|
||||
% axis([-0.1 1.1 -0.1 1.1])
|
||||
if i<p
|
||||
set(gca,'YTickLabel',[],'YTick',[]);
|
||||
else
|
||||
|
@ -144,16 +139,26 @@ for i = 1:p
|
|||
end
|
||||
if i==1
|
||||
if nflag == 1
|
||||
ylabel(vnames(j,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle');
|
||||
if options_.TeX
|
||||
ylabel(vnames(j,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle','Interpreter','latex');
|
||||
else
|
||||
ylabel(vnames(j,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle','Interpreter','none');
|
||||
end
|
||||
else
|
||||
ylabel([num2str(j),' '],'Rotation',90)
|
||||
end
|
||||
end
|
||||
if j==1
|
||||
if nflag == 1
|
||||
title(vnames(i,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom')
|
||||
if options_.TeX
|
||||
title(vnames(i,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom','Interpreter','latex')
|
||||
else
|
||||
title(vnames(i,:),'Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom','Interpreter','none')
|
||||
end
|
||||
else
|
||||
title(num2str(i))
|
||||
end
|
||||
|
@ -162,8 +167,13 @@ for i = 1:p
|
|||
end
|
||||
end
|
||||
if ~isoctave
|
||||
annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name,'Color','Blue','horizontalalignment','center','interpreter','none');
|
||||
annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
|
||||
if options_.TeX
|
||||
annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name_latex,'Color','Blue','horizontalalignment','center','interpreter','latex');
|
||||
annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name_latex,'Color','Red','horizontalalignment','center','interpreter','latex');
|
||||
else
|
||||
annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name,'Color','Blue','horizontalalignment','center','interpreter','none');
|
||||
annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
|
||||
end
|
||||
end
|
||||
|
||||
if ~nograph
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_)
|
||||
% scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_)
|
||||
% Pairwise scatter plots of the columns of x and y after Monte Carlo filtering
|
||||
% Inputs:
|
||||
% - X [double] nxk matrix with columns containing behavioural sample
|
||||
% - xp [double] mxk matrix with columns containing non-behavioural sample
|
||||
% - vnames [char] vector of variable names (default = numeric labels 1,2,3 etc.)
|
||||
% - plotsymbol [char] plt symbol (default = '.' for npts > 100, 'o' for npts < 100
|
||||
% - fnam [char] figure name
|
||||
% - dirname [char] directory name
|
||||
% - figtitle [char] figure title
|
||||
% - xparam1 [double] parameter vector
|
||||
% - options_ [struct] option structure
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
%
|
||||
|
||||
|
||||
% Copyright © 2017 European Commission
|
||||
% Copyright © 2017-2023 Dynare Team
|
||||
|
@ -23,23 +35,7 @@ function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1,
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
% PURPOSE: Pairwise scatter plots of the columns of x and y after
|
||||
% Monte Carlo filtering
|
||||
%---------------------------------------------------
|
||||
% USAGE: scatter_mcf(x,y,vnames,pltsym,diagon)
|
||||
% or scatter_mcf(x,y) which relies on defaults
|
||||
% where:
|
||||
% x = an nxk matrix with columns containing behavioural sample
|
||||
% y = an mxk matrix with columns containing non-behavioural sample
|
||||
% vnames = a vector of variable names
|
||||
% (default = numeric labels 1,2,3 etc.)
|
||||
% pltsym = a plt symbol
|
||||
% (default = '.' for npts > 100, 'o' for npts < 100
|
||||
|
||||
|
||||
[n,p] = size(X);
|
||||
% X = X - ones(n,1)*min(Z);
|
||||
% X = X ./ (ones(n,1)*max(Z));
|
||||
|
||||
nflag = 0;
|
||||
if nargin >=3
|
||||
|
@ -47,8 +43,10 @@ if nargin >=3
|
|||
end
|
||||
|
||||
if nargin<4 || isempty(plotsymbol)
|
||||
if n*p<100, plotsymbol = 'o';
|
||||
else plotsymbol = '.';
|
||||
if n*p<100
|
||||
plotsymbol = 'o';
|
||||
else
|
||||
plotsymbol = '.';
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -71,7 +69,7 @@ end
|
|||
|
||||
figtitle_tex=strrep(figtitle,'_','\_');
|
||||
|
||||
fig_nam_=[fnam];
|
||||
fig_nam_=fnam;
|
||||
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name',figtitle);
|
||||
set(hh_fig,'userdata',{X,xp})
|
||||
|
@ -90,7 +88,6 @@ for i = 1:p
|
|||
if i==j
|
||||
h1=cumplot(X(:,j));
|
||||
set(h,'Tag','cumplot')
|
||||
% set(h1,'color',[0 0 1], 'linestyle','--','LineWidth',1.5)
|
||||
set(h1,'color',[0 0 1],'LineWidth',1.5)
|
||||
if ~isempty(xparam1)
|
||||
hold on, plot(xparam1([j j]),[0 1],'k--')
|
||||
|
@ -102,39 +99,13 @@ for i = 1:p
|
|||
end
|
||||
set(gca,'YTickLabel',[],'YTick',[]);
|
||||
else
|
||||
if j>i
|
||||
plot(X(:,i),X(:,j),[plotsymbol,'b'])
|
||||
else
|
||||
plot(X(:,i),X(:,j),[plotsymbol,'b'])
|
||||
end
|
||||
plot(X(:,i),X(:,j),[plotsymbol,'b'])
|
||||
set(h,'Tag','scatter')
|
||||
|
||||
%%
|
||||
if ~isoctave
|
||||
% Define a context menu; it is not attached to anything
|
||||
hcmenu = uicontextmenu('Callback','pick','Tag','Run viewer');
|
||||
% Define callbacks for context menu
|
||||
% items that change linestyle
|
||||
hcb1 = 'scatter_callback';
|
||||
% hcb2 = ['set(gco,''LineStyle'','':'')'];
|
||||
% hcb3 = ['set(gco,''LineStyle'',''-'')'];
|
||||
% % Define the context menu items and install their callbacks
|
||||
item1 = uimenu(hcmenu,'Label','save','Callback',hcb1,'Tag','save params');
|
||||
item2 = uimenu(hcmenu,'Label','eval','Callback',hcb1,'Tag','eval params');
|
||||
% item3 = uimenu(hcmenu,'Label','solid','Callback',hcb3);
|
||||
% Locate line objects
|
||||
hlines = findall(h,'Type','line');
|
||||
% Attach the context menu to each line
|
||||
for line = 1:length(hlines)
|
||||
set(hlines(line),'uicontextmenu',hcmenu)
|
||||
end
|
||||
end
|
||||
%%
|
||||
if ~isempty(xparam1)
|
||||
hold on, plot(xparam1(i),xparam1(j),'s','MarkerFaceColor',[0 0.75 0],'MarkerEdgeColor',[0 0.75 0])
|
||||
end
|
||||
hold off;
|
||||
% axis([-0.1 1.1 -0.1 1.1])
|
||||
if i<p
|
||||
set(gca,'YTickLabel',[],'YTick',[]);
|
||||
else
|
||||
|
@ -149,16 +120,26 @@ for i = 1:p
|
|||
end
|
||||
if i==1
|
||||
if nflag == 1
|
||||
ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle');
|
||||
if options_.TeX
|
||||
ylabel(vnames(j,:),'Rotation',45,'interpreter','latex', ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle');
|
||||
else
|
||||
ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
|
||||
'HorizontalAlignment','right','VerticalAlignment','middle');
|
||||
end
|
||||
else
|
||||
ylabel([num2str(j),' '],'Rotation',90)
|
||||
end
|
||||
end
|
||||
if j==1
|
||||
if nflag == 1
|
||||
title(vnames(i,:),'interpreter','none','Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom')
|
||||
if options_.TeX
|
||||
title(vnames(i,:),'interpreter','latex','Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom')
|
||||
else
|
||||
title(vnames(i,:),'interpreter','none','Rotation',45, ...
|
||||
'HorizontalAlignment','left','VerticalAlignment','bottom')
|
||||
end
|
||||
else
|
||||
title(num2str(i))
|
||||
end
|
||||
|
@ -166,10 +147,6 @@ for i = 1:p
|
|||
drawnow
|
||||
end
|
||||
end
|
||||
% if ~isoctave
|
||||
% annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name,'Color','Blue','horizontalalignment','center','interpreter','none');
|
||||
% annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
|
||||
% end
|
||||
|
||||
if ~nograph
|
||||
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_],options_.nodisplay,options_.graph_format);
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
function set_shocks_param(xparam1)
|
||||
% function set_shocks_param(xparam1)
|
||||
function M_=set_shocks_param(M_,estim_params_,xparam1)
|
||||
% function M_=set_shocks_param(M_,estim_params_,xparam1)
|
||||
% Set the structural and measurement error variances and covariances
|
||||
% Inputs
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - xparam1 [double] parameter vector
|
||||
% Outputs:
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
%
|
||||
% Notes: closely follows set_all_parameters.m
|
||||
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -19,8 +27,6 @@ function set_shocks_param(xparam1)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global estim_params_ M_
|
||||
|
||||
nvx = estim_params_.nvx;
|
||||
ncx = estim_params_.ncx;
|
||||
nvn = estim_params_.nvn;
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
function x0 = stab_map_(OutputDirectoryName,opt_gsa)
|
||||
% x0 = stab_map_(OutputDirectoryName,opt_gsa)
|
||||
function x0 = stab_map_(OutputDirectoryName,opt_gsa,M_,oo_,options_,bayestopt_,estim_params_)
|
||||
% x0 = stab_map_(OutputDirectoryName,opt_gsa,M_,oo_,options_,bayestopt_,estim_params_)
|
||||
% Mapping of stability regions in the prior ranges applying
|
||||
% Monte Carlo filtering techniques.
|
||||
%
|
||||
% INPUTS (from opt_gsa structure)
|
||||
% Inputs
|
||||
% - OutputDirectoryName [string] name of the output directory
|
||||
% - opt_gsa [structure] GSA options structure
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
% - oo_ [structure] Matlab's structure describing the results
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
%
|
||||
% Outputs:
|
||||
% - x0 one parameter vector for which the model is stable.
|
||||
%
|
||||
%
|
||||
% Inputs from opt_gsa structure
|
||||
% Nsam = MC sample size
|
||||
% fload = 0 to run new MC; 1 to load prevoiusly generated analysis
|
||||
% alpha2 = significance level for bivariate sensitivity analysis
|
||||
|
@ -14,8 +27,6 @@ function x0 = stab_map_(OutputDirectoryName,opt_gsa)
|
|||
% _prior.mat file
|
||||
% = 0: sample from posterior ranges: sample saved in
|
||||
% _mc.mat file
|
||||
% OUTPUT:
|
||||
% x0: one parameter vector for which the model is stable.
|
||||
%
|
||||
% GRAPHS
|
||||
% 1) Pdf's of marginal distributions under the stability (dotted
|
||||
|
@ -50,11 +61,6 @@ function x0 = stab_map_(OutputDirectoryName,opt_gsa)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
%global bayestopt_ estim_params_ dr_ options_ ys_ fname_
|
||||
global bayestopt_ estim_params_ options_ oo_ M_
|
||||
|
||||
% opt_gsa=options_.opt_gsa;
|
||||
|
||||
Nsam = opt_gsa.Nsam;
|
||||
fload = opt_gsa.load_stab;
|
||||
alpha2 = opt_gsa.alpha2_stab;
|
||||
|
@ -82,6 +88,7 @@ nshock = nshock + estim_params_.ncn;
|
|||
lpmat0=zeros(Nsam,0);
|
||||
xparam1=[];
|
||||
|
||||
%% prepare prior bounds
|
||||
[~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
|
||||
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
|
||||
% Set prior bounds
|
||||
|
@ -107,15 +114,16 @@ options_mcf.pvalue_ks = pvalue_ks;
|
|||
options_mcf.pvalue_corr = pvalue_corr;
|
||||
options_mcf.alpha2 = alpha2;
|
||||
|
||||
%% get LaTeX names
|
||||
name=cell(np,1);
|
||||
name_tex=cell(np,1);
|
||||
for jj=1:np
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_);
|
||||
name_tex{jj,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name_tex{jj,1} = param_name_tex_temp;
|
||||
name{jj,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(nshock+jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name{jj,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
@ -128,19 +136,18 @@ options_mcf.fname_ = fname_;
|
|||
options_mcf.OutputDirectoryName = OutputDirectoryName;
|
||||
options_mcf.xparam1 = [];
|
||||
|
||||
opt=options_;
|
||||
options_.periods=0;
|
||||
options_.nomoments=1;
|
||||
options_.irf=0;
|
||||
options_.noprint=1;
|
||||
if fload==0
|
||||
if fload==0 %run new MC
|
||||
if isfield(dr_,'ghx')
|
||||
egg=zeros(length(dr_.eigval),Nsam);
|
||||
end
|
||||
yys=zeros(length(dr_.ys),Nsam);
|
||||
|
||||
if opt_gsa.morris == 1
|
||||
[lpmat, OutFact] = Sampling_Function_2(nliv, np+nshock, ntra, ones(np+nshock, 1), zeros(np+nshock,1), []);
|
||||
[lpmat] = Sampling_Function_2(nliv, np+nshock, ntra, ones(np+nshock, 1), zeros(np+nshock,1), []);
|
||||
lpmat = lpmat.*(nliv-1)/nliv+1/nliv/2;
|
||||
Nsam=size(lpmat,1);
|
||||
lpmat0 = lpmat(:,1:nshock);
|
||||
|
@ -158,10 +165,9 @@ if fload==0
|
|||
for j=1:np
|
||||
lpmat(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
dummy=prior_draw_gsa(1);
|
||||
prior_draw_gsa(M_,bayestopt_,options_,estim_params_,1); %initialize
|
||||
if pprior
|
||||
for j=1:nshock
|
||||
if opt_gsa.morris~=1
|
||||
|
@ -178,16 +184,16 @@ if fload==0
|
|||
lpmat(:,j)=lpmat(:,j).*(upper_bound-lower_bound)+lower_bound;
|
||||
end
|
||||
else
|
||||
xx=prior_draw_gsa(0,[lpmat0 lpmat]);
|
||||
xx=prior_draw_gsa(M_,bayestopt_,options_,estim_params_,0,[lpmat0 lpmat]);
|
||||
lpmat0=xx(:,1:nshock);
|
||||
lpmat=xx(:,nshock+1:end);
|
||||
clear xx;
|
||||
end
|
||||
else
|
||||
else %posterior analysis
|
||||
if neighborhood_width>0 && isempty(options_.mode_file)
|
||||
xparam1 = get_all_parameters(estim_params_,M_);
|
||||
else
|
||||
eval(['load ' options_.mode_file '.mat;']);
|
||||
load([options_.mode_file '.mat'],'hh','xparam1');
|
||||
end
|
||||
if neighborhood_width>0
|
||||
for j=1:nshock
|
||||
|
@ -216,8 +222,8 @@ if fload==0
|
|||
for j=1:Nsam*2
|
||||
lnprior(j) = any(lp(j,:)'<=bounds.lb | lp(j,:)'>=bounds.ub);
|
||||
end
|
||||
ireal=[1:2*Nsam];
|
||||
ireal=ireal(find(lnprior==0));
|
||||
ireal=1:2*Nsam;
|
||||
ireal=ireal(lnprior==0);
|
||||
lp=lp(ireal,:);
|
||||
Nsam=min(Nsam, length(ireal));
|
||||
lpmat0=lp(1:Nsam,1:nshock);
|
||||
|
@ -227,9 +233,9 @@ if fload==0
|
|||
end
|
||||
%
|
||||
h = dyn_waitbar(0,'Please wait...');
|
||||
istable=[1:Nsam];
|
||||
istable=1:Nsam;
|
||||
jstab=0;
|
||||
iunstable=[1:Nsam];
|
||||
iunstable=1:Nsam;
|
||||
iindeterm=zeros(1,Nsam);
|
||||
iwrong=zeros(1,Nsam);
|
||||
inorestriction=zeros(1,Nsam);
|
||||
|
@ -237,12 +243,11 @@ if fload==0
|
|||
infox=zeros(Nsam,1);
|
||||
for j=1:Nsam
|
||||
M_ = set_all_parameters([lpmat0(j,:) lpmat(j,:)]',estim_params_,M_);
|
||||
%try stoch_simul([]);
|
||||
try
|
||||
if ~ isempty(options_.endogenous_prior_restrictions.moment)
|
||||
[Tt,Rr,SteadyState,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
if ~isempty(options_.endogenous_prior_restrictions.moment)
|
||||
[Tt,Rr,~,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
|
||||
else
|
||||
[Tt,Rr,SteadyState,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,'restrict');
|
||||
[Tt,Rr,~,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,'restrict');
|
||||
end
|
||||
infox(j,1)=info(1);
|
||||
if infox(j,1)==0 && ~exist('T','var')
|
||||
|
@ -250,8 +255,7 @@ if fload==0
|
|||
if prepSA
|
||||
try
|
||||
T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam);
|
||||
catch
|
||||
ME = lasterror();
|
||||
catch ME
|
||||
if strcmp('MATLAB:nomem',ME.identifier)
|
||||
prepSA=0;
|
||||
disp('The model is too large for storing state space matrices ...')
|
||||
|
@ -324,8 +328,9 @@ if fload==0
|
|||
end
|
||||
ys_=real(dr_.ys);
|
||||
yys(:,j) = ys_;
|
||||
ys_=yys(:,1);
|
||||
dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
|
||||
if mod(j,3)
|
||||
dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
|
||||
end
|
||||
end
|
||||
dyn_waitbar_close(h);
|
||||
if prepSA && jstab
|
||||
|
@ -333,13 +338,13 @@ if fload==0
|
|||
else
|
||||
T=[];
|
||||
end
|
||||
istable=istable(find(istable)); % stable params ignoring restrictions
|
||||
irestriction=irestriction(find(irestriction)); % stable params & restrictions OK
|
||||
inorestriction=inorestriction(find(inorestriction)); % stable params violating restrictions
|
||||
iunstable=iunstable(find(iunstable)); % violation of BK & restrictions & solution could not be found (whatever goes wrong)
|
||||
iindeterm=iindeterm(find(iindeterm)); % indeterminacy
|
||||
iwrong=iwrong(find(iwrong)); % dynare could not find solution
|
||||
ixun=iunstable(find(~ismember(iunstable,[iindeterm,iwrong,inorestriction]))); % explosive roots
|
||||
istable=istable(istable~=0); % stable params ignoring restrictions
|
||||
irestriction=irestriction(irestriction~=0); % stable params & restrictions OK
|
||||
inorestriction=inorestriction(inorestriction~=0); % stable params violating restrictions
|
||||
iunstable=iunstable(iunstable~=0); % violation of BK & restrictions & solution could not be found (whatever goes wrong)
|
||||
iindeterm=iindeterm(iindeterm~=0); % indeterminacy
|
||||
iwrong=iwrong(iwrong~=0); % dynare could not find solution
|
||||
ixun=iunstable(~ismember(iunstable,[iindeterm,iwrong,inorestriction])); % explosive roots
|
||||
|
||||
bkpprior.pshape=bayestopt_.pshape;
|
||||
bkpprior.p1=bayestopt_.p1;
|
||||
|
@ -356,8 +361,7 @@ if fload==0
|
|||
'bkpprior','lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
|
||||
'egg','yys','T','nspred','nboth','nfwrd','infox')
|
||||
end
|
||||
|
||||
else
|
||||
else %~pprior
|
||||
if ~prepSA
|
||||
save([OutputDirectoryName filesep fname_ '_mc.mat'], ...
|
||||
'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
|
||||
|
@ -368,19 +372,18 @@ if fload==0
|
|||
'egg','yys','T','nspred','nboth','nfwrd','infox')
|
||||
end
|
||||
end
|
||||
else
|
||||
else %load old run
|
||||
if pprior
|
||||
filetoload=[OutputDirectoryName filesep fname_ '_prior.mat'];
|
||||
else
|
||||
filetoload=[OutputDirectoryName filesep fname_ '_mc.mat'];
|
||||
end
|
||||
load(filetoload,'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun','egg','yys','nspred','nboth','nfwrd','infox')
|
||||
load(filetoload,'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun','infox')
|
||||
Nsam = size(lpmat,1);
|
||||
if pprior==0 && ~isempty(options_.mode_file)
|
||||
eval(['load ' options_.mode_file '.mat;']);
|
||||
load([options_.mode_file '.mat'],'xparam1');
|
||||
end
|
||||
|
||||
|
||||
if prepSA && isempty(strmatch('T',who('-file', filetoload),'exact'))
|
||||
h = dyn_waitbar(0,'Please wait...');
|
||||
options_.periods=0;
|
||||
|
@ -392,30 +395,24 @@ else
|
|||
yys=NaN(length(ys_),ntrans);
|
||||
for j=1:ntrans
|
||||
M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)';
|
||||
%stoch_simul([]);
|
||||
[Tt,Rr,SteadyState,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,'restrict');
|
||||
[~,~,~,~,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,'restrict');
|
||||
if ~exist('T','var')
|
||||
T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),ntrans);
|
||||
end
|
||||
dr_ = oo_.dr;
|
||||
T(:,:,j) = [dr_.ghx dr_.ghu];
|
||||
if ~exist('nspred','var')
|
||||
nspred = dr_.nspred; %size(dr_.ghx,2);
|
||||
nboth = dr_.nboth;
|
||||
nfwrd = dr_.nfwrd;
|
||||
end
|
||||
ys_=real(dr_.ys);
|
||||
yys(:,j) = ys_;
|
||||
ys_=yys(:,1);
|
||||
dyn_waitbar(j/ntrans,h,['MC iteration ',int2str(j),'/',int2str(ntrans)])
|
||||
if mod(j,3)
|
||||
dyn_waitbar(j/ntrans,h,['MC iteration ',int2str(j),'/',int2str(ntrans)])
|
||||
end
|
||||
end
|
||||
dyn_waitbar_close(h);
|
||||
save(filetoload,'T','-append')
|
||||
elseif prepSA
|
||||
load(filetoload,'T')
|
||||
end
|
||||
end
|
||||
|
||||
%% display and save output
|
||||
if pprior
|
||||
aunstname='prior_unstable'; aunsttitle='Prior StabMap: explosiveness of solution';
|
||||
aindname='prior_indeterm'; aindtitle='Prior StabMap: Indeterminacy';
|
||||
|
@ -435,17 +432,18 @@ delete([OutputDirectoryName,filesep,fname_,'_',aindname,'.*']);
|
|||
delete([OutputDirectoryName,filesep,fname_,'_',aunstname,'.*']);
|
||||
delete([OutputDirectoryName,filesep,fname_,'_',awrongname,'.*']);
|
||||
|
||||
if length(iunstable)>0 || length(iwrong)>0
|
||||
fprintf(['%4.1f%% of the prior support gives unique saddle-path solution.\n'],length(istable)/Nsam*100)
|
||||
fprintf(['%4.1f%% of the prior support gives explosive dynamics.\n'],(length(ixun) )/Nsam*100)
|
||||
fprintf('\nSensitivity Analysis: Stability mapping:\n')
|
||||
if ~isempty(iunstable) || ~isempty(iwrong)
|
||||
fprintf('%4.1f%% of the prior support gives unique saddle-path solution.\n',length(istable)/Nsam*100)
|
||||
fprintf('%4.1f%% of the prior support gives explosive dynamics.\n',(length(ixun) )/Nsam*100)
|
||||
if ~isempty(iindeterm)
|
||||
fprintf(['%4.1f%% of the prior support gives indeterminacy.\n'],length(iindeterm)/Nsam*100)
|
||||
fprintf('%4.1f%% of the prior support gives indeterminacy.\n',length(iindeterm)/Nsam*100)
|
||||
end
|
||||
inorestriction = istable(find(~ismember(istable,irestriction))); % violation of prior restrictions
|
||||
inorestriction = istable(~ismember(istable,irestriction)); % violation of prior restrictions
|
||||
if ~isempty(iwrong) || ~isempty(inorestriction)
|
||||
skipline()
|
||||
if any(infox==49)
|
||||
fprintf(['%4.1f%% of the prior support violates prior restrictions.\n'],(length(inorestriction) )/Nsam*100)
|
||||
fprintf('%4.1f%% of the prior support violates prior restrictions.\n',(length(inorestriction) )/Nsam*100)
|
||||
end
|
||||
if ~isempty(iwrong)
|
||||
skipline()
|
||||
|
@ -486,50 +484,66 @@ if length(iunstable)>0 || length(iwrong)>0
|
|||
end
|
||||
skipline()
|
||||
if length(iunstable)<Nsam || length(istable)>1
|
||||
itot = [1:Nsam];
|
||||
isolve = itot(find(~ismember(itot,iwrong))); % dynare could find a solution
|
||||
itot = 1:Nsam;
|
||||
isolve = itot(~ismember(itot,iwrong)); % dynare could find a solution
|
||||
% Blanchard Kahn
|
||||
if neighborhood_width
|
||||
options_mcf.xparam1 = xparam1(nshock+1:end);
|
||||
end
|
||||
itmp = itot(find(~ismember(itot,istable)));
|
||||
itmp = itot(~ismember(itot,istable));
|
||||
options_mcf.amcf_name = asname;
|
||||
options_mcf.amcf_title = atitle;
|
||||
options_mcf.beha_title = 'unique Stable Saddle-Path';
|
||||
options_mcf.nobeha_title = 'NO unique Stable Saddle-Path';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'unique Stable Saddle-Path';
|
||||
options_mcf.nobeha_title_latex = 'NO unique Stable Saddle-Path';
|
||||
end
|
||||
options_mcf.title = 'unique solution';
|
||||
mcf_analysis(lpmat, istable, itmp, options_mcf, options_);
|
||||
mcf_analysis(lpmat, istable, itmp, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
|
||||
if ~isempty(iindeterm)
|
||||
itmp = isolve(find(~ismember(isolve,iindeterm)));
|
||||
itmp = isolve(~ismember(isolve,iindeterm));
|
||||
options_mcf.amcf_name = aindname;
|
||||
options_mcf.amcf_title = aindtitle;
|
||||
options_mcf.beha_title = 'NO indeterminacy';
|
||||
options_mcf.nobeha_title = 'indeterminacy';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'NO indeterminacy';
|
||||
options_mcf.nobeha_title_latex = 'indeterminacy';
|
||||
end
|
||||
options_mcf.title = 'indeterminacy';
|
||||
mcf_analysis(lpmat, itmp, iindeterm, options_mcf, options_);
|
||||
mcf_analysis(lpmat, itmp, iindeterm, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
|
||||
if ~isempty(ixun)
|
||||
itmp = isolve(find(~ismember(isolve,ixun)));
|
||||
itmp = isolve(~ismember(isolve,ixun));
|
||||
options_mcf.amcf_name = aunstname;
|
||||
options_mcf.amcf_title = aunsttitle;
|
||||
options_mcf.beha_title = 'NO explosive solution';
|
||||
options_mcf.nobeha_title = 'explosive solution';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'NO explosive solution';
|
||||
options_mcf.nobeha_title_latex = 'explosive solution';
|
||||
end
|
||||
options_mcf.title = 'instability';
|
||||
mcf_analysis(lpmat, itmp, ixun, options_mcf, options_);
|
||||
mcf_analysis(lpmat, itmp, ixun, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
|
||||
inorestriction = istable(find(~ismember(istable,irestriction))); % violation of prior restrictions
|
||||
iwrong = iwrong(find(~ismember(iwrong,inorestriction))); % what went wrong beyond prior restrictions
|
||||
inorestriction = istable(~ismember(istable,irestriction)); % violation of prior restrictions
|
||||
iwrong = iwrong(~ismember(iwrong,inorestriction)); % what went wrong beyond prior restrictions
|
||||
if ~isempty(iwrong)
|
||||
itmp = itot(find(~ismember(itot,iwrong)));
|
||||
itmp = itot(~ismember(itot,iwrong));
|
||||
options_mcf.amcf_name = awrongname;
|
||||
options_mcf.amcf_title = awrongtitle;
|
||||
options_mcf.beha_title = 'NO inability to find a solution';
|
||||
options_mcf.nobeha_title = 'inability to find a solution';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'NO inability to find a solution';
|
||||
options_mcf.nobeha_title_latex = 'inability to find a solution';
|
||||
end
|
||||
options_mcf.title = 'inability to find a solution';
|
||||
mcf_analysis(lpmat, itmp, iwrong, options_mcf, options_);
|
||||
mcf_analysis(lpmat, itmp, iwrong, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
end
|
||||
|
||||
if ~isempty(irestriction)
|
||||
|
@ -541,11 +555,11 @@ if length(iunstable)>0 || length(iwrong)>0
|
|||
name_tex=cell(np,1);
|
||||
for jj=1:np
|
||||
if options_.TeX
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
name_tex{jj,1} = strrep(param_name_tex_temp,'$','');
|
||||
[param_name_temp, param_name_tex_temp]= get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name_tex{jj,1} = param_name_tex_temp;
|
||||
name{jj,1} = param_name_temp;
|
||||
else
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_temp = get_the_name(jj,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
name{jj,1} = param_name_temp;
|
||||
end
|
||||
end
|
||||
|
@ -557,8 +571,12 @@ if length(iunstable)>0 || length(iwrong)>0
|
|||
options_mcf.amcf_title = acalibtitle;
|
||||
options_mcf.beha_title = 'prior IRF/moment calibration';
|
||||
options_mcf.nobeha_title = 'NO prior IRF/moment calibration';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'prior IRF/moment calibration';
|
||||
options_mcf.nobeha_title_latex = 'NO prior IRF/moment calibration';
|
||||
end
|
||||
options_mcf.title = 'prior restrictions';
|
||||
mcf_analysis([lpmat0 lpmat], irestriction, inorestriction, options_mcf, options_);
|
||||
mcf_analysis([lpmat0 lpmat], irestriction, inorestriction, options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
iok = irestriction(1);
|
||||
x0 = [lpmat0(iok,:)'; lpmat(iok,:)'];
|
||||
else
|
||||
|
@ -568,7 +586,7 @@ if length(iunstable)>0 || length(iwrong)>0
|
|||
end
|
||||
|
||||
M_ = set_all_parameters(x0,estim_params_,M_);
|
||||
[oo_.dr,info,M_.params] = resol(0,M_,options_,oo_.dr ,oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
[oo_.dr,~,M_.params] = resol(0,M_,options_,oo_.dr ,oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
else
|
||||
disp('All parameter values in the specified ranges are not acceptable!')
|
||||
x0=[];
|
||||
|
@ -578,15 +596,8 @@ else
|
|||
disp('and match prior IRF/moment restriction(s) if any!')
|
||||
x0=0.5.*(bounds.ub(1:nshock)-bounds.lb(1:nshock))+bounds.lb(1:nshock);
|
||||
x0 = [x0; lpmat(istable(1),:)'];
|
||||
|
||||
end
|
||||
skipline(1);
|
||||
|
||||
xparam1=x0;
|
||||
save([OutputDirectoryName filesep 'prior_ok.mat'],'xparam1');
|
||||
|
||||
options_.periods=opt.periods;
|
||||
if isfield(opt,'nomoments')
|
||||
options_.nomoments=opt.nomoments;
|
||||
end
|
||||
options_.irf=opt.irf;
|
||||
options_.noprint=opt.noprint;
|
||||
save([OutputDirectoryName filesep 'prior_ok.mat'],'xparam1');
|
|
@ -1,16 +1,20 @@
|
|||
function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname, pcrit, atitle)
|
||||
%function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname, pcrit)
|
||||
%
|
||||
% lpmat = Monte Carlo matrix
|
||||
% ibehaviour = index of behavioural runs
|
||||
% inonbehaviour = index of non-behavioural runs
|
||||
% aname = label of the analysis
|
||||
% iplot = 1 plot cumulative distributions (default)
|
||||
% iplot = 0 no plots
|
||||
% ipar = index array of parameters to plot
|
||||
% dirname = (OPTIONAL) path of the directory where to save
|
||||
% (default: current directory)
|
||||
% pcrit = (OPTIONAL) critical value of the pvalue below which show the plots
|
||||
function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, fname_, options_, parnames, estim_params_, iplot, ipar, dirname, pcrit, atitle)
|
||||
% [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, fname_, options_, parnames, estim_params_, iplot, ipar, dirname, pcrit, atitle)
|
||||
% Inputs:
|
||||
% - lpmat [double] Monte Carlo matrix
|
||||
% - ibehaviour [integer] index of behavioural runs
|
||||
% - inonbehaviour [integer] index of non-behavioural runs
|
||||
% - aname [string] label of the analysis
|
||||
% - fname_ [string] file name
|
||||
% - options_ [structure] options structure
|
||||
% - parnames [char] parameter name vector
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - iplot [boolean] 1 plot cumulative distributions (default)
|
||||
% 0 no plots
|
||||
% - ipar [integer] index array of parameters to plot
|
||||
% - dirname [string] (OPTIONAL) path of the directory where to save
|
||||
% (default: current directory)
|
||||
% - pcrit [double] (OPTIONAL) critical value of the pvalue below which show the plots
|
||||
%
|
||||
% Plots: dotted lines for BEHAVIOURAL
|
||||
% solid lines for NON BEHAVIOURAL
|
||||
|
@ -38,16 +42,13 @@ function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, i
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global estim_params_ bayestopt_ M_ options_
|
||||
|
||||
if nargin<5
|
||||
if nargin<9
|
||||
iplot=1;
|
||||
end
|
||||
fname_ = M_.fname;
|
||||
if nargin<7
|
||||
if nargin<11
|
||||
dirname='';
|
||||
end
|
||||
if nargin<9,
|
||||
if nargin<13
|
||||
atitle=aname;
|
||||
end
|
||||
|
||||
|
@ -59,27 +60,28 @@ nshock = nshock + estim_params_.ncn;
|
|||
npar=size(lpmat,2);
|
||||
ishock= npar>estim_params_.np;
|
||||
|
||||
if nargin<6
|
||||
if nargin<10
|
||||
ipar=[];
|
||||
end
|
||||
if nargin<8 || isempty(pcrit)
|
||||
if nargin<12 || isempty(pcrit)
|
||||
pcrit=1;
|
||||
end
|
||||
|
||||
% Smirnov test for Blanchard;
|
||||
% Smirnov test for Blanchard
|
||||
proba=NaN(npar,1);
|
||||
dproba=NaN(npar,1);
|
||||
for j=1:npar
|
||||
[H,P,KSSTAT] = smirnov(lpmat(ibehaviour,j),lpmat(inonbehaviour,j));
|
||||
[~,P,KSSTAT] = smirnov(lpmat(ibehaviour,j),lpmat(inonbehaviour,j));
|
||||
proba(j)=P;
|
||||
dproba(j)=KSSTAT;
|
||||
end
|
||||
if isempty(ipar)
|
||||
% ipar=find(dproba>dcrit);
|
||||
ipar=find(proba<pcrit);
|
||||
end
|
||||
nparplot=length(ipar);
|
||||
if iplot && ~options_.nograph
|
||||
lpmat=lpmat(:,ipar);
|
||||
ftit=bayestopt_.name(ipar+nshock*(1-ishock));
|
||||
ftit=parnames(ipar+nshock*(1-ishock));
|
||||
|
||||
for i=1:ceil(nparplot/12)
|
||||
hh_fig=dyn_figure(options_.nodisplay,'name',atitle);
|
||||
|
@ -94,7 +96,6 @@ if iplot && ~options_.nograph
|
|||
h=cumplot(lpmat(inonbehaviour,j));
|
||||
set(h,'color',[0 0 0],'LineWidth',1.5)
|
||||
end
|
||||
% title([ftit{j},'. D-stat ', num2str(dproba(ipar(j)),2)],'interpreter','none')
|
||||
title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
|
||||
end
|
||||
if nparplot>12
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figtitle)
|
||||
% function stab_map_2(x, alpha2, pvalue, fnam, dirname,xparam1)
|
||||
function indcorr = stab_map_2(x,alpha2, pvalue_crit, M_,options_,bayestopt_,estim_params_, case_name_plain, case_name_latex, dirname,xparam1,figtitle,fig_caption_latex)
|
||||
% indcorr = stab_map_2(x,alpha2, pvalue_crit, M_,options_,bayestopt_,estim_params_, fnam, fnam_latex, dirname,xparam1,figtitle,fig_caption_latex)
|
||||
% Inputs:
|
||||
% - x
|
||||
% - alpha2
|
||||
% - pvalue_crit
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - bayestopt_ [structure] describing the priors
|
||||
% - estim_params_ [structure] characterizing parameters to be estimated
|
||||
% - fnam [string] file name
|
||||
% - dirnam [string] directory name
|
||||
% - xparam1 [double] parameter vector
|
||||
% - figtitle [string] figure title
|
||||
%
|
||||
% Output:
|
||||
% - indcorr
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
@ -22,29 +36,30 @@ function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figti
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
%global bayestopt_ estim_params_ dr_ options_ ys_ fname_
|
||||
global bayestopt_ estim_params_ options_ oo_ M_
|
||||
|
||||
npar=size(x,2);
|
||||
nsam=size(x,1);
|
||||
ishock= npar>estim_params_.np;
|
||||
nograph = options_.nograph;
|
||||
if nargin<4
|
||||
fnam='';
|
||||
|
||||
if nargin<8
|
||||
case_name_plain='';
|
||||
end
|
||||
if nargin<5
|
||||
if nargin<9
|
||||
case_name_latex=case_name_plain;
|
||||
end
|
||||
if nargin<10
|
||||
dirname='';
|
||||
nograph=1;
|
||||
end
|
||||
if nargin<6
|
||||
if nargin<11
|
||||
xparam1=[];
|
||||
end
|
||||
if nargin<7
|
||||
figtitle=fnam;
|
||||
if nargin<12
|
||||
figtitle=case_name_plain;
|
||||
end
|
||||
if nargin<13
|
||||
fig_caption_latex=case_name_latex;
|
||||
end
|
||||
|
||||
ys_ = oo_.dr.ys;
|
||||
dr_ = oo_.dr;
|
||||
fname_ = M_.fname;
|
||||
nshock = estim_params_.nvx;
|
||||
nshock = nshock + estim_params_.nvn;
|
||||
|
@ -53,9 +68,9 @@ nshock = nshock + estim_params_.ncn;
|
|||
|
||||
[c0, pvalue] = corrcoef(x);
|
||||
c00=tril(c0,-1);
|
||||
fig_nam_=[fname_,'_',fnam,'_corr_'];
|
||||
fig_nam_tex_table=strrep([fnam,'_corr'],' ','_');
|
||||
fig_nam_=strrep(fig_nam_,' ','_');
|
||||
fig_nam_save=[fname_,'_',case_name_plain,'_corr_'];
|
||||
fig_nam_save=strrep(fig_nam_save,' ','_');
|
||||
fig_nam_tex_table_save=strrep([case_name_plain,'_corr'],' ','_');
|
||||
|
||||
ifig=0;
|
||||
j2=0;
|
||||
|
@ -67,47 +82,43 @@ if ishock==0
|
|||
else
|
||||
npar=estim_params_.np+nshock;
|
||||
end
|
||||
title_string=['Correlation analysis for ',fnam];
|
||||
title_string_tex=['Correlation analysis for ',strrep(fnam,'_','\\_')];
|
||||
title_string=['Correlation analysis for ',case_name_plain];
|
||||
title_string_tex=['Correlation analysis for ',case_name_latex];
|
||||
|
||||
indcorr = [];
|
||||
entry_iter=1;
|
||||
for j=1:npar
|
||||
i2=find(abs(c00(:,j))>alpha2);
|
||||
if length(i2)>0
|
||||
if ~isempty(i2)
|
||||
for jx=1:length(i2)
|
||||
if pvalue(j,i2(jx))<pvalue_crit
|
||||
indcorr = [indcorr; [j i2(jx)]];
|
||||
j2=j2+1;
|
||||
if ishock
|
||||
if options_.TeX
|
||||
[param_name_temp1, param_name_tex_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_tex_temp1 = strrep(param_name_tex_temp1,'$','');
|
||||
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_);
|
||||
param_name_tex_temp2 = strrep(param_name_tex_temp2,'$','');
|
||||
[param_name_temp1, param_name_tex_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_.varobs);
|
||||
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
||||
tmp_name_tex=(['[',param_name_tex_temp1,',',param_name_tex_temp2,']']);
|
||||
name{entry_iter,1}=tmp_name;
|
||||
name_tex{entry_iter,1}=tmp_name_tex;
|
||||
name_tex{entry_iter,1}=strrep(tmp_name_tex,'$',''); %prevent $ inside of expression for table
|
||||
else
|
||||
[param_name_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_);
|
||||
[param_name_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_);
|
||||
[param_name_temp1]= get_the_name(j,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
[param_name_temp2]= get_the_name(i2(jx),options_.TeX,M_,estim_params_,options_.varobs);
|
||||
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
||||
name{entry_iter,1}=tmp_name;
|
||||
end
|
||||
else
|
||||
if options_.TeX
|
||||
[param_name_temp1, param_name_tex_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_tex_temp1 = strrep(param_name_tex_temp1,'$','');
|
||||
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_);
|
||||
param_name_tex_temp2 = strrep(param_name_tex_temp2,'$','');
|
||||
[param_name_temp1, param_name_tex_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
[param_name_temp2, param_name_tex_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
||||
tmp_name_tex=(['[',param_name_tex_temp1,',',param_name_tex_temp2,']']);
|
||||
name{entry_iter,1}=tmp_name;
|
||||
name_tex{entry_iter,1}=tmp_name_tex;
|
||||
name_tex{entry_iter,1}=strrep(tmp_name_tex,'$',''); %prevent $ inside of expression for table
|
||||
else
|
||||
[param_name_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_);
|
||||
[param_name_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_);
|
||||
[param_name_temp1]= get_the_name(j+nshock,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
[param_name_temp2]= get_the_name(i2(jx)+nshock,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
tmp_name=(['[',param_name_temp1,',',param_name_temp2,']']);
|
||||
name{entry_iter,1}=tmp_name;
|
||||
end
|
||||
|
@ -121,17 +132,10 @@ for j=1:npar
|
|||
hh_fig=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
||||
end
|
||||
subplot(3,4,j2-(ifig-1)*12)
|
||||
% bar(c0(i2,j)),
|
||||
% set(gca,'xticklabel',bayestopt_.name(i2)),
|
||||
% set(gca,'xtick',[1:length(i2)])
|
||||
%plot(stock_par(ixx(nfilt+1:end,i),j),stock_par(ixx(nfilt+1:end,i),i2(jx)),'.k')
|
||||
%hold on,
|
||||
plot(x(:,j),x(:,i2(jx)),'.')
|
||||
if ~isempty(xparam1)
|
||||
hold on, plot(xparam1(j),xparam1(i2(jx)),'ro')
|
||||
end
|
||||
% xlabel(deblank(estim_params_.param_names(j,:)),'interpreter','none'),
|
||||
% ylabel(deblank(estim_params_.param_names(i2(jx),:)),'interpreter','none'),
|
||||
if ishock
|
||||
xlabel(bayestopt_.name{j},'interpreter','none'),
|
||||
ylabel(bayestopt_.name{i2(jx)},'interpreter','none'),
|
||||
|
@ -141,16 +145,16 @@ for j=1:npar
|
|||
end
|
||||
title(['cc = ',num2str(c0(i2(jx),j))])
|
||||
if (mod(j2,12)==0) && j2>0
|
||||
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_save,int2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
|
||||
fidTeX = fopen([dirname,filesep,fig_nam_save,int2str(ifig),'.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s}\n',strrep([dirname,'/',fig_nam_,int2str(ifig)],'\','/'));
|
||||
fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
||||
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s}\n',strrep([dirname,'/',fig_nam_save,int2str(ifig)],'\','/'));
|
||||
fprintf(fidTeX,'\\caption{%s.}',[fig_caption_latex,' sample bivariate projection ', num2str(ifig)]);
|
||||
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_save,ifig);
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
fprintf(fidTeX,'%% End Of TeX file. \n');
|
||||
fclose(fidTeX);
|
||||
|
@ -162,16 +166,16 @@ for j=1:npar
|
|||
end
|
||||
end
|
||||
if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0)
|
||||
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_save,int2str(ifig)],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
|
||||
fidTeX = fopen([dirname,filesep,fig_nam_save,int2str(ifig),'.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s}\n',options_.figures.textwidth*min((j2-(ifig-1)*12)/3,1),strrep([dirname,'/',fig_nam_,int2str(ifig)],'\','/'));
|
||||
fprintf(fidTeX,'\\caption{%s.}',[figtitle,' sample bivariate projection ', num2str(ifig)]);
|
||||
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_,ifig);
|
||||
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s}\n',options_.figures.textwidth*min((j2-(ifig-1)*12)/3,1),strrep([dirname,'/',fig_nam_save,int2str(ifig)],'\','/'));
|
||||
fprintf(fidTeX,'\\caption{%s.}',[fig_caption_latex,' sample bivariate projection ', num2str(ifig)]);
|
||||
fprintf(fidTeX,'\\label{Fig:%s:%u}\n',fig_nam_save,ifig);
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
fprintf(fidTeX,'%% End Of TeX file. \n');
|
||||
fclose(fidTeX);
|
||||
|
@ -181,7 +185,7 @@ end
|
|||
|
||||
if j2==0
|
||||
skipline();
|
||||
disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam])
|
||||
disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',case_name_plain])
|
||||
else
|
||||
headers={'Parameters'; 'corrcoef'};
|
||||
if ~options_.noprint
|
||||
|
@ -189,7 +193,6 @@ else
|
|||
end
|
||||
dyntable(options_,title_string,headers, name, data_mat, 0, 7, 3);
|
||||
if options_.TeX
|
||||
dyn_latex_table(M_, options_, title_string_tex, fig_nam_tex_table, headers, name_tex, data_mat, 0, 7, 3);
|
||||
dyn_latex_table(M_, options_, title_string_tex, fig_nam_tex_table_save, headers, name_tex, data_mat, 0, 7, 3);
|
||||
end
|
||||
end
|
||||
%close all
|
||||
end
|
|
@ -1,20 +1,22 @@
|
|||
function [y, meany, stdy] = stand_(x)
|
||||
% STAND_ Standardise a matrix by columns
|
||||
% [y, meany, stdy] = stand_(x)
|
||||
% Standardise a matrix by columns
|
||||
%
|
||||
% [x,my,sy]=stand(y)
|
||||
%
|
||||
% y: Time series (column matrix)
|
||||
% Inputs:
|
||||
% - x: Time series (column matrix)
|
||||
%
|
||||
% x: standardised equivalent of y
|
||||
% my: Vector of mean values for each column of y
|
||||
% sy: Vector of standard deviations for each column of y
|
||||
% - y: standardised equivalent of x
|
||||
% - meany: Vector of mean values for each column of x
|
||||
% - stdy: Vector of standard deviations for each column of x
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team%
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
|
@ -34,9 +36,11 @@ if nargin==0
|
|||
return
|
||||
end
|
||||
|
||||
meany=NaN(size(x,2),1);
|
||||
stdy=NaN(size(x,2),1);
|
||||
y=NaN(size(x));
|
||||
for j=1:size(x,2)
|
||||
meany(j)=mean(x(find(~isnan(x(:,j))),j));
|
||||
stdy(j)=std(x(find(~isnan(x(:,j))),j));
|
||||
meany(j)=mean(x(~isnan(x(:,j)),j));
|
||||
stdy(j)=std(x(~isnan(x(:,j)),j));
|
||||
y(:,j)=(x(:,j)-meany(j))./stdy(j);
|
||||
end
|
||||
% end of m-file
|
||||
end
|
|
@ -150,4 +150,4 @@ if n<=100
|
|||
t_crit=t_crit(n,ncol);
|
||||
else
|
||||
t_crit=t_crit(end,ncol);
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,15 +37,12 @@ if ndim==3
|
|||
[ir, ic]=(find( (tmax-tmin)>1.e-8));
|
||||
j0 = length(ir);
|
||||
yt=zeros(Nsam, j0);
|
||||
|
||||
for j=1:j0
|
||||
y0=squeeze(T(ir(j),ic(j),:));
|
||||
%y1=ones(size(lpmat,1),1)*NaN;
|
||||
y1=ones(Nsam,1)*NaN;
|
||||
y1(istable,1)=y0;
|
||||
yt(:,j)=y1;
|
||||
end
|
||||
|
||||
else
|
||||
tmax=max(T,[],2);
|
||||
tmin=min(T,[],2);
|
||||
|
@ -53,7 +50,4 @@ else
|
|||
j0 = length(ir);
|
||||
yt=NaN(Nsam, j0);
|
||||
yt(istable,:)=T(ir,:)';
|
||||
|
||||
|
||||
end
|
||||
%clear y0 y1;
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
|
||||
% [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
|
||||
function [vdec, corr, autocorr, z, zz] = th_moments(dr,options_,M_)
|
||||
% [vdec, corr, autocorr, z, zz] = th_moments(dr,options_,M_)
|
||||
% Computes theoretical moments for GSA
|
||||
%
|
||||
% INPUTS
|
||||
% - dr [structure] model information structure
|
||||
% - options_ [structure] Matlab's structure describing the current options
|
||||
% - M_ [structure] Matlab's structure describing the model
|
||||
%
|
||||
% OUTPUTS
|
||||
% - vdec [double] variance decomposition matrix
|
||||
% - corr [double] correlation matrix
|
||||
% - autocorr [cell] contains autocorrelation or
|
||||
% auto- and cross-covariance matrices
|
||||
% - z [double] matrix containing mean, standard
|
||||
% deviation, and variance vector
|
||||
% - zz [double] autocorrelation matrix
|
||||
|
||||
% Copyright © 2012-2018 Dynare Team
|
||||
% Copyright © 2012-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -18,18 +33,16 @@ function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ oo_ options_
|
||||
|
||||
nvar = length(var_list);
|
||||
nvar = length(options_.varobs);
|
||||
if nvar == 0
|
||||
nvar = length(dr.order_var);
|
||||
ivar = [1:nvar]';
|
||||
else
|
||||
ivar=zeros(nvar,1);
|
||||
for i=1:nvar
|
||||
i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
|
||||
i_tmp = strmatch(options_.varobs{i}, M_.endo_names, 'exact');
|
||||
if isempty(i_tmp)
|
||||
error(['One of the variables specified does not exist']) ;
|
||||
error('th_moments: One of the variables specified does not exist');
|
||||
else
|
||||
ivar(i) = i_tmp;
|
||||
end
|
||||
|
@ -39,21 +52,11 @@ end
|
|||
[gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_, options_);
|
||||
m = dr.ys(ivar(stationary_vars));
|
||||
|
||||
|
||||
% i1 = find(abs(diag(gamma_y{1})) > 1e-12);
|
||||
i1 = [1:length(ivar)];
|
||||
i1 = 1:length(ivar);
|
||||
s2 = diag(gamma_y{1});
|
||||
sd = sqrt(s2);
|
||||
|
||||
|
||||
z = [ m sd s2 ];
|
||||
mean = m;
|
||||
var = gamma_y{1};
|
||||
|
||||
|
||||
%'THEORETICAL MOMENTS';
|
||||
%'MEAN','STD. DEV.','VARIANCE');
|
||||
z;
|
||||
|
||||
%'VARIANCE DECOMPOSITION (in percent)';
|
||||
if M_.exo_nbr>1
|
||||
|
@ -69,6 +72,7 @@ else
|
|||
corr = gamma_y{1}(i1,i1);
|
||||
end
|
||||
if options_.ar > 0
|
||||
zz=NaN(length(ivar),options_.ar);
|
||||
%'COEFFICIENTS OF AUTOCORRELATION';
|
||||
for i=1:options_.ar
|
||||
if options_.opt_gsa.useautocorr
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
function yr = trank(y)
|
||||
% yr = trank(y);
|
||||
% yr is the rank transformation of y
|
||||
%
|
||||
% Written by Marco Ratto
|
||||
% Joint Research Centre, The European Commission,
|
||||
% marco.ratto@ec.europa.eu
|
||||
%
|
||||
% Reference:
|
||||
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
|
||||
|
||||
% Copyright © 2012 European Commission
|
||||
% Copyright © 2012-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
[nr, nc] = size(y);
|
||||
for j=1:nc
|
||||
[dum, is]=sort(y(:,j));
|
||||
yr(is,j)=[1:nr]'./nr;
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
function [pars, cosnJ] = ident_bruteforce(J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv)
|
||||
% function [pars, cosnJ] = ident_bruteforce(J,n,TeX, pnames_TeX,tittxt)
|
||||
function [pars, cosnJ] = ident_bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv)
|
||||
% [pars, cosnJ] = ident_bruteforce(dname,fname,J, max_dim_cova_group, TeX, name_tex, tittxt, tol_deriv)
|
||||
% -------------------------------------------------------------------------
|
||||
% given the Jacobian matrix J of moment derivatives w.r.t. parameters
|
||||
% computes, for each column of J, the groups of columns from 1 to n that
|
||||
|
@ -20,7 +20,7 @@ function [pars, cosnJ] = ident_bruteforce(J, max_dim_cova_group, TeX, name_tex,
|
|||
% This function is called by
|
||||
% * identification_analysis.m
|
||||
% =========================================================================
|
||||
% Copyright © 2009-2019 Dynare Team
|
||||
% Copyright © 2009-2023 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -38,20 +38,18 @@ function [pars, cosnJ] = ident_bruteforce(J, max_dim_cova_group, TeX, name_tex,
|
|||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
|
||||
global M_ options_
|
||||
|
||||
OutputDirectoryName = CheckPath('identification',M_.dname);
|
||||
OutputDirectoryName = CheckPath('identification',dname);
|
||||
|
||||
totparam_nbr = size(J,2); % number of parameters
|
||||
|
||||
if nargin<2 || isempty(max_dim_cova_group)
|
||||
if nargin<4 || isempty(max_dim_cova_group)
|
||||
max_dim_cova_group = 4; % max n-tuple
|
||||
end
|
||||
if nargin<3 || isempty(TeX)
|
||||
if nargin<5 || isempty(TeX)
|
||||
TeX = 0; % no Tex output
|
||||
tittxt='';
|
||||
end
|
||||
if nargin < 6
|
||||
if nargin < 8
|
||||
tol_deriv = 1.e-8;
|
||||
end
|
||||
|
||||
|
@ -87,7 +85,7 @@ for ll = 1:max_dim_cova_group
|
|||
end
|
||||
dyn_waitbar_close(h);
|
||||
if TeX
|
||||
filename = [OutputDirectoryName '/' M_.fname '_collin_patterns_',tittxt1,'_' int2str(ll) '.tex'];
|
||||
filename = [OutputDirectoryName '/' fname '_collin_patterns_',tittxt1,'_' int2str(ll) '.tex'];
|
||||
fidTeX = fopen(filename,'w');
|
||||
fprintf(fidTeX,'%% TeX-table generated by ident_bruteforce (Dynare).\n');
|
||||
fprintf(fidTeX,['%% Collinearity patterns with ',int2str(ll),' parameter(s): ',tittxt,'\n']);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, derivatives_info, info, error_indicator] = identification_analysis(params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, init)
|
||||
% [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, derivatives_info, info, error_indicator] = identification_analysis(params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, init)
|
||||
function [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, derivatives_info, info, error_indicator] = identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, init)
|
||||
% [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide_dynamic, derivatives_info, info, error_indicator] = identification_analysis(M_,options_,oo_,bayestopt_,estim_params_,params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, init)
|
||||
% -------------------------------------------------------------------------
|
||||
% This function wraps all identification analysis, i.e. it
|
||||
% (1) wraps functions for the theoretical identification analysis based on moments (Iskrev, 2010),
|
||||
|
@ -12,6 +12,11 @@ function [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide
|
|||
% moments, spectrum, reduced-form solution and dynamic model derivatives
|
||||
% =========================================================================
|
||||
% INPUTS
|
||||
% * M_ [structure] describing the model
|
||||
% * options_ [structure] describing the options
|
||||
% * oo_ [structure] storing the results
|
||||
% * bayestopt_ [structure] describing the priors
|
||||
% * estim_params_ [structure] characterizing parameters to be estimated
|
||||
% * params [mc_sample_nbr by totparam_nbr]
|
||||
% parameter values for identification checks
|
||||
% * indpmodel [modparam_nbr by 1]
|
||||
|
@ -91,7 +96,6 @@ function [ide_moments, ide_spectrum, ide_minimal, ide_hess, ide_reducedform, ide
|
|||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
|
||||
global oo_ M_ options_ bayestopt_ estim_params_
|
||||
persistent ind_dMOMENTS ind_dREDUCEDFORM ind_dDYNAMIC
|
||||
% persistent indices are necessary, because in a MC loop the numerical threshold
|
||||
% used may provide vectors of different length, leading to crashes in MC loops
|
||||
|
@ -138,7 +142,7 @@ error_indicator.identification_spectrum=0;
|
|||
|
||||
if info(1) == 0 %no errors in solution
|
||||
% Compute parameter Jacobians for identification analysis
|
||||
[MEAN, dMEAN, REDUCEDFORM, dREDUCEDFORM, DYNAMIC, dDYNAMIC, MOMENTS, dMOMENTS, dSPECTRUM, dSPECTRUM_NO_MEAN, dMINIMAL, derivatives_info] = get_identification_jacobians(estim_params_, M_, options_, options_ident, indpmodel, indpstderr, indpcorr, indvobs, oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
[~, ~, REDUCEDFORM, dREDUCEDFORM, DYNAMIC, dDYNAMIC, MOMENTS, dMOMENTS, dSPECTRUM, dSPECTRUM_NO_MEAN, dMINIMAL, derivatives_info] = get_identification_jacobians(estim_params_, M_, options_, options_ident, indpmodel, indpstderr, indpcorr, indvobs, oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
if isempty(dMINIMAL)
|
||||
% Komunjer and Ng is not computed if (1) minimality conditions are not fullfilled or (2) there are more shocks and measurement errors than observables, so we need to reset options
|
||||
error_indicator.identification_minimal = 1;
|
||||
|
@ -296,7 +300,7 @@ if info(1) == 0 %no errors in solution
|
|||
derivatives_info.no_DLIK = 1;
|
||||
bounds = prior_bounds(bayestopt_, options_.prior_trunc); %reset bounds as lb and ub must only be operational during mode-finding
|
||||
%note that for order>1 we do not provide any information on DT,DYss,DOM in derivatives_info, such that dsge_likelihood creates an error. Therefore the computation will be based on simulated_moment_uncertainty for order>1.
|
||||
[fval, info, cost_flag, DLIK, AHess, ys, trend_coeff, M_, options_, bayestopt_, oo_.dr] = dsge_likelihood(params', dataset_, dataset_info, options_, M_, estim_params_, bayestopt_, bounds, oo_.dr, oo_.steady_state,oo_.exo_steady_state, oo_.exo_det_steady_state. derivatives_info); %non-used output variables need to be set for octave for some reason
|
||||
[~, info, ~, ~, AHess, ~, ~, M_, options_, ~, oo_.dr] = dsge_likelihood(params', dataset_, dataset_info, options_, M_, estim_params_, bayestopt_, bounds, oo_.dr, oo_.steady_state,oo_.exo_steady_state, oo_.exo_det_steady_state. derivatives_info); %non-used output variables need to be set for octave for some reason
|
||||
%note that for the order of parameters in AHess we have: stderr parameters come first, corr parameters second, model parameters third. the order within these blocks corresponds to the order specified in the estimated_params block
|
||||
options_.analytic_derivation = analytic_derivation; %reset option
|
||||
AHess = -AHess; %take negative of hessian
|
||||
|
@ -462,7 +466,7 @@ if info(1) == 0 %no errors in solution
|
|||
|
||||
if advanced
|
||||
% here we do not normalize (i.e. we set norm_dMOMENTS=1) as the OLS in ident_bruteforce is very sensitive to norm_dMOMENTS
|
||||
[ide_moments.pars, ide_moments.cosndMOMENTS] = ident_bruteforce(dMOMENTS(ind_dMOMENTS,:), max_dim_cova_group, options_.TeX, options_ident.name_tex, options_ident.tittxt, tol_deriv);
|
||||
[ide_moments.pars, ide_moments.cosndMOMENTS] = ident_bruteforce(M_.dname,M_.fname,dMOMENTS(ind_dMOMENTS,:), max_dim_cova_group, options_.TeX, options_ident.name_tex, options_ident.tittxt, tol_deriv);
|
||||
end
|
||||
|
||||
%here we focus on the unnormalized S and V, which is then used in plot_identification.m and for prior_mc > 1
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
function mh_autocorrelation_function(options_,M_,estim_params_,type,blck,name1,name2)
|
||||
% mh_autocorrelation_function(options_,M_,estim_params_,type,blck,name1,name2)
|
||||
% This function plots the autocorrelation of the sampled draws in the
|
||||
% posterior distribution.
|
||||
%
|
||||
%
|
||||
% INPUTS
|
||||
%
|
||||
% options_ [structure] Dynare structure.
|
||||
% M_ [structure] Dynare structure (related to model definition).
|
||||
% estim_params_ [structure] Dynare structure (related to estimation).
|
||||
|
@ -63,7 +62,7 @@ clear record;
|
|||
PosteriorDraws = GetAllPosteriorDraws(M_.dname, M_.fname, column, FirstMhFile, FirstLine, TotalNumberOfMhFiles, NumberOfDraws, nblck, blck);
|
||||
|
||||
% Compute the autocorrelation function:
|
||||
[autocov,autocor] = sample_autocovariance(PosteriorDraws,options_.mh_autocorrelation_function_size);
|
||||
[~,autocor] = sample_autocovariance(PosteriorDraws,options_.mh_autocorrelation_function_size);
|
||||
|
||||
% Plot the posterior draws:
|
||||
|
||||
|
@ -101,9 +100,9 @@ axis tight
|
|||
if ~exist(M_.dname, 'dir')
|
||||
mkdir('.',M_.dname);
|
||||
end
|
||||
if ~exist([M_.dname filesep 'graphs'])
|
||||
if ~exist([M_.dname filesep 'graphs'],'dir')
|
||||
mkdir(M_.dname,'graphs');
|
||||
end
|
||||
|
||||
plot_name=get_the_name(column,0,M_,estim_params_,options_);
|
||||
plot_name=get_the_name(column,0,M_,estim_params_,options_.varobs);
|
||||
dyn_saveas(hh_fig,[M_.dname, filesep, 'graphs', filesep, 'MH_Autocorrelation_' plot_name],options_.nodisplay,options_.graph_format)
|
||||
|
|
|
@ -95,7 +95,7 @@ for plt = 1:nbplt
|
|||
for k = 1:min(nstar,length(xparam)-(plt-1)*nstar)
|
||||
subplot(nr,nc,k)
|
||||
kk = (plt-1)*nstar+k;
|
||||
[name,texname] = get_the_name(kk,options_.TeX,M_,estim_params_,options_);
|
||||
[name,texname] = get_the_name(kk,options_.TeX,M_,estim_params_,options_.varobs);
|
||||
xx = xparam;
|
||||
if xparam(kk)~=0 && ~isinf(bounds.lb(kk)) && ~isinf(bounds.ub(kk))
|
||||
l1 = max(bounds.lb(kk),(1-sign(xparam(kk))*ll)*xparam(kk)); m1 = 0; % lower bound
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
|
||||
function sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
||||
|
||||
% sout = myboxplot (data,notched,symbol,vertical,maxwhisker)
|
||||
|
||||
%
|
||||
% Copyright © 2010-2017 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
% % % % endif
|
||||
if nargin < 5 || isempty(maxwhisker), maxwhisker = 1.5; end
|
||||
if nargin < 4 || isempty(vertical), vertical = 1; end
|
||||
if nargin < 3 || isempty(symbol), symbol = ['+','o']; end
|
||||
if nargin < 2 || isempty(notched), notched = 0; end
|
||||
|
||||
if length(symbol)==1, symbol(2)=symbol(1); end
|
||||
|
||||
if notched==1, notched=0.25; end
|
||||
a=1-notched;
|
||||
|
||||
% ## figure out how many data sets we have
|
||||
if iscell(data)
|
||||
nc = length(data);
|
||||
else
|
||||
% if isvector(data), data = data(:); end
|
||||
nc = size(data,2);
|
||||
end
|
||||
|
||||
% ## compute statistics
|
||||
% ## s will contain
|
||||
% ## 1,5 min and max
|
||||
% ## 2,3,4 1st, 2nd and 3rd quartile
|
||||
% ## 6,7 lower and upper confidence intervals for median
|
||||
s = zeros(7,nc);
|
||||
box = zeros(1,nc);
|
||||
whisker_x = ones(2,1)*[1:nc,1:nc];
|
||||
whisker_y = zeros(2,2*nc);
|
||||
outliers_x = [];
|
||||
outliers_y = [];
|
||||
outliers2_x = [];
|
||||
outliers2_y = [];
|
||||
|
||||
for i=1:nc
|
||||
% ## Get the next data set from the array or cell array
|
||||
if iscell(data)
|
||||
col = data{i}(:);
|
||||
else
|
||||
col = data(:,i);
|
||||
end
|
||||
% ## Skip missing data
|
||||
% % % % % % % col(isnan(col) | isna (col)) = [];
|
||||
col(isnan(col)) = [];
|
||||
|
||||
% ## Remember the data length
|
||||
nd = length(col);
|
||||
box(i) = nd;
|
||||
if (nd > 1)
|
||||
% ## min,max and quartiles
|
||||
% s(1:5,i) = statistics(col)(1:5);
|
||||
s(1,i)=min(col);
|
||||
s(5,i)=max(col);
|
||||
s(2,i)=myprctilecol(col,25);
|
||||
s(3,i)=myprctilecol(col,50);
|
||||
s(4,i)=myprctilecol(col,75);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% ## confidence interval for the median
|
||||
est = 1.57*(s(4,i)-s(2,i))/sqrt(nd);
|
||||
s(6,i) = max([s(3,i)-est, s(2,i)]);
|
||||
s(7,i) = min([s(3,i)+est, s(4,i)]);
|
||||
% ## whiskers out to the last point within the desired inter-quartile range
|
||||
IQR = maxwhisker*(s(4,i)-s(2,i));
|
||||
whisker_y(:,i) = [min(col(col >= s(2,i)-IQR)); s(2,i)];
|
||||
whisker_y(:,nc+i) = [max(col(col <= s(4,i)+IQR)); s(4,i)];
|
||||
% ## outliers beyond 1 and 2 inter-quartile ranges
|
||||
outliers = col((col < s(2,i)-IQR & col >= s(2,i)-2*IQR) | (col > s(4,i)+IQR & col <= s(4,i)+2*IQR));
|
||||
outliers2 = col(col < s(2,i)-2*IQR | col > s(4,i)+2*IQR);
|
||||
outliers_x = [outliers_x; i*ones(size(outliers))];
|
||||
outliers_y = [outliers_y; outliers];
|
||||
outliers2_x = [outliers2_x; i*ones(size(outliers2))];
|
||||
outliers2_y = [outliers2_y; outliers2];
|
||||
elseif (nd == 1)
|
||||
% ## all statistics collapse to the value of the point
|
||||
s(:,i) = col;
|
||||
% ## single point data sets are plotted as outliers.
|
||||
outliers_x = [outliers_x; i];
|
||||
outliers_y = [outliers_y; col];
|
||||
else
|
||||
% ## no statistics if no points
|
||||
s(:,i) = NaN;
|
||||
end
|
||||
end
|
||||
% % % % if isempty(outliers2_y)
|
||||
% % % % outliers2_y=
|
||||
% ## Note which boxes don't have enough stats
|
||||
chop = find(box <= 1);
|
||||
|
||||
% ## Draw a box around the quartiles, with width proportional to the number of
|
||||
% ## items in the box. Draw notches if desired.
|
||||
box = box*0.23/max(box);
|
||||
quartile_x = ones(11,1)*[1:nc] + [-a;-1;-1;1;1;a;1;1;-1;-1;-a]*box;
|
||||
quartile_y = s([3,7,4,4,7,3,6,2,2,6,3],:);
|
||||
|
||||
% ## Draw a line through the median
|
||||
median_x = ones(2,1)*[1:nc] + [-a;+a]*box;
|
||||
% median_x=median(col);
|
||||
median_y = s([3,3],:);
|
||||
|
||||
% ## Chop all boxes which don't have enough stats
|
||||
quartile_x(:,chop) = [];
|
||||
quartile_y(:,chop) = [];
|
||||
whisker_x(:,[chop,chop+nc]) = [];
|
||||
whisker_y(:,[chop,chop+nc]) = [];
|
||||
median_x(:,chop) = [];
|
||||
median_y(:,chop) = [];
|
||||
% % % %
|
||||
% ## Add caps to the remaining whiskers
|
||||
cap_x = whisker_x;
|
||||
cap_x(1,:) =cap_x(1,:)- 0.05;
|
||||
cap_x(2,:) =cap_x(2,:)+ 0.05;
|
||||
cap_y = whisker_y([1,1],:);
|
||||
|
||||
% #quartile_x,quartile_y
|
||||
% #whisker_x,whisker_y
|
||||
% #median_x,median_y
|
||||
% #cap_x,cap_y
|
||||
%
|
||||
% ## Do the plot
|
||||
|
||||
mm=min(min(data));
|
||||
MM=max(max(data));
|
||||
if isnan(mm), mm=0; MM=0; end
|
||||
|
||||
if vertical
|
||||
plot (quartile_x, quartile_y, 'b', ...
|
||||
whisker_x, whisker_y, 'b--', ...
|
||||
cap_x, cap_y, 'k', ...
|
||||
median_x, median_y, 'r', ...
|
||||
outliers_x, outliers_y, [symbol(1),'r'], ...
|
||||
outliers2_x, outliers2_y, [symbol(2),'r']);
|
||||
set(gca,'XTick',1:nc);
|
||||
set(gca, 'XLim', [0.5, nc+0.5]);
|
||||
set(gca, 'YLim', [mm-(MM-mm)*0.05-eps, MM+(MM-mm)*0.05+eps]);
|
||||
|
||||
else
|
||||
% % % % % plot (quartile_y, quartile_x, "b;;",
|
||||
% % % % % whisker_y, whisker_x, "b;;",
|
||||
% % % % % cap_y, cap_x, "b;;",
|
||||
% % % % % median_y, median_x, "r;;",
|
||||
% % % % % outliers_y, outliers_x, [symbol(1),"r;;"],
|
||||
% % % % % outliers2_y, outliers2_x, [symbol(2),"r;;"]);
|
||||
end
|
||||
|
||||
if nargout
|
||||
sout=s;
|
||||
end
|
||||
% % % endfunction
|
|
@ -389,7 +389,7 @@ for plt = 1:nbplt
|
|||
hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Trajectories');
|
||||
for k=1:length(pmean)
|
||||
subplot(nr,nc,k)
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
% Draw the surface for an interval containing 95% of the particles.
|
||||
area(1:sample_size, ub95_xparam(k,:), 'FaceColor', [.9 .9 .9], 'BaseValue', min(lb95_xparam(k,:)));
|
||||
hold on
|
||||
|
@ -426,7 +426,7 @@ for plt = 1:nbplt
|
|||
hh_fig = dyn_figure(options_.nodisplay,'Name','Parameters Densities');
|
||||
for k=1:length(pmean)
|
||||
subplot(nr,nc,k)
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_);
|
||||
[name,texname] = get_the_name(k,TeX,M_,estim_params_,options_.varobs);
|
||||
optimal_bandwidth = mh_optimal_bandwidth(xparam(k,:)',number_of_particles,bandwidth,kernel_function);
|
||||
[density(:,1),density(:,2)] = kernel_density_estimate(xparam(k,:)', number_of_grid_points, ...
|
||||
number_of_particles, optimal_bandwidth, kernel_function);
|
||||
|
|
|
@ -65,7 +65,7 @@ disp('PRIOR OPTIMIZATION')
|
|||
disp('------------------')
|
||||
skipline()
|
||||
for i = 1:length(xparams)
|
||||
disp(['deep parameter ' int2str(i) ': ' get_the_name(i,0,M_,estim_params_,options_) '.'])
|
||||
disp(['deep parameter ' int2str(i) ': ' get_the_name(i,0,M_,estim_params_,options_.varobs) '.'])
|
||||
disp([' Initial condition ....... ' num2str(xinit(i)) '.'])
|
||||
disp([' Prior mode .............. ' num2str(bayestopt_.p5(i)) '.'])
|
||||
disp([' Optimized prior mode .... ' num2str(xparams(i)) '.'])
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
function plot_identification(params, idemoments, idehess, idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName, tit_TeX, name_tex)
|
||||
% function plot_identification(params,idemoments,idehess,idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName)
|
||||
function plot_identification(M_, params, idemoments, idehess, idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName, fname, options_, estim_params_, bayestopt_, tit_TeX, name_tex)
|
||||
% plot_identification(M_, params,idemoments,idehess,idemodel, idelre, advanced, tittxt, name, IdentifDirectoryName, fname, options_, estim_params_, bayestopt_, tit_TeX, name_tex)
|
||||
%
|
||||
% INPUTS
|
||||
% o M_ [structure] model
|
||||
% o params [array] parameter values for identification checks
|
||||
% o idemoments [structure] identification results for the moments
|
||||
% o idehess [structure] identification results for the Hessian
|
||||
|
@ -9,10 +10,15 @@ function plot_identification(params, idemoments, idehess, idemodel, idelre, adva
|
|||
% o idelre [structure] identification results for the LRE model
|
||||
% o advanced [integer] flag for advanced identification checks
|
||||
% o tittxt [char] name of the results to plot
|
||||
% o name [char] list of names
|
||||
% o name [char] list of parameter names
|
||||
% o IdentifDirectoryName [char] directory name
|
||||
% o fname [char] file name
|
||||
% o options_ [structure] structure describing the current options
|
||||
% o estim_params_ [structure] characterizing parameters to be estimated
|
||||
% o bayestopt_ [structure] describing the priors
|
||||
% o tittxt [char] TeX-name of the results to plot
|
||||
% o name_tex [char] TeX-names of the parameters
|
||||
%
|
||||
% OUTPUTS
|
||||
% None
|
||||
%
|
||||
|
@ -36,13 +42,11 @@ function plot_identification(params, idemoments, idehess, idemodel, idelre, adva
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ options_
|
||||
|
||||
if nargin <10 || isempty(tit_TeX)
|
||||
if nargin <14 || isempty(tit_TeX)
|
||||
tit_TeX=tittxt;
|
||||
end
|
||||
|
||||
if nargin <11
|
||||
if nargin <15
|
||||
name_tex=name;
|
||||
end
|
||||
|
||||
|
@ -54,20 +58,19 @@ si_dLREnorm = idelre.si_dDYNAMICnorm;
|
|||
tittxt1=regexprep(tittxt, ' ', '_');
|
||||
tittxt1=strrep(tittxt1, '.', '');
|
||||
if SampleSize == 1
|
||||
si_dMOMENTS = idemoments.si_dMOMENTS;
|
||||
hh_fig = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Identification using info from observables']);
|
||||
subplot(211)
|
||||
mmm = (idehess.ide_strength_dMOMENTS);
|
||||
[ss, is] = sort(mmm);
|
||||
[~, is] = sort(mmm);
|
||||
if ~all(isnan(idehess.ide_strength_dMOMENTS_prior)) ...
|
||||
&& ~(nparam == 1 && ~isoctave && matlab_ver_less_than('9.7')) % MATLAB < R2019b does not accept bar(1, [2 3])
|
||||
bar(1:nparam,log([idehess.ide_strength_dMOMENTS(:,is)' idehess.ide_strength_dMOMENTS_prior(:,is)']))
|
||||
else
|
||||
bar(1:nparam,log([idehess.ide_strength_dMOMENTS(:,is)' ]))
|
||||
bar(1:nparam,log(idehess.ide_strength_dMOMENTS(:,is)'))
|
||||
end
|
||||
hold on
|
||||
plot((1:length(idehess.ide_strength_dMOMENTS(:,is)))-0.15,log([idehess.ide_strength_dMOMENTS(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.ide_strength_dMOMENTS_prior(:,is)))+0.15,log([idehess.ide_strength_dMOMENTS_prior(:,is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.ide_strength_dMOMENTS(:,is)))-0.15,log(idehess.ide_strength_dMOMENTS(:,is)'),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.ide_strength_dMOMENTS_prior(:,is)))+0.15,log(idehess.ide_strength_dMOMENTS_prior(:,is)'),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
if any(isinf(log(idehess.ide_strength_dMOMENTS(idehess.identified_parameter_indices))))
|
||||
%-Inf, i.e. 0 strength
|
||||
inf_indices=find(isinf(log(idehess.ide_strength_dMOMENTS(idehess.identified_parameter_indices))) & log(idehess.ide_strength_dMOMENTS(idehess.identified_parameter_indices))<0);
|
||||
|
@ -117,8 +120,8 @@ if SampleSize == 1
|
|||
bar(1:nparam, log([idehess.deltaM(is)]))
|
||||
end
|
||||
hold on
|
||||
plot((1:length(idehess.deltaM(is)))-0.15,log([idehess.deltaM(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.deltaM_prior(is)))+0.15,log([idehess.deltaM_prior(is)']),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.deltaM(is)))-0.15,log(idehess.deltaM(is)'),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
plot((1:length(idehess.deltaM_prior(is)))+0.15,log(idehess.deltaM_prior(is)'),'o','MarkerSize',7,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor','none')
|
||||
inf_pos=find(isinf(log(idehess.deltaM)));
|
||||
if ~isempty(inf_pos)
|
||||
inf_indices=~ismember(inf_pos,idehess.sensitivity_zero_pos);
|
||||
|
@ -152,19 +155,19 @@ if SampleSize == 1
|
|||
title('Sensitivity component with moments Information matrix (log-scale)')
|
||||
end
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1,'.tex'],'w');
|
||||
fidTeX = fopen([IdentifDirectoryName '/' fname '_ident_strength_' tittxt1,'.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_strength_%s}\n',[IdentifDirectoryName '/' M_.fname],tittxt1);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_strength_%s}\n',[IdentifDirectoryName '/' fname],tittxt1);
|
||||
fprintf(fidTeX,'\\caption{%s - Identification using info from observables.}',tit_TeX);
|
||||
fprintf(fidTeX,'\\label{Fig:ident:%s}\n',deblank(tittxt));
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
fprintf(fidTeX,'%% End Of TeX file. \n');
|
||||
fclose(fidTeX);
|
||||
end
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
|
||||
|
||||
if advanced
|
||||
if ~options_.nodisplay
|
||||
|
@ -197,14 +200,14 @@ if SampleSize == 1
|
|||
end
|
||||
legend('Moments','Model','LRE model','Location','Best')
|
||||
title('Sensitivity bars using derivatives (log-scale)')
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' fname '_sensitivity_' tittxt1 ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1,'.tex'],'w');
|
||||
fidTeX = fopen([IdentifDirectoryName '/' fname '_sensitivity_' tittxt1,'.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_sensitivity_%s}\n',[IdentifDirectoryName '/' M_.fname],tittxt1);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_sensitivity_%s}\n',[IdentifDirectoryName '/' fname],tittxt1);
|
||||
fprintf(fidTeX,'\\caption{%s - Sensitivity plot.}',tit_TeX);
|
||||
fprintf(fidTeX,'\\label{Fig:sensitivity:%s}\n',deblank(tittxt));
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -215,9 +218,6 @@ if SampleSize == 1
|
|||
% identificaton patterns
|
||||
for j=1:size(idemoments.cosndMOMENTS,2)
|
||||
pax=NaN(nparam,nparam);
|
||||
% fprintf('\n')
|
||||
% disp(['Collinearity patterns with ', int2str(j) ,' parameter(s)'])
|
||||
% fprintf('%-15s [%-*s] %10s\n','Parameter',(15+1)*j,' Expl. params ','cosn')
|
||||
for i=1:nparam
|
||||
namx='';
|
||||
for in=1:j
|
||||
|
@ -233,7 +233,6 @@ if SampleSize == 1
|
|||
pax(i,dumpindx)=idemoments.cosndMOMENTS(i,j);
|
||||
end
|
||||
end
|
||||
% fprintf('%-15s [%s] %10.3f\n',name{i},namx,idemoments.cosndMOMENTS(i,j))
|
||||
end
|
||||
hh_fig = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)']);
|
||||
imagesc(pax,[0 1]);
|
||||
|
@ -260,14 +259,14 @@ if SampleSize == 1
|
|||
set(gca,'xgrid','on')
|
||||
set(gca,'ygrid','on')
|
||||
xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'],'interpreter','none')
|
||||
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j),'.tex'],'w');
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' fname '_ident_collinearity_' tittxt1 '_' int2str(j),'.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_collinearity_%s_%u}\n',[IdentifDirectoryName '/' M_.fname],tittxt1,j);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_collinearity_%s_%u}\n',[IdentifDirectoryName '/' fname],tittxt1,j);
|
||||
fprintf(fidTeX,'\\caption{%s - Collinearity patterns with %u parameter(s).}',tit_TeX,j);
|
||||
fprintf(fidTeX,'\\label{Fig:collinearity:%s:%u_pars}\n',deblank(tittxt),j);
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -276,7 +275,7 @@ if SampleSize == 1
|
|||
end
|
||||
end
|
||||
skipline()
|
||||
[U,S,V]=svd(idehess.AHess,0);
|
||||
[~,S,V]=svd(idehess.AHess,0);
|
||||
S=diag(S);
|
||||
if idehess.flag_score
|
||||
if nparam<5
|
||||
|
@ -289,8 +288,6 @@ if SampleSize == 1
|
|||
tex_tit_2=[tittxt,' - Identification patterns (Information matrix): HIGHEST SV'];
|
||||
end
|
||||
else
|
||||
% S = idemoments.S;
|
||||
% V = idemoments.V;
|
||||
if nparam<5
|
||||
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (moments Information matrix)']);
|
||||
tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix)'];
|
||||
|
@ -329,14 +326,14 @@ if SampleSize == 1
|
|||
end
|
||||
title(['Singular value ',num2str(Stit)])
|
||||
end
|
||||
dyn_saveas(f1,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(f1,[ IdentifDirectoryName '/' fname '_ident_pattern_' tittxt1 '_1' ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1','.tex'],'w');
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' fname '_ident_pattern_' tittxt1 '_1','.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_pattern_%s_1}\n',[IdentifDirectoryName '/' M_.fname],tittxt1);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_pattern_%s_1}\n',[IdentifDirectoryName '/' fname],tittxt1);
|
||||
fprintf(fidTeX,'\\caption{%s.}',tex_tit_1);
|
||||
fprintf(fidTeX,'\\label{Fig:ident_pattern:%s:1}\n',tittxt1);
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -344,14 +341,14 @@ if SampleSize == 1
|
|||
fclose(fidTeX);
|
||||
end
|
||||
if nparam>4
|
||||
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(f2,[ IdentifDirectoryName '/' fname '_ident_pattern_' tittxt1 '_2' ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.tex'],'w');
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' fname '_ident_pattern_' tittxt1 '_2.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_pattern_%s_2}\n',[IdentifDirectoryName '/' M_.fname],tittxt1);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_ident_pattern_%s_2}\n',[IdentifDirectoryName '/' fname],tittxt1);
|
||||
fprintf(fidTeX,'\\caption{%s.}',tex_tit_2);
|
||||
fprintf(fidTeX,'\\label{Fig:ident_pattern:%s:2}\n',tittxt1);
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -362,10 +359,10 @@ if SampleSize == 1
|
|||
end
|
||||
|
||||
else
|
||||
hh_fig = dyn_figure(options_.nodisplay,'Name',['MC sensitivities']);
|
||||
hh_fig = dyn_figure(options_.nodisplay,'Name','MC sensitivities');
|
||||
subplot(211)
|
||||
mmm = (idehess.ide_strength_dMOMENTS);
|
||||
[ss, is] = sort(mmm);
|
||||
[~, is] = sort(mmm);
|
||||
mmm = mean(si_dMOMENTSnorm)';
|
||||
mmm = mmm./max(mmm);
|
||||
if advanced
|
||||
|
@ -392,14 +389,14 @@ else
|
|||
legend('Moments','Model','LRE model','Location','Best')
|
||||
end
|
||||
title('MC mean of sensitivity measures')
|
||||
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[ IdentifDirectoryName '/' fname '_MC_sensitivity' ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_sensitivity.tex'],'w');
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' fname '_MC_sensitivity.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_sensitivity}\n',[IdentifDirectoryName '/' M_.fname]);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_sensitivity}\n',[IdentifDirectoryName '/' fname]);
|
||||
fprintf(fidTeX,'\\caption{MC mean of sensitivity measures}');
|
||||
fprintf(fidTeX,'\\label{Fig:_MC_sensitivity}\n');
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -408,57 +405,62 @@ else
|
|||
end
|
||||
|
||||
if advanced
|
||||
if ~options_.nodisplay,
|
||||
if ~options_.nodisplay
|
||||
skipline()
|
||||
disp('Displaying advanced diagnostics')
|
||||
end
|
||||
% options_.nograph=1;
|
||||
hh_fig = dyn_figure(options_.nodisplay,'Name','MC Condition Number');
|
||||
subplot(221)
|
||||
hist(log10(idemodel.cond))
|
||||
if isoctave
|
||||
hist(log10(idemodel.cond))
|
||||
else
|
||||
histogram(log10(idemodel.cond))
|
||||
end
|
||||
title('log10 of Condition number in the model')
|
||||
subplot(222)
|
||||
hist(log10(idemoments.cond))
|
||||
if isoctave
|
||||
hist(log10(idemoments.cond))
|
||||
else
|
||||
histogram(log10(idemoments.cond))
|
||||
end
|
||||
title('log10 of Condition number in the moments')
|
||||
subplot(223)
|
||||
hist(log10(idelre.cond))
|
||||
if isoctave
|
||||
hist(log10(idelre.cond))
|
||||
else
|
||||
histogram(log10(idelre.cond))
|
||||
end
|
||||
title('log10 of Condition number in the LRE model')
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(hh_fig,[IdentifDirectoryName '/' fname '_ident_COND' ],options_.nodisplay,options_.graph_format);
|
||||
options_mcf.pvalue_ks = 0.1;
|
||||
options_mcf.pvalue_corr = 0.001;
|
||||
options_mcf.alpha2 = 0;
|
||||
options_mcf.param_names = name;
|
||||
options_mcf.param_names_tex = name_tex;
|
||||
options_mcf.fname_ = M_.fname;
|
||||
options_mcf.fname_ = fname;
|
||||
options_mcf.OutputDirectoryName = IdentifDirectoryName;
|
||||
options_mcf.beha_title = 'LOW condition nbr';
|
||||
options_mcf.nobeha_title = 'HIGH condition nbr';
|
||||
if options_.TeX
|
||||
options_mcf.beha_title_latex = 'LOW condition nbr';
|
||||
options_mcf.nobeha_title_latex = 'HIGH condition nbr';
|
||||
end
|
||||
options_mcf.amcf_name = 'MC_HighestCondNumberLRE';
|
||||
options_mcf.amcf_title = 'MC Highest Condition Number LRE Model';
|
||||
options_mcf.title = 'MC Highest Condition Number LRE Model';
|
||||
ncut=floor(SampleSize/10*9);
|
||||
[dum,is]=sort(idelre.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, options_);
|
||||
[~,is]=sort(idelre.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
options_mcf.amcf_name = 'MC_HighestCondNumberModel';
|
||||
options_mcf.amcf_title = 'MC Highest Condition Number Model Solution';
|
||||
options_mcf.title = 'MC Highest Condition Number Model Solution';
|
||||
[dum,is]=sort(idemodel.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, options_);
|
||||
[~,is]=sort(idemodel.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
options_mcf.amcf_name = 'MC_HighestCondNumberMoments';
|
||||
options_mcf.amcf_title = 'MC Highest Condition Number Model Moments';
|
||||
options_mcf.title = 'MC Highest Condition Number Model Moments';
|
||||
[dum,is]=sort(idemoments.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, options_);
|
||||
% [proba, dproba] = stab_map_1(idemoments.Mco', is(1:ncut), is(ncut+1:end), 'HighestCondNumberMoments_vs_Mco', 1, [], IdentifDirectoryName);
|
||||
% for j=1:nparam,
|
||||
% % ibeh=find(idemoments.Mco(j,:)<0.9);
|
||||
% % inonbeh=find(idemoments.Mco(j,:)>=0.9);
|
||||
% % if ~isempty(ibeh) && ~isempty(inonbeh)
|
||||
% % [proba, dproba] = stab_map_1(params, ibeh, inonbeh, ['HighestMultiCollinearity_',name{j}], 1, [], IdentifDirectoryName);
|
||||
% % end
|
||||
% [~,is]=sort(idemoments.Mco(:,j));
|
||||
% [proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), ['MC_HighestMultiCollinearity_',name{j}], 1, [], IdentifDirectoryName, 0.15);
|
||||
% end
|
||||
[~,is]=sort(idemoments.cond);
|
||||
mcf_analysis(params, is(1:ncut), is(ncut+1:end), options_mcf, M_, options_, bayestopt_, estim_params_);
|
||||
|
||||
if nparam<5
|
||||
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
|
||||
|
@ -488,8 +490,10 @@ else
|
|||
SSS = idemoments.S(:,jj);
|
||||
end
|
||||
subplot(nsubplo,1,jj)
|
||||
post_median=NaN(1,nparam);
|
||||
hpd_interval=NaN(nparam,2);
|
||||
for i=1:nparam
|
||||
[post_mean, post_median(:,i), post_var, hpd_interval(i,:), post_deciles] = posterior_moments(VVV(:,i),0,0.9);
|
||||
[~, post_median(:,i), ~, hpd_interval(i,:)] = posterior_moments(VVV(:,i),0,0.9);
|
||||
end
|
||||
bar(post_median)
|
||||
hold on, plot(hpd_interval,'--*r'),
|
||||
|
@ -507,14 +511,14 @@ else
|
|||
end
|
||||
title(['MEAN Singular value ',num2str(Stit)])
|
||||
end
|
||||
dyn_saveas(f1,[IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(f1,[IdentifDirectoryName '/' fname '_MC_ident_pattern_1' ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1.tex'],'w');
|
||||
fidTeX = fopen([IdentifDirectoryName '/' fname '_MC_ident_pattern_1.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_ident_pattern_1}\n',[IdentifDirectoryName '/' M_.fname]);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_ident_pattern_1}\n',[IdentifDirectoryName '/' fname]);
|
||||
fprintf(fidTeX,'\\caption{%s.}',tex_tit_1);
|
||||
fprintf(fidTeX,'\\label{Fig:MC_ident_pattern:1}\n');
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
@ -522,14 +526,14 @@ else
|
|||
fclose(fidTeX);
|
||||
end
|
||||
if nparam>4
|
||||
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2' ],options_.nodisplay,options_.graph_format);
|
||||
dyn_saveas(f2,[ IdentifDirectoryName '/' fname '_MC_ident_pattern_2' ],options_.nodisplay,options_.graph_format);
|
||||
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.tex'],'w');
|
||||
fidTeX = fopen([ IdentifDirectoryName '/' fname '_MC_ident_pattern_2.tex'],'w');
|
||||
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
|
||||
fprintf(fidTeX,['%% ' datestr(now,0) '\n\n']);
|
||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
||||
fprintf(fidTeX,'\\centering \n');
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_ident_pattern_2}\n',[IdentifDirectoryName '/' M_.fname]);
|
||||
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s_MC_ident_pattern_2}\n',[IdentifDirectoryName '/' fname]);
|
||||
fprintf(fidTeX,'\\caption{%s.}',tex_tit_2);
|
||||
fprintf(fidTeX,'\\label{Fig:MC_ident_pattern:2}\n');
|
||||
fprintf(fidTeX,'\\end{figure}\n\n');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function plot_priors(bayestopt_,M_,estim_params_,options_,optional_title)
|
||||
% function plot_priors
|
||||
% plot_priors(bayestopt_,M_,estim_params_,options_,optional_title)
|
||||
% plots prior density
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -41,7 +41,7 @@ else
|
|||
figurename = optional_title;
|
||||
end
|
||||
npar = length(bayestopt_.p1);
|
||||
[nbplt,nr,nc,lr,lc,nstar] = pltorg(npar);
|
||||
[nbplt,nr,nc,~,~,nstar] = pltorg(npar);
|
||||
|
||||
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
|
||||
fidTeX = fopen([latexDirectoryName filesep M_.fname '_Priors.tex'],'w');
|
||||
|
@ -59,8 +59,8 @@ for plt = 1:nbplt
|
|||
for index=1:nstar0
|
||||
names = [];
|
||||
i = (plt-1)*nstar + index;
|
||||
[x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_);
|
||||
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
|
||||
[x,f] = draw_prior_density(i,bayestopt_);
|
||||
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_.varobs);
|
||||
subplot(nr,nc,index)
|
||||
hh_plt = plot(x,f,'-k','linewidth',2);
|
||||
set(hh_plt,'color',[0.7 0.7 0.7]);
|
||||
|
|
|
@ -52,7 +52,7 @@ options_.prior_trunc = prior_trunc_backup ;
|
|||
RESIZE = false;
|
||||
|
||||
for i=1:size(bayestopt_.name,1)
|
||||
[Name,tmp] = get_the_name(i,1,M_,estim_params_,options_);
|
||||
[Name,~] = get_the_name(i,1,M_,estim_params_,options_.varobs);
|
||||
if length(Name)>size(T1,2)
|
||||
resize = true;
|
||||
else
|
||||
|
|
|
@ -23,8 +23,6 @@ function pdraw = prior_draw(bayestopt_, prior_trunc, uniform)
|
|||
%
|
||||
% NOTE 1. Input arguments 1 and 2 are only needed for initialization.
|
||||
% NOTE 2. A given draw from the joint prior distribution does not satisfy BK conditions a priori.
|
||||
% NOTE 3. This code relies on bayestopt_ as created in the base workspace
|
||||
% by the preprocessor (or as updated in subsequent pieces of code and handed to the base workspace)
|
||||
%
|
||||
% Copyright © 2006-2023 Dynare Team
|
||||
%
|
||||
|
|
|
@ -133,7 +133,7 @@ if ncn
|
|||
bayestopt_.p4 = [ bayestopt_.p4; estim_params_.corrn(:,10)]; %take generalized distribution into account
|
||||
bayestopt_.jscale = [ bayestopt_.jscale; estim_params_.corrn(:,11)];
|
||||
baseid = length(bayestopt_.name);
|
||||
bayestopt_.name = [bayestopt_.name; cell(ncn, 1)];;
|
||||
bayestopt_.name = [bayestopt_.name; cell(ncn, 1)];
|
||||
for i=1:ncn
|
||||
k1 = estim_params_.corrn(i,1);
|
||||
k2 = estim_params_.corrn(i,2);
|
||||
|
@ -163,8 +163,8 @@ bayestopt_.p7 = bayestopt_.p6 ;
|
|||
|
||||
%% check for point priors and disallow them as they do not work with MCMC
|
||||
if any(bayestopt_.p2 ==0)
|
||||
error(sprintf(['Error in prior for %s: you cannot use a point prior in estimation. Either increase the prior standard deviation',...
|
||||
' or fix the parameter completely.'], bayestopt_.name{bayestopt_.p2 ==0}))
|
||||
error('Error in prior for %s: you cannot use a point prior in estimation. Either increase the prior standard deviation',...
|
||||
' or fix the parameter completely.', bayestopt_.name{bayestopt_.p2 ==0})
|
||||
end
|
||||
|
||||
% generalized location parameters by default for beta distribution
|
||||
|
@ -285,7 +285,7 @@ end
|
|||
CheckPath('prior',M_.dname);
|
||||
|
||||
% I save the prior definition if the prior has changed.
|
||||
if exist([ M_.dname '/prior/definition.mat'])
|
||||
if exist([ M_.dname '/prior/definition.mat'],'file')
|
||||
old = load([M_.dname '/prior/definition.mat'],'bayestopt_');
|
||||
prior_has_changed = 0;
|
||||
if length(bayestopt_.p1)==length(old.bayestopt_.p1)
|
||||
|
|
|
@ -153,7 +153,7 @@ end
|
|||
if strcmpi(type,'PosteriorDensity')
|
||||
plot_name='Posterior';
|
||||
else
|
||||
plot_name=get_the_name(column,0,M_,estim_params_,options_);
|
||||
plot_name=get_the_name(column,0,M_,estim_params_,options_.varobs);
|
||||
end
|
||||
if n_nblocks_to_plot==1
|
||||
plot_name=[plot_name,'_blck_',num2str(blck)];
|
||||
|
|
|
@ -48,7 +48,7 @@ catch
|
|||
params_at_bound = find(abs(xparam1-bounds.ub)<tol_bounds | abs(xparam1-bounds.lb)<tol_bounds);
|
||||
if ~isempty(params_at_bound)
|
||||
for ii=1:length(params_at_bound)
|
||||
params_at_bound_name{ii,1}=get_the_name(params_at_bound(ii),0,M_,estim_params_,options_);
|
||||
params_at_bound_name{ii,1}=get_the_name(params_at_bound(ii),0,M_,estim_params_,options_.varobs);
|
||||
end
|
||||
disp_string=[params_at_bound_name{1,:}];
|
||||
for ii=2:size(params_at_bound_name,1)
|
||||
|
|
|
@ -37,7 +37,7 @@ bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
|||
outside_bound_pars = find(xparam < bounds.lb | xparam > bounds.ub);
|
||||
if ~isempty(outside_bound_pars)
|
||||
for ii = 1:length(outside_bound_pars)
|
||||
outside_bound_par_names{ii,1} = get_the_name(ii,0,M_,estim_params_,options_);
|
||||
outside_bound_par_names{ii,1} = get_the_name(ii,0,M_,estim_params_,options_.varobs);
|
||||
end
|
||||
disp_string = [outside_bound_par_names{1,:}];
|
||||
for ii = 2:size(outside_bound_par_names,1)
|
||||
|
|
|
@ -28,7 +28,7 @@ function write_latex_prior_table
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ options_ bayestopt_ estim_params_
|
||||
global M_ options_ estim_params_
|
||||
|
||||
if ~isbayes(estim_params_)
|
||||
fprintf('\nwrite_latex_prior_table:: No prior distributions detected. Skipping table creation.\n')
|
||||
|
@ -39,13 +39,13 @@ if (size(estim_params_.var_endo,1) || size(estim_params_.corrn,1))
|
|||
% Prior over measurement errors are defined...
|
||||
if ((isfield(options_,'varobs') && isempty(options_.varobs)) || ~isfield(options_,'varobs'))
|
||||
% ... But the list of observed variabled is not yet defined.
|
||||
fprintf(['\nwrite_latex_prior_table:: varobs should be declared before. Skipping table creation.\n'])
|
||||
fprintf('\nwrite_latex_prior_table:: varobs should be declared before. Skipping table creation.\n')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
% Fill or update bayestopt_ structure
|
||||
[xparam1, estim_params_, BayesOptions, lb, ub, M_] = set_prior(estim_params_, M_, options_);
|
||||
[~, estim_params_, BayesOptions, ~, ~, M_] = set_prior(estim_params_, M_, options_);
|
||||
|
||||
% Get untruncated bounds
|
||||
bounds = prior_bounds(BayesOptions, options_.prior_trunc);
|
||||
|
@ -112,7 +112,7 @@ fprintf(fidTeX,'\\endlastfoot\n');
|
|||
% Column 8: the upper bound of the interval containing 90% of the prior mass.
|
||||
PriorIntervals = prior_bounds(BayesOptions,(1-options_.prior_interval)/2) ;
|
||||
for i=1:size(BayesOptions.name,1)
|
||||
[tmp,TexName] = get_the_name(i, 1, M_, estim_params_, options_);
|
||||
[~,TexName] = get_the_name(i, 1, M_, estim_params_, options_.varobs);
|
||||
PriorShape = PriorNames{ BayesOptions.pshape(i) };
|
||||
PriorMean = BayesOptions.p1(i);
|
||||
PriorMode = BayesOptions.p5(i);
|
||||
|
|
10
meson.build
10
meson.build
|
@ -804,10 +804,12 @@ mod_and_m_tests = [
|
|||
'estimation/fsdat_simul.m' ] },
|
||||
{ 'test' : [ 'estimation/fs2000.mod' ],
|
||||
'extra' : [ 'estimation/fsdat_simul.m' ] },
|
||||
{ 'test' : [ 'gsa/ls2003a.mod' ],
|
||||
'extra' : [ 'gsa/data_ca1.m' ] },
|
||||
{ 'test' : [ 'gsa/ls2003.mod' ],
|
||||
'extra' : [ 'gsa/data_ca1.m' ] },
|
||||
{ 'test' : [ 'gsa/ls2003a.mod',
|
||||
'gsa/ls2003.mod',
|
||||
'gsa/ls2003scr.mod',
|
||||
'gsa/ls2003ide.mod' ],
|
||||
'extra' : [ 'gsa/data_ca1.m',
|
||||
'gsa/ls2003_model.inc' ] },
|
||||
{ 'test' : [ 'gsa/cod_ML_morris/cod_ML_morris.mod' ] },
|
||||
{ 'test' : [ 'gsa/morris/nk_est.mod' ],
|
||||
'extra' : [ 'gsa/morris/nk_est_data.m' ] },
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 73be95423d3f8c1aa05a5edae2712ffbf646602a
|
||||
Subproject commit 378d00fc3a50a11c3dce615ea337ad55989c938e
|
|
@ -185,6 +185,8 @@ stoch_simul(order=1,irf=20,graph_format=eps,periods=0,contemporaneous_correlatio
|
|||
collect_latex_files;
|
||||
|
||||
//identification(advanced=1,max_dim_cova_group=3,prior_mc=250);
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
|
|
|
@ -418,7 +418,7 @@ for jj = 1:2
|
|||
if jj==1
|
||||
strparamset = 'PRIOR';
|
||||
nSYM = nSYMprior;
|
||||
xparam_prior = set_prior(estim_params_,M_,options_);
|
||||
[xparam_prior, estim_params_]= set_prior(estim_params_,M_,options_);
|
||||
M_ = set_all_parameters(xparam_prior,estim_params_,M_);
|
||||
elseif jj==2
|
||||
strparamset = 'CALIBRATION';
|
||||
|
|
|
@ -113,7 +113,7 @@ stoch_simul(order=@{ORDER},k_order_solver,irf=0,drop=0,periods=0,nograph);
|
|||
identification(order=@{ORDER},nograph,no_identification_strength);
|
||||
|
||||
%make sure everything is computed at prior mean
|
||||
xparam_prior = set_prior(estim_params_,M_,options_);
|
||||
[xparam_prior, estim_params_]= set_prior(estim_params_,M_,options_);
|
||||
M_ = set_all_parameters(xparam_prior,estim_params_,M_);
|
||||
[oo_.dr,info,M_.params] = resol(0,M_, options_, oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var c, y_ro, psi, s, tt, pi_h, mc_ro, i_ro, pi_ro, pi_eu, pi_f, y_eu, mc_eu, i_eu, g, a, cp, bnr, gs, as ;
|
||||
varexo eps_a, eps_g, eps_cp, eps_s, eps_m, eps_as, eps_gs, eps_ms;
|
||||
parameters alfa, niu, delt, teta_h, teta_f, bet, fi, sigm, h, ro, psi_pi, tetas, rhos, psi_pis, psi_y, psi_deltay, rho_g, rho_a, rho_cp, rho_s, rho_gs, rho_as ;
|
||||
var c, y_ro, psi, s, tt, pi_h ${\pi_h}$, mc_ro, i_ro, pi_ro ${\pi_\rho}$, pi_eu, pi_f, y_eu, mc_eu, i_eu, g, a, cp, bnr, gs, as ;
|
||||
varexo eps_a, eps_g, eps_cp, eps_s, eps_m $\varepsilon_m$, eps_as, eps_gs, eps_ms;
|
||||
parameters alfa, niu, delt, teta_h, teta_f, bet, fi, sigm, h, ro, psi_pi $\psi_\pi$, tetas, rhos, psi_pis, psi_y, psi_deltay, rho_g, rho_a, rho_cp, rho_s, rho_gs, rho_as ;
|
||||
|
||||
alfa = 0.425 ;
|
||||
bet = 0.99 ;
|
||||
|
@ -121,7 +121,7 @@ stderr eps_as, 1, 0.01, 10 ;
|
|||
end;
|
||||
|
||||
varobs y_ro, pi_ro, i_ro, s, y_eu, pi_eu, i_eu, tt ;
|
||||
|
||||
options_.TeX =1;
|
||||
dynare_sensitivity (identification=1, nsam = 500, lik_only = 1, morris=2) ;
|
||||
|
||||
stoch_simul(order=2,irf=20) y_ro pi_ro i_ro s ;
|
||||
|
|
|
@ -1,45 +1,4 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs ${R^{obs}}$;
|
||||
varexo e_R ${e^R}$ e_q e_ys e_pies e_A;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R ${\rho_R}$ tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+k*alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
@#include "ls2003_model.inc"
|
||||
|
||||
estimated_params;
|
||||
psi1 , gamma_pdf,1.5,0.5;
|
||||
|
@ -66,7 +25,7 @@ options_.TeX=true;
|
|||
disp(' ');
|
||||
disp('NOW I DO STABILITY MAPPING and prepare sample for Reduced form Mapping');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
dynare_sensitivity(redform=1,nodisplay,Nsam=512); //create sample of reduced form coefficients
|
||||
// NOTE: since namendo is empty by default,
|
||||
|
@ -75,7 +34,7 @@ dynare_sensitivity(redform=1,nodisplay,Nsam=512); //create sample of reduced for
|
|||
disp(' ');
|
||||
disp('ANALYSIS OF REDUCED FORM COEFFICIENTS');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
dynare_sensitivity(nodisplay, load_stab=1, // load previously generated sample analysed for stability
|
||||
redform=1, // do the reduced form mapping
|
||||
|
@ -87,6 +46,7 @@ stab=0, // don't repeat again the stability mapping
|
|||
Nsam=512);
|
||||
|
||||
|
||||
|
||||
disp(' ');
|
||||
disp('THE PREVIOUS TWO CALLS COULD BE DONE TOGETHER');
|
||||
disp('BY USING THE COMBINED CALL');
|
||||
|
@ -94,7 +54,7 @@ disp(' ');
|
|||
disp('dynare_sensitivity(redform=1,')
|
||||
disp('threshold_redform=[-1 0], namendo=(pie,R), namexo=(e_R), namlagendo=(R));')
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
//dynare_sensitivity(
|
||||
//redform=1, //create sample of reduced form coefficients
|
||||
//logtrans_redform=1, // estimate log-transformed reduced form coefficients (default=0)
|
||||
|
@ -107,7 +67,7 @@ disp('Press ENTER to continue'); pause(5);
|
|||
|
||||
disp(' ');
|
||||
disp('MC FILTERING(rmse=1), TO MAP THE FIT FROM PRIORS');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
%disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
dynare_sensitivity(nodisplay, datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1, // also presample=2,loglinear, are admissible
|
||||
load_stab=1, // load prior sample
|
||||
|
@ -125,7 +85,7 @@ disp('logtrans_redform=1, namendo=(pie,R), namexo=(e_R), namlagendo=(R),')
|
|||
disp('datafile=data_ca1.m,first_obs=8,nobs=79,prefilter=1,')
|
||||
disp('istart_rmse=2, rmse=1);')
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
//dynare_sensitivity(
|
||||
//redform=1, //create sample of reduced form coefficients
|
||||
//logtrans_redform=1, // estimate log-transformed reduced form coefficients (default=0)
|
||||
|
@ -142,14 +102,13 @@ disp('Press ENTER to continue'); pause(5);
|
|||
disp(' ');
|
||||
disp('I ESTIMATE THE MODEL');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
// run this to generate posterior mode and Metropolis files if not yet done
|
||||
estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=1,
|
||||
prefilter=1,mh_jscale=0.5,mh_replic=5000,silent_optimizer, mode_compute=4, mh_drop=0.6, nodisplay,
|
||||
bayesian_irf, filtered_vars, smoother) y_obs R_obs pie_obs dq de;
|
||||
|
||||
|
||||
// run this to produce posterior samples of filtered, smoothed and irf variables, if not yet done
|
||||
//estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=2,prefilter=1,mh_jscale=0.3,
|
||||
// mh_replic=0, mode_file='ls2003/Output/ls2003_mode', mode_compute=0, load_mh_file, bayesian_irf,
|
||||
|
@ -160,7 +119,7 @@ disp('WE DO STABILITY MAPPING AGAIN, EXPLORING AROUND THE MODE BY A WIDTH +- 0.2
|
|||
disp('THEN WE DO RMSE analysis in this neighborhood');
|
||||
disp('Typical for ML estimation, also feasible for posterior mode');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
dynare_sensitivity(nodisplay, pprior=0,Nsam=512,neighborhood_width=0.2,
|
||||
mode_file='ls2003/Output/ls2003_mode', // specifies the mode file where the mode and Hessian are stored
|
||||
|
@ -171,7 +130,7 @@ disp(' ');
|
|||
disp('WE DO STABILITY MAPPING AGAIN, BUT FOR MULTIVARIATE SAMPLE AT THE POSTERIOR MODE (or ML) and Hessian (pprior=0 & ppost=0)');
|
||||
disp('Typical for ML estimation, also feasible for posterior mode');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
|
||||
dynare_sensitivity(nodisplay, pprior=0,Nsam=512,
|
||||
mode_file='ls2003/Output/ls2003_mode' // specifies the mode file where the mode and Hessian are stored
|
||||
|
@ -181,7 +140,7 @@ mode_file='ls2003/Output/ls2003_mode' // specifies the mode file where the mode
|
|||
disp(' ');
|
||||
disp('RMSE ANALYSIS FOR MULTIVARIATE SAMPLE AT THE POSTERIOR MODE');
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
disp('Press ENTER to continue'); % pause(5);
|
||||
dynare_sensitivity(nodisplay, mode_file='ls2003/Output/ls2003_mode',
|
||||
datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1,
|
||||
pprior=0,
|
||||
|
@ -199,10 +158,10 @@ disp('dynare_sensitivity(pprior=0,Nsam=512,alpha2_stab=0.4,mode_file=ls2003_mode
|
|||
disp('datafile=data_ca1.m,first_obs=8,nobs=79,prefilter=1,')
|
||||
disp('rmse=1, alpha2_rmse=0, alpha_rmse=0);')
|
||||
disp(' ');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
//dynare_sensitivity(pprior=0,Nsam=2048,alpha2_stab=0.4,mode_file='ls2003/Output/ls2003_mode',
|
||||
//datafile='data_ca1.m',first_obs=8,nobs=79,prefilter=1,
|
||||
//rmse=1,
|
||||
//rmse=1pae
|
||||
//alpha2_rmse=0, // no correlation analysis
|
||||
//alpha_rmse=0 // no Smirnov sensitivity analysis
|
||||
//);
|
||||
|
@ -210,7 +169,7 @@ disp('Press ENTER to continue'); pause(5);
|
|||
disp(' ');
|
||||
disp('RMSE ANALYSIS FOR POSTERIOR MCMC sample (ppost=1)');
|
||||
disp('Needs a call to dynare_estimation to load all MH environment');
|
||||
disp('Press ENTER to continue'); pause(5);
|
||||
% disp('Press ENTER to continue'); pause(5);
|
||||
//estimation(datafile='data_ca1.m',first_obs=8,nobs=79,mh_nblocks=2, mode_file='ls2003/Output/ls2003_mode', load_mh_file,
|
||||
// prefilter=1,mh_jscale=0.5,mh_replic=0, mode_compute=0, mh_drop=0.6);
|
||||
|
||||
|
@ -220,6 +179,8 @@ alpha2_rmse=0, // no correlation analysis
|
|||
rmse=1,ppost=1,Nsam=512);
|
||||
|
||||
collect_latex_files;
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
var y
|
||||
y_s
|
||||
R
|
||||
pie $\pi$
|
||||
dq
|
||||
pie_s
|
||||
de
|
||||
A
|
||||
y_obs ${y^{obs}}$
|
||||
pie_obs ${\pi^{obs}}$
|
||||
R_obs ${R^{obs}}$;
|
||||
|
||||
varexo e_R ${\varepsilon^R}$
|
||||
e_q ${\varepsilon^q}$
|
||||
e_ys ${\varepsilon^{ys}}$
|
||||
e_pies ${\varepsilon^\pi}$
|
||||
e_A ${\varepsilon^A}$;
|
||||
|
||||
parameters psi1 ${\psi_1}$
|
||||
psi2 ${\psi_2}$
|
||||
psi3 ${\psi_3}$
|
||||
rho_R ${\rho_R}$
|
||||
tau ${\tau}$
|
||||
alpha ${\alpha}$
|
||||
rr
|
||||
k
|
||||
rho_q ${\rho_q}$
|
||||
rho_A ${\rho_A}$
|
||||
rho_ys ${\rho_{ys}}$
|
||||
rho_pies ${\rho_\pi}$;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+k*alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
|
||||
options_.TeX=1;
|
|
@ -1,45 +1,4 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
|
||||
varexo e_R e_q e_ys e_pies e_A;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+k*alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
@#include "ls2003_model.inc"
|
||||
|
||||
estimated_params;
|
||||
psi1 , gamma_pdf,1.5,0.5;
|
||||
|
|
|
@ -1,45 +1,4 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
|
||||
varexo e_R e_q e_ys e_pies e_A;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+k*alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
@#include "ls2003_model.inc"
|
||||
|
||||
estimated_params;
|
||||
psi1 , gamma_pdf,1.5,0.5;
|
||||
|
@ -65,15 +24,14 @@ end;
|
|||
disp('CREATE SCREENING SAMPLE, CHECK FOR STABILITY AND PERFORM A SCREENING FOR IDENTIFICATION ANALYSIS');
|
||||
disp('TYPE II ERRORS')
|
||||
disp(' ')
|
||||
disp('PRESS ENTER TO CONTUNUE');
|
||||
pause(5);
|
||||
% disp('PRESS ENTER TO CONTUNUE');
|
||||
% pause(5);
|
||||
|
||||
dynare_sensitivity(identification=1, morris_nliv=6, morris_ntra=50);
|
||||
|
||||
disp('CREATE MC SAMPLE, CHECK FOR STABILITY AND PERFORM IDENTIFICATION ANALYSIS');
|
||||
disp('WIth analytic derivatives')
|
||||
disp('With analytic derivatives')
|
||||
disp(' ')
|
||||
disp('PRESS ENTER TO CONTUNUE');
|
||||
pause(5);
|
||||
dynare_sensitivity(identification=1, morris=2);
|
||||
|
||||
% disp('PRESS ENTER TO CONTUNUE');
|
||||
% pause(5);
|
||||
dynare_sensitivity(identification=1, morris=2);
|
|
@ -1,45 +1,4 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
|
||||
varexo e_R e_q e_ys e_pies e_A;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+k*alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
@#include "ls2003_model.inc"
|
||||
|
||||
estimated_params;
|
||||
psi1 , gamma_pdf,1.5,0.5;
|
||||
|
@ -63,8 +22,8 @@ end;
|
|||
|
||||
|
||||
disp('CREATE SCREENING SAMPLE, CHECK FOR STABILITY AND PERFORM SENSITIVITY ANALYSIS');
|
||||
disp('PRESS ENTER TO CONTUNUE');
|
||||
pause;
|
||||
% disp('PRESS ENTER TO CONTUNUE');
|
||||
% pause;
|
||||
|
||||
dynare_sensitivity(morris=1, morris_nliv=6, morris_ntra=20, redform=1,
|
||||
namendo=(:), namexo=(:), namlagendo=(:));
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
|
||||
var pie y R g z YGR INFL INT;
|
||||
varexo e_R e_g e_z;
|
||||
parameters tau kap psi1 psi2 rhoR rhog rhoz rr_steady pi_steady gam_steady std_R std_g std_z;
|
||||
var pie $\pi$ y R g z YGR INFL INT;
|
||||
varexo e_R $\varepsilon_R$ e_g e_z;
|
||||
parameters tau $\tau$ kap $\kappa$ psi1 psi2 rhoR rhog rhoz rr_steady pi_steady gam_steady std_R std_g std_z;
|
||||
|
||||
tau = 2;
|
||||
kap = 0.15;
|
||||
|
@ -96,7 +96,9 @@ identification(tex);
|
|||
identification(tex,advanced=1,max_dim_cova_group=3,prior_mc=250,no_identification_spectrum, no_identification_minimal);
|
||||
|
||||
collect_latex_files;
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
close all;
|
||||
|
|
|
@ -134,6 +134,8 @@ identification(advanced=1,max_dim_cova_group=3,prior_mc=250,tex);
|
|||
|
||||
collect_latex_files;
|
||||
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ TRUE_SOLUTION2 = 1/(KAPPA*PSI/TAU +1)*[1 KAPPA*PSI PSI;
|
|||
-1/TAU 1 -PSI/TAU;
|
||||
-KAPPA/TAU KAPPA 1];
|
||||
% note that BETA drops out from the solution
|
||||
|
||||
stoch_simul(order=1,noprint,irf=0,nomoments);
|
||||
if max(max(abs(TRUE_SOLUTION1 - oo_.dr.ghu))) > 1e-15
|
||||
error('Something wrong with perturbation');
|
||||
end
|
||||
|
|
|
@ -125,4 +125,5 @@ end
|
|||
|
||||
% Integration test if identification works without priors
|
||||
estim_params_=[];
|
||||
dumpy=0;
|
||||
identification(advanced=1,max_dim_cova_group=3);
|
||||
|
|
|
@ -245,6 +245,8 @@ write_latex_original_model(write_equation_tags);
|
|||
write_latex_steady_state_model;
|
||||
|
||||
collect_latex_files;
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -165,6 +165,8 @@ realtime_shock_decomposition(fast_realtime=75) y_obs R_obs pie_obs dq de;
|
|||
squeeze_shock_decomposition;
|
||||
|
||||
collect_latex_files;
|
||||
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
|
||||
[status, cmdout]=system(['pdflatex -halt-on-error -interaction=nonstopmode ' M_.fname '_TeX_binder.tex']);
|
||||
if status
|
||||
cmdout
|
||||
error('TeX-File did not compile.')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue