time-shift
Johannes Pfeifer 2013-05-18 10:44:07 +02:00
commit 834e18c02c
53 changed files with 1804 additions and 1068 deletions

View File

@ -105,6 +105,7 @@ This is Dynare Reference Manual, version @value{VERSION}.
* Dynare invocation::
* The Model file::
* The Configuration File::
* Reporting::
* Examples::
* Dynare internal documentation and unitary tests::
* Bibliography::
@ -168,6 +169,7 @@ Expressions
* Parameters and variables::
* Operators::
* Functions::
* A few words of warning in stochastic context::
Parameters and variables
@ -577,8 +579,9 @@ addpath /Applications/Dynare/4.@var{x}.@var{y}/matlab
If you don't want to type this command every time you run Octave, you
can put it in a file called @file{.octaverc} in your home directory
(under Windows this will generally by @file{c:\Documents and
Settings\USERNAME\}). This file is run by Octave at every startup.
(under Windows this will generally be @file{c:\Documents and
Settings\USERNAME\} while under Mac OS X it is @file{/Users/USERNAME/}).
This file is run by Octave at every startup.
@node Some words of warning
@subsection Some words of warning
@ -595,8 +598,8 @@ your configuration). You must verify that there is no directory coming
from another version of Dynare than the one you are planning to use.
You have to be aware that adding other directories to your path can
potentially create problems, if some of your M-files have the same names
than Dynare files. Your files would then override Dynare files, and make
potentially create problems if any of your M-files have the same name
as a Dynare file. Your file would then override the Dynare file, making
Dynare unusable.
@node Dynare invocation
@ -865,8 +868,8 @@ alphabetical character and can't contain: @samp{()+-*/^=!;:@@#.} or
accentuated characters;
@item
@var{LATEX_NAME} indicates a valid LaTeX expression in math mode (not
including the dollar signs);
@var{LATEX_NAME} indicates a valid @LaTeX{} expression in math mode
(not including the dollar signs);
@item
@var{FUNCTION_NAME} indicates a valid MATLAB function name;
@ -891,9 +894,9 @@ Declarations of variables and parameters are made with the following commands:
This required command declares the endogenous variables in the
model. @xref{Conventions}, for the syntax of @var{VARIABLE_NAME} and
@var{MODEL_EXPRESSION}. Optionally it is possible to give a LaTeX name
to the variable or, if it is nonstationary, provide information regarding
its deflator.
@var{MODEL_EXPRESSION}. Optionally it is possible to give a @LaTeX{}
name to the variable or, if it is nonstationary, provide information
regarding its deflator.
@code{var} commands can appear several times in the file and Dynare will
concatenate them.
@ -938,7 +941,7 @@ var(deflator=A) i b;
This optional command declares the exogenous variables in the model.
@xref{Conventions}, for the syntax of @var{VARIABLE_NAME}. Optionally it
is possible to give a LaTeX name to the variable.
is possible to give a @LaTeX{} name to the variable.
Exogenous variables are required if the user wants to be able to apply
shocks to her model.
@ -960,8 +963,8 @@ varexo m gov;
This optional command declares exogenous deterministic variables in a
stochastic model. See @ref{Conventions}, for the syntax of
@var{VARIABLE_NAME}. Optionally it is possible to give a LaTeX name to
the variable.
@var{VARIABLE_NAME}. Optionally it is possible to give a @LaTeX{} name
to the variable.
It is possible to mix deterministic and stochastic shocks to build
models where agents know from the start of the simulation about future
@ -992,7 +995,7 @@ varexo_det tau;
This command declares parameters used in the model, in variable
initialization or in shocks declarations. See @ref{Conventions}, for the
syntax of @var{PARAMETER_NAME}. Optionally it is possible to give a
LaTeX name to the parameter.
@LaTeX{} name to the parameter.
The parameters must subsequently be assigned values (@pxref{Parameter
initialization}).
@ -1099,9 +1102,9 @@ end;
@descriptionhead
This optional command declares the trend variables in the
model. @xref{Conventions}, for the syntax of @var{MODEL_EXPRESSION} and
@var{VARIABLE_NAME}. Optionally it is possible to give a LaTeX name to
the variable.
model. @xref{Conventions}, for the syntax of @var{MODEL_EXPRESSION}
and @var{VARIABLE_NAME}. Optionally it is possible to give a @LaTeX{}
name to the variable.
The variable is assumed to have a multiplicative growth trend. For an
additive growth trend, use @code{log_trend_var} instead.
@ -1178,6 +1181,7 @@ Represents infinity.
* Parameters and variables::
* Operators::
* Functions::
* A few words of warning in stochastic context::
@end menu
@node Parameters and variables
@ -1250,6 +1254,13 @@ unary arithmetic operators: @code{+}, @code{-}
binary comparison operators (which evaluate to either @code{0} or
@code{1}): @code{<}, @code{>}, @code{<=}, @code{>=}, @code{==},
@code{!=}
Note that these operators are differentiable everywhere except on a
line of the 2-dimensional real plane. However for facilitating
convergence of Newton-type methods, Dynare assumes that, at the points
of non-differentiability, the partial derivatives of these operators
with respect to both arguments is equal to @math{0} (since this is the
value of the partial derivatives everywhere else).
@end itemize
The following special operators are accepted in @var{MODEL_EXPRESSION}
@ -1305,10 +1316,23 @@ Square root.
@defun abs (@var{x})
Absolute value.
Note that this function is not differentiable at @math{x=0}. However,
for facilitating convergence of Newton-type methods, Dynare assumes
that the derivative at @math{x=0} is equal to @math{0} (this
assumption comes from the observation that the derivative of
@math{abs(x)} is equal to @math{sign(x)} for @math{x\neq 0} and from
the convention for the derivative of @math{sign(x)} at @math{x=0}).
@end defun
@defun sign (@var{x})
Signum function.
Note that this function is not differentiable at @math{x=0}. However,
for facilitating convergence of Newton-type methods, Dynare assumes
that the derivative at @math{x=0} is equal to @math{0} (this assumption
comes from the observation that both the right- and left-derivatives
at this point exist and are equal to @math{0}).
@end defun
@defun sin (@var{x})
@ -1323,6 +1347,15 @@ Trigonometric functions.
@defun max (@var{a}, @var{b})
@defunx min (@var{a}, @var{b})
Maximum and minimum of two reals.
Note that these functions are differentiable everywhere except on a
line of the 2-dimensional real plane defined by @math{a=b}. However
for facilitating convergence of Newton-type methods, Dynare assumes
that, at the points of non-differentiability, the partial derivative
of these functions with respect to the first (resp. the second)
argument is equal to @math{1} (resp. to @math{0}) (@i{i.e.} the
derivatives at the kink are equal to the derivatives observed on the
half-plane where the function is equal to its first argument).
@end defun
@defun normcdf (@var{x})
@ -1405,6 +1438,25 @@ external_function(name = yetotherfuncname, nargs = 3,
@end deffn
@node A few words of warning in stochastic context
@subsection A few words of warning in stochastic context
The use of the following functions and operators is strongly
discouraged in a stochastic context: @code{max}, @code{min},
@code{abs}, @code{sign}, @code{<}, @code{>}, @code{<=}, @code{>=},
@code{==}, @code{!=}.
The reason is that the local approximation used by @code{stoch_simul}
or @code{estimation} will by nature ignore the non-linearities
introduced by these functions if the steady state is away from the
kink. And, if the steady state is exactly at the kink, then the
approximation will be bogus because the derivative of these functions
at the kink is bogus (as explained in the respective documentations of
these functions and operators).
Note that @code{extended_path} is not affected by this problem,
because it uses a global approximation method, not a local one.
@node Parameter initialization
@section Parameter initialization
@ -1557,6 +1609,7 @@ Don't create the static model file. This can be useful for models which
don't have a steady state.
@item differentiate_forward_vars
@itemx differentiate_forward_vars = ( @var{VARIABLE_NAME} [@var{VARIABLE_NAME} @dots{}] )
Tells Dynare to create a new auxiliary variable for each endogenous
variable that appears with a lead, such that the new variable is the
time differentiate of the original one. More precisely, if the model
@ -1564,6 +1617,11 @@ contains @code{x(+1)}, then a variable @code{AUX_DIFF_VAR} will be
created such that @code{AUX_DIFF_VAR=x-x(-1)}, and @code{x(+1)} will
be replaced with @code{x+AUX_DIFF_VAR(+1)}.
The transformation is applied to all endogenous variables with a lead
if the option is given without a list of variables. If there is a
list, the transformation is restricted to endogenous with a lead that
also appear in the list.
This option can useful for some deterministic simulations where
convergence is hard to obtain. Bad values for terminal conditions in
the case of very persistent dynamics or permanent shocks can hinder
@ -1620,7 +1678,7 @@ end;
@end deffn
Dynare has the ability to output the list of model equations to a
LaTeX file, using the @code{write_latex_dynamic_model} command. The
@LaTeX{} file, using the @code{write_latex_dynamic_model} command. The
static model can also be written with the
@code{write_latex_static_model} command.
@ -1630,21 +1688,21 @@ static model can also be written with the
@descriptionhead
This command creates a LaTeX file containing the (dynamic) model.
This command creates a @LaTeX{} file containing the (dynamic) model.
If your @file{.mod} file is @file{@var{FILENAME}.mod}, then Dynare
will create a file called @file{@var{FILENAME}_dynamic.tex},
containing the list of all the dynamic model equations.
If LaTeX names were given for variables and parameters
If @LaTeX{} names were given for variables and parameters
(@pxref{Variable declarations}), then those will be used; otherwise,
the plain text names will be used.
Time subscripts (@code{t}, @code{t+1}, @code{t-1}, @dots{}) will be
appended to the variable names, as LaTeX subscripts.
appended to the variable names, as @LaTeX{} subscripts.
Note that the model written in the TeX file will differ from the model
declared by the user in the following dimensions:
Note that the model written in the @TeX{} file will differ from the
model declared by the user in the following dimensions:
@itemize
@ -1668,7 +1726,7 @@ for a stochastic model, exogenous variables with leads or lags will
also have been replaced by new auxiliary variables and equations.
@end itemize
Compiling the TeX file requires the following Latex packages:
Compiling the @TeX{} file requires the following @LaTeX{} packages:
@code{geometry}, @code{fullpage}, @code{breqn}.
@end deffn
@ -1677,18 +1735,18 @@ Compiling the TeX file requires the following Latex packages:
@descriptionhead
This command creates a LaTeX file containing the static model.
This command creates a @LaTeX{} file containing the static model.
If your @file{.mod} file is @file{@var{FILENAME}.mod}, then Dynare
will create a file called @file{@var{FILENAME}_static.tex}, containing
the list of all the equations of the steady state model.
If LaTeX names were given for variables and parameters
If @LaTeX{} names were given for variables and parameters
(@pxref{Variable declarations}), then those will be used; otherwise,
the plain text names will be used.
Note that the model written in the TeX file will differ from the model
declared by the user in the some dimensions
Note that the model written in the @TeX{} file will differ from the
model declared by the user in the some dimensions
(@pxref{write_latex_dynamic_model} for details).
Also note that this command will not output the contents of the
@ -1696,7 +1754,7 @@ optional @code{steady_state_model} block (@pxref{steady_state_model});
it will rather output a static version (@i{i.e.} without leads and
lags) of the dynamic model declared in the @code{model} block.
Compiling the TeX file requires the following Latex packages:
Compiling the @TeX{} file requires the following @LaTeX{} packages:
@code{geometry}, @code{fullpage}, @code{breqn}.
@end deffn
@ -4360,9 +4418,9 @@ distribution of forecasts is stored in variables
these variables.
@item tex
@anchor{tex} Requests the printing of results and graphs in TeX tables
and graphics that can be later directly included in LaTeX files (not
yet implemented)
@anchor{tex} Requests the printing of results and graphs in @TeX{}
tables and graphics that can be later directly included in @LaTeX{}
files (not yet implemented)
@item kalman_algo = @var{INTEGER}
@anchor{kalman_algo}
@ -7655,6 +7713,380 @@ MatlabOctavePath = matlab
@end deffn
@node Reporting
@chapter Reporting
Dynare provides a simple interface for creating @LaTeX{} reports,
comprised of @LaTeX{} tables and TikZ graphs. You can use the report as
created through Dynare or pick out the pieces you want for inclusion
in your own paper.
Reports are created and modified by calling methods on class
objects. The objects are hierarchichal, with the following order (from
highest to lowest): @code{Report, Page, Section, Graph/Table/Vspace,
Series}. For simplicity of syntax, we abstract away from these
classes, allowing you to operate directly on a @code{Report} object,
while maintaining the names of these classes in the @code{Report}
Class methods you will use.
The report is created sequentially, command by command, hence the
order of the commands matters. When an object of a certain hierarchy
is inserted, all methods will function on that object until an object
of equal or greater hierarchy is added. Hence, once you add a
@code{Page} to the report, every time you add a @code{Section} object,
it will be added to this @code{Page} until another @code{Page} is
added to the report (via @ref{addPage}). This will become more clear
with the example at the end of the section.
Options to the methods are passed differently than those to Dynare
commands. They take the form of named options to Matlab functions
where the arguments come in pairs (@i{e.g.}
@code{function_name(`option_1_name', `option_1_value',
`option_2_name', `option_2_value', ...)}, where @code{option_X_name}
is the name of the option while @code{option_X_value} is the value
assigned to that option). The ordering of the option pairs matters
only in the unusual case when an option is provided twice (probably
erroneously). In this case, the last value passed is the one that is
used.
Below, you will see a list of methods available for the Report class and
a clarifying example.
@defmethod Report report compiler, showDate, filename, margin, marginUnit, orientation, paper, title
Instantiates a @code{Report} object.
@optionshead
@table @code
@anchor{compiler}
@item compiler, @var{FILENAME}
The full path to the @LaTeX{} compiler on your system. If this option
is not provided, Dynare will try to find the appropriate program to
compile @LaTeX{} on your system. Default is system dependent: Windows:
?, Mac OS X: @code{/usr/texbin/pdflatex}, Linux: the result of
@code{which pdflatex}
@item showDate, @code{BOOLEAN}
Display the date and time when the report was compiled. Default:
@code{true}
@anchor{filename}
@item filename, @var{FILENAME}
The filename to use when saving this report. Default:
@code{report.tex}
@item margin, @var{DOUBLE}
The margin size. Default: @code{2.5}
@item marginUnit, `cm' | `in'
Units associated with the margin. Default: @code{`cm'}
@anchor{orientation}
@item orientation, `landscape' | `portrait'
Paper orientation: Default: @code{`portrait'}
@anchor{paper}
@item paper, `a4' | `letter'
Paper size. Default: @code{`a4'}
@item title, @code{STRING}
Report Title. Default: @code{none}
@end table
@end defmethod
@anchor{addPage}
@defmethod Report addPage footnote, orientation, paper, title, titleFormat
Adds a @code{Page} to the @code{Report}.
@optionshead
@table @code
@item footnote, @code{STRING}
A footnote to be included at the bottom of this page. Default: @code{none}
@item orientation, `landscape' | `portrait'
@xref{orientation}.
@item paper, `a4' | `letter'
@xref{paper}.
@anchor{title}
@item title, @code{STRING} | @code{CELL_ARRAY_STRINGS}
With one entry (a @code{STRING}), the title of the page. With more
than one entry (a @code{CELL_ARRAY_STRINGS}), the title and subtitle(s)
of the page. Default: @code{none}
@anchor{titleFormat}
@item titleFormat, @code{STRING} | @code{CELL_ARRAY_STRINGS}
A string representing the @LaTeX{} markup to use on the
@ref{title}. The number of cell array entries must be equal to that of
the @ref{title} option. Default: @code{none}
@end table
@end defmethod
@defmethod Report addSection cols, height
Adds a @code{Section} to a @code{Page}.
@optionshead
@table @code
@item cols, @code{INTEGER}
The number of columns in the section. Default: @code{1}
@item height, @code{STRING}
A string to be used with the @code{\sectionheight} @LaTeX{}
command. Default: @code{`!'}
@end table
@end defmethod
@defmethod Report addGraph data, figname, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, xlabel, ylabel, xrange, yrange, showZeroline
Adds a @code{Graph} to a @code{Section}.
@optionshead
@table @code
@anchor{data}
@item data, @code{dynSeries}
The @code{dynSeries} that provides the data for the graph. Default:
@code{none}
@item figname, @code{STRING}
The name to use when saving this figure. Default: @code{[tempname
`.tex']}
@item showGrid, @code{BOOLEAN}
Whether or not to display the minor grid on the graph. Default:
@code{true}
@item showLegend, @code{BOOLEAN}
Whether or not to display the legend. Default: @code{false}
@item showLegendBox, @code{BOOLEAN}
Whether or not to display a box around the legend. Default:
@code{false}
@item legendLocation, `North' | `South' | `East' | `West' | `NorthEast' | `SouthEast' | `NorthWest' | `SouthWest' | `NorthOutside' | `SouthOutside' | `EastOutside' | `WestOutside' | `NorthEastOutside' | `SouthEastOutside' | `NorthWestOutside' | `SouthWestOutside' | `Best' | `BestOutside'
Where to place the legend in the graph. NB: some of these are not
available under Octave. Default: @code{`SouthEast'}
@item legendOrientation, `vertical' | `horizontal'
Orientation of the legend. Default: @code{`horizontal'}
@item legendFontSize, @code{DOUBLE}
The font size for legend entries. Default: @code{8}
@anchor{seriesToUse}
@item seriesToUse, @code{CELL_ARRAY_STRINGS}
The names of the series contained in the @code{dynSeries} provided to
the @ref{data} option. If empty, use all series provided to
@ref{data} option. Default: @code{empty}
@item shade, @code{dynDate}:@code{dynDate}
A @code{dynDates} range showing the portion of the graph that should
be shaded. Default: @code{none}
@item shadeColor, @code{MATLAB_COLOR_NAME}
The color to use in the shaded portion of the graph. Default:
@code{`green'}
@item shadeOpacity, @code{DOUBLE}
The opacity of the shaded area, must be in @math{[0,1]}. Default: @code{.2}
@item title, @code{STRING}
Title for the graph. Default: @code{none}
@item xlabel, @code{STRING}
The x-axis label. Default: @code{none}
@item ylabel, @code{STRING}
The y-axis label. Default: @code{none}
@item xrange, @code{dynDate}:@code{dynDate}
The boundary on the x-axis to display in the graph, represented as a
@code{dynDate} range. Default: all
@item yrange, @code{dynDate}:@code{dynDate}
The boundary on the y-axis to display in the graph, represented as a
@code{dynDate} range. Default: all
@item showZeroline, @code{BOOLEAN}
Display a solid black line at @math{y = 0}. Default: @code{false}
@end table
@end defmethod
@defmethod Report addTable data, showHlines, precision, range, seriesToUse, title, titleSize, vlineAfter, showVlines
Adds a @code{Table} to a @code{Section}.
@optionshead
@table @code
@item data, @code{dynSeries}
@xref{data}.
@item showHlines, @code{BOOLEAN}
Whether or not to show horizontal lines separating the rows. Default: @code{false}
@item precision, @code{INTEGER}
The number of decimal places to report in the table data. Default: @code{1}
@item range, @code{dynDate}:@code{dynDate}
The date range of the data to be displayed. Default: @code{all}
@item seriesToUse, @code{CELL_ARRAY_STRINGS}
@xref{seriesToUse}.
@item title, @code{STRING}
Title for the table. Default: @code{none}
@item titleSize, @code{STRING}
@LaTeX{} string representing the size of the table title. Default: @code{large}
@item vlineAfter, @code{dynDate}
Show a vertical line after the specified date. Default: @code{empty}
@item showVlines, @code{BOOLEAN}
Whether or not to show vertical lines separating the columns. Default: @code{false}
@end table
@end defmethod
@anchor{addSeries}
@defmethod Report addSeries data, graphLineColor, graphLineStyle, graphLineWidth, graphMarker, graphMarkerEdgeColor, graphMarkerFaceColor, graphMarkerSize, tableShowMarkers, tableAlignRight, tableNegColor, tablePosColor
Adds a @code{Series} to a @code{Graph} or a @code{Table}.
@optionshead
@table @code
@item data, @code{dynSeries}
@xref{data}.
@item graphLineColor, @code{MATLAB_COLOR}
Color to use for the series in a graph. Default: @code{`k'}
@item graphLineStyle, @code{`none'} | @code{`-'} | @code{`--'} | @code{`:'} | @code{`-.'}
Line style for this series in a graph. Default: @code{'-'}
@item graphLineWidth @code{DOUBLE}
Line width for this series in a graph. Default: @code{0.5}
@item graphMarker, @code{`+'} | @code{`o'} | @code{`*'} | @code{`.'} | @code{`x'} | @code{`s'} | @code{`square'} | @code{`d'} | @code{`diamond'} | @code{`^'} | @code{`v'} | @code{`>'} | @code{`<'} | @code{`p'} | @code{`pentagram'} | @code{`h'} | @code{`hexagram'} | @code{`none'}
The Marker to use on this series in a graph. Default: @code{none}
@item graphMarkerEdgeColor, @code{MATLAB_COLOR}
The edge color of the graph marker. Default: @code{`auto'}
@item graphMarkerFaceColor, @code{MATLAB_COLOR}
The face color of the graph marker. Default: @code{`auto'}
@item graphMarkerSize, @code{DOUBLE}
The size of the graph marker. Default: @code{6}
@item tableShowMarkers, @code{BOOLEAN}
In a Table, if @code{true}, surround each cell with brackets and color
it according to @ref{tableNegColor} and @ref{tablePosColor}. No effect
for graphs. Default: @code{false}
@item tableAlignRight, @code{BOOLEAN}
Whether or not to align the series name to the right of the
cell. Default: @code{false}
@item tableMarkerLimit, @code{DOUBLE}
For values less than @math{-1*@code{tableMarkerLimit}}, mark the cell
with the color denoted by @ref{tableNegColor}. For those greater than
@code{tableMarkerLimit}, mark the cell with the color denoted by
@ref{tablePosColor}. Default: @code{1e-4}
@anchor{tableNegColor}
@item tableNegColor, @code{LATEX_COLOR}
The color to use when marking Table data that is less than
zero. Default: @code{`red'}
@anchor{tablePosColor}
@item tablePosColor, @code{LATEX_COLOR}
The color to use when marking Table data that is greater than
zero. Default: @code{`blue'}
@end table
@end defmethod
@defmethod Report addVspace hline, number
Adds a @code{Vspace} (vertical space) to a @code{Section}.
@optionshead
@table @code
@item hline, @code{INTEGER}
The number of horizontal lines to be inserted. Default: @code{0}
@item number, @code{INTEGER}
The number of new lines to be inserted. Default: @code{1}
@end table
@end defmethod
@anchor{write}
@defmethod Report write
Writes the @LaTeX{} representation of this @code{Report}, saving it to
the file specified by @ref{filename}.
@end defmethod
@defmethod Report compile compiler
Compiles the report written by @ref{write} into a @code{pdf} file. If
the report has not already been written (determined by the existence
of the file specified by @ref{filename}, @ref{write} is called.
optionshead
@table @code
@item compiler, @code{FILENAME}
Like @ref{compiler}, except will not overwrite the value of
@code{compiler} contained in the report object. Hence, passing the
value here is useful for using different @LaTeX{} compilers or just
for passing the value at the last minute.
@end table
@end defmethod
@examplehead
The following code creates a one page report. The first part of the
page contains two graphs displayed across two columns and one
row. The bottom of the page displays a centered table.
@example
%% Create dynSeries
dsq = dynSeries(`quarterly.csv');
dsa = dynSeries(`annual.csv');
dsca = dynSeries(`annual_control.csv');
%% Report
rep = report();
%% Page 1
rep = rep.addPage(`title', `My Page Title', `titleFormat', `\large\bfseries');
% Section 1
rep = rep.addSection(`cols', 2);
rep = rep.addGraph(`title', `Graph (1,1)', `showLegend', true, ...
`xrange', dynDate(`2007q1'):dynDate(`2013q4'), ...
`shade', dynDate(`2012q2'):dynDate(`2013q4'));
rep = rep.addSeries(`data', dsq@{`SERIES1'@}, `color', `b', ...
`graphLineWidth', 1);
rep = rep.addSeries(`data', dsq@{`SERIES2'@}, `color', `g', ...
`graphLineStyle', '--', `graphLineWidth', 1.5);
rep = rep.addGraph(`title', `Graph (1,2)', `showLegend', true, ...
`xrange', dynDate(`2007q1'):dynDate(`2013q4'), ...
`shade', dynDate(`2012q2'):dynDate(`2013q4'));
rep = rep.addSeries(`data', dsq@{`SERIES3'@}, `color', `b', ...
`graphLineWidth', 1);
rep = rep.addSeries(`data', dsq@{`SERIES4'@}, `color', `g', ...
`graphLineStyle', '--', `graphLineWidth', 1.5);
% Section 2
rep = rep.addSection();
rep = rep.addTable(`title', `Table 1', ...
`range', dynDate(`2012'):dynDate(`2014'));
shortNames = @{`US', `EU'@};
longNames = @{`United States', `Euro Area'@};
for i=1:length(shortNames)
rep = rep.addSeries(`data', dsa@{[`GDP_' shortNames@{i@}]@});
delta = dsa@{[`GDP_' shortNames@{i@}]@}-dsca@{[`GDP_' shortNames@{i@}]@};
delta = delta.tex_rename(`$\Delta$');
rep = rep.addSeries(`data', delta, ...
`tableShowMarkers', true, ...
`tableAlignRight', true);
end
%% Write & Compile Report
rep.write();
rep.compile();
@end example
@node Examples
@chapter Examples

81
matlab/@dynSeries/lag.m Normal file
View File

@ -0,0 +1,81 @@
function us = lag(ts,p)
%@info:
%! @deftypefn {Function File} {@var{us} =} lag (@var{ts})
%! @anchor{lag}
%! @sp 1
%! Computes lagged time series.
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @var
%! @item ts
%! Dynare time series object, instantiated by @ref{dynSeries}
%! @end table
%! @sp 2
%! @strong{Outputs}
%! @sp 1
%! @table @var
%! @item us
%! Dynare time series object with transformed data field.
%! @end table
%! @end deftypefn
%@eod:
% Copyright (C) 2013 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/>.
% Set default number of lags
if nargin<2
p = 1;
end
% Copy of ts dynSeries object
us = ts;
% Update data member
us.data = [NaN(p,ts.vobs); ts.data(1:end-p,:)];
for i=1:ts.vobs
us.name(i) = {[ 'lag(' ts.name{i} ',' int2str(p) ')']};
us.tex(i) = {[ ts.tex{i} '_{-' int2str(p) '}']};
end
%@test:1
%$ t = zeros(4,1);
%$
%$ try
%$ data = transpose(0:1:50);
%$ ts = dynSeries(data,'1950Q1');
%$ a = ts.lag;
%$ b = ts.lag.lag;
%$ c = lag(ts,2);
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ DATA = [NaN(1,ts.vobs); transpose(0:1:49)];
%$ t(2) = dyn_assert(a.data,DATA,1e-15);
%$ DATA = [NaN(2,ts.vobs); transpose(0:1:48)];
%$ t(3) = dyn_assert(b.data,DATA,1e-15);
%$ t(4) = dyn_assert(b.data,c.data,1e-15);
%$ end
%$
%$ T = all(t);
%@eof:1b

View File

@ -66,7 +66,7 @@ switch S(1).type
switch S(1).subs
case {'data','nobs','vobs','name','tex','freq','time','init'} % Public members.
B = builtin('subsref', A, S(1));
case {'log','exp','ygrowth','qgrowth','ydiff','qdiff'} % Give "dot access" to public methods.
case {'log','exp','ygrowth','qgrowth','ydiff','qdiff','lag'} % Give "dot access" to public methods.
B = feval(S(1).subs,A);
case {'save'} % Save dynSeries object on disk (default is a csv file).
B = NaN;

View File

@ -0,0 +1,560 @@
function oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,table_title,field_name)
%function oo_=display_results_table(xparam1,stdh,M_,estim_params_,bayestopt_,oo_,pnames,table_title,field_name)
% Display estimation results on screen and write them to TeX-file
%
% INPUTS
% o xparam1 [double] (p*1) vector of estimate parameters.
% o stdh [double] (p*1) vector of estimate parameters.
% o M_ Matlab's structure describing the Model (initialized by dynare, see @ref{M_}).
% o estim_params_ Matlab's structure describing the estimated_parameters (initialized by dynare, see @ref{estim_params_}).
% o options_ Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
% o bayestopt_ Matlab's structure describing the priors (initialized by dynare, see @ref{bayesopt_}).
% o oo_ Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
% o pnames [string] Character Array storing the names for prior distributions
% o table_title [string] Title of the Table
% o field_name [string] String storing the name of the fields for oo_ where the parameters are stored
%
% OUTPUTS
% o oo_ Matlab's structure gathering the results
%
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 2013 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/>.
nvx = estim_params_.nvx; % Variance of the structural innovations (number of parameters).
nvn = estim_params_.nvn; % Variance of the measurement innovations (number of parameters).
ncx = estim_params_.ncx; % Covariance of the structural innovations (number of parameters).
ncn = estim_params_.ncn; % Covariance of the measurement innovations (number of parameters).
np = estim_params_.np ; % Number of deep parameters.
nx = nvx+nvn+ncx+ncn+np; % Total number of parameters to be estimated.
disp(' ')
disp(['RESULTS FROM ' upper(table_title) ' ESTIMATION'])
LaTeXtitle=strrep(table_title,' ','_');
tstath = abs(xparam1)./stdh;
header_width = row_header_width(M_,estim_params_,bayestopt_);
if strcmp(field_name,'posterior')
tit1 = sprintf('%-*s %7s %8s %7s %4s %6s\n',header_width-2,' ','prior mean', ...
'mode','s.d.','prior','pstdev');
else
tit1 = sprintf('%-*s %10s %7s %6s\n',header_width-2,' ','Estimate','s.d.','t-stat');
end
if np
ip = nvx+nvn+ncx+ncn+1;
disp('parameters')
disp(tit1)
for i=1:np
name = bayestopt_.name{ip};
if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name, ...
bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip));
else
fprintf('%-*s %8.4f %7.4f %7.4f \n', ...
header_width,name,xparam1(ip),stdh(ip),tstath(ip));
end
eval(['oo_.' field_name '_mode.parameters.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std.parameters.' name ' = stdh(ip);']);
ip = ip+1;
end
disp(' ')
end
if nvx
ip = 1;
disp('standard deviation of shocks')
disp(tit1)
for i=1:nvx
k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:));
if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip), ...
stdh(ip),pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip));
else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip));
end
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
eval(['oo_.' field_name '_mode.shocks_std.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std.shocks_std.' name ' = stdh(ip);']);
ip = ip+1;
end
disp(' ')
end
if nvn
disp('standard deviation of measurement errors')
disp(tit1)
ip = nvx+1;
for i=1:nvn
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip), ...
xparam1(ip),stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip));
else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip))
end
eval(['oo_.' field_name '_mode.measurement_errors_std.' name ' = xparam1(ip);']);
eval(['oo_.' field_name '_std.measurement_errors_std.' name ' = stdh(ip);']);
ip = ip+1;
end
disp(' ')
end
if ncx
disp('correlation of shocks')
disp(tit1)
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip));
else
fprintf('%-*s %8.4f %7.4f %7.4f \n', header_width,name,xparam1(ip),stdh(ip),tstath(ip));
end
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
eval(['oo_.' field_name '_mode.shocks_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.' field_name '_std.shocks_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
disp(' ')
end
if ncn
disp('correlation of measurement errors')
disp(tit1)
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
if strcmp(field_name,'posterior')
fprintf('%-*s %7.3f %8.4f %7.4f %4s %6.4f \n', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip));
else
fprintf('%-*s %8.4f %7.4f %7.4f \n',header_width,name,xparam1(ip),stdh(ip),tstath(ip));
end
eval(['oo_.' field_name '_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.' field_name '_std.measurement_errors_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
disp(' ')
end
OutputDirectoryName = CheckPath('Output',M_.dname);
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
if np
filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (parameters)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+ncn+1;
for i=1:np
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
bayestopt_.p1(ip),...
bayestopt_.p2(ip),...
xparam1(ip),...
stdh(ip));
ip = ip + 1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_2.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of structural shocks)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = 1;
for i=1:nvx
k = estim_params_.var_exo(i,1);
fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
deblank(M_.exo_names_tex(k,:)),...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
bayestopt_.p1(ip),...
bayestopt_.p2(ip),...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_3.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of measurement errors)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+1;
for i=1:nvn
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
deblank(M_.endo_names_tex(idx,:)), ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip),...
xparam1(ip),...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_4.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of structural shocks)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_5.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of measurement errors)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
elseif all(bayestopt_.pshape == 0) && options_.TeX %% MLE and GMM Latex output
if np
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_1.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (parameters)\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (parameters)}\n ']);
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':1}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':1}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+ncn+1;
for i=1:np
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n',...
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
xparam1(ip),...
stdh(ip),...
tstath(ip));
ip = ip + 1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_2.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (standard deviation of structural shocks)\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (standard deviation of structural shocks)}\n ']);
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':2}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':2}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = 1;
for i=1:nvx
k = estim_params_.var_exo(i,1);
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f\\\\ \n'],...
deblank(M_.exo_names_tex(k,:)),...
xparam1(ip), ...
stdh(ip),...
tstath(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_3.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (standard deviation of measurement errors)\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (standard deviation of measurement errors)}\n ']);
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':3}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':3}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+1;
for i=1:nvn
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',...
deblank(M_.endo_names_tex(idx,:)), ...
xparam1(ip),...
stdh(ip),...
tstath(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncx
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_4.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (correlation of structural shocks)\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (correlation of structural shocks)}\n ']);
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':4}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':4}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
fprintf(fidTeX,[ '$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n'],...
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
xparam1(ip), ...
stdh(ip),...
tstath(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncn
filename = [OutputDirectoryName '/' M_.fname '_' LaTeXtitle '_Mode_5.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,['%% RESULTS FROM ' table_title ' MAXIMIZATION (correlation of measurement errors)\n']);
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcc} \n');
fprintf(fidTeX,['\\caption{Results from ' table_title ' maximization (correlation of measurement errors)}\n ']);
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':5}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,['\\label{Table:' LaTeXtitle ':5}\\\\\n']);
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Mode & s.d. & t-stat\\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{4}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
fprintf(fidTeX,'$%s$ & %8.4f & %7.4f & %7.4f \\\\ \n',...
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
xparam1(ip), ...
stdh(ip),...
tstath(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
end

View File

@ -523,102 +523,8 @@ if ~options_.cova_compute
end
if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
disp(' ')
disp('RESULTS FROM POSTERIOR MAXIMIZATION')
tstath = zeros(nx,1);
for i = 1:nx
tstath(i) = abs(xparam1(i))/stdh(i);
end
header_width = row_header_width(M_,estim_params_,bayestopt_);
tit1 = sprintf('%-*s %7s %8s %7s %6s %4s %6s\n',header_width-2,' ','prior mean', ...
'mode','s.d.','t-stat','prior','pstdev');
if np
ip = nvx+nvn+ncx+ncn+1;
disp('parameters')
disp(tit1)
for i=1:np
name = bayestopt_.name{ip};
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
header_width,name, ...
bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip)));
eval(['oo_.posterior_mode.parameters.' name ' = xparam1(ip);']);
eval(['oo_.posterior_std.parameters.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if nvx
ip = 1;
disp('standard deviation of shocks')
disp(tit1)
for i=1:nvx
k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:));
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip), ...
stdh(ip),tstath(ip),pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip)));
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
eval(['oo_.posterior_mode.shocks_std.' name ' = xparam1(ip);']);
eval(['oo_.posterior_std.shocks_std.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if nvn
disp('standard deviation of measurement errors')
disp(tit1)
ip = nvx+1;
for i=1:nvn
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
header_width,name,bayestopt_.p1(ip), ...
xparam1(ip),stdh(ip),tstath(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p2(ip)));
eval(['oo_.posterior_mode.measurement_errors_std.' name ' = xparam1(ip);']);
eval(['oo_.posterior_std.measurement_errors_std.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if ncx
disp('correlation of shocks')
disp(tit1)
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)));
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
eval(['oo_.posterior_mode.shocks_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.posterior_std.shocks_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
end
if ncn
disp('correlation of measurement errors')
disp(tit1)
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
disp(sprintf('%-*s %7.3f %8.4f %7.4f %7.4f %4s %6.4f', ...
header_width,name,bayestopt_.p1(ip),xparam1(ip),stdh(ip),tstath(ip), ...
pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.p2(ip)));
eval(['oo_.posterior_mode.measurement_errors_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.posterior_std.measurement_errors_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
end
%% display results table and store parameter estimates and standard errors in results
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Posterior','posterior');
%% Laplace approximation to the marginal log density:
if options_.cova_compute
estim_params_nbr = size(xparam1,1);
@ -631,289 +537,11 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
disp(' ')
end
elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
disp(' ')
disp('RESULTS FROM MAXIMUM LIKELIHOOD')
tstath = zeros(nx,1);
for i = 1:nx
tstath(i) = abs(xparam1(i))/stdh(i);
end
header_width = row_header_width(M_,estim_params_,bayestopt_);
tit1 = sprintf('%-*s %10s %7s %6s\n',header_width-2,' ','Estimate','s.d.','t-stat');
if np
ip = nvx+nvn+ncx+ncn+1;
disp('parameters')
disp(tit1)
for i=1:np
name = bayestopt_.name{ip};
disp(sprintf('%-*s %8.4f %7.4f %7.4f', ...
header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
eval(['oo_.mle_mode.parameters.' name ' = xparam1(ip);']);
eval(['oo_.mle_std.parameters.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if nvx
ip = 1;
disp('standard deviation of shocks')
disp(tit1)
for i=1:nvx
k = estim_params_.var_exo(i,1);
name = deblank(M_.exo_names(k,:));
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
eval(['oo_.mle_mode.shocks_std.' name ' = xparam1(ip);']);
eval(['oo_.mle_std.shocks_std.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if nvn
disp('standard deviation of measurement errors')
disp(tit1)
ip = nvx+1;
for i=1:nvn
name = deblank(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:));
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)))
eval(['oo_.mle_mode.measurement_errors_std.' name ' = xparam1(ip);']);
eval(['oo_.mle_std.measurement_errors_std.' name ' = stdh(ip);']);
ip = ip+1;
end
end
if ncx
disp('correlation of shocks')
disp(tit1)
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
disp(sprintf('%-*s %8.4f %7.4f %7.4f', header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
eval(['oo_.mle_mode.shocks_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.mle_std.shocks_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
end
if ncn
disp('correlation of measurement errors')
disp(tit1)
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
disp(sprintf('%-*s %8.4f %7.4f %7.4f',header_width,name,xparam1(ip),stdh(ip),tstath(ip)));
eval(['oo_.mle_mode.measurement_error_corr.' NAME ' = xparam1(ip);']);
eval(['oo_.mle_std.measurement_error_corr.' NAME ' = stdh(ip);']);
ip = ip+1;
end
end
oo_=display_estimation_results_table(xparam1,stdh,M_,options_,estim_params_,bayestopt_,oo_,pnames,'Maximum Likelihood','mle');
end
OutputDirectoryName = CheckPath('Output',M_.dname);
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
if np
filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.TeX'];
fidTeX = fopen(filename,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (parameters)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (parameters)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:1}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+ncn+1;
for i=1:np
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
M_.param_names_tex(estim_params_.param_vals(i,1),:),...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
bayestopt_.p1(ip),...
bayestopt_.p2(ip),...
xparam1(ip),...
stdh(ip));
ip = ip + 1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_2.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of structural shocks)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:2}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = 1;
for i=1:nvx
k = estim_params_.var_exo(i,1);
fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
deblank(M_.exo_names_tex(k,:)),...
deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
bayestopt_.p1(ip),...
bayestopt_.p2(ip),...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if nvn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_3.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of measurement errors)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior maximization (standard deviation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:3}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+1;
for i=1:nvn
idx = strmatch(options_.varobs(estim_params_.nvn_observable_correspondence(i,1),:),M_.endo_names);
fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
deblank(M_.endo_names_tex(idx,:)), ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip),...
xparam1(ip),...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncx
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_4.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of structural shocks)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtable}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:4}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+1;
for i=1:ncx
k1 = estim_params_.corrx(i,1);
k2 = estim_params_.corrx(i,2);
fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n'],...
[deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
if ncn
TeXfile = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_5.TeX'];
fidTeX = fopen(TeXfile,'w');
fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n');
fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of measurement errors)\n');
fprintf(fidTeX,['%% ' datestr(now,0)]);
fprintf(fidTeX,' \n');
fprintf(fidTeX,' \n');
fprintf(fidTeX,'\\begin{center}\n');
fprintf(fidTeX,'\\begin{longtabe}{l|lcccc} \n');
fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endfirsthead \n');
fprintf(fidTeX,'\\caption{(continued)}\n ');
fprintf(fidTeX,'\\label{Table:Posterior:5}\\\\\n');
fprintf(fidTeX,'\\hline\\hline \\\\ \n');
fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n');
fprintf(fidTeX,'\\hline \\endhead \n');
fprintf(fidTeX,'\\hline \\multicolumn{6}{r}{(Continued on next page)} \\\\ \\hline \\endfoot \n');
fprintf(fidTeX,'\\hline \\hline \\endlastfoot \n');
ip = nvx+nvn+ncx+1;
for i=1:ncn
k1 = estim_params_.corrn(i,1);
k2 = estim_params_.corrn(i,2);
fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n',...
[deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
pnames(bayestopt_.pshape(ip)+1,:), ...
bayestopt_.p1(ip), ...
bayestopt_.p2(ip), ...
xparam1(ip), ...
stdh(ip));
ip = ip+1;
end
fprintf(fidTeX,'\\end{longtable}\n ');
fprintf(fidTeX,'\\end{center}\n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);
end
end
if np > 0
pindx = estim_params_.param_vals(:,1);
save([M_.fname '_params.mat'],'pindx');
@ -927,9 +555,12 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
bayestopt_.lb = bounds(:,1);
bayestopt_.ub = bounds(:,2);
if any(xparam1 < bounds(:,1)) || any(xparam1 > bounds(:,2))
find(xparam1 < bounds(:,1))
find(xparam1 > bounds(:,2))
error('Mode values are outside prior bounds. Reduce prior_trunc.')
outside_bound_vars=bayestopt_.name([find(xparam1 < bounds(:,1)); find(xparam1 > bounds(:,2))],:);
disp_string=[outside_bound_vars{1,:}];
for ii=2:size(outside_bound_vars,1)
disp_string=[disp_string,', ',outside_bound_vars{ii,:}];
end
error(['Mode value(s) of ', disp_string ,' are outside parameter bounds. Potentially, you should set prior_trunc=0.'])
end
% runs MCMC
if options_.mh_replic

View File

@ -163,9 +163,9 @@ for j=1:size(anamendo,1)
disp([M_.param_names(estim_params_.param_vals(indsmirnov(jp),1),:),' d-stat = ', num2str(dproba(indsmirnov(jp)),'%1.3f'),' p-value = ', num2str(proba(indsmirnov(jp)),'%1.3f')])
end
disp(' ');
stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,indsmirnov,xdir,[],['Reduced Form Mapping (Threshold) for ', namendo,' vs. lagged ', namlagendo]);
stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir,[],['Reduced Form Mapping (Inside Threshold)for ', namendo,' vs. lagged ', namlagendo])
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir,[],['Reduced Form Mapping (Outside Threshold) for ', namendo,' vs. lagged ', namlagendo])
stab_map_1(x0, iy, iyc, 'threshold',pvalue_ks,indsmirnov,xdir,[],['Reduced Form Mapping (Threshold) for ', namendo,' vs. lagged ', namexo]);
stab_map_2(x0(iy,:),alpha2,pvalue_corr,'inside_threshold',xdir,[],['Reduced Form Mapping (Inside Threshold)for ', namendo,' vs. lagged ', namexo])
stab_map_2(x0(iyc,:),alpha2,pvalue_corr,'outside_threshold',xdir,[],['Reduced Form Mapping (Outside Threshold) for ', namendo,' vs. lagged ', namexo])
lpmat=x0(iy,:);
if nshocks,
lpmat0=xx0(iy,:);

