Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dóra Kocsis
dynare
Commits
16b7a9ed
Commit
16b7a9ed
authored
11 years ago
by
Johannes Pfeifer
Browse files
Options
Downloads
Patches
Plain Diff
Change get_prior_info.m to reflect user-specified bounds. Also corrects LaTeX-code
parent
c2345fd2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/get_prior_info.m
+51
-10
51 additions, 10 deletions
matlab/get_prior_info.m
with
51 additions
and
10 deletions
matlab/get_prior_info.m
+
51
−
10
View file @
16b7a9ed
...
...
@@ -54,13 +54,32 @@ options_.order = 1;
[
xparam1
,
estim_params_
,
bayestopt_
,
lb
,
ub
,
M_
]
=
set_prior
(
estim_params_
,
M_
,
options_
);
if
plt_flag
plot_priors
(
bayestopt_
,
M_
,
options_
)
;
plot_priors
(
bayestopt_
,
M_
,
estim_params_
,
options_
)
end
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.
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 2: the prior mean.
% 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
}
LowerBound
=
bayestopt_
.
p3
(
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
);
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
if
isinf
(
bayestopt_
.
p3
(
i
))
if
isinf
(
bayestopt_
.
p3
(
i
))
&&
isinf
(
bayestopt_
.
lb
(
i
))
LowerBound
=
'$-\infty$'
;
else
LowerBound
=
bayestopt_
.
p3
(
i
);
if
~
isinf
(
bayestopt_
.
lb
(
i
))
LowerBound
=
max
(
LowerBound
,
bayestopt_
.
lb
(
i
));
end
end
if
isinf
(
bayestopt_
.
p4
(
i
))
if
isinf
(
bayestopt_
.
p4
(
i
))
&&
isinf
(
bayestopt_
.
ub
(
i
))
UpperBound
=
'$\infty$'
;
else
UpperBound
=
bayestopt_
.
p4
(
i
);
if
~
isinf
(
bayestopt_
.
ub
(
i
))
UpperBound
=
min
(
UpperBound
,
bayestopt_
.
ub
(
i
));
end
end
otherwise
error
(
'get_prior_info:: Dynare bug!'
)
end
format_string
=
build_format_string
(
bayestopt_
,
i
);
format_string
=
build_format_string
(
PriorStandardDeviation
,
LowerBound
,
UpperBound
);
fprintf
(
fidTeX
,
format_string
,
...
TexName
,
...
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
,
2
)
);
end
fprintf
(
fidTeX
,
'\\end{longtable}\n '
);
fprintf
(
fidTeX
,
'\\end{center}\n'
);
fprintf
(
fidTeX
,
'%% End of TeX file.\n'
);
fclose
(
fidTeX
);
end
...
...
@@ -191,19 +232,19 @@ end
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 &'
];
if
is
inf
(
bayestopt
.
p2
(
i
)
)
if
~
is
numeric
(
PriorStandardDeviation
)
format_string
=
[
format_string
,
' %s &'
];
else
format_string
=
[
format_string
,
' %6.4f &'
];
end
if
is
inf
(
bayestopt
.
p3
(
i
)
)
if
~
is
numeric
(
LowerBound
)
format_string
=
[
format_string
,
' %s &'
];
else
format_string
=
[
format_string
,
' %6.4f &'
];
end
if
is
inf
(
bayestopt
.
p4
(
i
)
)
if
~
is
numeric
(
UpperBound
)
format_string
=
[
format_string
,
' %s &'
];
else
format_string
=
[
format_string
,
' %6.4f &'
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment