New version with the shape of the likelihood kernel on the top of posterior shape;
Use of one single loop, by merging the previous three cases, for easier parallelizing. git-svn-id: https://www.dynare.org/svn/dynare/trunk@2773 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
d10423ec19
commit
27850744ba
|
@ -39,7 +39,8 @@ global bayestopt_ M_ options_
|
||||||
|
|
||||||
TeX = options_.TeX;
|
TeX = options_.TeX;
|
||||||
[ s_min, k ] = min(diag(hessian)) ;
|
[ s_min, k ] = min(diag(hessian)) ;
|
||||||
|
fval = DsgeLikelihood(x,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
||||||
|
bayestopt_.penalty=fval;
|
||||||
disp(' ')
|
disp(' ')
|
||||||
disp('MODE CHECK')
|
disp('MODE CHECK')
|
||||||
disp(' ')
|
disp(' ')
|
||||||
|
@ -59,69 +60,13 @@ if TeX
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if nbplt == 1
|
for plt = 1:nbplt,
|
||||||
if TeX
|
if TeX
|
||||||
NAMES = [];
|
NAMES = [];
|
||||||
TeXNAMES = [];
|
TeXNAMES = [];
|
||||||
end
|
end
|
||||||
hh = figure('Name','Check plots');
|
hh = figure('Name','Check plots');
|
||||||
for k=1:length(x)
|
for k=1:min(nstar,length(x)-(plt-1)*nstar)
|
||||||
subplot(nr,nc,k)
|
|
||||||
[name,texname] = get_the_name(k,TeX);
|
|
||||||
if TeX
|
|
||||||
NAMES = strvcat(NAMES,name);
|
|
||||||
TeXNAMES = strvcat(TeXNAMES,texname);
|
|
||||||
end
|
|
||||||
xx = x;
|
|
||||||
l1 = max(lb(k),0.8*x(k)); % kk -> k
|
|
||||||
l2 = min(ub(k),1.2*x(k)); % kk -> k
|
|
||||||
z = [l1:(l2-l1)/20:l2];
|
|
||||||
y = zeros(length(z),1);
|
|
||||||
for i=1:length(z)
|
|
||||||
xx(k) = z(i); % kk -> k
|
|
||||||
if isempty(strmatch('dsge_prior_weight',M_.param_names))
|
|
||||||
y(i) = DsgeLikelihood(xx,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
|
||||||
else
|
|
||||||
y(i) = DsgeVarLikelihood(xx,gend);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
plot(z,y)
|
|
||||||
hold on
|
|
||||||
yl=get(gca,'ylim');
|
|
||||||
plot([x(k) x(k)],yl,'c','LineWidth', 1);% kk -> k
|
|
||||||
title(name,'interpreter','none');
|
|
||||||
hold off
|
|
||||||
drawnow
|
|
||||||
end
|
|
||||||
eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(1) '.eps' ]);
|
|
||||||
if ~exist('OCTAVE_VERSION')
|
|
||||||
eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(1)]);
|
|
||||||
saveas(hh,[M_.fname '_CheckPlots' int2str(1) '.fig']);
|
|
||||||
end
|
|
||||||
if options_.nograph, close(hh), end
|
|
||||||
% TeX eps loader file
|
|
||||||
if TeX
|
|
||||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
|
||||||
for jj = 1:length(x)
|
|
||||||
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
|
|
||||||
end
|
|
||||||
fprintf(fidTeX,'\\centering \n');
|
|
||||||
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_CheckPlots%s}\n',M_.fname,int2str(1));
|
|
||||||
fprintf(fidTeX,'\\caption{Priors.}');
|
|
||||||
fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n',int2str(1));
|
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
|
||||||
fprintf(fidTeX,'\n');
|
|
||||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
|
||||||
fclose(fidTeX);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for plt = 1:nbplt-1
|
|
||||||
if TeX
|
|
||||||
NAMES = [];
|
|
||||||
TeXNAMES = [];
|
|
||||||
end
|
|
||||||
hh = figure('Name','Check plots');
|
|
||||||
for k=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);
|
||||||
|
@ -130,16 +75,27 @@ else
|
||||||
TeXNAMES = strvcat(TeXNAMES,texname);
|
TeXNAMES = strvcat(TeXNAMES,texname);
|
||||||
end
|
end
|
||||||
xx = x;
|
xx = x;
|
||||||
l1 = max(lb(kk),0.8*x(kk));
|
l1 = max(lb(kk),0.5*x(kk));
|
||||||
l2 = min(ub(kk),1.2*x(kk));
|
l2 = min(ub(kk),1.5*x(kk));
|
||||||
z = [l1:(l2-l1)/20:l2];
|
z = [l1:(l2-l1)/20:l2];
|
||||||
y = zeros(length(z),1);
|
if options_.mode_check_nolik==0,
|
||||||
|
y = zeros(length(z),2);
|
||||||
|
dy = priordens(xx,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
||||||
|
end
|
||||||
for i=1:length(z)
|
for i=1:length(z)
|
||||||
xx(kk) = z(i);
|
xx(kk) = z(i);
|
||||||
if isempty(strmatch('dsge_prior_weight',M_.param_names))
|
if isempty(strmatch('dsge_prior_weight',M_.param_names)),
|
||||||
y(i) = DsgeLikelihood(xx,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
try
|
||||||
|
y(i,1) = DsgeLikelihood(xx,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
||||||
|
catch
|
||||||
|
y(i,1) = bayestopt_.penalty;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
y(i) = DsgeVarLikelihood(xx,gend);
|
y(i,1) = DsgeVarLikelihood(xx,gend);
|
||||||
|
end
|
||||||
|
if options_.mode_check_nolik==0,
|
||||||
|
lnprior = priordens(xx,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
||||||
|
y(i,2) = (y(i,1)+lnprior-dy);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
plot(z,y);
|
plot(z,y);
|
||||||
|
@ -150,6 +106,18 @@ else
|
||||||
hold off
|
hold off
|
||||||
drawnow
|
drawnow
|
||||||
end
|
end
|
||||||
|
if options_.mode_check_nolik==0,
|
||||||
|
if exist('OCTAVE_VERSION'),
|
||||||
|
axes('outerposition',[0.3 0.93 0.42 0.07],'box','on'),
|
||||||
|
else
|
||||||
|
axes('position',[0.3 0.01 0.42 0.05],'box','on'),
|
||||||
|
end
|
||||||
|
plot([0.48 0.68],[0.5 0.5],'color',[0 0.5 0])
|
||||||
|
hold on, plot([0.04 0.24],[0.5 0.5],'b')
|
||||||
|
set(gca,'xlim',[0 1],'ylim',[0 1],'xtick',[],'ytick',[])
|
||||||
|
text(0.25,0.5,'log-post')
|
||||||
|
text(0.69,0.5,'log-lik kernel')
|
||||||
|
end
|
||||||
eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(plt) '.eps']);
|
eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(plt) '.eps']);
|
||||||
if ~exist('OCTAVE_VERSION')
|
if ~exist('OCTAVE_VERSION')
|
||||||
eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(plt)]);
|
eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(plt)]);
|
||||||
|
@ -169,67 +137,6 @@ else
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
fprintf(fidTeX,'\\end{figure}\n');
|
||||||
fprintf(fidTeX,' \n');
|
fprintf(fidTeX,' \n');
|
||||||
end
|
end
|
||||||
end
|
|
||||||
hh = figure('Name','Check plots');
|
|
||||||
k = 1;
|
|
||||||
if TeX
|
|
||||||
NAMES = [];
|
|
||||||
TeXNAMES = [];
|
|
||||||
end
|
|
||||||
while (nbplt-1)*nstar+k <= length(x)
|
|
||||||
kk = (nbplt-1)*nstar+k;
|
|
||||||
[name,texname] = get_the_name(kk,TeX);
|
|
||||||
if TeX
|
|
||||||
NAMES = strvcat(NAMES,name);
|
|
||||||
TeXNAMES = strvcat(TeXNAMES,texname);
|
|
||||||
end
|
|
||||||
if lr ~= 0
|
|
||||||
subplot(lr,lc,k)
|
|
||||||
else
|
|
||||||
subplot(nr,nc,k)
|
|
||||||
end
|
|
||||||
xx = x;
|
|
||||||
l1 = max(lb(kk),0.8*x(kk));
|
|
||||||
l2 = min(ub(kk),1.2*x(kk));
|
|
||||||
z = [l1:(l2-l1)/20:l2];
|
|
||||||
y = zeros(length(z),1);
|
|
||||||
for i=1:length(z)
|
|
||||||
xx(kk) = z(i);
|
|
||||||
if isempty(strmatch('dsge_prior_weight',M_.param_names))
|
|
||||||
y(i) = DsgeLikelihood(xx,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
|
||||||
else
|
|
||||||
y(i) = DsgeVarLikelihood(xx,gend);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
plot(z,y)
|
|
||||||
hold on
|
|
||||||
yl=get(gca,'ylim');
|
|
||||||
plot( [x(kk) x(kk)], yl, 'c', 'LineWidth', 1)
|
|
||||||
title(name,'interpreter','none')
|
|
||||||
hold off
|
|
||||||
k = k + 1;
|
|
||||||
drawnow
|
|
||||||
end
|
|
||||||
eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(nbplt) '.eps']);
|
|
||||||
if ~exist('OCTAVE_VERSION')
|
|
||||||
eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(nbplt)]);
|
|
||||||
saveas(hh,[M_.fname '_CheckPlots' int2str(nbplt) '.fig']);
|
|
||||||
end
|
|
||||||
if options_.nograph, close(hh), end
|
|
||||||
if TeX
|
|
||||||
fprintf(fidTeX,'\\begin{figure}[H]\n');
|
|
||||||
for jj = 1:lr*lc
|
|
||||||
fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n',deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
|
|
||||||
end
|
|
||||||
fprintf(fidTeX,'\\centering \n');
|
|
||||||
fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_CheckPlots%s}\n',M_.fname,int2str(nbplt));
|
|
||||||
fprintf(fidTeX,'\\caption{Check plots.}');
|
|
||||||
fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n',int2str(nbplt));
|
|
||||||
fprintf(fidTeX,'\\end{figure}\n');
|
|
||||||
fprintf(fidTeX,' \n');
|
|
||||||
fprintf(fidTeX,'%% End of TeX file.\n');
|
|
||||||
fclose(fidTeX);
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
% SA 07-31-2004 * New default : no more than nine plots per figure.
|
% SA 07-31-2004 * New default : no more than nine plots per figure.
|
||||||
|
|
Loading…
Reference in New Issue