View File

@ -39,6 +39,56 @@ switch(order)
return;
end
dr.g_1 = g_1;
case 2
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
if err
info(1)=9;
return;
end
dr.g_0 = g_0;
dr.g_1 = g_1;
dr.g_2 = g_2;
case 3
if options.pruning
[err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ...
M,options);
if err
info(1)=9;
return;
end
else
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ...
M,options);
if err
info(1)=9;
return;
end
end
dr.g_0 = g_0;
dr.g_1 = g_1;
dr.g_2 = g_2;
dr.g_3 = g_3;
otherwise
error('order > 3 isn''t implemented')
end
% Now fill in dr.ghx, dr.ghu...
if options.pruning && order == 3
dr.ghx = derivs.gy;
dr.ghu = derivs.gu;
dr.ghxx = unfold2(derivs.gyy,nspred);
dr.ghxu = derivs.gyu;
dr.ghuu = unfold2(derivs.guu,exo_nbr);
dr.ghs2 = derivs.gss;
dr.ghxxx = unfold3(derivs.gyyy,nspred);
dr.ghxxu = unfold21(derivs.gyyu,nspred,exo_nbr);
dr.ghxuu = unfold12(derivs.gyuu,nspred,exo_nbr);
dr.ghuuu = unfold3(derivs.guuu,exo_nbr);
dr.ghxss = derivs.gyss;
dr.ghuss = derivs.guss;
else
nspred = M.nspred;
dr.ghx = dr.g_1(:,1:nspred);
dr.ghu = dr.g_1(:,nspred+1:end);
@ -53,19 +103,7 @@ switch(order)
dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
end
case 2
[err, g_0, g_1, g_2] = k_order_perturbation(dr,M,options);
if err
info(1)=9;
return;
end
dr.g_0 = g_0;
dr.g_1 = g_1;
dr.g_2 = g_2;
dr.ghx = dr.g_1(:,1:nspred);
dr.ghu = dr.g_1(:,nspred+1:end);
if order > 1
dr.ghs2 = 2*g_0;
s0 = 0;
s1 = 0;
@ -97,44 +135,9 @@ switch(order)
dr.ghxx = ghxx;
dr.ghxu = ghxu;
dr.ghuu = ghuu;
case 3
if options.pruning
[err, g_0, g_1, g_2, g_3, derivs] = k_order_perturbation(dr, ...
M,options);
if err
info(1)=9;
return;
end
dr.ghx = derivs.gy;
dr.ghu = derivs.gu;
dr.ghxx = unfold2(derivs.gyy,nspred);
dr.ghxu = derivs.gyu;
dr.ghuu = unfold2(derivs.guu,exo_nbr);
dr.ghs2 = derivs.gss;
dr.ghxxx = unfold3(derivs.gyyy,nspred);
dr.ghxxu = unfold21(derivs.gyyu,nspred,exo_nbr);
dr.ghxuu = unfold12(derivs.gyuu,nspred,exo_nbr);
dr.ghuuu = unfold3(derivs.guuu,exo_nbr);
dr.ghxss = derivs.gyss;
dr.ghuss = derivs.guss;
else
[err, g_0, g_1, g_2, g_3] = k_order_perturbation(dr, ...
M,options);
if err
info(1)=9;
return;
end
end
dr.g_0 = g_0;
dr.g_1 = g_1;
dr.g_2 = g_2;
dr.g_3 = g_3;
otherwise
error('order > 3 isn''t implemented')
end
function y = unfold2(x,n)
y=zeros(size(x,1),n*n);
m = 1;

