Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • benchmark-ec
  • clang+openmp
  • covariance-quadratic-approximation
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dprior
  • dragonfly
  • dynamic-striated
  • dynare_minreal
  • eigen
  • ep-sparse
  • error_msg_undeclared_model_vars
  • estim_params
  • exceptions
  • exo_steady_state
  • filter_initial_state
  • gpm-optimal-policy
  • julia
  • kalman_mex
  • master
  • mex-GetPowerDeriv
  • mr#2134
  • new-samplers
  • newton-quadratic-equation-solver
  • nlf-fixes
  • nlf-fixes-r
  • nls-fixes
  • nonlinear-filter-fixes
  • occbin
  • pac-mce-with-composite-target
  • parfor
  • penalty
  • rebase-1
  • remove-persistent-variables
  • remove-priordens
  • reset-seed-in-unit-tests
  • rmExtraExo
  • sep
  • sep-fixes
  • separateM_
  • silicon
  • silicon-new-samplers
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • use-dprior
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
111 results

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
  • ebenetce/dynare
  • chskcau/dynare-doc-fixes
28 results
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dragonfly
  • dynare_minreal
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exo_steady_state
  • gpm-optimal-policy
  • julia
  • madysson
  • master
  • mex-GetPowerDeriv
  • penalty
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 6-beta1
  • 6-beta2
  • 6.0
  • 6.1
  • 6.2
  • 6.3
  • 6.4
