File: print_table_prior.m

package info (click to toggle)
dynare 4.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,408 kB
  • sloc: cpp: 84,998; ansic: 29,058; pascal: 13,843; sh: 4,833; objc: 4,236; yacc: 3,622; makefile: 2,278; lex: 1,541; python: 236; lisp: 69; xml: 8
file content (160 lines) | stat: -rw-r--r-- 4,946 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function print_table_prior(lb, ub, DynareOptions, ModelInfo, BayesInfo, EstimationInfo)

% This routine prints in the command window some descriptive statistics about the prior distribution.

% Copyright (C) 2015-2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

PriorNames = 'Beta';
PriorNames = strvcat(PriorNames,'Gamma');
PriorNames = strvcat(PriorNames,'Gaussian');
PriorNames = strvcat(PriorNames,'Inverted Gamma');
PriorNames = strvcat(PriorNames,'Uniform');
PriorNames = strvcat(PriorNames,'Inverted Gamma -- 2');
PriorNames = strvcat(PriorNames,'Dirichlet');
PriorNames = strvcat(PriorNames,'Weibull');

n = size(BayesInfo.name,1); % Numbe rof estimated parameters.

l1 = printline(10, '-');
T1 = strvcat(l1, 'PARAMETER ');
T1 = strvcat(T1, l1);

l2 = printline(133, '-');
T2 = 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'));
T2 = strvcat(T2, l2);

prior_trunc_backup = DynareOptions.prior_trunc ;
DynareOptions.prior_trunc = (1-DynareOptions.prior_interval)/2 ;
PriorIntervals = prior_bounds(BayesInfo, DynareOptions.prior_trunc) ;
DynareOptions.prior_trunc = prior_trunc_backup ;

RESIZE = false;

for i=1:size(BayesInfo.name,1)
    [Name,tmp] = get_the_name(i,1,ModelInfo,EstimationInfo,DynareOptions);
    if length(Name)>size(T1,2)
        resize = true;
    else
        resize = false;
    end
    T1 = strvcat(T1, Name);
    if resize
        RESIZE = true;
        l1 = printline(length(Name));
        T1(1,:) = l1;
        T1(3,:) = l1;
    end
    PriorShape = PriorNames(BayesInfo.pshape(i),:);
    PriorMean = BayesInfo.p1(i);
    PriorMode = BayesInfo.p5(i);
    PriorStandardDeviation = BayesInfo.p2(i);
    switch BayesInfo.pshape(i)
      case { 1 , 5 }
        LowerBound = BayesInfo.p3(i);
        UpperBound = BayesInfo.p4(i);
        if ~isinf(lb(i))
            LowerBound=max(LowerBound,lb(i));
        end
        if ~isinf(ub(i))
            UpperBound=min(UpperBound,ub(i));
        end
      case { 2 , 4 , 6 , 8}
        LowerBound = BayesInfo.p3(i);
        if ~isinf(lb(i))
            LowerBound=max(LowerBound,lb(i));
        end
        if ~isinf(ub(i))
            UpperBound=ub(i);
        else
            UpperBound = Inf;
        end
      case 3
        if isinf(BayesInfo.p3(i)) && isinf(lb(i))
            LowerBound = -Inf;
        else
            LowerBound = BayesInfo.p3(i);
            if ~isinf(lb(i))
                LowerBound=max(LowerBound,lb(i));
            end
        end
        if isinf(BayesInfo.p4(i)) && isinf(ub(i))
            UpperBound = Inf;
        else
            UpperBound = BayesInfo.p4(i);
            if ~isinf(ub(i))
                UpperBound=min(UpperBound,ub(i));
            end
        end
      otherwise
        error('get_prior_info:: Dynare bug!')
    end
    format_string = build_format_string(PriorMode, PriorStandardDeviation,LowerBound,UpperBound);
    str = sprintf(format_string, ...
                  PriorShape, ...
                  PriorMean, ...
                  PriorMode, ...
                  PriorStandardDeviation, ...
                  LowerBound, ...
                  UpperBound, ...
                  PriorIntervals.lb(i), ...
                  PriorIntervals.ub(i) );
    T2 = strvcat(T2, str);
end

T1 = strvcat(T1, l1);
T2 = strvcat(T2, l2);

skipline(2)

if RESIZE
    l0 = printline(2);
    T0 = strvcat(l0,'  ');
    T0 = strvcat(T0, l0);
    T0 = strvcat(T0, repmat('  ', n, 1));
    T0 = strvcat(T0, l0);
    disp([T1, T0, T2])
else
    disp([T1, T2])
end

skipline(2)


function format_string = build_format_string(PriorMode,PriorStandardDeviation,LowerBound,UpperBound)
format_string = ['%s \t %6.4f \t'];
if isnan(PriorMode)
    format_string = [ format_string , ' %s \t'];
else
    format_string = [ format_string , ' %6.4f \t'];
end
if ~isnumeric(PriorStandardDeviation)
    format_string = [ format_string , ' %s \t'];
else
    format_string = [ format_string , ' %6.4f \t'];
end
if ~isnumeric(LowerBound)
    format_string = [ format_string , ' %s \t'];
else
    format_string = [ format_string , ' %6.4f \t'];
end
if ~isnumeric(UpperBound)
    format_string = [ format_string , ' %s \t'];
else
    format_string = [ format_string , ' %6.4f \t'];
end
format_string = [ format_string , ' %6.4f \t %6.4f'];