View File

@ -90,7 +90,7 @@ init = dynDate(1);
varlist = [];
if ~exist('OCTAVE_VERSION')
% Under Matlab, save time by using importdata
assert(exist(file, 'file'), 'load_csv_file_data: I can''t find file ' file '!');
assert(exist(file, 'file') == 2, ['load_csv_file_data: I can''t find file ' file '!']);
A = importdata(file, ',', withnames);
if withnames && withtime
if size(A.textdata, 1) == 1

View File

@ -93,7 +93,11 @@ varlist = {};
if isempty(varlist0)
for i=1:length(list_of_variables)
if isequal(list_of_variables(i).name,'freq') || isequal(list_of_variables(i).name,'time') || isequal(list_of_variables(i).name,'data') || isequal(list_of_variables(i).name,'varlist')
if isequal(list_of_variables(i).name,'freq') || isequal(list_of_variables(i).name,'time') || isequal(list_of_variables(i).name,'data') ...
|| isequal(list_of_variables(i).name,'varlist') ...
|| isequal(list_of_variables(i).name,'varlist0') ...
|| isequal(list_of_variables(i).name,'list_of_variables') ...
|| isequal(list_of_variables(i).name,'tex') ...
continue
end
if list_of_variables(i).global || list_of_variables(i).persistent

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Elements object
%
% INPUTS
% none
% o [elements] elements object
%
% OUTPUTS
% none
@ -28,9 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section.elements';
disp(' ');
disp([name ' = ']);
disp(' ');
disp(getElements(o));
reporting_object_display(o);
end