91 results
Show changes
Showing
with 310 additions and 122 deletions
...@@ -68,7 +68,7 @@ for indPC=1:length(Parallel), ...@@ -68,7 +68,7 @@ for indPC=1:length(Parallel),
% It is necessary because the command rmdir always ask at the user to confirm your decision before % It is necessary because the command rmdir always ask at the user to confirm your decision before
% deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir' % deleting a directory: this stops the computation! The Octave native function 'confirm_recursive_rmdir'
% disable this mechanism. % disable this mechanism.
val = confirm_recursive_rmdir (false); val = confirm_recursive_rmdir (false, 'local');
[stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s'); [stat, mess, id] = rmdir(['\\',Parallel(indPC).ComputerName,'\',Parallel(indPC).RemoteDrive,'$\',Parallel(indPC).RemoteDirectory,'\',PRCDir],'s');
else else
......
...@@ -153,9 +153,9 @@ if SampleSize == 1, ...@@ -153,9 +153,9 @@ if SampleSize == 1,
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_); dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_);
end end
skipline() skipline()
if idehess.flag_score,
[U,S,V]=svd(idehess.AHess,0); [U,S,V]=svd(idehess.AHess,0);
S=diag(S); S=diag(S);
if idehess.flag_score,
if nparam<5, if nparam<5,
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix)']); f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix)']);
else else
...@@ -163,13 +163,13 @@ if SampleSize == 1, ...@@ -163,13 +163,13 @@ if SampleSize == 1,
f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']); f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']);
end end
else else
S = idemoments.S; % S = idemoments.S;
V = idemoments.V; % V = idemoments.V;
if nparam<5, if nparam<5,
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments)']); f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix)']);
else else
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments): SMALLEST SV']); f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV']);
f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments): HIGHEST SV']); f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV']);
end end
end end
for j=1:min(nparam,8), for j=1:min(nparam,8),
...@@ -249,11 +249,11 @@ else ...@@ -249,11 +249,11 @@ else
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_); dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_);
ncut=floor(SampleSize/10*9); ncut=floor(SampleSize/10*9);
[dum,is]=sort(idelre.cond); [dum,is]=sort(idelre.cond);
[proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberLRE', 1, [], IdentifDirectoryName, 0.1); [proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberLRE', 1, [], IdentifDirectoryName, 0.1,'MC Highest Condition Number LRE Model');
[dum,is]=sort(idemodel.cond); [dum,is]=sort(idemodel.cond);
[proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberModel', 1, [], IdentifDirectoryName, 0.1); [proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberModel', 1, [], IdentifDirectoryName, 0.1,'MC Highest Condition Number Model Solution');
[dum,is]=sort(idemoments.cond); [dum,is]=sort(idemoments.cond);
[proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberMoments', 1, [], IdentifDirectoryName, 0.1); [proba, dproba] = stab_map_1(params, is(1:ncut), is(ncut+1:end), 'MC_HighestCondNumberMoments', 1, [], IdentifDirectoryName, 0.1,'MC Highest Condition Number Model Moments');
% [proba, dproba] = stab_map_1(idemoments.Mco', is(1:ncut), is(ncut+1:end), 'HighestCondNumberMoments_vs_Mco', 1, [], IdentifDirectoryName); % [proba, dproba] = stab_map_1(idemoments.Mco', is(1:ncut), is(ncut+1:end), 'HighestCondNumberMoments_vs_Mco', 1, [], IdentifDirectoryName);
% for j=1:nparam, % for j=1:nparam,
% % ibeh=find(idemoments.Mco(j,:)<0.9); % % ibeh=find(idemoments.Mco(j,:)<0.9);
......
...@@ -40,9 +40,8 @@ else ...@@ -40,9 +40,8 @@ else
end end
end end
if options_.TeX if options_.TeX
% needs to be fixed
if isempty(tit_tex), if isempty(tit_tex),
tit_tex=M_.endo_names_tex; tit_tex=names1;
end end
varlist_TeX = []; varlist_TeX = [];
...@@ -56,29 +55,70 @@ if options_.TeX ...@@ -56,29 +55,70 @@ if options_.TeX
end end
Mean = zeros(n2,nvar); Mean = zeros(n2,nvar);
Median = zeros(n2,nvar); Median = zeros(n2,nvar);
Std = zeros(n2,nvar); Var = zeros(n2,nvar);
Distrib = zeros(9,n2,nvar); Distrib = zeros(9,n2,nvar);
HPD = zeros(2,n2,nvar); HPD = zeros(2,n2,nvar);
fprintf(['Estimation::mcmc: ' tit1 '\n']); fprintf(['Estimation::mcmc: ' tit1 '\n']);
stock1 = zeros(n1,n2,B); stock1 = zeros(n1,n2,B);
k = 0; k = 0;
filter_step_ahead_indicator=0;
for file = 1:ifil for file = 1:ifil
load([DirectoryName '/' M_.fname var_type int2str(file)]); load([DirectoryName '/' M_.fname var_type int2str(file)]);
if size(size(stock),2) == 4 if size(size(stock),2) == 4
stock = squeeze(stock(1,:,1:n2,:)); if file==1 %on first run, initialize variable for storing filter_step_ahead
stock1_filter_step_ahead=NaN(n1,n2,B,length(options_.filter_step_ahead));
end
filter_step_ahead_indicator=1;
stock_filter_step_ahead=zeros(n1,n2,size(stock,4),length(options_.filter_step_ahead));
for ii=1:length(options_.filter_step_ahead)
K_step_ahead=options_.filter_step_ahead(ii);
stock_filter_step_ahead(:,:,:,ii)=stock(ii,:,1+K_step_ahead:n2+K_step_ahead,:);
end
stock = squeeze(stock(1,:,1+1:1+n2,:)); %1 step ahead starts at entry 2
end end
k = k(end)+(1:size(stock,3)); k = k(end)+(1:size(stock,3));
stock1(:,:,k) = stock; stock1(:,:,k) = stock;
if filter_step_ahead_indicator
stock1_filter_step_ahead(:,:,k,:) = stock_filter_step_ahead;
end
end end
clear stock clear stock
if filter_step_ahead_indicator
clear stock_filter_step_ahead
filter_steps=length(options_.filter_step_ahead);
Mean_filter_step_ahead = zeros(filter_steps,nvar,n2);
Median_filter_step_ahead = zeros(filter_steps,nvar,n2);
Var_filter_step_ahead = zeros(filter_steps,nvar,n2);
Distrib_filter_step_ahead = zeros(9,filter_steps,nvar,n2);
HPD_filter_step_ahead = zeros(2,filter_steps,nvar,n2);
end
tmp =zeros(B,1); tmp =zeros(B,1);
for i = 1:nvar for i = 1:nvar
for j = 1:n2 for j = 1:n2
[Mean(j,i),Median(j,i),Var(j,i),HPD(:,j,i),Distrib(:,j,i)] = ... [Mean(j,i),Median(j,i),Var(j,i),HPD(:,j,i),Distrib(:,j,i)] = ...
posterior_moments(squeeze(stock1(SelecVariables(i),j,:)),0,options_.mh_conf_sig); posterior_moments(squeeze(stock1(SelecVariables(i),j,:)),0,options_.mh_conf_sig);
if filter_step_ahead_indicator
for K_step = 1:length(options_.filter_step_ahead)
[Mean_filter_step_ahead(K_step,i,j),Median_filter_step_ahead(K_step,i,j),Var_filter_step_ahead(K_step,i,j),HPD_filter_step_ahead(:,K_step,i,j),Distrib_filter_step_ahead(:,K_step,i,j)] = ...
posterior_moments(squeeze(stock1_filter_step_ahead(SelecVariables(i),j,:,K_step)),0,options_.mh_conf_sig);
end
end
end end
end end
clear stock1 clear stock1
if filter_step_ahead_indicator %write matrices corresponding to ML
clear stock1_filter_step_ahead
FilteredVariablesKStepAhead=zeros(length(options_.filter_step_ahead),nvar,n2+max(options_.filter_step_ahead));
FilteredVariablesKStepAheadVariances=zeros(length(options_.filter_step_ahead),nvar,n2+max(options_.filter_step_ahead));
for K_step = 1:length(options_.filter_step_ahead)
FilteredVariablesKStepAhead(K_step,:,1+options_.filter_step_ahead(K_step):n2+options_.filter_step_ahead(K_step))=Mean_filter_step_ahead(K_step,:,:);
FilteredVariablesKStepAheadVariances(K_step,:,1+options_.filter_step_ahead(K_step):n2+options_.filter_step_ahead(K_step))=Mean_filter_step_ahead(K_step,:,:);
end
oo_.FilteredVariablesKStepAhead=FilteredVariablesKStepAhead;
oo_.FilteredVariablesKStepAheadVariances=FilteredVariablesKStepAheadVariances;
end
for i = 1:nvar for i = 1:nvar
name = deblank(names1(SelecVariables(i),:)); name = deblank(names1(SelecVariables(i),:));
eval(['oo_.' name3 '.Mean.' name ' = Mean(:,i);']); eval(['oo_.' name3 '.Mean.' name ' = Mean(:,i);']);
...@@ -87,6 +127,17 @@ for i = 1:nvar ...@@ -87,6 +127,17 @@ for i = 1:nvar
eval(['oo_.' name3 '.deciles.' name ' = Distrib(:,:,i);']); eval(['oo_.' name3 '.deciles.' name ' = Distrib(:,:,i);']);
eval(['oo_.' name3 '.HPDinf.' name ' = HPD(1,:,i);']); eval(['oo_.' name3 '.HPDinf.' name ' = HPD(1,:,i);']);
eval(['oo_.' name3 '.HPDsup.' name ' = HPD(2,:,i);']); eval(['oo_.' name3 '.HPDsup.' name ' = HPD(2,:,i);']);
if filter_step_ahead_indicator
for K_step = 1:length(options_.filter_step_ahead)
name4=['Filtered_Variables_',num2str(K_step),'_step_ahead'];
eval(['oo_.' name4 '.Mean.' name ' = squeeze(Mean_filter_step_ahead(K_step,i,:));']);
eval(['oo_.' name4 '.Median.' name ' = squeeze(Median_filter_step_ahead(K_step,i,:));']);
eval(['oo_.' name4 '.Var.' name ' = squeeze(Var_filter_step_ahead(K_step,i,:));']);
eval(['oo_.' name4 '.deciles.' name ' = squeeze(Distrib_filter_step_ahead(:,K_step,i,:));']);
eval(['oo_.' name4 '.HPDinf.' name ' = squeeze(HPD_filter_step_ahead(1,K_step,i,:));']);
eval(['oo_.' name4 '.HPDsup.' name ' = squeeze(HPD_filter_step_ahead(2,K_step,i,:));']);
end
end
end end
%% %%
%% Finally I build the plots. %% Finally I build the plots.
......
...@@ -48,6 +48,8 @@ post_var = var(xx); ...@@ -48,6 +48,8 @@ post_var = var(xx);
number_of_draws = length(xx); number_of_draws = length(xx);
hpd_draws = round((1-mh_conf_sig)*number_of_draws); hpd_draws = round((1-mh_conf_sig)*number_of_draws);
if hpd_draws>2
kk = zeros(hpd_draws,1); kk = zeros(hpd_draws,1);
jj = number_of_draws-hpd_draws; jj = number_of_draws-hpd_draws;
for ii = 1:hpd_draws for ii = 1:hpd_draws
...@@ -56,7 +58,10 @@ for ii = 1:hpd_draws ...@@ -56,7 +58,10 @@ for ii = 1:hpd_draws
end end
[kmin,idx] = min(kk); [kmin,idx] = min(kk);
hpd_interval = [xx(idx) xx(idx)+kmin]; hpd_interval = [xx(idx) xx(idx)+kmin];
else
hpd_interval=NaN(1,2);
end
if length(xx)>9
post_deciles = xx([round(0.1*number_of_draws) ... post_deciles = xx([round(0.1*number_of_draws) ...
round(0.2*number_of_draws) ... round(0.2*number_of_draws) ...
round(0.3*number_of_draws) ... round(0.3*number_of_draws) ...
...@@ -66,7 +71,9 @@ post_deciles = xx([round(0.1*number_of_draws) ... ...@@ -66,7 +71,9 @@ post_deciles = xx([round(0.1*number_of_draws) ...
round(0.7*number_of_draws) ... round(0.7*number_of_draws) ...
round(0.8*number_of_draws) ... round(0.8*number_of_draws) ...
round(0.9*number_of_draws)]); round(0.9*number_of_draws)]);
else
post_deciles=NaN(9,1);
end
density = []; density = [];
if info if info
number_of_grid_points = 2^9; % 2^9 = 512 !... Must be a power of two. number_of_grid_points = 2^9; % 2^9 = 512 !... Must be a power of two.
......
...@@ -105,6 +105,7 @@ if ~noprint ...@@ -105,6 +105,7 @@ if ~noprint
case 49 case 49
error('The model violates one (many) endogenous prior restriction(s)') error('The model violates one (many) endogenous prior restriction(s)')
case 51 case 51
fprintf('\n The dsge_prior_weight is dsge_var=%5.4f, but must be at least %5.4f for the prior to be proper.\n',info(2),info(3));
error('You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!') error('You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!')
case 52 %dsge_var_likelihood case 52 %dsge_var_likelihood
error('You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations is not positive definite!'); error('You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations is not positive definite!');
......
...@@ -58,7 +58,8 @@ naK = length(options_.filter_step_ahead); ...@@ -58,7 +58,8 @@ naK = length(options_.filter_step_ahead);
MaxNumberOfBytes=options_.MaxNumberOfBytes; MaxNumberOfBytes=options_.MaxNumberOfBytes;
endo_nbr=M_.endo_nbr; endo_nbr=M_.endo_nbr;
exo_nbr=M_.exo_nbr; exo_nbr=M_.exo_nbr;
nvobs = size(options_.varobs,1); meas_err_nbr=length(M_.Correlation_matrix_ME);
nvobs = length(options_.varobs);
iendo = 1:endo_nbr; iendo = 1:endo_nbr;
horizon = options_.forecast; horizon = options_.forecast;
filtered_vars = options_.filtered_vars; filtered_vars = options_.filtered_vars;
...@@ -288,10 +289,15 @@ if options_.smoother ...@@ -288,10 +289,15 @@ if options_.smoother
'',M_.exo_names,M_.exo_names_tex,M_.exo_names,... '',M_.exo_names,M_.exo_names_tex,M_.exo_names,...
M_.exo_names,'SmoothedShocks',DirectoryName,'_inno'); M_.exo_names,'SmoothedShocks',DirectoryName,'_inno');
if nvn if nvn
% needs to be fixed for obs_iter=1:size(options_.varobs,1)
% pm3(endo_nbr,gend,ifil(3),B,'Smoothed measurement errors',... meas_error_names{obs_iter,1}=['SE_EOBS_' M_.endo_names(strmatch(options_.varobs(obs_iter,:),M_.endo_names,'exact'),:)];
% M_.endo_names(SelecVariables),M_.endo_names,'tit_tex',M_.endo_names,... texnames{obs_iter,1}=['SE_EOBS_' M_.endo_names_tex(strmatch(options_.varobs(obs_iter,:),M_.endo_names,'exact'),:)];
% 'names2','smooth_errors',[M_.fname '/metropolis'],'_error') end
meas_error_names=char(meas_error_names);
texnames=char(texnames);
pm3(meas_err_nbr,gend,ifil(3),B,'Smoothed measurement errors',...
'',meas_error_names,texnames,meas_error_names,...
meas_error_names,'SmoothedMeasurementErrors',DirectoryName,'_error')
end end
end end
...@@ -300,7 +306,7 @@ if options_.filtered_vars ...@@ -300,7 +306,7 @@ if options_.filtered_vars
'',varlist,M_.endo_names_tex,M_.endo_names,... '',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'UpdatedVariables',DirectoryName, ... varlist,'UpdatedVariables',DirectoryName, ...
'_update'); '_update');
pm3(endo_nbr,gend+1,ifil(4),B,'One step ahead forecast (filtered variables)',... pm3(endo_nbr,gend,ifil(4),B,'One step ahead forecast (filtered variables)',...
'',varlist,M_.endo_names_tex,M_.endo_names,... '',varlist,M_.endo_names_tex,M_.endo_names,...
varlist,'FilteredVariables',DirectoryName,'_filter_step_ahead'); varlist,'FilteredVariables',DirectoryName,'_filter_step_ahead');
end end
......
...@@ -277,6 +277,8 @@ for b=fpar:B ...@@ -277,6 +277,8 @@ for b=fpar:B
if irun(5) > MAX_nruns || b == B if irun(5) > MAX_nruns || b == B
stock = stock_param(1:irun(5)-1,:); stock = stock_param(1:irun(5)-1,:);
stock_logpo = stock_logpo(1:irun(5)-1);
stock_ys = stock_ys(1:irun(5)-1,:);
ifil(5) = ifil(5) + 1; ifil(5) = ifil(5) + 1;
save([DirectoryName '/' M_.fname '_param' int2str(ifil(5)) '.mat'],'stock','stock_logpo','stock_ys'); save([DirectoryName '/' M_.fname '_param' int2str(ifil(5)) '.mat'],'stock','stock_logpo','stock_ys');
if RemoteFlag==1, if RemoteFlag==1,
......
function [info,number_of_calls] = homotopic_steps(tdx,positive_var_indx,shocks,init_weight,step,init,number_of_calls) function c = read_key_value_string(s)
% Copyright (C) 2010 Dynare Team % Transforms a string of Key-Value options as returned by the preprocessor (for optim option in the
% estimation command) into a cell (first column for the option name ans second column for the
% option value).
% Copyright (C) 2011-2013 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -17,67 +21,47 @@ function [info,number_of_calls] = homotopic_steps(tdx,positive_var_indx,shocks,i ...@@ -17,67 +21,47 @@ function [info,number_of_calls] = homotopic_steps(tdx,positive_var_indx,shocks,i
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global oo_ iComma = strfind(s,',');
number_of_calls = number_of_calls + 1; nComma = length(iComma);
max_number_of_calls = 50;
if number_of_calls>max_number_of_calls if iseven(nComma)
info = NaN; error('read_key_value_string: Wrong number of Key-Value pairs!')
return
end end
max_iter = 100;
weight = init_weight; c = cell((nComma+1)/2,2);
verbose = 0;
iter = 0; for i = 1:nComma
time = 0; j = comma2opt(i);
reduce_step = 0; if j>0, continue, end
while iter<=max_iter && weight<=1 if isequal(i,1)
iter = iter+1; i1 = 1;
old_weight = weight; i2 = iComma(i)-1;
weight = weight+step;
oo_.exo_simul(tdx,positive_var_indx) = weight*shocks+(1-weight);
if init
info = perfect_foresight_simulation(oo_.dr,oo_.steady_state);
else else
info = perfect_foresight_simulation; i1 = iComma(i-1)+1;
i2 = iComma(i)-1;
end end
time = time+info.time; if isequal(i,nComma)
if verbose i3 = iComma(i)+1;
[iter,step] i4 = length(s);
[info.iterations.time,info.iterations.error]
end
if ~info.convergence
if verbose
disp('Reduce step size!')
end
reduce_step = 1;
break
else else
if length(info.iterations.error)<5 i3 = iComma(i)+1;
if verbose i4 = iComma(i+1)-1;
disp('Increase step size!')
end
step = step*1.5;
end end
end c(-j,1) = {s(i1+1:i2-1)};
end tmp = str2num(s(i3:i4));
if reduce_step if isempty(tmp)
step=step/1.5; c(-j,2) = {s(i3+1:i4-1)};
[info,number_of_calls] = homotopic_steps(tdx,positive_var_indx,shocks,old_weight,step,init,number_of_calls);
if isstruct(info) && ~isnan(info.error)
time = time+info.time;
return
else else
return c(-j,2) = {tmp};
end
end end
if weight<1 && iter<max_iter
oo_.exo_simul(tdx,positive_var_indx) = shocks;
if init
info = perfect_foresight_simulation(oo_.dr,oo_.steady_state);
else
info = perfect_foresight_simulation;
end end
info.time = info.time+time;
function j = comma2opt(i)
if isodd(i)
% The comma is a separator between a Key and a Value (returned j is minus the option number).
j = - (i+1)/2;
else else
info.time = time; % The comma is a separator between two options (returned j is the option number).
j = i/2;
end end
\ No newline at end of file
...@@ -93,7 +93,7 @@ switch (extension) ...@@ -93,7 +93,7 @@ switch (extension)
for dyn_i_01=1:var_size_01 for dyn_i_01=1:var_size_01
iv = strmatch(strtrim(var_names_01(dyn_i_01,:)),varlist,'exact'); iv = strmatch(strtrim(var_names_01(dyn_i_01,:)),varlist,'exact');
if ~isempty(iv) if ~isempty(iv)
dyn_tmp_01 = [data(2:end,iv)]'; dyn_tmp_01 = [data(:,iv)]';
if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0
cd(old_pwd) cd(old_pwd)
error('data size is too large') error('data size is too large')
...@@ -110,7 +110,7 @@ switch (extension) ...@@ -110,7 +110,7 @@ switch (extension)
for dyn_i_01=1:var_size_01 for dyn_i_01=1:var_size_01
iv = strmatch(strtrim(var_names_01(dyn_i_01,:)),varlist,'exact'); iv = strmatch(strtrim(var_names_01(dyn_i_01,:)),varlist,'exact');
if ~isempty(iv) if ~isempty(iv)
dyn_tmp_01 = [data(2:end,iv)]'; dyn_tmp_01 = [data(:,iv)]';
if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0
cd(old_pwd) cd(old_pwd)
error('data size is too large') error('data size is too large')
......
...@@ -110,6 +110,7 @@ if isempty(o.xTickLabels) ...@@ -110,6 +110,7 @@ if isempty(o.xTickLabels)
end end
end end
else else
set(gca, 'XTick', o.xTicks);
xTickLabels = o.xTickLabels; xTickLabels = o.xTickLabels;
end end
set(gca, 'XTickLabel', xTickLabels); set(gca, 'XTickLabel', xTickLabels);
...@@ -135,11 +136,11 @@ end ...@@ -135,11 +136,11 @@ end
drawnow; drawnow;
if isempty(o.figname) if isempty(o.figname)
tn = tempname; [junk, tn] = fileparts(tempname);
if strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64') if strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
tn = strrep(tn, '\', '/'); tn = strrep(tn, '_', '-');
end end
o.figname = [tn '.tex']; o.figname = [o.figDirName '/' tn '.tex'];
end end
disp(' converting to tex....'); disp(' converting to tex....');
if isoctave && isempty(regexpi(computer, '.*apple.*', 'once')) if isoctave && isempty(regexpi(computer, '.*apple.*', 'once'))
......
...@@ -39,6 +39,7 @@ o.title = ''; ...@@ -39,6 +39,7 @@ o.title = '';
o.ylabel = ''; o.ylabel = '';
o.xlabel = ''; o.xlabel = '';
o.figDirName = 'tmpFigDir';
o.figname = ''; o.figname = '';
o.data = ''; o.data = '';
o.seriesToUse = ''; o.seriesToUse = '';
...@@ -60,6 +61,7 @@ o.legendFontSize = 8; ...@@ -60,6 +61,7 @@ o.legendFontSize = 8;
o.showZeroline = false; o.showZeroline = false;
o.graphSize = []; o.graphSize = [];
o.xTicks = [];
o.xTickLabels = {}; o.xTickLabels = {};
if nargin == 1 if nargin == 1
...@@ -92,6 +94,7 @@ assert(ischar(o.title), '@graph.graph: title must be a string'); ...@@ -92,6 +94,7 @@ assert(ischar(o.title), '@graph.graph: title must be a string');
assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string'); assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string');
assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string'); assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string');
assert(ischar(o.figname), '@graph.graph: figname must be a string'); assert(ischar(o.figname), '@graph.graph: figname must be a string');
assert(ischar(o.figDirName), '@graph.graph: figDirName must be a string');
assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false'); assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false');
assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false'); assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false');
assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false'); assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false');
...@@ -133,8 +136,17 @@ assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ... ...@@ -133,8 +136,17 @@ assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 2)),... assert(isempty(o.graphSize) || ((isfloat(o.graphSize) && length(o.graphSize) == 2)),...
['@graph.graph: graphSize is specified as an array with two float ' ... ['@graph.graph: graphSize is specified as an array with two float ' ...
'entries, [width height]']); 'entries, [width height]']);
assert(isempty(o.xTicks) || isfloat(o.xTicks),...
'@graph.graph: xTicks must be a numerical array');
assert(iscellstr(o.xTickLabels), ... assert(iscellstr(o.xTickLabels), ...
'@graph.graph: xTickLabels must be a cell array of strings'); '@graph.graph: xTickLabels must be a cell array of strings');
if ~isempty(o.xTickLabels)
assert(~isempty(o.xTicks), '@graph.graph: if you set xTickLabels, you must set xTicks');
end
if ~isempty(o.xTicks)
assert(~isempty(o.xTickLabels), '@graph.graph: if you set xTicks, you must set xTickLabels');
end
% using o.seriesToUse, create series objects and put them in o.seriesElements % using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data) if ~isempty(o.data)
if isempty(o.seriesToUse) if isempty(o.seriesToUse)
...@@ -150,6 +162,10 @@ end ...@@ -150,6 +162,10 @@ end
o = rmfield(o, 'seriesToUse'); o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data'); o = rmfield(o, 'data');
if ~exist(o.figDirName, 'file')
mkdir(o.figDirName);
end
% Create graph object % Create graph object
o = class(o, 'graph'); o = class(o, 'graph');
end end
\ No newline at end of file
...@@ -43,6 +43,6 @@ if ~isempty(o.figname) ...@@ -43,6 +43,6 @@ if ~isempty(o.figname)
end end
if ~isempty(o.title) if ~isempty(o.title)
fprintf(fid,'\\end{tabular}',o.title); fprintf(fid,'\\end{tabular}');
end end
end end
\ No newline at end of file
File mode changed from 100755 to 100644
...@@ -11,7 +11,7 @@ function o = write(o) ...@@ -11,7 +11,7 @@ function o = write(o)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2013 Dynare Team % Copyright (C) 2013-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -30,7 +30,7 @@ function o = write(o) ...@@ -30,7 +30,7 @@ function o = write(o)
[fid, msg] = fopen(o.filename, 'w'); [fid, msg] = fopen(o.filename, 'w');
if fid == -1 if fid == -1
error(['@report.subsasgn: ' msg]); error(['@report.write: ' msg]);
end end
fprintf(fid, '%% Report Object\n'); fprintf(fid, '%% Report Object\n');
...@@ -82,7 +82,7 @@ fprintf(fid, '\\end{document}\n'); ...@@ -82,7 +82,7 @@ fprintf(fid, '\\end{document}\n');
fprintf(fid, '%% End Report Object\n'); fprintf(fid, '%% End Report Object\n');
status = fclose(fid); status = fclose(fid);
if status == -1 if status == -1
error('@report.wrie: closing %s\n', o.filename); error('@report.write: closing %s\n', o.filename);
end end
disp('Finished Writing Report!'); disp('Finished Writing Report!');
end end
...@@ -64,7 +64,7 @@ assert(isempty(xrange) || isa(xrange, 'dates')); ...@@ -64,7 +64,7 @@ assert(isempty(xrange) || isa(xrange, 'dates'));
assert(isfloat(o.zerotol), '@report_series.write: zerotol must be a float'); assert(isfloat(o.zerotol), '@report_series.write: zerotol must be a float');
%% %%
if isempty(xrange) || xrange == o.data.dates if isempty(xrange) || all(xrange == o.data.dates)
ds = o.data; ds = o.data;
else else
ds = o.data(xrange); ds = o.data(xrange);
......
function o = printSeries(o, fid, dser, dates, precision)
%function printSeries(o, fid, dser, dates, precision)
% function to print a row of data, contained in dser
%
% INPUTS
% fid [int] file id
% dser [string] name of data series to be printed
% dates [dates] dates for report_series slice
% precision [float] precision with which to print the data
%
%
% OUTPUTS
% o [report_series] report_series object
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
dataString = ['%.' num2str(precision) 'f'];
precision = 10^precision;
data = dser(dates);
data = data.data;
for i=1:size(data,1)
fprintf(fid, '&');
if o.tableShowMarkers
if data(i) < -o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif data(i) > o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end
fprintf(fid, dataString, round(data(i)*precision)/precision);
if o.tableShowMarkers
fprintf(fid, ']');
end
end
end
\ No newline at end of file
...@@ -14,7 +14,7 @@ function o = report_series(varargin) ...@@ -14,7 +14,7 @@ function o = report_series(varargin)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2013 Dynare Team % Copyright (C) 2013-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -54,6 +54,8 @@ o.tableAlignRight = false; ...@@ -54,6 +54,8 @@ o.tableAlignRight = false;
o.tableRowColor = 'white'; o.tableRowColor = 'white';
o.tableDataRhs = '';
o.zerotol = 1e-6; o.zerotol = 1e-6;
if nargin == 1 if nargin == 1
......
function o = write(o, fid, dates, precision, yrsForAvgs) function o = write(o, fid, dates, precision)
%function o = write(o, fid, dates, precision, yrsForAvgs) %function o = write(o, fid, dates, precision)
% Write Table Row % Write Table Row
% %
% INPUTS % INPUTS
...@@ -7,7 +7,6 @@ function o = write(o, fid, dates, precision, yrsForAvgs) ...@@ -7,7 +7,6 @@ function o = write(o, fid, dates, precision, yrsForAvgs)
% fid [int] file id % fid [int] file id
% dates [dates] dates for report_series slice % dates [dates] dates for report_series slice
% precision [float] precision with which to print the data % precision [float] precision with which to print the data
% yrsForAvgs [bool] the years for which to compute averages
% %
% %
% OUTPUTS % OUTPUTS
...@@ -16,7 +15,7 @@ function o = write(o, fid, dates, precision, yrsForAvgs) ...@@ -16,7 +15,7 @@ function o = write(o, fid, dates, precision, yrsForAvgs)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2013 Dynare Team % Copyright (C) 2013-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -35,7 +34,9 @@ function o = write(o, fid, dates, precision, yrsForAvgs) ...@@ -35,7 +34,9 @@ function o = write(o, fid, dates, precision, yrsForAvgs)
%% Validate options passed to function %% Validate options passed to function
assert(fid ~= -1); assert(fid ~= -1);
assert(isa(dates, 'dates')); for i=1:length(dates)
assert(isa(dates{i}, 'dates'));
end
assert(isint(precision)); assert(isint(precision));
%% Validate options provided by user %% Validate options provided by user
...@@ -43,6 +44,13 @@ assert(ischar(o.tableSubSectionHeader), '@report_series.write: tableSubSectionHe ...@@ -43,6 +44,13 @@ assert(ischar(o.tableSubSectionHeader), '@report_series.write: tableSubSectionHe
if isempty(o.tableSubSectionHeader) if isempty(o.tableSubSectionHeader)
assert(~isempty(o.data) && isa(o.data, 'dseries'), ... assert(~isempty(o.data) && isa(o.data, 'dseries'), ...
'@report_series.write: must provide data as a dseries'); '@report_series.write: must provide data as a dseries');
if ~isempty(o.tableDataRhs)
assert(~isempty(o.tableDataRhs) && isa(o.tableDataRhs, 'dseries'), ...
'@report_series.write: must provide tableDataRhs as a dseries');
assert(iscell(dates) && length(dates) == 2, ...
'@report_series.write: must provide second range with tableDataRhs');
end
end end
assert(ischar(o.tableNegColor), '@report_series.write: tableNegColor must be a string'); assert(ischar(o.tableNegColor), '@report_series.write: tableNegColor must be a string');
...@@ -53,18 +61,12 @@ assert(islogical(o.tableAlignRight), '@report_series.write: tableAlignRight must ...@@ -53,18 +61,12 @@ assert(islogical(o.tableAlignRight), '@report_series.write: tableAlignRight must
assert(isfloat(o.tableMarkerLimit), '@report_series,write: tableMarkerLimit must be a float'); assert(isfloat(o.tableMarkerLimit), '@report_series,write: tableMarkerLimit must be a float');
%% Write Output %% Write Output
dataString = ['%.' num2str(precision) 'f'];
precision = 10^precision;
fprintf(fid, '%% Table Row (report_series)\n'); fprintf(fid, '%% Table Row (report_series)\n');
if ~isempty(o.tableRowColor) if ~isempty(o.tableRowColor)
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor); fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
end end
if ~isempty(o.tableSubSectionHeader) if ~isempty(o.tableSubSectionHeader)
fprintf(fid, '%s', o.tableSubSectionHeader); fprintf(fid, '%s', o.tableSubSectionHeader);
for i=1:size(dates)+length(yrsForAvgs)
fprintf(fid, '&');
end
fprintf(fid, '\\\\%%\n'); fprintf(fid, '\\\\%%\n');
return; return;
end end
...@@ -75,45 +77,11 @@ fprintf(fid, '%s', o.data.tex{:}); ...@@ -75,45 +77,11 @@ fprintf(fid, '%s', o.data.tex{:});
if o.tableAlignRight if o.tableAlignRight
fprintf(fid, '}'); fprintf(fid, '}');
end end
data = o.data(dates);
data = data.data;
for i=1:size(data,1)
fprintf(fid, '&');
if o.tableShowMarkers
if data(i) < -o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif data(i) > o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end
fprintf(fid, dataString, round(data(i)*precision)/precision);
if o.tableShowMarkers printSeries(o, fid, o.data, dates{1}, precision);
fprintf(fid, ']'); if ~isempty(o.tableDataRhs)
end printSeries(o, fid, o.tableDataRhs, dates{2}, precision);
end
% Calculate and display annual averages
for i=1:length(yrsForAvgs)
slice = o.data(dates([num2str(yrsForAvgs(i)) 'q1']):dates([num2str(yrsForAvgs(i)) 'q4']));
avg = sum(slice.data)/size(slice);
fprintf(fid, '&');
if o.tableShowMarkers
if avg < -o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif avg > o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end end
fprintf(fid, dataString, round(avg*precision)/precision);
if o.tableShowMarkers
fprintf(fid, ']');
end
end
fprintf(fid, '\\\\%%\n'); fprintf(fid, '\\\\%%\n');
end end
...@@ -12,7 +12,7 @@ function o = report_table(varargin) ...@@ -12,7 +12,7 @@ function o = report_table(varargin)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2013 Dynare Team % Copyright (C) 2013-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -41,8 +41,6 @@ o.showVlines = false; ...@@ -41,8 +41,6 @@ o.showVlines = false;
o.vlineAfter = ''; o.vlineAfter = '';
o.vlineAfterEndOfPeriod = false; o.vlineAfterEndOfPeriod = false;
o.annualAverages = false;
o.data = ''; o.data = '';
o.seriesToUse = ''; o.seriesToUse = '';
o.range = {}; o.range = {};
...@@ -72,21 +70,27 @@ elseif nargin > 1 ...@@ -72,21 +70,27 @@ elseif nargin > 1
end end
end end
end end
if ~iscell(o.range)
o.range = {o.range};
end
if isa(o.vlineAfter, 'dates')
o.vlineAfter = {o.vlineAfter};
end
% Check options provided by user % Check options provided by user
assert(ischar(o.title), '@report_table.report_table: title must be a string'); assert(ischar(o.title), '@report_table.report_table: title must be a string');
assert(islogical(o.annualAverages), '@report_table.report_table: annualAverages must be true or false');
assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false'); assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false');
assert(islogical(o.showVlines), '@report_table.report_table: showVlines must be true or false'); assert(islogical(o.showVlines), '@report_table.report_table: showVlines must be true or false');
assert(isint(o.precision), '@report_table.report_table: precision must be an int'); assert(isint(o.precision), '@report_table.report_table: precision must be an int');
assert(isempty(o.range) || (isa(o.range, 'dates') && o.range.ndat >= 2), ... assert(isempty(o.range) || length(o.range) <=2 && allCellsAreDatesRange(o.range), ...
['@report_table.report_table: range is specified as a dates range, e.g. ' ... ['@report_table.report_table: range is specified as a dates range, e.g. ' ...
'''dates(''1999q1''):dates(''1999q3'')''.']); '''dates(''1999q1''):dates(''1999q3'')''.']);
assert(isempty(o.data) || isa(o.data, 'dseries'), ... assert(isempty(o.data) || isa(o.data, 'dseries'), ...
'@report_table.report_table: data must be a dseries'); '@report_table.report_table: data must be a dseries');
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ... assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
'@report_table.report_table: seriesToUse must be a cell array of string(s)'); '@report_table.report_table: seriesToUse must be a cell array of string(s)');
assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dates'), ... assert(isempty(o.vlineAfter) || allCellsAreDates(o.vlineAfter), ...
'@report_table.report_table: vlineAfter must be a dates'); '@report_table.report_table: vlineAfter must be a dates');
if o.showVlines if o.showVlines
o.vlineAfter = ''; o.vlineAfter = '';
......
...@@ -12,7 +12,7 @@ function o = write(o, fid) ...@@ -12,7 +12,7 @@ function o = write(o, fid)
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2013 Dynare Team % Copyright (C) 2013-2014 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -45,7 +45,7 @@ nlhc = 1; ...@@ -45,7 +45,7 @@ nlhc = 1;
if isempty(o.range) if isempty(o.range)
dates = o.seriesElements.getMaxRange(); dates = o.seriesElements.getMaxRange();
else else
dates = o.range; dates = o.range{1};
end end
ndates = dates.ndat; ndates = dates.ndat;
...@@ -64,7 +64,8 @@ for i=1:ndates ...@@ -64,7 +64,8 @@ for i=1:ndates
end end
end end
if ~isempty(o.vlineAfter) if ~isempty(o.vlineAfter)
if dates(i) == o.vlineAfter for j=1:length(o.vlineAfter)
if dates(i) == o.vlineAfter{j}
if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq) if ~(o.vlineAfterEndOfPeriod && dates(i).time(2) == dates(i).freq)
fprintf(fid, '|'); fprintf(fid, '|');
end end
...@@ -72,23 +73,29 @@ for i=1:ndates ...@@ -72,23 +73,29 @@ for i=1:ndates
end end
end end
end end
end
datedata = dates.time; datedata = dates.time;
years = unique(datedata(:, 1)); years = unique(datedata(:, 1));
if o.annualAverages if length(o.range) > 1
yrsForAvgs = years; rhscols = strings(o.range{2});
if o.range{2}.freq == 1
rhscols = strrep(rhscols, 'Y', '');
end
else else
yrsForAvgs = []; rhscols = {};
end end
for i=1:length(yrsForAvgs) for i=1:length(rhscols)
fprintf(fid, 'r'); fprintf(fid, 'r');
if o.showVlines if o.showVlines
fprintf(fid, '|'); fprintf(fid, '|');
end end
end end
nrhc = length(rhscols);
ncols = ndates+nlhc+nrhc;
fprintf(fid, '@{}}%%\n'); fprintf(fid, '@{}}%%\n');
if ~isempty(o.title) if ~isempty(o.title)
fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ... fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ...
ndates+nlhc, o.titleSize, o.title); ncols, o.titleSize, o.title);
end end
fprintf(fid, '\\toprule%%\n'); fprintf(fid, '\\toprule%%\n');
...@@ -99,6 +106,9 @@ switch dates.freq ...@@ -99,6 +106,9 @@ switch dates.freq
for i=1:size(thdr, 1) for i=1:size(thdr, 1)
fprintf(fid, ' & %d', thdr{i, 1}); fprintf(fid, ' & %d', thdr{i, 1});
end end
for i=1:length(rhscols)
fprintf(fid, ' & %s', rhscols{i});
end
case 4 case 4
thdr{1, 2} = datedata(:, 2)'; thdr{1, 2} = datedata(:, 2)';
if size(thdr, 1) > 1 if size(thdr, 1) > 1
...@@ -115,11 +125,10 @@ switch dates.freq ...@@ -115,11 +125,10 @@ switch dates.freq
for i=1:size(thdr, 1) for i=1:size(thdr, 1)
fprintf(fid, ' & \\multicolumn{%d}{c}{%d}', size(thdr{i,2}, 2), thdr{i,1}); fprintf(fid, ' & \\multicolumn{%d}{c}{%d}', size(thdr{i,2}, 2), thdr{i,1});
end end
fprintf(fid, '\\\\[-10pt]%%\n'); for i=1:length(rhscols)
for i=1:size(thdr, 1) fprintf(fid, ' & %s', rhscols{i});
fprintf(fid, ' & \\multicolumn{%d}{c}{\\hrulefill}', size(thdr{i,2}, 2));
end end
fprintf(fid, '\\\\%%\n'); fprintf(fid, '\\\\\\cline{%d-%d}%%\n', nlhc+1, ncols);
for i=1:size(thdr, 1) for i=1:size(thdr, 1)
quarters = thdr{i, 2}; quarters = thdr{i, 2};
for j=1:size(quarters, 2) for j=1:size(quarters, 2)
...@@ -131,9 +140,6 @@ switch dates.freq ...@@ -131,9 +140,6 @@ switch dates.freq
otherwise otherwise
error('@report_table.write: invalid dseries frequency'); error('@report_table.write: invalid dseries frequency');
end end
for i=1:length(yrsForAvgs)
fprintf(fid, ' & %d', years(i));
end
fprintf(fid, '\\\\[-2pt]%%\n'); fprintf(fid, '\\\\[-2pt]%%\n');
fprintf(fid, '\\hline%%\n'); fprintf(fid, '\\hline%%\n');
fprintf(fid, '%%\n'); fprintf(fid, '%%\n');
...@@ -141,7 +147,7 @@ fprintf(fid, '%%\n'); ...@@ -141,7 +147,7 @@ fprintf(fid, '%%\n');
% Write Report_Table Data % Write Report_Table Data
ne = o.seriesElements.numSeriesElements(); ne = o.seriesElements.numSeriesElements();
for i=1:ne for i=1:ne
o.seriesElements(i).write(fid, dates, o.precision, yrsForAvgs); o.seriesElements(i).write(fid, o.range, o.precision);
if o.showHlines if o.showHlines
fprintf(fid, '\\hline\n'); fprintf(fid, '\\hline\n');
end end
......