Change get_prior_info.m to reflect user-specified bounds. Also corrects LaTeX-code
parent
c2345fd23b
commit
16b7a9ed98
|
@ -54,13 +54,32 @@ options_.order = 1;
|
||||||
|
|
||||||
[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
|
[xparam1,estim_params_,bayestopt_,lb,ub,M_] = set_prior(estim_params_,M_,options_);
|
||||||
if plt_flag
|
if plt_flag
|
||||||
plot_priors(bayestopt_,M_,options_);
|
plot_priors(bayestopt_,M_,estim_params_,options_)
|
||||||
end
|
end
|
||||||
|
|
||||||
PriorNames = { 'Beta' , 'Gamma' , 'Gaussian' , 'Inverted Gamma' , 'Uniform' , 'Inverted Gamma -- 2' };
|
PriorNames = { 'Beta' , 'Gamma' , 'Gaussian' , 'Inverted Gamma' , 'Uniform' , 'Inverted Gamma -- 2' };
|
||||||
|
|
||||||
if size(M_.param_names,1)==size(M_.param_names_tex,1)% All the parameters have a TeX name.
|
if size(M_.param_names,1)==size(M_.param_names_tex,1)% All the parameters have a TeX name.
|
||||||
fidTeX = fopen('priors_data.tex','w+');
|
fidTeX = fopen('priors_data.tex','w+');
|
||||||
|
fprintf(fidTeX,'%% TeX-table generated by get_prior_info (Dynare).\n');
|
||||||
|
fprintf(fidTeX,'%% Prior Information\n');
|
||||||
|
fprintf(fidTeX,['%% ' datestr(now,0)]);
|
||||||
|
fprintf(fidTeX,' \n');
|
||||||
|
fprintf(fidTeX,' \n');
|
||||||
|
fprintf(fidTeX,'\\begin{center}\n');
|
||||||
|
fprintf(fidTeX,'\\begin{longtable}{l|ccccccc} \n');
|
||||||
|
fprintf(fidTeX,'\\caption{Prior information (parameters)}\\\\\n ');
|
||||||
|
fprintf(fidTeX,'\\label{Table:Prior}\\\\\n');
|
||||||
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||||
|
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Lower Bound & Upper Bound & LB Untrunc. 80\\%% HPDI & UB Untrunc. 80\\%% HPDI \\\\ \n');
|
||||||
|
fprintf(fidTeX,'\\hline \\endfirsthead \n');
|
||||||
|
fprintf(fidTeX,'\\caption{(continued)}\\\\\n ');
|
||||||
|
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
|
||||||
|
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Lower Bound & Upper Bound & LB Untrunc. 80\\%% HPDI & UB Untrunc. 80\\%% HPDI \\\\ \n');
|
||||||
|
fprintf(fidTeX,'\\hline \\endhead \n');
|
||||||
|
fprintf(fidTeX,'\\hline \\multicolumn{8}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
|
||||||
|
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
|
||||||
|
|
||||||
% Column 1: a string for the name of the prior distribution.
|
% Column 1: a string for the name of the prior distribution.
|
||||||
% Column 2: the prior mean.
|
% Column 2: the prior mean.
|
||||||
% Column 3: the prior standard deviation.
|
% Column 3: the prior standard deviation.
|
||||||
|
@ -81,24 +100,43 @@ if size(M_.param_names,1)==size(M_.param_names_tex,1)% All the parameters have a
|
||||||
case { 1 , 5 }
|
case { 1 , 5 }
|
||||||
LowerBound = bayestopt_.p3(i);
|
LowerBound = bayestopt_.p3(i);
|
||||||
UpperBound = bayestopt_.p4(i);
|
UpperBound = bayestopt_.p4(i);
|
||||||
case { 2 , 4 , 6 }
|
if ~isinf(bayestopt_.lb(i))
|
||||||
|
LowerBound=max(LowerBound,bayestopt_.lb(i));
|
||||||
|
end
|
||||||
|
if ~isinf(bayestopt_.ub(i))
|
||||||
|
UpperBound=min(UpperBound,bayestopt_.ub(i));
|
||||||
|
end
|
||||||
|
case { 2 , 4 , 6 }
|
||||||
LowerBound = bayestopt_.p3(i);
|
LowerBound = bayestopt_.p3(i);
|
||||||
UpperBound = '$\infty$';
|
if ~isinf(bayestopt_.lb(i))
|
||||||
|
LowerBound=max(LowerBound,bayestopt_.lb(i));
|
||||||
|
end
|
||||||
|
if ~isinf(bayestopt_.ub(i))
|
||||||
|
UpperBound=bayestopt_.ub(i);
|
||||||
|
else
|
||||||
|
UpperBound = '$\infty$';
|
||||||
|
end
|
||||||
case 3
|
case 3
|
||||||
if isinf(bayestopt_.p3(i))
|
if isinf(bayestopt_.p3(i)) && isinf(bayestopt_.lb(i))
|
||||||
LowerBound = '$-\infty$';
|
LowerBound = '$-\infty$';
|
||||||
else
|
else
|
||||||
LowerBound = bayestopt_.p3(i);
|
LowerBound = bayestopt_.p3(i);
|
||||||
|
if ~isinf(bayestopt_.lb(i))
|
||||||
|
LowerBound=max(LowerBound,bayestopt_.lb(i));
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if isinf(bayestopt_.p4(i))
|
if isinf(bayestopt_.p4(i)) && isinf(bayestopt_.ub(i))
|
||||||
UpperBound = '$\infty$';
|
UpperBound = '$\infty$';
|
||||||
else
|
else
|
||||||
UpperBound = bayestopt_.p4(i);
|
UpperBound = bayestopt_.p4(i);
|
||||||
|
if ~isinf(bayestopt_.ub(i))
|
||||||
|
UpperBound=min(UpperBound,bayestopt_.ub(i));
|
||||||
|
end
|
||||||
end
|
end
|
||||||
otherwise
|
otherwise
|
||||||
error('get_prior_info:: Dynare bug!')
|
error('get_prior_info:: Dynare bug!')
|
||||||
end
|
end
|
||||||
format_string = build_format_string(bayestopt_,i);
|
format_string = build_format_string(PriorStandardDeviation,LowerBound,UpperBound);
|
||||||
fprintf(fidTeX,format_string, ...
|
fprintf(fidTeX,format_string, ...
|
||||||
TexName, ...
|
TexName, ...
|
||||||
PriorShape, ...
|
PriorShape, ...
|
||||||
|
@ -109,6 +147,9 @@ if size(M_.param_names,1)==size(M_.param_names_tex,1)% All the parameters have a
|
||||||
PriorIntervals(i,1), ...
|
PriorIntervals(i,1), ...
|
||||||
PriorIntervals(i,2) );
|
PriorIntervals(i,2) );
|
||||||
end
|
end
|
||||||
|
fprintf(fidTeX,'\\end{longtable}\n ');
|
||||||
|
fprintf(fidTeX,'\\end{center}\n');
|
||||||
|
fprintf(fidTeX,'%% End of TeX file.\n');
|
||||||
fclose(fidTeX);
|
fclose(fidTeX);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,19 +232,19 @@ end
|
||||||
|
|
||||||
options_.order = order;
|
options_.order = order;
|
||||||
|
|
||||||
function format_string = build_format_string(bayestopt,i)
|
function format_string = build_format_string(PriorStandardDeviation,LowerBound,UpperBound)
|
||||||
format_string = ['%s & %s & %6.4f &'];
|
format_string = ['%s & %s & %6.4f &'];
|
||||||
if isinf(bayestopt.p2(i))
|
if ~isnumeric(PriorStandardDeviation)
|
||||||
format_string = [ format_string , ' %s &'];
|
format_string = [ format_string , ' %s &'];
|
||||||
else
|
else
|
||||||
format_string = [ format_string , ' %6.4f &'];
|
format_string = [ format_string , ' %6.4f &'];
|
||||||
end
|
end
|
||||||
if isinf(bayestopt.p3(i))
|
if ~isnumeric(LowerBound)
|
||||||
format_string = [ format_string , ' %s &'];
|
format_string = [ format_string , ' %s &'];
|
||||||
else
|
else
|
||||||
format_string = [ format_string , ' %6.4f &'];
|
format_string = [ format_string , ' %6.4f &'];
|
||||||
end
|
end
|
||||||
if isinf(bayestopt.p4(i))
|
if ~isnumeric(UpperBound)
|
||||||
format_string = [ format_string , ' %s &'];
|
format_string = [ format_string , ' %s &'];
|
||||||
else
|
else
|
||||||
format_string = [ format_string , ' %6.4f &'];
|
format_string = [ format_string , ' %6.4f &'];
|
||||||
|
|
Loading…
Reference in New Issue