View File

@ -18,5 +18,5 @@ function n = numElements(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n = o.objArray.numObjs();
n = o.objArray.numObjArray();
end

View File

@ -33,7 +33,7 @@ if ~isempty(o.figname)
o.figname);
end
if ~o.seriesElements.numElements()
if ~o.seriesElements.numSeriesElements()
warning('@graph.crepateGraph: no series to plot, returning');
return;
end
@ -41,7 +41,7 @@ end
h = figure('visible','off');
hold on;
box on;
if o.grid
if o.showGrid
grid on;
set(gca, 'GridLineStyle', '--');
end
@ -52,7 +52,7 @@ else
dd = o.xrange;
end
ne = o.seriesElements.numElements();
ne = o.seriesElements.numSeriesElements();
line_handles = zeros(ne, 1);
for i=1:ne
line_handles(i) = o.seriesElements(i).getLine(dd);
@ -66,7 +66,7 @@ if ~isempty(o.yrange)
ylim(o.yrange);
end
if o.zeroline
if o.showZeroline
a = ylim;
if 0 > a(1) && 0 < a(2)
lh = line(xlim, [0 0], 'color', 'k', 'LineWidth', 0.25);
@ -87,24 +87,32 @@ if ~isempty(o.shade)
% From ShadePlotForEmpahsis (Matlab Exchange)
% use patch bc area doesn't work with matlab2tikz
sh = patch([repmat(x1, 1, 2) repmat(x2, 1, 2)], ...
[yrange fliplr(yrange)], o.shade_color, ...
'facealpha', o.shade_opacity);
children =get(gca(), 'children');
[yrange fliplr(yrange)], o.shadeColor, ...
'facealpha', o.shadeOpacity);
children = get(gca, 'children');
children = [children(2:end); sh];
set(gca(), 'children', children);
set(gca, 'children', children);
end
xticks = get(gca, 'XTick');
[junk, ix, junk] = intersect(x, xticks);
set(gca, 'XTickLabel', xlabels(ix));
xTickLabels = cell(1, length(xticks));
for i=1:length(xticks)
if xticks(i) >= x(1) && ...
xticks(i) <= x(end)
xTickLabels{i} = xlabels{xticks(i)};
else
xTickLabels{i} = '';
end
end
set(gca, 'XTickLabel', xTickLabels);
if o.legend
if o.showLegend
lh = legend(line_handles, o.seriesElements.getTexNames(), ...
'orientation', o.legend_orientation, ...
'location', o.legend_location);
set(lh, 'FontSize', o.legend_font_size);
'orientation', o.legendOrientation, ...
'location', o.legendLocation);
set(lh, 'FontSize', o.legendFontSize);
set(lh, 'interpreter', 'latex');
if o.legend_boxoff
if ~o.showLegendBox
legend('boxoff');
end
end
@ -118,12 +126,18 @@ if ~isempty(o.ylabel)
end
drawnow;
o.figname = [tempname '.tex'];
if isempty(o.figname)
o.figname = [tempname '.tex'];
end
disp(' converting to tex....');
matlab2tikz('filename', o.figname, ...
if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once'))
print(o.figname, '-dtikz');
else
matlab2tikz('filename', o.figname, ...
'showInfo', false, ...
'showWarnings', false, ...
'checkForUpdates', false);
end
grid off;
box off;

View File

@ -28,49 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section.graph';
disp(' ');
disp([name '.title = ']);
disp(' ');
disp([' ''' o.title '''']);
disp(' ');
disp([name '.xlabel = ']);
disp(' ');
disp([' ''' o.xlabel '''']);
disp(' ');
disp([name '.ylabel = ']);
disp(' ');
disp([' ''' o.ylabel '''']);
disp(' ');
disp([name '.footnote = ']);
disp(' ');
disp([' ''' o.footnote '''']);
disp(' ');
disp([name '.figname = ']);
disp(' ');
disp([' ''' o.figname '''']);
disp(' ');
disp([name '.config = ']);
disp(' ');
disp([' ''' o.config '''']);
disp(' ');
disp([name '.legend = ']);
disp(' ');
disp(o.legend);
disp(' ');
disp([name '.shade = ']);
disp(' ');
disp(o.shade);
disp(' ');
disp([name '.seriesElements = ']);
disp(' ');
o.seriesElements.getSeriesElements()
reporting_object_display(o);
end

View File

@ -31,5 +31,5 @@ function lastIndex = end(o, k, n)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(k==1 && n==1, '@graph/end: graph only has one dimension');
lastIndex = o.seriesElements.numElements();
lastIndex = o.seriesElements.numSeriesElements();
end

View File

@ -33,34 +33,31 @@ function o = graph(varargin)
o = struct;
o.config = '';
o.seriesElements = seriesElements();
o.title = '';
o.ylabel = '';
o.xlabel = '';
o.footnote = '';
o.figname = '';
o.data = '';
o.seriestouse = '';
o.seriesToUse = '';
o.xrange = '';
o.yrange = '';
o.shade = '';
o.shade_color = [0 1 0];
o.shade_opacity = .2;
o.shadeColor = 'green';
o.shadeOpacity = .2;
o.grid = true;
o.showGrid = true;
o.legend = false;
o.legend_boxoff = false;
o.legend_location = 'SouthEast';
o.legend_orientation = 'horizontal';
o.legend_font_size = 8;
o.showLegend = false;
o.showLegendBox = false;
o.legendLocation = 'SouthEast';
o.legendOrientation = 'horizontal';
o.legendFontSize = 8;
o.zeroline = false;
o.showZeroline = false;
if nargin == 1
assert(isa(varargin{1}, 'graph'),['@graph.graph: with one arg you ' ...
@ -73,34 +70,34 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@graph.graph: %s is not a recognized option.', field);
error('@graph.graph: %s is not a recognized option.', pair{1});
end
end
end
% Check options provided by user
assert(ischar(o.title), '@graph.graph: title must be a string');
assert(ischar(o.footnote), '@graph.graph: footnote must be a string');
assert(ischar(o.config), '@graph.graph: config file must be a string');
assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string');
assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string');
assert(ischar(o.figname), '@graph.graph: figname must be a string');
assert(islogical(o.grid), '@graph.graph: grid must be either true or false');
assert(islogical(o.legend), '@graph.graph: legend must be either true or false');
assert(islogical(o.legend_boxoff), '@graph.graph: legend_boxoff must be either true or false');
assert(isint(o.legend_font_size), '@graph.graph: legend_font_size must be an integer');
assert(islogical(o.zeroline), '@graph.graph: zeroline must be either true or false');
assert(isfloat(o.shade_opacity) && length(o.shade_opacity)==1 && ...
o.shade_opacity >= 0 && o.shade_opacity <= 1, ...
'@graph.graph: o.shade_opacity must be a real in [0 1]');
assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false');
assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false');
assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false');
assert(isint(o.legendFontSize), '@graph.graph: legendFontSize must be an integer');
assert(islogical(o.showZeroline), '@graph.graph: showZeroline must be either true or false');
assert(ischar(o.shadeColor), '@graph.graph: shadeColor must be a string');
assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
o.shadeOpacity >= 0 && o.shadeOpacity <= 1, ...
'@graph.graph: o.shadeOpacity must be a real in [0 1]');
valid_legend_locations = ...
{'North', 'South', 'East', 'West', ...
'NorthEast', 'SouthEast', 'NorthWest', 'SouthWest', ...
@ -108,12 +105,12 @@ valid_legend_locations = ...
'NorthEastOutside', 'SouthEastOutside', 'NorthWestOutside', 'SouthWestOutside', ...
'Best', 'BestOutside', ...
};
assert(any(strcmp(o.legend_location, valid_legend_locations)), ...
['@graph.graph: legend_location must be one of ' strjoin(valid_legend_locations, ' ')]);
assert(any(strcmp(o.legendLocation, valid_legend_locations)), ...
['@graph.graph: legendLocation must be one of ' strjoin(valid_legend_locations, ' ')]);
valid_legend_orientations = {'vertical', 'horizontal'};
assert(any(strcmp(o.legend_orientation, valid_legend_orientations)), ...
['@graph.graph: legend_orientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
assert(any(strcmp(o.legendOrientation, valid_legend_orientations)), ...
['@graph.graph: legendOrientation must be one of ' strjoin(valid_legend_orientations, ' ')]);
assert(isempty(o.shade) || (isa(o.shade, 'dynDates') && o.shade.ndat >= 2), ...
['@graph.graph: shade is specified as a dynDates range, e.g. ' ...
@ -127,22 +124,22 @@ assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
'the lower bound and upper bound.']);
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ['@graph.graph: data must ' ...
'be a dynSeries']);
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ['@graph.graph: ' ...
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@graph.graph: ' ...
'series to use must be a cell array of string(s)']);
% using o.seriestouse, create series objects and put them in o.seriesElements
% using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data)
if isempty(o.seriestouse)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriestouse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
for i=1:length(o.seriesToUse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriestouse');
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
% Create graph object

View File

@ -3,7 +3,7 @@ function display(oa)
% Display an objArray object
%
% INPUTS
% none
% o [objArray] objArray object
%
% OUTPUTS
% none
@ -28,8 +28,5 @@ function display(oa)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
disp(' ');
disp([inputname(1) '.objs = ']);
disp(' ');
disp(oa.objs);
reporting_object_display(o);
end

View File

@ -1,5 +1,5 @@
function no = numObjs(oa)
%function no = numObjs(oa)
function n = numObjArray(o)
%function n = numObjArray(o)
% Copyright (C) 2013 Dynare Team
%
@ -18,5 +18,5 @@ function no = numObjs(oa)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
no = size(oa.objs, 2);
n = size(o.objs, 2);
end

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Page object
%
% INPUTS
% none
% o [page] page object
%
% OUTPUTS
% none
@ -28,9 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page';
disp(' ');
disp([name '.sections = ']);
disp(' ');
disp(o.sections());
reporting_object_display(o);
end

View File

@ -32,7 +32,7 @@ function o = page(varargin)
o = struct;
o.paper = '';
o.title = {};
o.title_format = {};
o.titleFormat = {};
o.orientation = '';
o.footnote = {};
o.sections = sections();
@ -48,15 +48,16 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@page.page: %s is not a recognized option.', field);
error('@page.page: %s is not a recognized option.', pair{1});
end
end
end
@ -65,15 +66,15 @@ end
if ischar(o.title)
o.title = {o.title};
end
if ischar(o.title_format)
o.title_format = {o.title_format};
if ischar(o.titleFormat)
o.titleFormat = {o.titleFormat};
end
assert(iscellstr(o.title), ...
'@page.page: title must be a cell array of strings');
assert(iscellstr(o.title_format), ...
'@page.page: title_format must be a cell array of strings');
assert(length(o.title)==length(o.title_format), ...
'@page.page: title and title_format must be of the same length');
assert(iscellstr(o.titleFormat), ...
'@page.page: titleFormat must be a cell array of strings');
assert(length(o.title)==length(o.titleFormat), ...
'@page.page: title and titleFormat must be of the same length');
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...

View File

@ -43,7 +43,7 @@ fprintf(fid,'\n');
fprintf(fid, '\\begin{tabular}[t]{c}\n');
for i=1:length(o.title)
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.title_format{i}, o.title{i});
fprintf(fid,'\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
end
o.sections.write(fid);

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Pages object
%
% INPUTS
% ps [pages] pages object
% o [pages] pages object
%
% OUTPUTS
% none
@ -28,9 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.pages';
disp(' ');
disp([name ' = ']);
disp(' ');
disp(getPages(o));
reporting_object_display(o);
end

View File

@ -1,6 +1,5 @@
function n = numPages(o)
% function n = numPages(o)
% Sections Class Constructor
%
% INPUTS
% o [page] pages object
@ -28,5 +27,5 @@ function n = numPages(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n = o.objArray.numObjs();
n = o.objArray.numObjArray();
end

View File

@ -1,9 +1,11 @@
function o = compile(o)
function o = compile(o, varargin)
%function o = compile(o)
% Compile Report Object
%
% INPUTS
% o [report] report object
% varargin [char] allows user to change report compiler for a
% given run of compile.
%
% OUTPUTS
% o [report] report object
@ -28,20 +30,32 @@ function o = compile(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(length(varargin) == 0 || length(varargin) == 2, ...
'@report.compile: calling form: compiler, ''/path/to/compiler''.');
if length(varargin) == 2
assert(ischar(varargin{1}) && strcmp(lower(varargin{1}), 'compiler'), ...
'@report.compile: ''compiler'' is the only option.');
assert(ischar(varargin{2}), ...
'@report.compile: the argument to ''compiler'' must be a char');
compiler = varargin{2};
else
compiler = o.compiler;
end
if ~exist(o.filename, 'file')
o.write();
end
compiler = o.compiler;
if isempty(compiler)
if strcmp(computer, 'MACI') || strcmp(computer, 'MACI64')
% Add most likely places for pdflatex to
% exist outside of default $PATH
if strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
% Add most likely places for pdflatex to exist outside of default $PATH
[status, compiler] = ...
system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ...
'which pdflatex'], '-echo');
elseif strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
% need to fill in for Windows
error(['@report.compile: On Windows machines, you must explicitly ' ...
'provide the ''compiler'' option or set the compiler ' ...
'variable in the Report class']);
else % gnu/linux
[status, compiler] = system('which pdflatex', '-echo');
end
@ -50,7 +64,12 @@ if isempty(compiler)
compiler = strtrim(compiler);
o.compiler = compiler;
end
[status output] = system([compiler ' ./' o.filename], '-echo');
if exist('OCTAVE_VERSION')
status = system([compiler ' ./' o.filename], 0);
else
status = system([compiler ' ./' o.filename], '-echo');
end
[junk, rfn, junk] = fileparts(o.filename);
if status ~= 0

View File

@ -28,39 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report';
disp(' ');
disp([name '.title = ']);
disp(' ');
disp([' ''' o.title '''']);
disp(' ')
disp([name '.paper = ']);
disp(' ');
disp([' ''' o.paper '''']);
disp(' ')
disp([name '.orientation = ']);
disp(' ');
disp([' ''' o.orientation '''']);
disp(' ')
disp([name '.filename = ']);
disp(' ');
disp([' ''' o.filename '''']);
disp(' ')
disp([name '.config = ']);
disp(' ');
disp([' ''' o.config '''']);
disp(' ')
disp([name '.numPages() = ']);
disp(' ');
disp([' ' num2str(numPages(o))]);
disp(' ');
disp([name '.pages = ']);
disp(' ');
disp(o.pages.getPages());
reporting_object_display(o);
end

View File

@ -36,11 +36,10 @@ o.title = '';
o.orientation = 'portrait';
o.paper = 'a4';
o.margin = 2.5;
o.margin_unit = 'cm';
o.marginUnit = 'cm';
o.pages = pages();
o.filename = 'report.tex';
o.config = '';
o.showdate = true;
o.showDate = true;
o.compiler = '';
if nargin == 1
@ -54,16 +53,16 @@ elseif nargin > 1
'pairs']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@report.report: %s is not a recognized option.', ...
field);
error('@report.report: %s is not a recognized option.', pair{1});
end
end
end
@ -71,14 +70,13 @@ end
% Check options provided by user
assert(ischar(o.title), '@report.report: title must be a string');
assert(ischar(o.filename), '@report.report: filename must be a string');
assert(ischar(o.config), '@report.report: config file must be a string');
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
assert(islogical(o.showdate), '@report.report: showdate must be either true or false');
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
valid_margin_unit = {'cm', 'in'};
assert(any(strcmp(o.margin_unit, valid_margin_unit)), ...
['@report.report: margin_unit must be one of ' strjoin(valid_margin_unit, ' ')]);
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
valid_paper = {'a4', 'letter'};
assert(any(strcmp(o.paper, valid_paper)), ...

View File

@ -36,16 +36,25 @@ end
fprintf(fid, '%% Report Object\n');
fprintf(fid, '\\documentclass[11pt]{article}\n');
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.margin_unit);
fprintf(fid, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.marginUnit);
if strcmpi(o.orientation, 'landscape')
fprintf(fid, ',landscape');
end
fprintf(fid, ']{geometry}\n');
fprintf(fid, '\\usepackage{pdflscape, pgf, pgfplots, booktabs}\n');
fprintf(fid, '\\usepackage{pdflscape, pgf, booktabs}\n');
fprintf(fid, ['\\makeatletter\n' ...
'\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ...
'\\makeatother\n']);
if o.showdate
if exist('OCTAVE_VERSION') && isempty(regexpi(computer, '.*apple.*', 'once'))
fprintf(fid, '\\usepackage[T1]{fontenc}\n');
fprintf(fid, '\\usepackage[utf8x]{inputenc}\n');
fprintf(fid, '\\usepackage{gnuplot-lua-tikz}\n');
else
fprintf(fid, '\\usepackage{pgfplots}\n');
end
if o.showDate
fprintf(fid, '\\usepackage{fancyhdr, datetime}\n');
fprintf(fid, '\\newdateformat{reportdate}{\\THEDAY\\ \\shortmonthname\\ \\THEYEAR}\n');
fprintf(fid, '\\pagestyle{fancy}\n');

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Section object
%
% INPUTS
% none
% o [section] section object
%
% OUTPUTS
% none
@ -28,15 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section';
disp(' ');
disp([name '.cols = ']);
disp(' ');
disp(o.cols);
disp(' ');
disp([name '.elements = ']);
disp(' ');
disp(o.elements.getElements());
reporting_object_display(o);
end

View File

@ -36,16 +36,16 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@section.section: %s is not a recognized option.', ...
field);
error('@section.section: %s is not a recognized option.', pair{1});
end
end
end

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Sections object
%
% INPUTS
% none
% o [sections] sections object
%
% OUTPUTS
% none
@ -28,9 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'reports.page';
disp(' ');
disp([name '.sections = ']);
disp(' ');
disp(getSections(o));
reporting_object_display(o);
end

View File

@ -1,5 +1,5 @@
function ns = numSections(ss)
% function ns = numSections(ss)
function n = numSections(o)
% function n = numSections(o)
% Copyright (C) 2013 Dynare Team
%
@ -18,5 +18,5 @@ function ns = numSections(ss)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
ns = ss.objArray.numObjs();
n = o.objArray.numObjArray();
end

View File

@ -28,44 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section.graph.series';
disp(' ');
disp([name '.data = ']);
disp(' ');
display(o.data);
disp(' ');
disp([name '.color = ']);
disp(' ');
disp([' ''' o.color '''']);
disp(' ');
disp([name '.line_style = ']);
disp(' ');
disp([' ''' o.line_style '''']);
disp(' ');
disp([name '.line_width = ']);
disp(' ');
disp([' ''' o.line_width '''']);
disp(' ');
disp([name '.graph_marker = ']);
disp(' ');
disp([' ''' o.graph_marker '''']);
disp(' ');
disp([name '.graph_marker_edge_color = ']);
disp(' ');
disp([' ''' o.graph_marker_edge_color '''']);
disp(' ');
disp([name '.graph_marker_face_color = ']);
disp(' ');
disp([' ''' o.graph_marker_face_color '''']);
disp(' ');
disp([name '.graph_marker_size = ']);
disp(' ');
disp([' ''' o.graph_marker_size '''']);
reporting_object_display(o);
end

View File

@ -34,28 +34,28 @@ assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ['@series.getLine: must ' .
'provide data as a dynSeries']);
% Line
assert(ischar(o.color), '@series.getLine: color must be a string');
assert(ischar(o.graphLineColor), '@series.getLine: graphLineColor must be a string');
valid_line_style = {'none', '-', '--', ':', '-.'};
assert(any(strcmp(o.line_style, valid_line_style)), ...
['@series.getLine: line_style must be one of ' strjoin(valid_line_style, ' ')]);
assert(isfloat(o.line_width), ['@series.getLine: line_width must be a ' ...
assert(any(strcmp(o.graphLineStyle, valid_line_style)), ...
['@series.getLine: graphLineStyle must be one of ' strjoin(valid_line_style, ' ')]);
assert(isfloat(o.graphLineWidth), ['@series.getLine: graphLineWidth must be a ' ...
'positive number']);
% Graph_Marker
valid_graph_marker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
% GraphMarker
valid_graphMarker = {'+', 'o', '*', '.', 'x', 's', 'square', 'd', 'diamond', ...
'^', 'v', '>', '<', 'p', 'pentagram', 'h', 'hexagram', ...
'none'};
assert(isempty(o.graph_marker) || any(strcmp(o.graph_marker, valid_graph_marker)), ...
['@series.getLine: graph_marker must be one of ' strjoin(valid_graph_marker)]);
assert(isempty(o.graphMarker) || any(strcmp(o.graphMarker, valid_graphMarker)), ...
['@series.getLine: graphMarker must be one of ' strjoin(valid_graphMarker)]);
assert(ischar(o.graph_marker_edge_color), '@series.getLine: graph_marker_edge_color must be a string');
assert(ischar(o.graph_marker_face_color), '@series.getLine: graph_marker_face_color must be a string');
assert(isfloat(o.graph_marker_size), ['@series.getLine: graph_marker_size must be a ' ...
assert(ischar(o.graphMarkerEdgeColor), '@series.getLine: graphMarkerEdgeColor must be a string');
assert(ischar(o.graphMarkerFaceColor), '@series.getLine: graphMarkerFaceColor must be a string');
assert(isfloat(o.graphMarkerSize), ['@series.getLine: graphMarkerSize must be a ' ...
'positive number']);
% Marker & Line
assert(~(strcmp(o.line_style, 'none') && isempty(o.graph_marker)), ['@series.getLine: ' ...
'you must provide at least one of line_style and graph_marker']);
assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@series.getLine: ' ...
'you must provide at least one of graphLineStyle and graphMarker']);
% Validate xrange
assert(isempty(xrange) || isa(xrange, 'dynDates'));
@ -70,15 +70,15 @@ end
opt = {'XData', 1:length(ds.data)};
opt = {opt{:}, 'YData', ds.data};
opt = {opt{:}, 'Color', o.color};
opt = {opt{:}, 'LineStyle', o.line_style};
opt = {opt{:}, 'LineWidth', o.line_width};
opt = {opt{:}, 'Color', o.graphLineColor};
opt = {opt{:}, 'LineStyle', o.graphLineStyle};
opt = {opt{:}, 'LineWidth', o.graphLineWidth};
if ~isempty(o.graph_marker)
opt = {opt{:}, 'Marker', o.graph_marker};
opt = {opt{:}, 'MarkerSize', o.graph_marker_size};
opt = {opt{:}, 'MarkerEdgeColor', o.graph_marker_edge_color};
opt = {opt{:}, 'MarkerFaceColor', o.graph_marker_face_color};
if ~isempty(o.graphMarker)
opt = {opt{:}, 'Marker', o.graphMarker};
opt = {opt{:}, 'MarkerSize', o.graphMarkerSize};
opt = {opt{:}, 'MarkerEdgeColor', o.graphMarkerEdgeColor};
opt = {opt{:}, 'MarkerFaceColor', o.graphMarkerFaceColor};
end
h = line(opt{:});

View File

@ -35,20 +35,21 @@ o = struct;
o.data = '';
o.color = 'k';
o.line_style = '-';
o.line_width = 0.5;
o.graphLineColor = 'k';
o.graphLineStyle = '-';
o.graphLineWidth = 0.5;
o.graph_marker = '';
o.graph_marker_edge_color = 'auto';
o.graph_marker_face_color = 'auto';
o.graph_marker_size = 6;
o.graphMarker = '';
o.graphMarkerEdgeColor = 'auto';
o.graphMarkerFaceColor = 'auto';
o.graphMarkerSize = 6;
o.table_markers = false;
o.table_neg_color = 'red';
o.table_pos_color = 'blue';
o.tableShowMarkers = false;
o.tableNegColor = 'red';
o.tablePosColor = 'blue';
o.tableMarkerLimit = 1e-4;
o.table_align_right = false;
o.tableAlignRight = false;
if nargin == 1
assert(isa(varargin{1}, 'series'),['@series.series: with one arg you ' ...
@ -61,15 +62,16 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@series.series: %s is not a recognized option.', field);
error('@series.series: %s is not a recognized option.', pair{1});
end
end
end

View File

@ -4,6 +4,7 @@ function o = write(o, fid, dates, precision)
%
% INPUTS
% o [series] series object
% fid [int] file id
% dates [dynDates] dates for series slice
% precision [float] precision with which to print the data
%
@ -39,42 +40,40 @@ assert(isint(precision));
assert(~isempty(o.data) && isa(o.data, 'dynSeries'), ...
'@series.write: must provide data as a dynSeries');
assert(ischar(o.color), '@series.write: color must be a string');
assert(ischar(o.table_neg_color), '@series.write: table_neg_color must be a string');
assert(ischar(o.table_pos_color), '@series.write: table_pos_color must be a string');
assert(islogical(o.table_markers), '@series.write: table_markers must be a string');
assert(islogical(o.table_align_right), '@series.write: table_align_right must be a string');
assert(ischar(o.tableNegColor), '@series.write: tableNegColor must be a string');
assert(ischar(o.tablePosColor), '@series.write: tablePosColor must be a string');
assert(islogical(o.tableShowMarkers), '@series.write: tableShowMarkers must be true or false');
assert(islogical(o.tableAlignRight), '@series.write: tableAlignRight must be true or false');
assert(isfloat(o.tableMarkerLimit), '@series,write: tableMarkerLimit must be a float');
%% Write Output
dataString = ['%.' num2str(precision) 'f'];
precision = 10^precision;
fprintf(fid, '%% Table Row (series)\n');
if o.table_align_right
if o.tableAlignRight
fprintf(fid, '\\multicolumn{1}{r}{');
end
fprintf(fid, '%s', o.data.tex{:});
if o.table_align_right
if o.tableAlignRight
fprintf(fid, '}');
end
data = o.data(dates);
data = data.data;
for i=1:size(data,1)
thisCellData = round(data(i)*precision)/precision;
fprintf(fid, ' &');
if o.table_markers
if thisCellData < 0
fprintf(fid, '\\color{%s}', o.table_neg_color);
elseif thisCellData > 0
fprintf(fid, '\\color{%s}', o.table_pos_color);
if o.tableShowMarkers
if data(i) < -o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tableNegColor);
elseif data(i) > o.tableMarkerLimit
fprintf(fid, '\\color{%s}', o.tablePosColor);
end
fprintf(fid, '[');
end
fprintf(fid, dataString, thisCellData);
fprintf(fid, dataString, round(data(i)*precision)/precision);
if o.table_markers
if o.tableShowMarkers
fprintf(fid, ']');
end
end

View File

@ -1,9 +1,9 @@
function display(o)
%function display(o)
% Display a Elements object
% Display a seriesElements object
%
% INPUTS
% none
% o [seriesElements] seriesElements object
%
% OUTPUTS
% none
@ -28,10 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section.elements.seriesElement';
disp(' ');
disp([name ' = ']);
disp(' ');
disp(getSeriesElements(o));
reporting_object_display(o);
end

View File

@ -18,7 +18,7 @@ function dd = getMaxRange(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
ne = numElements(o);
ne = numSeriesElements(o);
ddmin = dynDate();
ddmax = dynDate();
for i=1:ne

View File

@ -1,5 +1,5 @@
function n = numElements(o)
% function n = numElements(o)
function n = numSeriesElements(o)
% function n = numSeriesElements(o)
% Copyright (C) 2013 Dynare Team
%
@ -18,5 +18,5 @@ function n = numElements(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
n = o.objArray.numObjs();
n = o.objArray.numObjArray();
end

View File

@ -3,7 +3,7 @@ function display(o)
% Display a Table object
%
% INPUTS
% none
% o [table] table object
%
% OUTPUTS
% none
@ -28,34 +28,5 @@ function display(o)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
name = 'report.page.section.table';
disp(' ');
disp([name '.title = ']);
disp(' ');
disp([' ''' o.title '''']);
disp(' ');
disp([name '.footnote = ']);
disp(' ');
disp([' ''' o.footnote '''']);
disp(' ');
disp([name '.hlines = ']);
disp(' ');
disp(o.hlines);
disp(' ');
disp([name '.vlines = ']);
disp(' ');
disp(o.vlines);
disp(' ');
disp([name '.precision = ']);
disp(' ');
disp(o.precision);
disp(' ');
disp([name '.seriesElements = ']);
disp(' ');
o.seriesElements.getSeriesElements()
reporting_object_display(o);
end

View File

@ -34,16 +34,14 @@ o = struct;
o.seriesElements = seriesElements();
o.title = '';
o.title_size = 'large';
o.footnote = '';
o.titleSize = 'large';
o.config = '';
o.hlines = false;
o.vlines = false;
o.vline_after = '';
o.showHlines = false;
o.showVlines = false;
o.vlineAfter = '';
o.data = '';
o.seriestouse = '';
o.seriesToUse = '';
o.range = {};
o.precision = 1;
@ -58,57 +56,55 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('%s is not a recognized option to the Table constructor.', ...
field);
error('%s is not a recognized option to the Table constructor.', pair{1});
end
end
end
% Check options provided by user
assert(ischar(o.title), '@table.table: title must be a string');
assert(ischar(o.footnote), '@table.table: footnote must be a string');
assert(ischar(o.config), '@table.table: config file must be a string');
assert(islogical(o.hlines), '@table.table: hlines must be true or false');
assert(islogical(o.vlines), '@table.table: vlines must be true or false');
assert(islogical(o.showHlines), '@table.table: showHlines must be true or false');
assert(islogical(o.showVlines), '@table.table: showVlines must be true or false');
assert(isint(o.precision), '@table.table: precision must be an int');
assert(isempty(o.range) || (isa(o.range, 'dynDates') && o.range.ndat >= 2), ...
['@table.table: range is specified as a dynDates range, e.g. ' ...
'''dynDates(''1999q1''):dynDates(''1999q3'')''.']);
assert(isempty(o.data) || isa(o.data, 'dynSeries'), ...
'@table.table: data must be a dynSeries');
assert(isempty(o.seriestouse) || iscellstr(o.seriestouse), ...
'@table.table: seriestouse must be a cell array of string(s)');
assert(isempty(o.vline_after) || isa(o.vline_after, 'dynDate'), ...
'@table.table: vline_after must be a dynDate');
if o.vlines
o.vline_after = '';
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
'@table.table: seriesToUse must be a cell array of string(s)');
assert(isempty(o.vlineAfter) || isa(o.vlineAfter, 'dynDate'), ...
'@table.table: vlineAfter must be a dynDate');
if o.showVlines
o.vlineAfter = '';
end
valid_title_sizes = {'Huge', 'huge', 'LARGE', 'Large', 'large', 'normalsize', ...
'small', 'footnotesize', 'scriptsize', 'tiny'};
assert(any(strcmp(o.title_size, valid_title_sizes)), ...
['@table.table: title_size must be one of ' strjoin(valid_title_sizes, ' ')]);
assert(any(strcmp(o.titleSize, valid_title_sizes)), ...
['@table.table: titleSize must be one of ' strjoin(valid_title_sizes, ' ')]);
% using o.seriestouse, create series objects and put them in o.seriesElements
% using o.seriesToUse, create series objects and put them in o.seriesElements
if ~isempty(o.data)
if isempty(o.seriestouse)
if isempty(o.seriesToUse)
for i=1:o.data.vobs
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.data.name{i}});
end
else
for i=1:length(o.seriestouse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriestouse{i}});
for i=1:length(o.seriesToUse)
o.seriesElements = o.seriesElements.addSeries('data', o.data{o.seriesToUse{i}});
end
end
end
o = rmfield(o, 'seriestouse');
o = rmfield(o, 'seriesToUse');
o = rmfield(o, 'data');
% Create table object

