+ Removed globals from get_the_name routine. Added texinfo header.

time-shift
Stéphane Adjemian (Charybdis) 2011-09-14 19:03:56 +02:00
parent 9b3ca2b663
commit e2d98b9f32
6 changed files with 72 additions and 56 deletions

View File

@ -138,7 +138,7 @@ for i = 1:pages
boxplot = 1; boxplot = 1;
for j = 1:3 % Loop over parameters for j = 1:3 % Loop over parameters
k = k+1; k = k+1;
[nam,namtex] = get_the_name(k,TeX); [nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_);
for crit = 1:3% Loop over criteria for crit = 1:3% Loop over criteria
if crit == 1 if crit == 1
plt1 = UDIAG(:,1,k); plt1 = UDIAG(:,1,k);
@ -213,7 +213,7 @@ if reste
boxplot = 1; boxplot = 1;
for j = 1:reste for j = 1:reste
k = k+1; k = k+1;
[nam,namtex] = get_the_name(k,TeX); [nam,namtex] = get_the_name(k,TeX,M_,estim_params_,options_);
for crit = 1:3 for crit = 1:3
if crit == 1 if crit == 1
plt1 = UDIAG(:,1,k); plt1 = UDIAG(:,1,k);

View File

@ -69,7 +69,7 @@ for i=1:npar
hfig = figure('Name',figurename); hfig = figure('Name',figurename);
end end
end end
[nam,texnam] = get_the_name(i,TeX); [nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
if subplotnum == 1 if subplotnum == 1
NAMES = nam; NAMES = nam;
if TeX if TeX

View File

@ -66,7 +66,7 @@ if size(M_.param_names,1)==size(M_.param_names_tex,1)% All the parameters have a
PriorIntervals = prior_bounds(bayestopt_) ; PriorIntervals = prior_bounds(bayestopt_) ;
options_.prior_trunc = prior_trunc_backup ; options_.prior_trunc = prior_trunc_backup ;
for i=1:size(bayestopt_.name,1) for i=1:size(bayestopt_.name,1)
[tmp,TexName] = get_the_name(i,1); [tmp,TexName] = get_the_name(i,1,M_,estim_params_,options_);
PriorShape = PriorNames{ bayestopt_.pshape(i) }; PriorShape = PriorNames{ bayestopt_.pshape(i) };
PriorMean = bayestopt_.p1(i); PriorMean = bayestopt_.p1(i);
PriorStandardDeviation = bayestopt_.p2(i); PriorStandardDeviation = bayestopt_.p2(i);
@ -157,7 +157,7 @@ if info==2% Prior optimization.
disp('------------------') disp('------------------')
disp(' ') disp(' ')
for i = 1:length(xparams) for i = 1:length(xparams)
disp(['deep parameter ' int2str(i) ': ' get_the_name(i,0) '.']) disp(['deep parameter ' int2str(i) ': ' get_the_name(i,0,M_,estim_params_,options_) '.'])
disp([' Initial condition ....... ' num2str(xinit(i)) '.']) disp([' Initial condition ....... ' num2str(xinit(i)) '.'])
disp([' Prior mode .............. ' num2str(bayestopt_.p5(i)) '.']) disp([' Prior mode .............. ' num2str(bayestopt_.p5(i)) '.'])
disp([' Optimized prior mode .... ' num2str(xparams(i)) '.']) disp([' Optimized prior mode .... ' num2str(xparams(i)) '.'])

View File

@ -1,21 +1,46 @@
function [nam,texnam] = get_the_name(k,TeX) function [nam,texnam] = get_the_name(k,TeX,M_,estim_params_,options_)
% function [nam,texnam] = get_the_name(k,TeX) %@info:
% get the name of parameters %! @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}
% INPUTS %! @sp 1
% k: parameter number %! Returns the name of the estimated parameter number @var{k}, following the internal ordering of the estimated parameters.
% Tex=1: tex variable name %! @sp 2
% Tex=0: variable name (in the mod-file) %! @strong{Inputs}
% %! @sp 1
% OUTPUTS %! @table @ @var
% nam: variable name %! @item k
% texnam: variable tex name %! Integer scalar, parameter number.
% %! @item TeX
% SPECIAL REQUIREMENTS %! Integer scalar, if @var{TeX}==0 then @var{texnam} is not returned (empty matrix).
% none %! @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{McMCDiagnostics}, @ref{mode_check}, @ref{PlotPosteriorDistributions}, @ref{plot_priors}
%! @sp 2
%! @strong{This function calls:}
%! @sp 1
%! None.
%! @end deftypefn
%@eod:
% Copyright (C) 2004-2010 Dynare Team % Copyright (C) 2004-2011 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -32,8 +57,6 @@ function [nam,texnam] = get_the_name(k,TeX)
% 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 M_ estim_params_ options_
nam = []; nam = [];
texnam = []; texnam = [];
@ -77,15 +100,10 @@ elseif k <= (nvx+nvn+ncx+ncn)
texnam =['$ CC_{' tname '} $']; texnam =['$ CC_{' tname '} $'];
end end
else else
jj = k - (nvx+nvn+ncx+ncn); jj = k - (nvx+nvn+ncx+ncn);
jj1 = estim_params_.param_vals(jj,1); jj1 = estim_params_.param_vals(jj,1);
nam = deblank(M_.param_names(jj1,:)); nam = deblank(M_.param_names(jj1,:));
if TeX if TeX
texnam = ['$ ' deblank(M_.param_names_tex(jj1,:)) ' $']; texnam = ['$ ' deblank(M_.param_names_tex(jj1,:)) ' $'];
end end
end end
% SA 07-15-2004 Added TeX names.
% SA 12-02-2004 Changed non-TeX names format.
% SA 01-11-2005 v3TOv4

