1function print_table_prior(lb, ub, DynareOptions, ModelInfo, BayesInfo, EstimationInfo) 2 3% This routine prints in the command window some descriptive statistics about the prior distribution. 4 5% Copyright (C) 2015-2017 Dynare Team 6% 7% This file is part of Dynare. 8% 9% Dynare is free software: you can redistribute it and/or modify 10% it under the terms of the GNU General Public License as published by 11% the Free Software Foundation, either version 3 of the License, or 12% (at your option) any later version. 13% 14% Dynare is distributed in the hope that it will be useful, 15% but WITHOUT ANY WARRANTY; without even the implied warranty of 16% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17% GNU General Public License for more details. 18% 19% You should have received a copy of the GNU General Public License 20% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 21 22PriorNames = 'Beta'; 23PriorNames = strvcat(PriorNames,'Gamma'); 24PriorNames = strvcat(PriorNames,'Gaussian'); 25PriorNames = strvcat(PriorNames,'Inverted Gamma'); 26PriorNames = strvcat(PriorNames,'Uniform'); 27PriorNames = strvcat(PriorNames,'Inverted Gamma -- 2'); 28PriorNames = strvcat(PriorNames,'Dirichlet'); 29PriorNames = strvcat(PriorNames,'Weibull'); 30 31n = size(BayesInfo.name,1); % Numbe rof estimated parameters. 32 33l1 = printline(10, '-'); 34T1 = strvcat(l1, 'PARAMETER '); 35T1 = strvcat(T1, l1); 36 37l2 = printline(133, '-'); 38T2 = strvcat(l2, sprintf('Prior shape \t Prior mean \t Prior mode \t Prior std. \t Prior lb \t Prior ub \t Prior HPD lb \t Prior HPH ub')); 39T2 = strvcat(T2, l2); 40 41prior_trunc_backup = DynareOptions.prior_trunc ; 42DynareOptions.prior_trunc = (1-DynareOptions.prior_interval)/2 ; 43PriorIntervals = prior_bounds(BayesInfo, DynareOptions.prior_trunc) ; 44DynareOptions.prior_trunc = prior_trunc_backup ; 45 46RESIZE = false; 47 48for i=1:size(BayesInfo.name,1) 49 [Name,tmp] = get_the_name(i,1,ModelInfo,EstimationInfo,DynareOptions); 50 if length(Name)>size(T1,2) 51 resize = true; 52 else 53 resize = false; 54 end 55 T1 = strvcat(T1, Name); 56 if resize 57 RESIZE = true; 58 l1 = printline(length(Name)); 59 T1(1,:) = l1; 60 T1(3,:) = l1; 61 end 62 PriorShape = PriorNames(BayesInfo.pshape(i),:); 63 PriorMean = BayesInfo.p1(i); 64 PriorMode = BayesInfo.p5(i); 65 PriorStandardDeviation = BayesInfo.p2(i); 66 switch BayesInfo.pshape(i) 67 case { 1 , 5 } 68 LowerBound = BayesInfo.p3(i); 69 UpperBound = BayesInfo.p4(i); 70 if ~isinf(lb(i)) 71 LowerBound=max(LowerBound,lb(i)); 72 end 73 if ~isinf(ub(i)) 74 UpperBound=min(UpperBound,ub(i)); 75 end 76 case { 2 , 4 , 6 , 8} 77 LowerBound = BayesInfo.p3(i); 78 if ~isinf(lb(i)) 79 LowerBound=max(LowerBound,lb(i)); 80 end 81 if ~isinf(ub(i)) 82 UpperBound=ub(i); 83 else 84 UpperBound = Inf; 85 end 86 case 3 87 if isinf(BayesInfo.p3(i)) && isinf(lb(i)) 88 LowerBound = -Inf; 89 else 90 LowerBound = BayesInfo.p3(i); 91 if ~isinf(lb(i)) 92 LowerBound=max(LowerBound,lb(i)); 93 end 94 end 95 if isinf(BayesInfo.p4(i)) && isinf(ub(i)) 96 UpperBound = Inf; 97 else 98 UpperBound = BayesInfo.p4(i); 99 if ~isinf(ub(i)) 100 UpperBound=min(UpperBound,ub(i)); 101 end 102 end 103 otherwise 104 error('get_prior_info:: Dynare bug!') 105 end 106 format_string = build_format_string(PriorMode, PriorStandardDeviation,LowerBound,UpperBound); 107 str = sprintf(format_string, ... 108 PriorShape, ... 109 PriorMean, ... 110 PriorMode, ... 111 PriorStandardDeviation, ... 112 LowerBound, ... 113 UpperBound, ... 114 PriorIntervals.lb(i), ... 115 PriorIntervals.ub(i) ); 116 T2 = strvcat(T2, str); 117end 118 119T1 = strvcat(T1, l1); 120T2 = strvcat(T2, l2); 121 122skipline(2) 123 124if RESIZE 125 l0 = printline(2); 126 T0 = strvcat(l0,' '); 127 T0 = strvcat(T0, l0); 128 T0 = strvcat(T0, repmat(' ', n, 1)); 129 T0 = strvcat(T0, l0); 130 disp([T1, T0, T2]) 131else 132 disp([T1, T2]) 133end 134 135skipline(2) 136 137 138function format_string = build_format_string(PriorMode,PriorStandardDeviation,LowerBound,UpperBound) 139format_string = ['%s \t %6.4f \t']; 140if isnan(PriorMode) 141 format_string = [ format_string , ' %s \t']; 142else 143 format_string = [ format_string , ' %6.4f \t']; 144end 145if ~isnumeric(PriorStandardDeviation) 146 format_string = [ format_string , ' %s \t']; 147else 148 format_string = [ format_string , ' %6.4f \t']; 149end 150if ~isnumeric(LowerBound) 151 format_string = [ format_string , ' %s \t']; 152else 153 format_string = [ format_string , ' %6.4f \t']; 154end 155if ~isnumeric(UpperBound) 156 format_string = [ format_string , ' %s \t']; 157else 158 format_string = [ format_string , ' %6.4f \t']; 159end 160format_string = [ format_string , ' %6.4f \t %6.4f'];