View File

@ -30,7 +30,7 @@ function o = write(o, fid)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(fid ~= -1);
if ~o.seriesElements.numElements()
if ~o.seriesElements.numSeriesElements()
warning('@table.write: no series to plot, returning');
return;
end
@ -54,12 +54,12 @@ fprintf(fid, '\\setlength{\\tabcolsep}{4pt}\n');
fprintf(fid, '\\begin{tabular}{@{}l');
for i=1:ndates
if o.vlines
if o.showVlines
fprintf(fid, '|');
end
fprintf(fid, 'r');
if ~isempty(o.vline_after)
if dates(i) == o.vline_after
if ~isempty(o.vlineAfter)
if dates(i) == o.vlineAfter
fprintf(fid, '|');
end
end
@ -67,7 +67,7 @@ end
fprintf(fid, '@{}}%%\n');
if ~isempty(o.title)
fprintf(fid, '\\multicolumn{%d}{c}{\\%s %s}\\\\\n', ...
ndates+nlhc, o.title_size, o.title);
ndates+nlhc, o.titleSize, o.title);
end
fprintf(fid, '\\toprule%%\n');
@ -122,9 +122,12 @@ fprintf(fid, '\\\\%%\n');
fprintf(fid, '%%\n');
% Write Table Data
ne = o.seriesElements.numElements();
ne = o.seriesElements.numSeriesElements();
for i=1:ne
o.seriesElements(i).write(fid, dates, o.precision);
if o.showHlines
fprintf(fid, '\\hline\n');
end
end
fprintf(fid, '\\bottomrule\n');