View File

@ -35,7 +35,7 @@ function mode_check(x,fval,hessian,gend,data,lb,ub,data_index,number_of_observat
% 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 bayestopt_ M_ options_ global bayestopt_ M_ options_ estim_params_
TeX = options_.TeX; TeX = options_.TeX;
if ~isempty(hessian); if ~isempty(hessian);
@ -77,7 +77,7 @@ for plt = 1:nbplt,
for k=1:min(nstar,length(x)-(plt-1)*nstar) for k=1:min(nstar,length(x)-(plt-1)*nstar)
subplot(nr,nc,k) subplot(nr,nc,k)
kk = (plt-1)*nstar+k; kk = (plt-1)*nstar+k;
[name,texname] = get_the_name(kk,TeX); [name,texname] = get_the_name(kk,TeX,M_,estim_params_,options_);
if TeX if TeX
if isempty(NAMES) if isempty(NAMES)
NAMES = name; NAMES = name;

View File

@ -1,4 +1,4 @@
function plot_priors(bayestopt_,M_,options_) function plot_priors(bayestopt_,M_,estim_params_,options_)
% function plot_priors % function plot_priors
% plots prior density % plots prior density
% %
@ -6,10 +6,10 @@ function plot_priors(bayestopt_,M_,options_)
% o bayestopt_ [structure] % o bayestopt_ [structure]
% o M_ [structure] % o M_ [structure]
% o options_ [structure] % o options_ [structure]
% %
% OUTPUTS % OUTPUTS
% None % None
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% None % None
@ -46,11 +46,11 @@ if nbplt == 1
h1 = figure('Name',figurename); h1 = figure('Name',figurename);
if TeX if TeX
TeXNAMES = []; TeXNAMES = [];
NAMES = []; NAMES = [];
end end
for i=1:npar for i=1:npar
[x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_); [x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_);
[nam,texnam] = get_the_name(i,TeX); [nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
if TeX if TeX
if i==1 if i==1
TeXNAMES = texnam; TeXNAMES = texnam;
@ -59,7 +59,7 @@ if nbplt == 1
TeXNAMES = char(TeXNAMES,texnam); TeXNAMES = char(TeXNAMES,texnam);
NAMES = char(NAMES,nam); NAMES = char(NAMES,nam);
end end
end end
subplot(nr,nc,i) subplot(nr,nc,i)
hh = plot(x,f,'-k','linewidth',2); hh = plot(x,f,'-k','linewidth',2);
set(hh,'color',[0.7 0.7 0.7]); set(hh,'color',[0.7 0.7 0.7]);
@ -77,7 +77,7 @@ if nbplt == 1
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:npar for jj = 1:npar
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
end end
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(1)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(1));
fprintf(fidTeX,'\\caption{Priors.}'); fprintf(fidTeX,'\\caption{Priors.}');
@ -92,13 +92,13 @@ else
hplt = figure('Name',figurename); hplt = figure('Name',figurename);
if TeX if TeX
TeXNAMES = []; TeXNAMES = [];
NAMES = []; NAMES = [];
end end
for index=1:nstar for index=1:nstar
names = []; names = [];
i = (plt-1)*nstar + index; i = (plt-1)*nstar + index;
[nam,texnam] = get_the_name(i,TeX); [nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
[x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_); [x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_);
if TeX if TeX
if index==1 if index==1
TeXNAMES = texnam; TeXNAMES = texnam;
@ -125,24 +125,24 @@ else
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:nstar for jj = 1:nstar
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
end end
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(plt)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(plt));
fprintf(fidTeX,'\\caption{Priors.}'); fprintf(fidTeX,'\\caption{Priors.}');
fprintf(fidTeX,'\\label{Fig:Priors:%s}\n',int2str(plt)); fprintf(fidTeX,'\\label{Fig:Priors:%s}\n',int2str(plt));
fprintf(fidTeX,'\\end{figure}\n'); fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n'); fprintf(fidTeX,' \n');
end end
end % plt = 1:nbplt-1 end % plt = 1:nbplt-1
hplt = figure('Name',figurename); hplt = figure('Name',figurename);
if TeX if TeX
TeXNAMES = []; TeXNAMES = [];
NAMES = []; NAMES = [];
end end
for index=1:npar-(nbplt-1)*nstar for index=1:npar-(nbplt-1)*nstar
i = (nbplt-1)*nstar + index; i = (nbplt-1)*nstar + index;
[x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_); [x,f,abscissa,dens,binf,bsup] = draw_prior_density(i,bayestopt_);
[nam,texnam] = get_the_name(i,TeX); [nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
if TeX if TeX
if index==1 if index==1
TeXNAMES = texnam; TeXNAMES = texnam;
@ -151,12 +151,12 @@ else
TeXNAMES = char(TeXNAMES,texnam); TeXNAMES = char(TeXNAMES,texnam);
NAMES = char(NAMES,nam); NAMES = char(NAMES,nam);
end end
end end
if lr if lr
subplot(lc,lr,index); subplot(lc,lr,index);
else else
subplot(nr,nc,index); subplot(nr,nc,index);
end end
hh = plot(x,f,'-k','linewidth',2); hh = plot(x,f,'-k','linewidth',2);
set(hh,'color',[0.7 0.7 0.7]); set(hh,'color',[0.7 0.7 0.7]);
box on box on
@ -173,7 +173,7 @@ else
fprintf(fidTeX,'\\begin{figure}[H]\n'); fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:npar-(nbplt-1)*nstar for jj = 1:npar-(nbplt-1)*nstar
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:))); fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
end end
fprintf(fidTeX,'\\centering\n'); fprintf(fidTeX,'\\centering\n');
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(nbplt)); fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n',M_.fname,int2str(nbplt));
fprintf(fidTeX,'\\caption{Priors.}'); fprintf(fidTeX,'\\caption{Priors.}');
@ -183,6 +183,4 @@ else
fprintf(fidTeX,'%% End of TeX file.\n'); fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX); fclose(fidTeX);
end end
end end
% SA 01-11-2005 v3TOv4