Commit 7be8f10e authored by Stéphane Adjemian's avatar Stéphane Adjemian Committed by Stéphane Adjemian

Use cells of strings instead of char arrays.

parent 2be12bd5
......@@ -17,7 +17,7 @@ global M_
% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
paramname = deblank(M_.param_names(ii,:));
paramname = M_.param_names{ii};
eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
......@@ -96,11 +96,11 @@ g2=epsilon/(epsilon-1)*g1;
%% end own model equations
for iter = 1:length(M_.params) %update parameters set in the file
eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names{iter} ';' ])
end
NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
varname = deblank(M_.endo_names(ii,:));
varname = M_.endo_names{ii};
eval(['ys(' int2str(ii) ') = ' varname ';']);
end
This diff is collapsed.
......@@ -16,7 +16,7 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-2017 Dynare Team
% Copyright (C) 2005-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -63,24 +63,24 @@ for i=1:npar
subplotnum = subplotnum+1;
if subplotnum == 1
figunumber = figunumber+1;
hfig=dyn_figure(options_.nodisplay,'Name',figurename);
hfig=dyn_figure(options_.nodisplay, 'Name', figurename);
end
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
[nam,texnam] = get_the_name(i, TeX, M_, estim_params_, options_);
if subplotnum == 1
NAMES = nam;
NAMES = {nam};
if TeX
TeXNAMES = texnam;
TeXNAMES = {texnam};
end
else
NAMES = char(NAMES,nam);
NAMES = [NAMES; {nam}];
if TeX
TeXNAMES = char(TeXNAMES,texnam);
TeXNAMES = [TeXNAMES; {texnam}];
end
end
[x2,f2,abscissa,dens,binf2,bsup2] = draw_prior_density(i,bayestopt_);
[x2, f2, abscissa, dens, binf2, bsup2] = draw_prior_density(i, bayestopt_);
top2 = max(f2);
if i <= nvx
name = deblank(M_.exo_names(estim_params_.var_exo(i,1),:));
name = M_.exo_names{estim_params_.var_exo(i,1)};
x1 = oo_.posterior_density.shocks_std.(name)(:,1);
f1 = oo_.posterior_density.shocks_std.(name)(:,2);
oo_.prior_density.shocks_std.(name)(:,1) = x2;
......@@ -101,7 +101,7 @@ for i=1:npar
j = i - (nvx+nvn);
k1 = estim_params_.corrx(j,1);
k2 = estim_params_.corrx(j,2);
name = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
name = sprintf('%s_%s', M_.exo_names{k1}, M_.exo_names{k2});
x1 = oo_.posterior_density.shocks_corr.(name)(:,1);
f1 = oo_.posterior_density.shocks_corr.(name)(:,2);
oo_.prior_density.shocks_corr.(name)(:,1) = x2;
......@@ -113,7 +113,7 @@ for i=1:npar
j = i - (nvx+nvn+ncx);
k1 = estim_params_.corrn(j,1);
k2 = estim_params_.corrn(j,2);
name = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
name = sprintf('%s_%s', M_.endo_names{k1}, M_.endo_names{k2});
x1 = oo_.posterior_density.measurement_errors_corr.(name)(:,1);
f1 = oo_.posterior_density.measurement_errors_corr.(name)(:,2);
oo_.prior_density.measurement_errors_corr.(name)(:,1) = x2;
......@@ -123,7 +123,7 @@ for i=1:npar
end
else
j = i - (nvx+nvn+ncx+ncn);
name = deblank(M_.param_names(estim_params_.param_vals(j,1),:));
name = M_.param_names{estim_params_.param_vals(j,1)};
x1 = oo_.posterior_density.parameters.(name)(:,1);
f1 = oo_.posterior_density.parameters.(name)(:,2);
oo_.prior_density.parameters.(name)(:,1) = x2;
......@@ -133,35 +133,36 @@ for i=1:npar
end
end
top1 = max(f1);
top0 = max([top1;top2]);
top0 = max([top1; top2]);
binf1 = x1(1);
bsup1 = x1(end);
borneinf = min(binf1,binf2);
bornesup = max(bsup1,bsup2);
subplot(nn,nn,subplotnum)
hh = plot(x2,f2,'-k','linewidth',2);
set(hh,'color',[0.7 0.7 0.7]);
borneinf = min(binf1, binf2);
bornesup = max(bsup1, bsup2);
subplot(nn, nn, subplotnum)
hh = plot(x2, f2, '-k', 'linewidth', 2);
set(hh, 'color', [0.7 0.7 0.7]);
hold on;
plot(x1,f1,'-k','linewidth',2);
plot(x1, f1, '-k', 'linewidth', 2);
if ~options_.mh_posterior_mode_estimation
plot( [pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2);
plot([pmod pmod], [0.0 1.1*top0], '--g', 'linewidth', 2);
end
box on;
axis([borneinf bornesup 0 1.1*top0]);
title(nam,'Interpreter','none');
hold off;
box on
axis([borneinf bornesup 0 1.1*top0])
title(nam, 'Interpreter', 'none')
hold off
drawnow
if subplotnum == MaxNumberOfPlotPerFigure || i == npar
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:size(NAMES,1)
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(j,:)),deblank(TeXNAMES(j,:)));
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)], options_.nodisplay, options_.graph_format);
if TeX && any(strcmp('eps', cellstr(options_.graph_format)))
fprintf(fidTeX, '\\begin{figure}[H]\n');
for j = 1:size(NAMES, 1)
fprintf(fidTeX, '\\psfrag{%s}[1][][0.5][0]{%s}\n', NAMES{j}, TeXNAMES{j});
end
fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_PriorsAndPosteriors%s}\n',options_.figures.textwidth*min(subplotnum/nn,1),OutputDirectoryName,M_.fname,int2str(figunumber));
fprintf(fidTeX, '\\centering\n');
fprintf(fidTeX, '\\includegraphics[width=%2.2f\\textwidth]{%s/%s_PriorsAndPosteriors%s}\n', ...
options_.figures.textwidth*min(subplotnum/nn,1), OutputDirectoryName, M_.fname, int2str(figunumber));
fprintf(fidTeX,'\\caption{Priors and posteriors.}');
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n',int2str(figunumber));
fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n', int2str(figunumber));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
if i == npar
......
......@@ -16,7 +16,7 @@ function PosteriorIRF(type)
% functions associated with it(the _core1 and _core2).
% See also the comments posterior_sampler.m funtion.
% Copyright (C) 2006-2017 Dynare Team
% Copyright (C) 2006-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -43,17 +43,17 @@ end
% Set varlist if necessary
varlist = options_.varlist;
if isempty(varlist)
varlist = char(options_.varobs);
varlist = options_.varobs;
end
options_.varlist = varlist;
nvar = size(varlist,1);
nvar = length(varlist);
IndxVariables = [];
for i=1:nvar
idx = strmatch(deblank(varlist(i,:)),M_.endo_names,'exact');
idx = strmatch(varlist{i}, M_.endo_names, 'exact');
if isempty(idx)
disp(['PosteriorIRF :: ' deblank(varlist(i,:)) 'is not a declared endogenous variable!'])
disp(['PosteriorIRF :: ' varlist{i} 'is not a declared endogenous variable!'])
else
IndxVariables = [IndxVariables,idx];
IndxVariables = [IndxVariables, idx];
end
end
......@@ -281,17 +281,14 @@ DistribIRF = zeros(options_.irf,9,nvar,M_.exo_nbr);
HPDIRF = zeros(options_.irf,2,nvar,M_.exo_nbr);
if options_.TeX
varlist_TeX = cell(nvar, 1);
for i=1:nvar
if i==1
varlist_TeX = M_.endo_names_tex(IndxVariables(i),:);
else
varlist_TeX = char(varlist_TeX,M_.endo_names_tex(IndxVariables(i),:));
end
varlist_TeX(i) = {M_.endo_names_tex{IndxVariables(i)}};
end
end
fprintf('Estimation::mcmc: Posterior (dsge) IRFs...\n');
tit(M_.exo_names_orig_ord,:) = M_.exo_names;
tit(M_.exo_names_orig_ord) = M_.exo_names;
kdx = 0;
for file = 1:NumberOfIRFfiles_dsge
......@@ -313,7 +310,7 @@ clear STOCK_IRF_DSGE;
for i = irf_shocks_indx
for j = 1:nvar
name = [deblank(M_.endo_names(IndxVariables(j),:)) '_' deblank(tit(i,:))];
name = sprintf('%s_%s', M_.endo_names{IndxVariables(j)}, tit{i});
oo_.PosteriorIRF.dsge.Mean.(name) = MeanIRF(:,j,i);
oo_.PosteriorIRF.dsge.Median.(name) = MedianIRF(:,j,i);
oo_.PosteriorIRF.dsge.Var.(name) = VarIRF(:,j,i);
......@@ -331,7 +328,7 @@ if MAX_nirfs_dsgevar
DistribIRFdsgevar = zeros(options_.irf,9,nvar,M_.exo_nbr);
HPDIRFdsgevar = zeros(options_.irf,2,nvar,M_.exo_nbr);
fprintf('Estimation::mcmc: Posterior (bvar-dsge) IRFs...\n');
tit(M_.exo_names_orig_ord,:) = M_.exo_names;
tit(M_.exo_names_orig_ord) = M_.exo_names;
kdx = 0;
for file = 1:NumberOfIRFfiles_dsgevar
load([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs' int2str(file) '.mat']);
......@@ -350,7 +347,7 @@ if MAX_nirfs_dsgevar
clear STOCK_IRF_BVARDSGE;
for i = irf_shocks_indx
for j = 1:nvar
name = [deblank(M_.endo_names(IndxVariables(j),:)) '_' deblank(tit(i,:))];
name = sprintf('%s_%s', M_.endo_names{IndxVariables(j)}, tit{i});
oo_.PosteriorIRF.bvardsge.Mean.(name) = MeanIRFdsgevar(:,j,i);
oo_.PosteriorIRF.bvardsge.Median.(name) = MedianIRFdsgevar(:,j,i);
oo_.PosteriorIRF.bvardsge.Var.(name) = VarIRFdsgevar(:,j,i);
......@@ -396,13 +393,13 @@ if ~options_.nograph && ~options_.no_graph.posterior
% The files .TeX are generated in sequential way always!
subplotnum = 0;
tit_TeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex;
titTeX(M_.exo_names_orig_ord) = M_.exo_names_tex;
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([DirectoryName filesep M_.fname '_BayesianIRF.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
titTeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex;
titTeX(M_.exo_names_orig_ord) = M_.exo_names_tex;
for ii=irf_shocks_indx
figunumber = 0;
......@@ -414,24 +411,23 @@ if ~options_.nograph && ~options_.no_graph.posterior
if subplotnum == 1
fprintf(fidTeX,'\\begin{figure}[H]\n');
end
name = deblank(varlist(jj,:));
texname = deblank(varlist_TeX(jj,:));
name = varlist{jj};
texname = varlist_TeX{jj};
fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n'],name,['$' texname '$']);
end
if subplotnum == MaxNumberOfPlotPerFigure || (jj == nvar && subplotnum> 0)
figunumber = figunumber+1;
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_Bayesian_IRF_%s_%d}\n',options_.figures.textwidth*min(subplotnum/nn,1),DirectoryName,M_.fname,deblank(tit(ii,:)),figunumber);
fprintf(fidTeX,'\\includegraphics[width=%2.2f\\textwidth]{%s/%s_Bayesian_IRF_%s_%d}\n',options_.figures.textwidth*min(subplotnum/nn,1),DirectoryName,M_.fname,tit{ii},figunumber);
if options_.relative_irf
fprintf(fidTeX,['\\caption{Bayesian relative IRF.}']);
else
fprintf(fidTeX,'\\caption{Bayesian IRF: Orthogonalized shock to $%s$.}\n',deblank(tit_TeX(ii,:)));
fprintf(fidTeX,'\\caption{Bayesian IRF: Orthogonalized shock to $%s$.}\n',titTeX{ii});
end
fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%d}\n',deblank(tit(ii,:)),figunumber);
fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%d}\n', tit{ii},figunumber);
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
subplotnum = 0;
end
end
......@@ -445,7 +441,7 @@ if ~options_.nograph && ~options_.no_graph.posterior
% Comment for testing!
if ~isoctave
if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(size(varlist,1)/MaxNumberOfPlotPerFigure))<8
if isnumeric(options_.parallel) || (M_.exo_nbr*ceil(length(varlist)/MaxNumberOfPlotPerFigure))<8
[fout] = PosteriorIRF_core2(localVars,1,M_.exo_nbr,0);
else
isRemoteOctave = 0;
......
......@@ -23,7 +23,7 @@ function myoutput=PosteriorIRF_core1(myinputs,fpar,B,whoiam, ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
%
% Copyright (C) 2006-2017 Dynare Team
% Copyright (C) 2006-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -195,7 +195,7 @@ while fpar<B
if MAX_nirfs_dsgevar
IRUN = IRUN+1;
[fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] = dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight',M_.param_names));
dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
explosive_var = 1;
......
......@@ -30,7 +30,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
%
% Copyright (C) 2006-2017 Dynare Team
% Copyright (C) 2006-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -103,9 +103,9 @@ for i=fpar:npar
if max(abs(MeanIRF(:,j,i))) >= options_.impulse_responses.plot_threshold
subplotnum = subplotnum+1;
if subplotnum == 1 && options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit(i,:)]);
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit{i}]);
elseif subplotnum == 1 && ~options_.relative_irf
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:)]);
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit{i}]);
end
set(0,'CurrentFigure',hh)
......@@ -142,17 +142,17 @@ for i=fpar:npar
remove_fractional_xticks;
hold off
end
name = deblank(varlist(j,:));
name = varlist{j};
title(name,'Interpreter','none')
else
if options_.debug
fprintf('POSTERIOR_IRF: The IRF of %s to %s is smaller than the irf_plot_threshold of %4.3f and will not be displayed.\n',deblank(varlist(j,:)),tit(i,:),options_.impulse_responses.plot_threshold)
fprintf('POSTERIOR_IRF: The IRF of %s to %s is smaller than the irf_plot_threshold of %4.3f and will not be displayed.\n',varlist{j},tit{i},options_.impulse_responses.plot_threshold)
end
end
if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar && subplotnum> 0)
figunumber = figunumber+1;
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' tit{i} '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if RemoteFlag==1
OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
end
......
......@@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list)
% Adapted from th_autocovariances.m.
% Copyright (C) 2006-2017 Dynare Team
% Copyright (C) 2006-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -50,15 +50,15 @@ else
warning off MATLAB:dividebyzero
end
if nargin<2
var_list = [];
var_list = {};
end
if size(var_list,1) == 0
var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
if isempty(var_list)
var_list = M_.endo_names(1:M_.orig_endo_nbr);
end
nvar = size(var_list,1);
nvar = length(var_list);
ivar=zeros(nvar,1);
for i=1:nvar
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact');
i_tmp = strmatch(var_list{i}, M_.endo_names, 'exact');
if isempty(i_tmp)
error (['One of the variables specified does not exist']) ;
else
......@@ -159,12 +159,12 @@ if options_.nograph == 0
end
for i= 1:nvar
hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' deblank(M_.endo_names(ivar(i),:)) '.']);
hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' M_.endo_names{ivar(i)} '.']);
plot(freqs,f(i,:),'-k','linewidth',2)
xlabel('0 \leq \omega \leq \pi')
ylabel('f(\omega)')
box on
axis tight
dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' deblank(M_.endo_names(ivar(i),:))],options_.nodisplay,options_.graph_format)
dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' M_.endo_names{ivar(i)}],options_.nodisplay,options_.graph_format)
end
end
......@@ -11,7 +11,7 @@ function WriteShockDecomp2Excel(z,shock_names,endo_names,i_var,initial_date,Dyna
% DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure
% Copyright (C) 2016-2017 Dynare Team
% Copyright (C) 2016-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -94,7 +94,7 @@ for j=1:nvar
z1 = squeeze(z(i_var(j),:,:));
if screen_shocks
[junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
labels = char(char(shock_names(isort(1:16),:)),'Others', 'Initial values');
labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
zres = sum(z1(isort(17:end),:),1);
z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
comp_nbr=18;
......@@ -115,9 +115,9 @@ for j=1:nvar
warning off
if ~ismac
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:)));
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
else
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:)));
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,endo_names{i_var(j)});
end
warning on
......
......@@ -32,7 +32,7 @@ function [z, endo_names, endo_names_tex, steady_state, i_var, oo_] = annualized_
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2017 Dynare Team
% Copyright (C) 2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -109,17 +109,15 @@ elseif mytype
gtex = 'g';
end
steady_state=steady_state(i_var);
% endo_names = M_.endo_names(i_var,:);
% endo_names_tex = M_.endo_names_tex(i_var,:);
nterms = size(z,2);
nfrcst = opts.forecast/4;
for j=1:nvar
if j>1
endo_names = char(endo_names,[deblank(M_.endo_names(i_var(j),:)) '_A']);
endo_names_tex = char(endo_names_tex,['{' deblank(M_.endo_names_tex(i_var(j),:)) '}^A']);
gendo_names = char(gendo_names,[gtxt endo_names(j,:)]);
gendo_names_tex = char(gendo_names_tex,[gtex '(' deblank(endo_names_tex(j,:)) ')']);
endo_names = char(endo_names, sprintf('%s_A', M_.endo_names{i_var(j)}));
endo_names_tex = char(endo_names_tex, sprintf('{%s}^A', M_.endo_names_tex{i_var(j)}));
gendo_names = char(gendo_names,[gtxt endo_names{j}]);
gendo_names_tex = char(gendo_names_tex,[gtex '(' endo_names_tex{j} ')']);
else
if nvar==1 && ~mytype
endo_names = mytxt;
......@@ -127,10 +125,10 @@ for j=1:nvar
gendo_names = gtxt;
gendo_names_tex = gtex;
else
endo_names = [deblank(M_.endo_names(i_var(j),:)) '_A'];
endo_names_tex = ['{' deblank(M_.endo_names_tex(i_var(j),:)) '}^A'];
gendo_names = [gtxt endo_names(j,:)];
gendo_names_tex = [gtex '(' deblank(endo_names_tex(j,:)) ')'];
endo_names = sprintf('%s_A', M_.endo_names{i_var(j)});
endo_names_tex = sprintf('{%s}^A', M_.endo_names_tex{i_var(j)});
gendo_names = [gtxt endo_names{j}];
gendo_names_tex = [gtex '(' endo_names_tex{j} ')'];
end
end
for k =1:nterms
......@@ -331,3 +329,6 @@ else
steady_state = steady_state_a;
end
end
endo_names = cellstr(endo_names);
endo_names_tex = cellstr(endo_names_tex);
\ No newline at end of file
......@@ -10,7 +10,7 @@ function forecasts = backward_model_forecast(initialcondition, listofvariables,
% OUTPUTS
% - forecast [dseries]
% Copyright (C) 2017 Dynare Team
% Copyright (C) 2017-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -39,7 +39,7 @@ forecasts = struct();
% Set defaults.
if nargin<2
listofvariables = cellstr(M_.endo_names);
listofvariables = M_.endo_names;
periods = 8;
withuncertainty = false;
end
......
......@@ -19,7 +19,7 @@ function [deviations, baseline, irfs] = backward_model_irf(initialcondition, inn
% argument.
% - If second argument is not empty, periods must not be greater than innovationbaseline.nobs.
% Copyright (C) 2017 Dynare Team
% Copyright (C) 2017-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -72,7 +72,7 @@ else
end
if deterministicshockflag
numberofexperiments = length(listofshocks);
exonames = cellstr(M_.exo_names);
exonames = M_.exo_names;
initialconditionperiod = initialcondition.dates(end);
for i=1:numberofexperiments
shock = listofshocks{i};
......@@ -108,7 +108,7 @@ if ~isempty(innovationbaseline)
error('The second input argument must at least have %s observations or lower the number of periods.', periods)
end
% Fill innovations with provided paths for the innovations.
exonames = cellstr(M_.exo_names);
exonames = M_.exo_names;
for i = 1:length(exonames)
if ~isempty(strmatch(exonames{i}, innovationbaseline.name))
Innovations(:,i) = innovationbaseline{exonames{i}}.data(1:periods);
......@@ -183,9 +183,9 @@ for i=1:length(listofshocks)
endo_simul__1 = feval(transform, ysim__1);
end
% Instantiate a dseries object (with all the endogenous variables)
alldeviations = dseries(transpose(endo_simul__1-endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:)));
alldeviations = dseries(transpose(endo_simul__1-endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
if nargout>2
allirfs = dseries(transpose(endo_simul__1), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:)));
allirfs = dseries(transpose(endo_simul__1), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
end
% Extract a sub-dseries object
if deterministicshockflag
......@@ -201,6 +201,6 @@ for i=1:length(listofshocks)
end
if nargout>1
baseline = dseries(transpose(endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), cellstr(DynareModel.endo_names_tex(1:M_.orig_endo_nbr,:)));
baseline = dseries(transpose(endo_simul__0), initialcondition.init, endonames(1:M_.orig_endo_nbr), DynareModel.endo_names_tex(1:M_.orig_endo_nbr));
baseline = [baseline, innovationbaseline];
end
\ No newline at end of file
......@@ -18,7 +18,7 @@ function simulation = simul_backward_model(initialconditions, samplesize, innova
% [3] If the first input argument is empty, the endogenous variables are initialized with 0, or if available with the informations
% provided thrtough the histval block.
% Copyright (C) 2012-2017 Dynare Team
% Copyright (C) 2012-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -47,7 +47,7 @@ else
end
% Set array holding innovations values.
Innovations = zeros(samplesize, M_.exo_nbr);
exonames = cellstr(M_.exo_names);
exonames = M_.exo_names;
for i=1:M_.exo_nbr
if ismember(exonames{i}, innovations.name)
Innovations(:,i) = innovations{exonames{i}}.data(1:samplesize);
......
......@@ -2,7 +2,7 @@ function [initialconditions, samplesize, innovations, DynareOptions, DynareModel
% Initialization of the routines simulating backward models.
% Copyright (C) 2017 Dynare Team
% Copyright (C) 2017-2018 Dynare Team
%
% This file is part of Dynare.
%
......@@ -41,7 +41,7 @@ if ~isdseries(initialconditions)
end
% Test if the first argument contains all the lagged endogenous variables
endonames = cellstr(DynareModel.endo_names);
endonames = DynareModel.endo_names;
missingendogenousvariables = setdiff(endonames, initialconditions.name);
endolags = get_lags_on_endogenous_variables(DynareModel);
endolags_ = endolags(find(endolags));
......@@ -84,7 +84,7 @@ if missinginitialcondition
end
% If the model has lags on the exogenous variables, test if we have corresponding initial conditions.
exonames = cellstr(DynareModel.exo_names);
exonames = DynareModel.exo_names;
missingexogenousvariables = setdiff(exonames, initialconditions.name);
exolags = get_lags_on_exogenous_variables(DynareModel);
exolags_ = exolags(find(exolags));
......@@ -131,16 +131,16 @@ k = 0;
for i = DynareModel.orig_endo_nbr+1:DynareModel.endo_nbr
k = k+1;
if DynareModel.aux_vars(k).type==1
if ismember(deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index,:)), initialconditions.name)
initialconditions{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).endo_index, :))} = ...
initialconditions{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :))}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
if ismember(DynareModel.endo_names{DynareModel.aux_vars(k).orig_index}, initialconditions.name)
initialconditions{DynareModel.endo_names{DynareModel.aux_vars(k).endo_index}} = ...
initialconditions{DynareModel.endo_names{DynareModel.aux_vars(k).orig_index}}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
else