View File

@ -0,0 +1,32 @@
function display(o)
%function display(o)
% Display a Vspace object
%
% INPUTS
% o [vspace] vspace object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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/>.
reporting_object_display(o);
end

View File

@ -44,15 +44,16 @@ elseif nargin > 1
'pairs.']);
end
optNames = lower(fieldnames(o));
optNames = fieldnames(o);
% overwrite default values
for pair = reshape(varargin, 2, [])
field = lower(pair{1});
if any(strmatch(field, optNames, 'exact'))
o.(field) = pair{2};
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else
error('@vspace.vspace: %s is not a recognized option.', field);
error('@vspace.vspace: %s is not a recognized option.', pair{1});
end
end
end

View File

@ -0,0 +1,89 @@
function reporting_object_display(o)
%function reporting_object_display(o)
% Display a Reporting Object
% i.e., one of: elements
% graph
% objArray
% page
% pages
% report
% section
% sections
% series
% seriesElements
% table
% vspace
%
% INPUTS
% o [object] reporting object
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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/>.
fprintf('\n%s Object = \n\n', upper(class(o)));
fields = fieldnames(o);
for i=1:length(fields)
fprintf(' %s: ', fields{i});
val = o.(fields{i});
if iscell(val)
fprintf('{');
for j=1:length(val)
assert(ischar(val{j}));
fprintf('''%s''', val{j});
if j~=length(val)
fprintf(', ');
end
end
fprintf('}');
elseif ischar(val)
fprintf('''%s''', val);
elseif isnumeric(val)
fprintf('%s', num2str(val));
elseif islogical(val)
if val
fprintf('true');
else
fprintf('false');
end
elseif isobject(val)
if isa(val, 'dynDates')
fprintf('<dynDates: %s, ..., %s>', ...
val(1).format, val(end).format);
elseif isa(val, 'dynSeries')
if numel(val) == 1
fprintf('<dynSeries: %s>', val.name{1});
else
fprintf('%s', class(val));
end
else
cl = class(val);
fprintf('%d', val.(['num' upper(cl(1)) cl(2:end)]));
end
else
keyboard
fprintf('fix this');
end
fprintf('\n');
end
fprintf('\n');
end

View File

@ -47,7 +47,7 @@ if options_.order == 3
options_.k_order_solver = 1;
end
if ~options_.k_order_solver
if ~options_.k_order_solver || (options_.k_order_solver && options_.pruning) %if k_order_pert is not used or if we do not use Dynare++ with k_order_pert
if iorder==1
y_(:,1) = y_(:,1)-dr.ys;
end

View File

@ -3924,29 +3924,29 @@ DynamicModel::writeLatexFile(const string &basename) const
void
DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model)
{
substituteLeadLagInternal(avEndoLead, deterministic_model);
substituteLeadLagInternal(avEndoLead, deterministic_model, vector<string>());
}
void
DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model)
{
substituteLeadLagInternal(avEndoLag, deterministic_model);
substituteLeadLagInternal(avEndoLag, deterministic_model, vector<string>());
}
void
DynamicModel::substituteExoLead(bool deterministic_model)
{
substituteLeadLagInternal(avExoLead, deterministic_model);
substituteLeadLagInternal(avExoLead, deterministic_model, vector<string>());
}
void
DynamicModel::substituteExoLag(bool deterministic_model)
{
substituteLeadLagInternal(avExoLag, deterministic_model);
substituteLeadLagInternal(avExoLag, deterministic_model, vector<string>());
}
void
DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model)
DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model, const vector<string> &subset)
{
ExprNode::subst_table_t subst_table;
vector<BinaryOpNode *> neweqs;
@ -3976,7 +3976,7 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
subst = value->substituteExoLag(subst_table, neweqs);
break;
case avDiffForward:
subst = value->differentiateForwardVars(subst_table, neweqs);
subst = value->differentiateForwardVars(subset, subst_table, neweqs);
break;
default:
cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
@ -4004,7 +4004,7 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
subst = equations[i]->substituteExoLag(subst_table, neweqs);
break;
case avDiffForward:
subst = equations[i]->differentiateForwardVars(subst_table, neweqs);
subst = equations[i]->differentiateForwardVars(subset, subst_table, neweqs);
break;
default:
cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
@ -4134,9 +4134,9 @@ DynamicModel::removeTrendVariableFromEquations()
}
void
DynamicModel::differentiateForwardVars()
DynamicModel::differentiateForwardVars(const vector<string> &subset)
{
substituteLeadLagInternal(avDiffForward, true);
substituteLeadLagInternal(avDiffForward, true, subset);
}
void

View File

@ -139,8 +139,11 @@ private:
void collectBlockVariables();
//! Factorized code for substitutions of leads/lags
/*! \param[in] type determines which type of variables is concerned */
void substituteLeadLagInternal(aux_var_t type, bool deterministic_model);
/*! \param[in] type determines which type of variables is concerned
\param[in] deterministic_model whether we are in a deterministic model (only for exogenous leads/lags)
\param[in] subset variables to which to apply the transformation (only for diff of forward vars)
*/
void substituteLeadLagInternal(aux_var_t type, bool deterministic_model, const vector<string> &subset);
private:
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
@ -281,7 +284,9 @@ public:
void removeTrendVariableFromEquations();
//! Transforms the model by creating aux vars for the diff of forward vars
void differentiateForwardVars();
/*! If subset is empty, does the transformation for all fwrd vars; otherwise
restrict it to the vars in subset */
void differentiateForwardVars(const vector<string> &subset);
//! Fills eval context with values of model local variables and auxiliary variables
void fillEvalContext(eval_context_t &eval_context) const;

View File

@ -568,7 +568,8 @@ model_options : BLOCK { driver.block(); }
| BYTECODE { driver.byte_code(); }
| USE_DLL { driver.use_dll(); }
| NO_STATIC { driver.no_static();}
| DIFFERENTIATE_FORWARD_VARS { driver.differentiate_forward_vars(); }
| DIFFERENTIATE_FORWARD_VARS { driver.differentiate_forward_vars_all(); }
| DIFFERENTIATE_FORWARD_VARS EQUAL '(' symbol_list ')' { driver.differentiate_forward_vars_some(); }
| o_linear
;

View File

@ -431,7 +431,7 @@ NumConstNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
}
expr_t
NumConstNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
NumConstNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<NumConstNode *>(this);
}
@ -1225,14 +1225,16 @@ VariableNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
}
expr_t
VariableNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
VariableNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t value;
switch (type)
{
case eEndogenous:
assert(lag <= 1);
if (lag <= 0)
if (lag <= 0
|| (subset.size() > 0
&& find(subset.begin(), subset.end(), datatree.symbol_table.getName(symb_id)) == subset.end()))
return const_cast<VariableNode *>(this);
else
{
@ -1255,7 +1257,7 @@ VariableNode::differentiateForwardVars(subst_table_t &subst_table, vector<Binary
if (value->maxEndoLead() <= 0)
return const_cast<VariableNode *>(this);
else
return value->differentiateForwardVars(subst_table, neweqs);
return value->differentiateForwardVars(subset, subst_table, neweqs);
default:
return const_cast<VariableNode *>(this);
}
@ -2339,9 +2341,9 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo
}
expr_t
UnaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
UnaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t argsubst = arg->differentiateForwardVars(subst_table, neweqs);
expr_t argsubst = arg->differentiateForwardVars(subset, subst_table, neweqs);
return buildSimilarUnaryOpNode(argsubst, datatree);
}
@ -3583,10 +3585,10 @@ BinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
expr_t
BinaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
BinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->differentiateForwardVars(subst_table, neweqs);
expr_t arg2subst = arg2->differentiateForwardVars(subst_table, neweqs);
expr_t arg1subst = arg1->differentiateForwardVars(subset, subst_table, neweqs);
expr_t arg2subst = arg2->differentiateForwardVars(subset, subst_table, neweqs);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
@ -4200,11 +4202,11 @@ TrinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOp
expr_t
TrinaryOpNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
TrinaryOpNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->differentiateForwardVars(subst_table, neweqs);
expr_t arg2subst = arg2->differentiateForwardVars(subst_table, neweqs);
expr_t arg3subst = arg3->differentiateForwardVars(subst_table, neweqs);
expr_t arg1subst = arg1->differentiateForwardVars(subset, subst_table, neweqs);
expr_t arg2subst = arg2->differentiateForwardVars(subset, subst_table, neweqs);
expr_t arg3subst = arg3->differentiateForwardVars(subset, subst_table, neweqs);
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
@ -4765,11 +4767,11 @@ ExternalFunctionNode::substituteExpectation(subst_table_t &subst_table, vector<B
}
expr_t
ExternalFunctionNode::differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
ExternalFunctionNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
vector<expr_t> arguments_subst;
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
arguments_subst.push_back((*it)->differentiateForwardVars(subst_table, neweqs));
arguments_subst.push_back((*it)->differentiateForwardVars(subset, subst_table, neweqs));
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}

View File

@ -361,11 +361,13 @@ public:
//! Constructs a new expression where forward variables (supposed to be at most in t+1) have been replaced by themselves at t, plus a new aux var representing their (time) differentiate
/*!
\param[in] subset variables to which to limit the transformation; transform
all fwrd vars if empty
\param[in,out] subst_table Map used to store mapping between a given
forward variable and the aux var that contains its differentiate
\param[out] neweqs Equations to be added to the model to match the creation of auxiliary variables.
*/
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
//! Return true if the nodeID is a numerical constant equal to value and false otherwise
/*!
@ -452,7 +454,7 @@ public:
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
@ -514,7 +516,7 @@ public:
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
@ -591,7 +593,7 @@ public:
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
@ -681,7 +683,7 @@ public:
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
@ -751,7 +753,7 @@ public:
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
@ -825,7 +827,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool containsEndogenous(void) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;

View File

@ -250,6 +250,19 @@ ModFile::checkPass()
cerr << "ERROR: marking equations as [static] or [dynamic] is not possible with ramsey_policy or discretionary_policy" << endl;
exit(EXIT_FAILURE);
}
if (stochastic_statement_present &&
(dynamic_model.isUnaryOpUsed(oSign)
|| dynamic_model.isUnaryOpUsed(oAbs)
|| dynamic_model.isBinaryOpUsed(oMax)
|| dynamic_model.isBinaryOpUsed(oMin)
|| dynamic_model.isBinaryOpUsed(oGreater)
|| dynamic_model.isBinaryOpUsed(oLess)
|| dynamic_model.isBinaryOpUsed(oGreaterEqual)
|| dynamic_model.isBinaryOpUsed(oLessEqual)
|| dynamic_model.isBinaryOpUsed(oEqualEqual)
|| dynamic_model.isBinaryOpUsed(oDifferent)))
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
}
void
@ -309,7 +322,7 @@ ModFile::transformPass()
}
if (differentiate_forward_vars)
dynamic_model.differentiateForwardVars();
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset);
if (mod_file_struct.dsge_var_estimated || !mod_file_struct.dsge_var_calibrated.empty())
try

View File

@ -78,6 +78,12 @@ public:
//! Is the 'differentiate_forward_vars' option used?
bool differentiate_forward_vars;
/*! If the 'differentiate_forward_vars' option is used, contains the set of
endogenous with respect to which to do the transformation;
if empty, means that the transformation must be applied to all endos
with a lead */
vector<string> differentiate_forward_vars_subset;
//! Are nonstationary variables present ?
bool nonstationary_variables;

View File

@ -494,11 +494,26 @@ ParsingDriver::byte_code()
}
void
ParsingDriver::differentiate_forward_vars()
ParsingDriver::differentiate_forward_vars_all()
{
mod_file->differentiate_forward_vars = true;
}
void
ParsingDriver::differentiate_forward_vars_some()
{
mod_file->differentiate_forward_vars = true;
mod_file->differentiate_forward_vars_subset = symbol_list.get_symbols();
for (vector<string>::const_iterator it = mod_file->differentiate_forward_vars_subset.begin();
it != mod_file->differentiate_forward_vars_subset.end(); ++it)
{
check_symbol_existence(*it);
if (mod_file->symbol_table.getType(*it) != eEndogenous)
error("Symbol " + *it + " is not an endogenous");
}
symbol_list.clear();
}
void
ParsingDriver::cutoff(string *value)
{

View File

@ -245,8 +245,10 @@ public:
void byte_code();
//! the static model is not computed
void no_static();
//! the differentiate_forward_vars option is enabled
void differentiate_forward_vars();
//! the differentiate_forward_vars option is enabled (for all vars)
void differentiate_forward_vars_all();
//! the differentiate_forward_vars option is enabled (for a subset of vars)
void differentiate_forward_vars_some();
//! cutoff option of model block
void cutoff(string *value);
//! mfs option of model block