Merge branch 'master' into ecb-master

time-shift
Houtan Bastani 2017-04-14 11:35:43 +02:00
commit db535236b2
91 changed files with 1968 additions and 847 deletions

View File

@ -26,7 +26,7 @@
}}
\author{S\'ebastien Villemot\thanks{Paris School of Economics and
CEPREMAP.} \and Johannes Pfeifer\thanks{University of Mannheim. E-mail: \href{mailto:pfeifer@uni-mannheim.de}{\texttt{pfeifer@uni-mannheim.de}}.}}
CEPREMAP.} \and Johannes Pfeifer\thanks{University of Cologne. E-mail: \href{mailto:jpfeifer@uni-koeln.de}{\texttt{jpfeifer@uni-koeln.de}}.}}
\date{First version: September 2007 \hspace{1cm} This version: October 2016}
\maketitle

View File

@ -2,6 +2,8 @@
@c %**start of header
@setfilename dynare.info
@documentencoding UTF-8
@set txicodequoteundirected
@settitle Dynare Reference Manual
@afourwide
@dircategory Math
@ -206,6 +208,9 @@ The Model file
* Deterministic simulation::
* Stochastic solution and simulation::
* Estimation::
* Model Comparison::
* Shock Decomposition::
* Calibrated Smoother::
* Forecasting::
* Optimal policy::
* Sensitivity and identification analysis::
@ -371,7 +376,7 @@ Adjemian (Université du Maine, Gains and Cepremap), Houtan Bastani
(Cepremap), Michel Juillard (Banque de France), Frédéric Karamé
(Université du Maine, Gains and Cepremap), Junior Maih (Norges Bank),
Ferhat Mihoubi (Université Paris-Est Créteil, Epee and Cepremap), George
Perendia, Johannes Pfeifer (University of Mannheim), Marco Ratto (European Commission, Joint Research Centre - JRC)
Perendia, Johannes Pfeifer (University of Cologne), Marco Ratto (European Commission, Joint Research Centre - JRC)
and Sébastien Villemot (OFCE Sciences Po).
Increasingly, the developer base is expanding, as tools developed by
researchers outside of Cepremap are integrated into Dynare. Financial
@ -1065,6 +1070,9 @@ end of line one and the parser would continue processing.
* Deterministic simulation::
* Stochastic solution and simulation::
* Estimation::
* Model Comparison::
* Shock Decomposition::
* Calibrated Smoother::
* Forecasting::
* Optimal policy::
* Sensitivity and identification analysis::
@ -1105,6 +1113,10 @@ mutually exclusive arguments are separated by vertical bars: @samp{|};
@item
@var{INTEGER} indicates an integer number;
@item
@var{INTEGER_VECTOR} indicates a vector of integer numbers separated by spaces,
enclosed by square brackets;
@item
@var{DOUBLE} indicates a double precision number. The following syntaxes
are valid: @code{1.1e3}, @code{1.1E3}, @code{1.1d3}, @code{1.1D3}. In
@ -2103,6 +2115,7 @@ Compiling the @TeX{} file requires the following @LaTeX{} packages:
@anchor{write_latex_dynamic_model}
@deffn Command write_latex_dynamic_model ;
@deffnx Command write_latex_dynamic_model (@var{OPTIONS}) ;
@descriptionhead
@ -2149,6 +2162,16 @@ also have been replaced by new auxiliary variables and equations.
For the required @LaTeX{} packages, @pxref{write_latex_original_model}.
@optionshead
@table @code
@item write_equation_tags
Write the equation tags in the @LaTeX{} output. NB: the equation tags will be
interpreted with @LaTeX{} markups.
@end table
@end deffn
@deffn Command write_latex_static_model ;
@ -3486,6 +3509,7 @@ end;
@deffn Command check ;
@deffnx Command check (solve_algo = @var{INTEGER}) ;
@anchor{check}
@descriptionhead
@ -6369,6 +6393,22 @@ Sets the method for approximating the particle distribution. Possible values for
@item cpf_weights = @var{OPTION}
@anchor{cpf_weights} Controls the method used to update the weights in conditional particle filter, possible values are @code{amisanotristani} (@cite{Amisano et al (2010)}) or @code{murrayjonesparslow} (@cite{Murray et al. (2013)}). Default value is @code{amisanotristani}.
@item nonlinear_filter_initialization = @var{INTEGER}
@anchor{nonlinear_filter_initialization} Sets the initial condition of the
nonlinear filters. By default the nonlinear filters are initialized with the
unconditional covariance matrix of the state variables, computed with the
reduced form solution of the first order approximation of the model. If
@code{nonlinear_filter_initialization=2}, the nonlinear filter is instead
initialized with a covariance matrix estimated with a stochastic simulation of
the reduced form solution of the second order approximation of the model. Both
these initializations assume that the model is stationary, and cannot be used
if the model has unit roots (which can be seen with the @ref{check} command
prior to estimation). If the model has stochastic trends, user must use
@code{nonlinear_filter_initialization=3}, the filters are then initialized with
an identity matrix for the covariance matrix of the state variables. Default
value is @code{nonlinear_filter_initialization=1} (initialization based on the
first order approximation of the model).
@end table
@ -7006,6 +7046,24 @@ estimates using a higher tapering are usually more reliable.
@end table
@end defvr
@deffn Command unit_root_vars @var{VARIABLE_NAME}@dots{};
This command is deprecated. Use @code{estimation} option @code{diffuse_filter} instead for estimating a model with non-stationary observed variables or @code{steady} option @code{nocheck} to prevent @code{steady} to check the steady state returned by your steady state file.
@end deffn
Dynare also has the ability to estimate Bayesian VARs:
@deffn Command bvar_density ;
Computes the marginal density of an estimated BVAR model, using
Minnesota priors.
See @file{bvar-a-la-sims.pdf}, which comes with Dynare distribution,
for more information on this command.
@end deffn
@node Model Comparison
@section Model Comparison
@deffn Command model_comparison @var{FILENAME}[(@var{DOUBLE})]@dots{};
@deffnx Command model_comparison (marginal_density = laplace | modifiedharmonicmean) @var{FILENAME}[(@var{DOUBLE})]@dots{};
@anchor{model_comparison}
@ -7081,6 +7139,8 @@ Posterior probability of the respective model
@end defvr
@node Shock Decomposition
@section Shock Decomposition
@deffn Command shock_decomposition [@var{VARIABLE_NAME}]@dots{};
@deffnx Command shock_decomposition (@var{OPTIONS}@dots{}) [@var{VARIABLE_NAME}]@dots{};
@ -7102,19 +7162,14 @@ model).
@table @code
@item parameter_set = @var{PARAMETER_SET}
Specify the parameter set to use for running the smoother. The
@var{PARAMETER_SET} can take one of the following seven values:
@code{calibration}, @code{prior_mode}, @code{prior_mean},
@code{posterior_mode}, @code{posterior_mean},
@code{posterior_median}, @code{mle_mode}. Note that the parameter
set used in subsequent commands like @code{stoch_simul} will be set to
the specified @code{parameter_set}.
Default value: @code{posterior_mean} if
@item parameter_set = @code{calibration} | @code{prior_mode} | @code{prior_mean} | @code{posterior_mode} | @code{posterior_mean} | @code{posterior_median} | @code{mle_mode}
@anchor{parameter_set} Specify the parameter set to use for running the smoother. Note that the
parameter set used in subsequent commands like @code{stoch_simul} will be set
to the specified @code{parameter_set}. Default value: @code{posterior_mean} if
Metropolis has been run, @code{mle_mode} if MLE has been run.
@item datafile = @var{FILENAME}
@xref{datafile}. Useful when computing the shock decomposition on a
@anchor{datafile_shock_decomp} @xref{datafile}. Useful when computing the shock decomposition on a
calibrated model.
@item first_obs = @var{INTEGER}
@ -7123,22 +7178,21 @@ calibrated model.
@item nobs = @var{INTEGER}
@xref{nobs}.
@item use_shock_groups [= @var{SHOCK_GROUPS_NAME}]
@anchor{use_shock_groups} Uses groups of shocks instead of individual shocks in
the decomposition. Groups of shocks are defined in the @ref{shock_groups} block.
@item use_shock_groups [= @var{STRING}]
@anchor{use_shock_groups} Uses shock grouping defined by the string instead of individual shocks in
the decomposition. The groups of shocks are defined in the @ref{shock_groups} block.
@item colormap = @var{COLORMAP_NAME}
@item colormap = @var{STRING}
@anchor{colormap} Controls the colormap used for the shocks decomposition
graphs. See @code{colormap} in Matlab/Octave manual.
graphs. See @code{colormap} in Matlab/Octave manual for valid arguments.
@item nograph
@xref{nograph} Suppresses the display and creation only within the
@code{shock_decomposition}-command but does not affect other commands.
@xref{nograph}. Suppresses the display and creation only within the
@code{shock_decomposition}-command, but does not affect other commands.
@xref{plot_shock_decomposition} for plotting graphs.
@item init_state = @var{INTEGER}
@anchor{init_state} It can take values of @math{0} or @math{1}. If equal to
@math{0}, the shock decomposition is computed conditional on the smoothed state
@item init_state = @var{BOOLEAN}
@anchor{init_state} If equal to @math{0}, the shock decomposition is computed conditional on the smoothed state
variables in period @math{0}, @i{i.e.} the smoothed shocks starting in period
@math{1} are used. If equal to @math{1}, the shock decomposition is computed
conditional on the smoothed state variables in period @math{1}. Default:
@ -7147,10 +7201,12 @@ conditional on the smoothed state variables in period @math{1}. Default:
@outputhead
@defvr {MATLAB/Octave variable} oo_.shock_decomposition
@vindex oo_.shock_decomposition
@anchor{oo_.shock_decomposition}
The results are stored in the field @code{oo_.shock_decomposition}, which is a three
dimensional array. The first dimension contains the @code{M_.endo_nbr} endogenous variables.
The second dimension stores
The second dimension stores
in the first @code{M_.exo_nbr} columns the contribution of the respective shocks.
Column @code{M_.exo_nbr+1} stores the contribution of the initial conditions,
while column @code{M_.exo_nbr+2} stores the smoothed value of the respective
@ -7158,6 +7214,7 @@ endogenous variable in deviations from their steady state, @i{i.e.} the mean and
subtracted. The third dimension stores the time periods. Both the variables
and shocks are stored in the order of declaration, @i{i.e.} @code{M_.endo_names} and
@code{M_.exo_names}, respectively.
@end defvr
@end deffn
@ -7168,11 +7225,11 @@ and shocks are stored in the order of declaration, @i{i.e.} @code{M_.endo_names}
of the shock groups is written in a block delimited by @code{shock_groups} and
@code{end}.
Each line defines a group of shock as a list of exogenous variables:
Each line defines a group of shocks as a list of exogenous variables:
@example
SHOCK_GROUP_NAME = VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
`SHOCK GROUP NAME' = VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
'SHOCK GROUP NAME' = VARIABLE_1 [[,] VARIABLE_2 [,]@dots{}];
@end example
@optionshead
@ -7196,12 +7253,13 @@ varexo e_a, e_b, e_c, e_d;
shock_groups(name=group1);
supply = e_a, e_b;
`aggregate demand' = e_c, e_d;
'aggregate demand' = e_c, e_d;
end;
shocks_decomposition(use_shock_groups=group1);
@end example
This example defines a shock grouping with the name @code{group1}, containing a set of supply and demand shocks
and conducts the shock decomposition for these two groups.
@end deffn
@deffn Command realtime_shock_decomposition [@var{VARIABLE_NAME}]@dots{};
@ -7212,16 +7270,22 @@ shocks_decomposition(use_shock_groups=group1);
This command computes the realtime historical shock decomposition for a given
sample based on the Kalman smoother. For each period
@math{T=[@code{presample}@dots{}@code{nobs}]}, it computes the:
@math{T=[@code{presample},@dots{},@code{nobs}]}, it recursively computes three objects:
@itemize @bullet
@item
realtime historical shock decomposition @math{Y(t|T)} for @math{t=[1@dots{}T]},
@i{i.e.} without observing data in @math{[T+1@dots{}@code{nobs}]};
realtime historical shock decomposition @math{Y(t|T)} for @math{t=[1,@dots{},T]},
@i{i.e.} without observing data in @math{[T+1,@dots{},@code{nobs}]}. This results in a standard
shock decomposition being computed for each additional datapoint becoming available after @code{presample}.
@item
conditional shock decomposition @math{Y(T|T)} conditional on @math{Y(T|T-1)},
@i{i.e.} @math{Y(t|T)} for @math{t=[T-1@dots{}T]};
forecast shock decomposition @math{Y(T+k|T)} for @math{k=[1,@dots{},forecast]}, @i{i.e.} the @math{k}-step
ahead forecast made for every @math{T} is decomposed in its shock contributions.
@item
forecast shock decomposition @math{Y(T|T-1)}.
realtime conditional shock decomposition of the difference between the realtime historical shock decomposition and the
forecast shock decomposition. If @ref{vintage} is equal to @math{0}, it computes the effect of shocks realizing in period
@math{T}, @i{i.e.} decomposes @math{Y(T|T)-Y(T|T-1)}. Put differently it conducts a @math{1}-period ahead shock decomposition from
@math{T-1} to @math{T}, by decomposing the update step of the Kalman filter. If @code{vintage>0} and smaller than @code{nobs},
the decomposition is conducted of the forecast revision @math{Y(T+k|T+k)-Y(T+k|T)}.
@end itemize
Like @ref{shock_decomposition} it decomposes the historical deviations of the endogenous
@ -7237,17 +7301,11 @@ model).
@table @code
@item parameter_set = @var{PARAMETER_SET}
Specify the parameter set to use for running the smoother.
@var{PARAMETER_SET} can take one of the following seven values:
@code{calibration}, @code{prior_mode}, @code{prior_mean},
@code{posterior_mode}, @code{posterior_mean},
@code{posterior_median}, @code{mle_mode}. Default value: @code{posterior_mean} if
Metropolis has been run, @code{mle_mode} if MLE has been run.
@item parameter_set = @code{calibration} | @code{prior_mode} | @code{prior_mean} | @code{posterior_mode} | @code{posterior_mean} | @code{posterior_median} | @code{mle_mode}
@xref{parameter_set}.
@item datafile = @var{FILENAME}
@xref{datafile}. Useful when computing the shock decomposition on a
calibrated model.
@xref{datafile_shock_decomp}.
@item first_obs = @var{INTEGER}
@xref{first_obs}.
@ -7255,14 +7313,11 @@ calibrated model.
@item nobs = @var{INTEGER}
@xref{nobs}.
@item use_shock_groups [= @var{SHOCK_GROUPS_NAME}]
@anchor{use_shock_groups_realtime} Uses groups of shocks instead of individual
shocks in the decomposition. Groups of shocks are defined in the
@ref{shock_groups} block.
@item use_shock_groups [= @var{STRING}]
@xref{use_shock_groups}.
@item colormap = @var{COLORMAP_NAME}
@anchor{colormap_realtime} Controls the colormap used for the shocks
decomposition graphs. See @code{colormap} in Matlab/Octave manual.
@item colormap = @var{STRING}
@xref{colormap}.
@item nograph
@xref{nograph}. Only shock decompositions are computed and stored in @code{oo_.realtime_shock_decomposition},
@ -7278,40 +7333,79 @@ realtime shock decompositions are computed, @i{i.e.} for
@anchor{forecast_shock_decomposition} Compute shock decompositions up to
@math{T+k} periods, @i{i.e.} get shock contributions to k-step ahead forecasts.
@item save_realtime = [@var{integer1} ... @var{integern}]
@item save_realtime = @var{INTEGER_VECTOR}
@anchor{save_realtime} Choose for which vintages to save the full realtime
shock decomposition. Default: @math{0}.
@end table
@outputhead
@defvr {MATLAB/Octave variable} oo_.realtime_shock_decomposition
@vindex oo_.realtime_shock_decomposition
The results of realtime historical decompositions are stored in the field
@code{oo_.realtime_shock_decomposition}, which is a structure. Field
@code{pool} stores the pooled decomposition (@xref{plot_shock_decomposition}).
Fields @code{time_*} store the vintages of realtime historical shock
decompositions.
Structure storing the results of realtime historical decompositions. Fields are three-dimensional arrays with
the first two dimension equal to the ones of @ref{oo_.shock_decomposition}. The third dimension stores the time
periods and is therefore of size @code{T+forecast}. Fields are of the form:
@example
@code{oo_.realtime_shock_decomposition.@var{OBJECT}}
@end example
where @var{OBJECT} is one of the following:
@vindex oo_.conditional_shock_decomposition
The results of realtime conditional decompositions are stored in the field
@code{oo_.conditional_shock_decomposition}, which is a structure. Field
@code{pool} stores the pooled decomposition @math{Y(t|T)} for
@math{t=T-1@dots{}T} @xref{plot_shock_decomposition}. Conditional shock
decomposition sets the initial condition in @math{T-1}, so only computes the
effect of shocks in period @math{T}, @i{i.e.} it is just a @math{1}-period
shock decomposition from @math{T-1} to @math{T}. In practice it decomposes the
update step of the Kalman filter. Fields @code{time_*} store the vintages of
@math{k}-step conditional forecast shock decompositions @math{Y(t|T+k)}, for
@math{t=[T@dots{}T+k}. @xref{vintage}.
@table @code
@item pool
Stores the pooled decomposition, @i{i.e.} for every realtime shock decomposition terminal period
@math{T=[@code{presample},@dots{},@code{nobs}]} it collects the last period's decomposition @math{Y(T|T)}
(see also @ref{plot_shock_decomposition}). The third dimension of the array will have size
@code{nobs+forecast}.
@item time_*
Stores the vintages of realtime historical shock decompositions if @code{save_realtime} is used. For example, if
@code{save_realtime=[5]} and @code{forecast=8}, the third dimension will be of size 13.
@end table
@end defvr
@defvr {MATLAB/Octave variable} oo_.realtime_conditional_shock_decomposition
@vindex oo_.realtime_conditional_shock_decomposition
Structure storing the results of realtime conditional decompositions. Fields are of the form:
@example
@code{oo_.realtime_conditional_shock_decomposition.@var{OBJECT}}
@end example
where @var{OBJECT} is one of the following:
@table @code
@item pool
Stores the pooled realtime conditional shock decomposition, @i{i.e.} collects the decompositions of
@math{Y(T|T)-Y(T|T-1)} for the terminal periods @math{T=[@code{presample},@dots{},@code{nobs}]}.
The third dimension is of size @code{nobs}.
@item time_*
Store the vintages of @math{k}-step conditional forecast shock decompositions @math{Y(t|T+k)}, for
@math{t=[T@dots{}T+k]}. @xref{vintage}. The third dimension is of size @code{1+forecast}.
@end table
@end defvr
@defvr {MATLAB/Octave variable} oo_.realtime_forecast_shock_decomposition
@vindex oo_.realtime_forecast_shock_decomposition
The results of realtime forecast decompositions are stored in the field
@code{oo_.realtime_forecast_shock_decomposition}, which is a structure. Field
@code{pool} stores the pooled decomposition @xref{plot_shock_decomposition}.
Forecast shock decomposition computes the @math{1}-step ahead effect of shocks
on the @math{1}-step ahead prediction, @i{i.e.} @math{Y(T|T-1)}. Fields
@code{time_*} store the vintages of @math{k}-step out-of-sample forecast shock
Structure storing the results of realtime forecast decompositions. Fields are of the form:
@example
@code{oo_.realtime_forecast_shock_decomposition.@var{OBJECT}}
@end example
where @var{OBJECT} is one of the following:
@table @code
@item pool
Stores the pooled realtime forecast decomposition of the @math{1}-step ahead effect of shocks
on the @math{1}-step ahead prediction, @i{i.e.} @math{Y(T|T-1)}.
@item time_*
Stores the vintages of @math{k}-step out-of-sample forecast shock
decompositions, @i{i.e.} @math{Y(t|T)}, for @math{t=[T@dots{}T+k]}. @xref{vintage}.
@end table
@end defvr
@end deffn
@ -7321,139 +7415,113 @@ decompositions, @i{i.e.} @math{Y(t|T)}, for @math{t=[T@dots{}T+k]}. @xref{vintag
@descriptionhead
This command plots the historical shock decomposition already computed by command
@code{shock_decomposition}.
The @code{variable_names} provided govern for which
variables the decomposition is plotted.
This command plots the historical shock decomposition already computed by
@code{shock_decomposition} or @code{realtime_shock_decomposition}. For that reason,
it must come after one of these commands. The @code{variable_names} provided govern which
variables the decomposition is plotted for.
Note that this command must come after @code{shock_decomposition} or @code{realtime_shock_decomposition}.
Further note that, unlike the majority of Dynare commands, the options
specified below are overwritten with their defaults before every call to
@code{plot_shock_decomposition}. Hence, if you want to reuse an option in a
subsequent call to @code{plot_shock_decomposition}, you must pass it to the
command again.
@optionshead
@table @code
@item use_shock_groups [= @var{SHOCK_GROUPS_NAME}]
@anchor{use_shock_groups_plot} Uses groups of shocks instead of individual
shocks in the decomposition. Groups of shocks are defined in the
@ref{shock_groups} block.
@item use_shock_groups [= @var{STRING}]
@xref{use_shock_groups}.
@item colormap = @var{COLORMAP_NAME}
@anchor{colormap_plot} Controls the colormap used for the shocks decomposition
graphs. See @code{colormap} in Matlab/Octave manual.
@item colormap = @var{STRING}
@xref{colormap}.
@item nodisplay
@xref{nodisplay}.
@item graph_format = (@var{GRAPH_FORMAT_LIST})
@item graph_format = @var{FORMAT}
@itemx graph_format = ( @var{FORMAT}, @var{FORMAT}@dots{} )
@xref{graph_format}.
@item detailed
@anchor{detailed} Plots shock contributions using subplots, one per shock (or group of shocks).
@item detail_plot
Plots shock contributions using subplots, one per shock (or group of
shocks). Default: not activated
@item interactive
@anchor{interactive} Under MATLAB, add uimenu's for detailed group plots.
@item interactive
Under MATLAB, add uimenus for detailed group plots. Default: not activated
@item screen
@anchor{screen} For large models (@i{i.e.} for models with more than @math{16}
@item screen_shocks
@anchor{screen_shcoks} For large models (@i{i.e.} for models with more than @math{16}
shocks), plots only the shocks that have the largest historical contribution
for chosen selected @code{variable_names}. Historical contribution is ranked
by the mean absolute value of all historical contributions.
@item steadystate = @var{INTEGER}
@anchor{steadystate} If equal to @math{1}, the the @math{y}-axis value of the
zero line in the shock decomposition plot is translated to the steady state
level. Default: @math{0}
@item steadystate
@anchor{steadystate} If passed, the the @math{y}-axis value of the zero line in
the shock decomposition plot is translated to the steady state level. Default:
not activated
@item type = @var{TYPE_NAME}
@anchor{type} For quarterly data, @var{TYPE_NAME} can take one of the
following values: @code{qoq} for quarter-on-quarter plots, @code{yoy} for
year-on-year plots of growth rates, @code{aoa} for annualized variables,
@i{i.e.} the value in the last quarter for each year is plotted. Default
value: @code{empty}, @i{i.e.} standard period-on-period plots (@code{qoq} for
quarterly data).
@item type = @code{qoq} | @code{yoy} | @code{aoa}
@anchor{type} For quarterly data, valid arguments are: @code{qoq} for
quarter-on-quarter plots, @code{yoy} for year-on-year plots of growth rates,
@code{aoa} for annualized variables, @i{i.e.} the value in the last quarter for
each year is plotted. Default value: @code{empty}, @i{i.e.} standard
period-on-period plots (@code{qoq} for quarterly data).
@item fig_name = @var{FIG_NAME}
@item fig_name = @var{STRING}
@anchor{fig_name} Specifies a user-defined keyword to be appended to the
default figure name set by @code{plot_shock_decomposition}. This can avoid to
overwrite plots in case of sequential calls to @code{plot_shock_decomposition}.
@item write_xls
@anchor{write_xls} Saves shock decompositions to excel.
@anchor{write_xls} Saves shock decompositions to Excel-file in the main directory, named
@code{FILENAME_shock_decomposition_TYPE_FIG_NAME.xls}. This option requires your system to be
configured to be able to write Excel files.@footnote{In case of Excel not being installed,
@url{https://mathworks.com/matlabcentral/fileexchange/38591-xlwrite--generate-xls-x--files-without-excel-on-mac-linux-win} may be helpful.}
@item realtime = @var{INTEGER}
@anchor{realtime} Which kind of shock decomposition to plot. @var{INTEGER} can take following values:
@itemize @bullet
@item
@code{0}: historical shock decomposition: @math{Y(t|T)} for
@math{t=[1@dots{}T]}, @math{T=} @code{nobs} full sample
@code{0}: standard historical shock decomposition. @xref{shock_decomposition}.
@item
@code{1}: realtime historical shock decomposition: for
@math{T=[1@dots{}@code{nobs}]}, realtime shock decomposition @math{Y(t|T)} for
@math{t=[1@dots{}T]}
@code{1}: realtime historical shock decomposition. @xref{realtime_shock_decomposition}.
@item
@code{2}: conditional shock decomposition: for @code{T=1:nobs}, realtime shock
decomposition of @math{Y(T|T)} conditional on @math{Y(T|T-1)}, @i{i.e.}
@math{Y(t|T)} for @math{t=[T-1@dots{}T]}
@code{2}: conditional realtime shock decomposition. @xref{realtime_shock_decomposition}.
@item
@code{3}: forecast shock decomposition: for @math{T=[1@dots{}@code{nobs}]},
realtime shock decomposition of @math{Y(T|T-1)}
@code{3}: realtime forecast shock decomposition. @xref{realtime_shock_decomposition}.
@end itemize
If no @ref{vintage} is requested, @i{i.e.} @code{vintage=0} then the pooled objects from @ref{realtime_shock_decomposition}
will be plotted and the respective vintage otherwise.
Default: @math{0}
@item vintage = @var{INTEGER}
@anchor{vintage} Applies if @code{realtime}@math{>0}. Can take following values:
@itemize @bullet
@item
@code{0}: plots @math{1}-step pooled shock decompositions
@item
@code{1}: pooled realtime shock decomposition. For @math{T=[1@dots{}@code{nobs}]}, plots last
time point @math{Y(T|T)} of each vintage shock decomposition @math{Y(1:T|T)}
@item
@code{2}: pooled conditional shock decomposition. For
@math{T=[1@dots{}@code{nobs}]}, realtime @math{1}-step shock decomposition of
@math{Y(T|T)} conditional on @math{Y(T|T-1)} (@i{i.e.} decomposition of
@math{1}-step filter updates of each vintage @math{T})
@item
@code{3}: pooled forecast shock decomposition. For
@math{T=[1@dots{}@code{nobs}]}, realtime @math{1}-step ahead shock
decomposition of @math{Y(T|T-1)} (@i{i.e.} decomposition of shock
contributions to @math{1}-step ahead forecasts of each vintage @math{T})
@end itemize
When the value passed is greater than @math{0}, it plots the shock
@anchor{vintage} Selects a particular data vintage in @math{[presample,@dots{},nobs]} for which to plot the results from
@ref{realtime_shock_decomposition} selected via the @ref{realtime} option. If the standard
historical shock decomposition is selected (@code{realtime=0}), @code{vintage} will have no effect. If @code{vintage=0}
the pooled objects from @ref{realtime_shock_decomposition} will be plotted. If @code{vintage>0}, it plots the shock
decompositions for vintage @math{T=@code{vintage}} under the following scenarios:
@itemize @bullet
@item
@code{realtime=1}: the full vintage shock decomposition @math{Y(t|T)} for
@math{t=[1@dots{}T]}
@math{t=[1,@dots{},T]}
@item
@code{realtime=2}: the conditional forecast shock decomposition from @math{T},
@i{i.e.} plots @math{Y(T+j|T+j)} and the shock contributions needed to get to
the data @math{Y(T+j)} conditional on @math{T=}@code{vintage}, with
@math{j=[0@dots{}@code{forecast}]}.
@math{j=[0,@dots{},@code{forecast}]}.
@item
@code{realtime=3}: plots unconditional forecast shock decomposition from
@math{T}, @i{i.e.} @math{Y(T+j|T)}, where @math{T=@code{vintage}} and
@math{j=[0@dots{}@code{forecast}]}.
@math{j=[0,@dots{},@code{forecast}]}.
@end itemize
Default: @math{0}
@end table
@end deffn
@deffn Command unit_root_vars @var{VARIABLE_NAME}@dots{};
This command is deprecated. Use @code{estimation} option @code{diffuse_filter} instead for estimating a model with non-stationary observed variables or @code{steady} option @code{nocheck} to prevent @code{steady} to check the steady state returned by your steady state file.
@end deffn
Dynare also has the ability to estimate Bayesian VARs:
@deffn Command bvar_density ;
Computes the marginal density of an estimated BVAR model, using
Minnesota priors.
See @file{bvar-a-la-sims.pdf}, which comes with Dynare distribution,
for more information on this command.
@end deffn
@node Calibrated Smoother
@section Calibrated Smoother
Dynare can also run the smoother on a calibrated model:
@ -12234,7 +12302,7 @@ plot(ts2.data,'--r'); % Plot of the filtered y.
hold off
axis tight
id = get(gca,'XTick');
set(gca,'XTickLabel',strings(ts.dates(id)));
set(gca,'XTickLabel',strings(ts1.dates(id)));
@end example
@iftex

View File

@ -255,7 +255,9 @@ if kalman_algo == 2 || kalman_algo == 4
[Pstar,Pinf] = compute_Pinf_Pstar(mf,ST,R1,Q,options_.qz_criterium);
else
Pstar = blkdiag(Pstar,H);
Pinf = blkdiag(Pinf,zeros(vobs));
if ~isempty(Pinf)
Pinf = blkdiag(Pinf,zeros(vobs));
end
end
%now reset H to 0
H = zeros(vobs,vobs);

View File

@ -16,7 +16,7 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2005-2016 Dynare Team
% Copyright (C) 2005-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -63,7 +63,7 @@ for i=1:npar
subplotnum = subplotnum+1;
if subplotnum == 1
figunumber = figunumber+1;
hfig=dyn_figure(options_,'Name',figurename);
hfig=dyn_figure(options_.nodisplay,'Name',figurename);
end
[nam,texnam] = get_the_name(i,TeX,M_,estim_params_,options_);
if subplotnum == 1
@ -152,7 +152,7 @@ for i=1:npar
hold off;
drawnow
if subplotnum == MaxNumberOfPlotPerFigure || i == npar;
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_);
dyn_saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:size(NAMES,1)

View File

@ -30,7 +30,7 @@ function myoutput=PosteriorIRF_core2(myinputs,fpar,npar,whoiam,ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
%
% Copyright (C) 2006-2016 Dynare Team
% Copyright (C) 2006-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -103,9 +103,9 @@ for i=fpar:npar,
if max(abs(MeanIRF(:,j,i))) >= options_.impulse_responses.plot_threshold
subplotnum = subplotnum+1;
if subplotnum == 1 && options_.relative_irf
hh = dyn_figure(options_,'Name',['Relative response to orthogonalized shock to ' tit(i,:)]);
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock to ' tit(i,:)]);
elseif subplotnum == 1 && ~options_.relative_irf
hh = dyn_figure(options_,'Name',['Orthogonalized shock to ' tit(i,:)]);
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:)]);
end
set(0,'CurrentFigure',hh)
@ -152,7 +152,7 @@ for i=fpar:npar,
if subplotnum == MaxNumberOfPlotPerFigure || (j == nvar && subplotnum> 0)
figunumber = figunumber+1;
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_);
dyn_saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)],options_.nodisplay,options_.graph_format);
if RemoteFlag==1,
OutputFileName = [OutputFileName; {[DirectoryName,filesep], [M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.*']}];
end

View File

@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list)
% Adapted from th_autocovariances.m.
% Copyright (C) 2006-2015 Dynare Team
% Copyright (C) 2006-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -159,12 +159,12 @@ if options_.nograph == 0
end
for i= 1:nvar
hh = dyn_figure(options_,'Name',['Spectral Density of ' deblank(M_.endo_names(ivar(i),:)) '.']);
hh = dyn_figure(options_.nodisplay,'Name',['Spectral Density of ' deblank(M_.endo_names(ivar(i),:)) '.']);
plot(freqs,f(i,:),'-k','linewidth',2)
xlabel('0 \leq \omega \leq \pi')
ylabel('f(\omega)')
box on
axis tight
dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' deblank(M_.endo_names(ivar(i),:))],options_)
dyn_saveas(hh,[M_.fname ,filesep,'graphs', filesep, 'SpectralDensity_' deblank(M_.endo_names(ivar(i),:))],options_.nodisplay,options_.graph_format)
end
end

View File

@ -31,9 +31,9 @@ function WriteShockDecomp2Excel(z,shock_names,endo_names,i_var,initial_date,Dyna
SteadyState=[];
fig_mode='';
fig_mode1='';
fig_names='';
fig_name='';
screen_shocks=0;
use_shock_groups = DynareOptions.use_shock_groups;
use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
if use_shock_groups
shock_groups = DynareModel.shock_groups.(use_shock_groups);
shock_ind = fieldnames(shock_groups);
@ -52,21 +52,21 @@ if nargin==8 ,
fig_mode = [fig_mode '_'];
end
if isfield(opts_decomp,'screen_shocks')
if DynareOptions.use_shock_groups,
if use_shock_groups
screen_shocks=0;
elseif comp_nbr>18
screen_shocks = opts_decomp.screen_shocks;
end
end
if isfield(opts_decomp,'fig_names')
fig_names = opts_decomp.fig_names;
% fig_names = ['_' fig_names];
fig_names1 = [fig_names];
fig_names = [fig_names '_'];
if isfield(opts_decomp,'fig_name')
fig_name = opts_decomp.fig_name;
% fig_name = ['_' fig_name];
fig_name1 = [fig_name];
fig_name = [fig_name '_'];
end
if screen_shocks
fig_names1 = [fig_names1 '_screen'];
fig_names = [fig_names 'screen_'];
fig_name1 = [fig_name1 '_screen'];
fig_name = [fig_name 'screen_'];
end
end
@ -115,9 +115,9 @@ for j=1:nvar
warning off
if ~ismac
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_names1],d0,deblank(endo_names(i_var(j),:)));
[STATUS,MESSAGE] = xlswrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:)));
else
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_names1],d0,deblank(endo_names(i_var(j),:)));
[STATUS] = xlwrite([DynareModel.fname,'_shock_decomposition',fig_mode,fig_name1],d0,deblank(endo_names(i_var(j),:)));
end
warning on

View File

@ -49,7 +49,7 @@ function [z, endo_names, endo_names_tex, steady_state, i_var, oo_] = annualized_
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
opts = options_.shock_decomp;
opts = options_.plot_shock_decomp;
nvar = length(i_var);
GYTREND0 = q2a.GYTREND0;
var_type = q2a.type;
@ -61,8 +61,8 @@ cumfix = q2a.cumfix;
if isstruct(oo_)
% z = oo_.shock_decomposition;
myopts=options_;
myopts.shock_decomp.type='qoq';
myopts.shock_decomp.realtime=0;
myopts.plot_shock_decomp.type='qoq';
myopts.plot_shock_decomp.realtime=0;
[z, junk] = plot_shock_decomposition(M_,oo_,myopts,[]);
else
z = oo_;
@ -93,8 +93,8 @@ end
if isstruct(aux)
if ischar(aux.y)
myopts=options_;
myopts.shock_decomp.type='qoq';
myopts.shock_decomp.realtime=0;
myopts.plot_shock_decomp.type='qoq';
myopts.plot_shock_decomp.realtime=0;
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux.y);
aux.y=y_aux;
aux.yss=steady_state_aux;
@ -183,9 +183,9 @@ for i=t0:4:t1,
za=[];
gza=[];
myopts=options_;
myopts.shock_decomp.type='qoq';
myopts.shock_decomp.realtime=1;
myopts.shock_decomp.vintage=i;
myopts.plot_shock_decomp.type='qoq';
myopts.plot_shock_decomp.realtime=1;
myopts.plot_shock_decomp.vintage=i;
[z, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,[]);
z = z(i_var,:,:);
if isstruct(aux)
@ -271,6 +271,17 @@ end
% fix total
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-nfrcst)])(:,end,:) = ...
oo_.annualized_realtime_shock_decomposition.pool(:,end,yr-nfrcst:end);
if i==t1
for my_forecast_=(nfrcst-1):-1:1,
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)]) = ...
oo_.annualized_realtime_shock_decomposition.pool(:,:,yr-my_forecast_:yr) - ...
oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,:,1:my_forecast_+1);
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,end-1,:) = ...
oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,end,1:my_forecast_+1);
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,end,:) = ...
oo_.annualized_realtime_shock_decomposition.pool(:,end,yr-my_forecast_:yr);
end
end
end
end
% ztmp=oo_.realtime_shock_decomposition.pool(:,:,21:29)-oo_.realtime_forecast_shock_decomposition.time_21;

View File

@ -11,7 +11,7 @@ function bvar_forecast(nlags)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2007-2013 Dynare Team
% Copyright (C) 2007-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -125,7 +125,7 @@ for i = 1:ny
options_.varobs{i});
end
dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_BVAR_forecast_',num2str(nlags)],options_)
dyn_saveas(dyn_graph.fh,[OutputDirectoryName '/' M_.fname '_BVAR_forecast_',num2str(nlags)],options_.nodisplay,options_.graph_format)
% Compute RMSE

View File

@ -418,6 +418,10 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
posterior_sampler_options.V1=V1;
posterior_sampler_options.WR=sqrt(diag(D))*3;
end
else
if ~options_.load_mh_file && ~posterior_sampler_options.slice_initialize_with_mode,
posterior_sampler_options.invhess=[];
end
end
% needs to be re-set to zero otherwise posterior analysis is filtered

View File

@ -16,7 +16,7 @@ function oo_ = McMCDiagnostics(options_, estim_params_, M_, oo_)
% PARALLEL CONTEXT
% See the comment in posterior_sampler.m funtion.
% Copyright (C) 2005-2016 Dynare Team
% Copyright (C) 2005-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -287,7 +287,7 @@ clear pmet temp moyenne CSUP CINF csup cinf n linea iter tmp;
pages = floor(npar/3);
k = 0;
for i = 1:pages
h=dyn_figure(options_,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman,1998)');
h=dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman,1998)');
boxplot = 1;
for j = 1:3 % Loop over parameters
k = k+1;
@ -325,7 +325,7 @@ for i = 1:pages
boxplot = boxplot + 1;
end
end
dyn_saveas(h,[OutputFolder '/' ModelName '_udiag' int2str(i)],options_);
dyn_saveas(h,[OutputFolder '/' ModelName '_udiag' int2str(i)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:size(NAMES,1)
@ -350,7 +350,7 @@ if reste
nr = 2;
nc = 3;
end
h = dyn_figure(options_,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman, 1998)');
h = dyn_figure(options_.nodisplay,'Name','MCMC univariate convergence diagnostic (Brooks and Gelman, 1998)');
boxplot = 1;
for j = 1:reste
k = k+1;
@ -388,7 +388,7 @@ if reste
boxplot = boxplot + 1;
end
end
dyn_saveas(h,[ OutputFolder '/' ModelName '_udiag' int2str(pages+1)],options_);
dyn_saveas(h,[ OutputFolder '/' ModelName '_udiag' int2str(pages+1)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:size(NAMES,1);
@ -461,7 +461,7 @@ for iter = Origin:StepSize:NumberOfDraws
end
MDIAG(:,[2 4 6],:) = MDIAG(:,[2 4 6],:)/nblck;
h = dyn_figure(options_,'Name','Multivariate convergence diagnostic');
h = dyn_figure(options_.nodisplay,'Name','Multivariate convergence diagnostic');
boxplot = 1;
for crit = 1:3
if crit == 1
@ -493,7 +493,7 @@ for crit = 1:3
title(namnam,'Interpreter','none');
boxplot = boxplot + 1;
end
dyn_saveas(h,[ OutputFolder '/' ModelName '_mdiag'],options_);
dyn_saveas(h,[ OutputFolder '/' ModelName '_mdiag'],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');

View File

@ -1,20 +1,23 @@
function datatomfile (s,var_list, names)
% function datatomfile (s,var_list)
% This optional command saves the simulation results in a text file. The name of each
% variable preceeds the corresponding results. This command must follow SIMUL.
%
% INPUTS
% s: data file name
% var_list: vector of selected endogenous variables
% names: vector of strings (alternative names for the endogenous variables in the data file)
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
function datatomfile (s, var_list, names)
% Copyright (C) 2001-2016 Dynare Team
% This command saves the simulation results in a text file. The name of each
% variable preceeds the corresponding results. This command must follow SIMUL
% or STOCH_SIMUL commands.
%
% INPUTS
% - s: data file name
% - var_list: vector of selected endogenous variables
% - names: vector of strings (alternative names for the endogenous variables in the data file)
%
% OUTPUTS
% none
%
% REMARKS
% Only the first argument is mandatory. If only one input argument is
% provided, all the variables as defined in M_.endo_names will be saved in
% the generated m file.
% Copyright (C) 2001-2017 Dynare Team
%
% This file is part of Dynare.
%

View File

@ -126,7 +126,6 @@ for file = 1:NumberOfDrawsFiles
if ~test% Prepare the last round...
Covariance_matrix = zeros(NumberOfLinesInTheLastCovarFile,nvar*(nvar+1)/2);
NumberOfCovarLines = NumberOfLinesInTheLastCovarFile;
CovarFileNumber = CovarFileNumber - 1;
elseif test<0
Covariance_matrix = zeros(MaXNumberOfCovarLines,nvar*(nvar+1)/2);
else

View File

@ -1,9 +1,9 @@
function h=dyn_figure(DynareOptions,varargin)
%function h=dyn_figure(DynareOptions,varargin)
function h = dyn_figure(nodisplay, varargin)
%function h = dyn_figure(nodisplay, varargin)
% initializes figures for DYNARE
%
% INPUTS
% DynareOptions: dynare options
% nodisplay: the value of the command-specific nodisplay argument or options_.nodisplay
% varargin: the same list of possible inputs of the MATLAB function figure
%
% OUTPUTS
@ -12,7 +12,7 @@ function h=dyn_figure(DynareOptions,varargin)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2012 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -29,7 +29,7 @@ function h=dyn_figure(DynareOptions,varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if DynareOptions.nodisplay,
if nodisplay
h = figure(varargin{:},'visible','off');
else
h = figure(varargin{:});

View File

@ -1,11 +1,12 @@
function dyn_saveas(h,fname,DynareOptions)
%function dyn_saveas(h,fname,DynareOptions)
function dyn_saveas(h, fname, nodisplay, graph_format)
%function dyn_saveas(h, fname, nodisplay, graph_format)
% save figures for DYNARE
%
% INPUTS
% h : figure handle
% fname : name of the saved figure
% DynareOptions: dynare options
% nodisplay: the value of the command-specific nodisplay argument or options_.nodisplay
% graph_format: the value of the command-specific graph_format argument or options_.graph_format
%
% OUTPUTS
% none
@ -13,7 +14,7 @@ function dyn_saveas(h,fname,DynareOptions)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2012-2013 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -30,28 +31,28 @@ function dyn_saveas(h,fname,DynareOptions)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if any(strcmp('eps',cellstr(DynareOptions.graph_format)))
if any(strcmp('eps',cellstr(graph_format)))
if isoctave
fname = strrep(fname,'/',filesep);
fname = strrep(fname,'\',filesep);
if DynareOptions.nodisplay && ispc,
if nodisplay && ispc
set(h, 'Visible','on');
end
end
print(h,'-depsc2',[fname,'.eps'])
end
if any(strcmp('pdf',cellstr(DynareOptions.graph_format)))
if any(strcmp('pdf',cellstr(graph_format)))
if isoctave
error('Octave cannot create pdf files!')
else
print(h,'-dpdf',[fname,'.pdf'])
end
end
if any(strcmp('fig',cellstr(DynareOptions.graph_format)))
if any(strcmp('fig',cellstr(graph_format)))
if isoctave
error('Octave cannot create fig files!')
else
if DynareOptions.nodisplay
if nodisplay
% THE FOLLOWING LINES COULD BE USED IF BUGS/PROBLEMS ARE REPORTED USING LINE 60
% set(h,'Units','Normalized')
% mypos=get(h,'Position');
@ -62,10 +63,10 @@ if any(strcmp('fig',cellstr(DynareOptions.graph_format)))
saveas(h,[fname '.fig']);
end
end
if any(strcmp('none',cellstr(DynareOptions.graph_format)))
if any(strcmp('none',cellstr(graph_format)))
% don't save
% check here as a reminder that none is an option to graph_format
end
if DynareOptions.nodisplay
if nodisplay
close(h);
end

View File

@ -118,6 +118,11 @@ if (isoctave && ~user_has_octave_forge_package('statistics')) ...
p{end+1} = '/missing/nanmean';
end
% Check if struct2array is available.
if ~exist('struct2array')
p{end+1} = '/missing/struct2array';
end
P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false);
% Get mex files folder(s)

View File

@ -12,7 +12,7 @@ function oo_recursive_=dynare_estimation(var_list,dname)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2015 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -151,7 +151,7 @@ if nnobs > 1 && horizon > 0
for i = 1:size(var_list,1)
if mod(i,nstar) == 1
plot_index=plot_index+1;
hfig = dyn_figure(options_,'Name',['Out of sample forecasts (',num2str(plot_index),')']);
hfig = dyn_figure(options_.nodisplay,'Name',['Out of sample forecasts (',num2str(plot_index),')']);
m = 1;
end
subplot(nr,nc,m)
@ -208,7 +208,7 @@ if nnobs > 1 && horizon > 0
xlim([nobs(1)-offsetx nobs(end)+horizon])
m = m + 1;
if mod(i+1,nstar) == 1 || i ==size(var_list,1)
dyn_saveas(hfig,[M_.fname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_);
dyn_saveas(hfig,[M_.fname,filesep,'graphs',filesep M_.fname '_RecursiveForecasts_' int2str(plot_index)],options_.nodisplay,options_.graph_format);
end
end
end

View File

@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2016 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -44,6 +44,11 @@ end
%store qz_criterium
qz_criterium_old=options_.qz_criterium;
if isnan(options_.first_obs)
first_obs_nan_indicator=true;
else
first_obs_nan_indicator=false;
end
% Set particle filter flag.
if options_.order > 1
@ -414,7 +419,6 @@ end
if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
(any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
outside_bound_pars=find(xparam1 < bounds.lb | xparam1 > bounds.ub);
if ~isempty(outside_bound_pars)
for ii=1:length(outside_bound_pars)
@ -542,7 +546,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
fprintf(fidTeX,' \n');
end
for plt = 1:nbplt,
fh = dyn_figure(options_,'Name','Smoothed shocks');
fh = dyn_figure(options_.nodisplay,'Name','Smoothed shocks');
NAMES = [];
if options_.TeX, TeXNAMES = []; end
nstar0=min(nstar,M_.exo_nbr-(plt-1)*nstar);
@ -583,7 +587,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
end
title(name,'Interpreter','none')
end
dyn_saveas(fh,[M_.fname '_SmoothedShocks' int2str(plt)],options_);
dyn_saveas(fh,[M_.fname '_SmoothedShocks' int2str(plt)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:nstar0
@ -621,7 +625,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
fprintf(fidTeX,' \n');
end
for plt = 1:nbplt
fh = dyn_figure(options_,'Name','Smoothed observation errors');
fh = dyn_figure(options_.nodisplay,'Name','Smoothed observation errors');
NAMES = [];
if options_.TeX, TeXNAMES = []; end
nstar0=min(nstar,number_of_plots_to_draw-(nbplt-1)*nstar);
@ -663,7 +667,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
end
title(name,'Interpreter','none')
end
dyn_saveas(fh,[M_.fname '_SmoothedObservationErrors' int2str(plt)],options_);
dyn_saveas(fh,[M_.fname '_SmoothedObservationErrors' int2str(plt)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:nstar0
@ -696,7 +700,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
fprintf(fidTeX,' \n');
end
for plt = 1:nbplt,
fh = dyn_figure(options_,'Name','Historical and smoothed variables');
fh = dyn_figure(options_.nodisplay,'Name','Historical and smoothed variables');
NAMES = [];
if options_.TeX, TeXNAMES = []; end
nstar0=min(nstar,n_varobs-(plt-1)*nstar);
@ -738,7 +742,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
end
title(name,'Interpreter','none')
end
dyn_saveas(fh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)],options_);
dyn_saveas(fh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:nstar0,
@ -776,3 +780,6 @@ if reset_options_related_to_estimation
options_.mode_compute = mode_compute_o;
options_.mh_replic = mh_replic_o;
end
if first_obs_nan_indicator
options_.first_obs=NaN;
end

View File

@ -527,13 +527,16 @@ if ~isempty(options_.datafile)
end
end
if isnan(options_.first_obs)
options_.first_obs=1;
end
[dataset_, dataset_info, newdatainterfaceflag] = makedataset(options_, options_.dsge_var*options_.dsge_varlag, gsa_flag);
%set options for old interface from the ones for new interface
if ~isempty(dataset_)
options_.nobs = dataset_.nobs;
options_.first_obs=double(dataset_.init);
end
% setting steadystate_check_flag option
if options_.diffuse_filter || options_.steadystate.nocheck
steadystate_check_flag = 0;

View File

@ -12,7 +12,7 @@ function dyn_graph=dynare_graph_init(figure_name,nplot,line_types,line_width)
% SPECIAL REQUIREMENT
% none
% Copyright (C) 2006-2013 Dynare Team
% Copyright (C) 2006-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -31,7 +31,7 @@ function dyn_graph=dynare_graph_init(figure_name,nplot,line_types,line_width)
global options_
dyn_graph.fh = dyn_figure(options_,'Name',figure_name);
dyn_graph.fh = dyn_figure(options_.nodisplay,'Name',figure_name);
dyn_graph.figure_name = figure_name;
if nargin > 2
dyn_graph.line_types = line_types;

View File

@ -37,7 +37,7 @@ function [oo_,M_,options_,bayestopt_,Smoothed_variables_declaration_order_deviat
% [1] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
% is called more than once (by changing the value of parameters) the sample *must not* change.
% Copyright (C) 2010-2016 Dynare Team
% Copyright (C) 2010-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -54,21 +54,17 @@ function [oo_,M_,options_,bayestopt_,Smoothed_variables_declaration_order_deviat
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
persistent dataset_ dataset_info
%store qz_criterium
% store qz_criterium
qz_criterium_old=options_.qz_criterium;
if ischar(parameters) && strcmp(parameters,'calibration')
options_.smoother=1;
end
if isempty(dataset_) || isempty(bayestopt_) || (options_.nobs ~= dataset_.nobs)
[dataset_,dataset_info,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list, M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_);
else
[dataset_,dataset_info,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list, M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_);
% set the qz_criterium
options_=select_qz_criterium_value(options_);
end
options_=select_qz_criterium_value(options_);
if nargin==0
parameters = 'posterior_mode';

View File

@ -37,7 +37,7 @@ end
% define expanded group
label = mydata.shock_group.label;
shocks = mydata.shock_group.shocks;
options.shock_decomp.fig_names = [mydata.fig_names '. Expand'];
options.shock_decomp.fig_name = [mydata.fig_name '. Expand'];
options.use_shock_groups = strrep(label,' ','_'); %[use_shock_groups_old int2str(ic)];
for j=1:length(shocks)
M.shock_groups.(options.use_shock_groups).(['group' int2str(j)]).label=shocks{j};

View File

@ -8,7 +8,7 @@ function forecast_graphs(var_list,M_, oo_,options_)
% o oo_ outputs structure
% o options_ options structure
% Copyright (C) 2008-2016 Dynare Team
% Copyright (C) 2008-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -61,10 +61,10 @@ end
m = 1;
n_fig = 1;
hh=dyn_figure(options_,'Name','Forecasts (I)');
hh=dyn_figure(options_.nodisplay,'Name','Forecasts (I)');
for j= 1:nvar
if m > nc*nr;
dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)],options_);
dyn_saveas(hh,[ dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -75,7 +75,7 @@ for j= 1:nvar
fprintf(fidTeX,' \n');
end
n_fig =n_fig+1;
eval(['hh=dyn_figure(options_,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
m = 1;
end
subplot(nr,nc,m);
@ -100,7 +100,7 @@ for j= 1:nvar
end
if m > 1
dyn_saveas(hh,[dname '/graphs/forcst' int2str(n_fig)],options_);
dyn_saveas(hh,[dname '/graphs/forcst' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -125,10 +125,10 @@ if isfield(oo_.forecast,'HPDinf_ME')
m = 1;
n_fig = 1;
hh=dyn_figure(options_,'Name','Forecasts including ME (I)');
hh=dyn_figure(options_.nodisplay,'Name','Forecasts including ME (I)');
for j= 1:length(var_names)
if m > nc*nr;
dyn_saveas(hh,[ dname '/graphs/forcst_ME' int2str(n_fig)],options_);
dyn_saveas(hh,[ dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
@ -139,7 +139,7 @@ if isfield(oo_.forecast,'HPDinf_ME')
fprintf(fidTeX,' \n');
end
n_fig =n_fig+1;
eval(['hh=dyn_figure(options_,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
eval(['hh=dyn_figure(options_.nodisplay,''Name'',''Forecasts (' int2str(n_fig) ')'');']);
m = 1;
end
subplot(nr,nc,m);
@ -158,7 +158,7 @@ if isfield(oo_.forecast,'HPDinf_ME')
end
if m > 1
dyn_saveas(hh,[dname '/graphs/forcst_ME' int2str(n_fig)],options_);
dyn_saveas(hh,[dname '/graphs/forcst_ME' int2str(n_fig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');

View File

@ -11,7 +11,7 @@ function global_initialization()
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2016 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -723,23 +723,13 @@ options_.discretionary_tol = 1e-7;
options_.parameter_set = [];
options_.use_shock_groups = '';
options_.colormap = '';
options_.shock_decomp.detail_plot=0;
options_.shock_decomp.fig_names='';
options_.shock_decomp.init_state = 0;
options_.shock_decomp.interactive = 0;
options_.shock_decomp.plot_end_date=[];
options_.shock_decomp.plot_init_date=[];
options_.shock_decomp.screen_shocks=0;
options_.shock_decomp.steadystate=0;
options_.shock_decomp.type = '';
options_.shock_decomp.write_xls=0;
% Shock decomposition realtime
options_.shock_decomp.realtime=0; % 0 is standard; 1 is realtime (pool/vintage); 2 is conditional (pool/vintage); 3 is forecast (pool/vintage)
options_.shock_decomp.vintage=0; % 0 pool realtime/conditional; int: forecast/conditional shock decompositions
options_.shock_decomp.forecast=0;
options_.shock_decomp.presample=NaN;
options_.shock_decomp.save_realtime=0; % saves memory
% Shock decomposition realtime
options_.shock_decomp.forecast = 0;
options_.shock_decomp.presample = NaN;
options_.shock_decomp.save_realtime = 0; % saves memory
options_ = set_default_plot_shock_decomposition_options(options_);
% Nonlinearfilters
options_.nonlinear_filter = [];

View File

@ -11,7 +11,7 @@ function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date,DynareModel
% DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure
% Copyright (C) 2010-2016 Dynare Team
% Copyright (C) 2010-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -29,7 +29,7 @@ function []=graph_decomp(z,shock_names,endo_names,i_var,initial_date,DynareModel
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
new_colormap = DynareOptions.colormap;
new_colormap = DynareOptions.plot_shock_decomp.colormap;
% number of components equals number of shocks + 1 (initial conditions)
comp_nbr = size(z,2)-1;
@ -37,9 +37,9 @@ comp_nbr = size(z,2)-1;
SteadyState=[];
fig_mode='';
fig_mode1='';
% fig_names='';
% fig_name='';
% screen_shocks=0;
opts_decomp = DynareOptions.shock_decomp;
opts_decomp = DynareOptions.plot_shock_decomp;
if isfield(opts_decomp,'steady_state')
SteadyState = opts_decomp.steady_state;
end
@ -48,9 +48,9 @@ if ~isempty(opts_decomp.type)
fig_mode1 = ['_' fig_mode];
fig_mode = [fig_mode '_'];
end
fig_names_long = opts_decomp.fig_names;
fig_name_long = opts_decomp.fig_name;
use_shock_groups = DynareOptions.use_shock_groups;
use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
screen_shocks = opts_decomp.screen_shocks;
if use_shock_groups | comp_nbr<=18,
screen_shocks=0;
@ -60,16 +60,16 @@ if use_shock_groups
shock_ind = fieldnames(shock_groups);
end
if screen_shocks
fig_names_long = [fig_names_long ' SCREEN'];
fig_name_long = [fig_name_long ' SCREEN'];
end
fig_names=strrep(fig_names_long, '(given ', '');
fig_names=strrep(fig_names, '(vintage ', '');
fig_names=regexprep(fig_names, ' ', '_');
fig_names=strrep(fig_names, '.', '');
fig_names=strrep(fig_names, '-', '');
fig_names=strrep(fig_names, ')', '');
fig_names=strrep(fig_names, '(', '');
fig_name=strrep(fig_name_long, '(given ', '');
fig_name=strrep(fig_name, '(vintage ', '');
fig_name=regexprep(fig_name, ' ', '_');
fig_name=strrep(fig_name, '.', '');
fig_name=strrep(fig_name, '-', '');
fig_name=strrep(fig_name, ')', '');
fig_name=strrep(fig_name, '(', '');
interactive = opts_decomp.interactive;
@ -87,8 +87,8 @@ end
nvar = length(i_var);
%% write LaTeX-Header
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_names '.tex'],'w');
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp.m.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
@ -128,7 +128,7 @@ for j=1:nvar
if ymax-ymin < 1e-6
continue
end
fhandle = dyn_figure(DynareOptions,'Name',[preamble_txt fig_names_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) '.'], 'PaperPositionMode', 'auto','PaperOrientation','landscape','renderermode','auto');
fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) '.'], 'PaperPositionMode', 'auto','PaperOrientation','landscape','renderermode','auto');
set(fhandle,'position' ,[50 50 1500 750])
ax=axes('Position',[0.1 0.1 0.6 0.8],'box','on');
% plot(ax,x(2:end),z1(end,:),'k-','LineWidth',2)
@ -190,15 +190,15 @@ for j=1:nvar
ht = text(0.3,y1+0.3*height,labels(i,:),'Interpreter','none');
hold on
if interactive & (~isoctave & use_shock_groups)
mydata.fig_names = DynareOptions.shock_decomp.fig_names(2:end);
mydata.use_shock_groups = DynareOptions.use_shock_groups;
mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end);
mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{i});
mydata.shock_decomp = DynareOptions.shock_decomp;
mydata.shock_decomp = DynareOptions.plot_shock_decomp;
if ~isempty(mydata.shock_group.shocks{1})
c = uicontextmenu;
hl.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(endo_names(i_var(j),:)) ''',' int2str(i) ')']);
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(mydata.shock_decomp.orig_varlist(j,:)) ''',' int2str(i) ')']);
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(i)]);
for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember))
@ -213,20 +213,20 @@ for j=1:nvar
colormap(new_colormap)
end
hold off
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_names],DynareOptions);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_names]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_names]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_names_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:)));
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_name]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_name]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
end
%% write LaTeX-Footer
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,' \n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);

View File

@ -1,4 +1,4 @@
function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,DynareModel,DynareOptions,opts_decomp)
function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,DynareModel,DynareOptions)
%function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,DynareModel,DynareOptions)
% Plots the results from the shock_decomposition command
%
@ -11,7 +11,7 @@ function []=graph_decomp_detail(z,shock_names,endo_names,i_var,initial_date,Dyna
% DynareModel [structure] Dynare model structure
% DynareOptions [structure] Dynare options structure
% Copyright (C) 2010-2016 Dynare Team
% Copyright (C) 2010-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -32,9 +32,9 @@ GraphDirectoryName = CheckPath('graphs',DynareModel.dname);
% interactive = 0;
fig_mode='';
fig_mode1='';
% fig_names='';
% fig_name='';
% screen_shocks=0;
use_shock_groups = DynareOptions.use_shock_groups;
use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
if use_shock_groups
shock_groups = DynareModel.shock_groups.(use_shock_groups);
shock_ind = fieldnames(shock_groups);
@ -43,7 +43,7 @@ end
% number of components equals number of shocks + 1 (initial conditions)
comp_nbr = size(z,2)-1;
opts_decomp = DynareOptions.shock_decomp;
opts_decomp = DynareOptions.plot_shock_decomp;
interactive = opts_decomp.interactive;
if ~isempty(opts_decomp.type)
@ -52,26 +52,26 @@ if ~isempty(opts_decomp.type)
fig_mode = [fig_mode '_'];
end
screen_shocks = opts_decomp.screen_shocks;
if DynareOptions.use_shock_groups | comp_nbr<=18,
if DynareOptions.plot_shock_decomp.use_shock_groups | comp_nbr<=18,
screen_shocks=0;
end
fig_names_long = opts_decomp.fig_names;
% fig_names = ['_' fig_names];
fig_name_long = opts_decomp.fig_name;
% fig_name = ['_' fig_name];
if screen_shocks
% fig_names1 = [fig_names1 '_screen'];
fig_names_long = [fig_names_long ' SCREEN'];
% fig_name1 = [fig_name1 '_screen'];
fig_name_long = [fig_name_long ' SCREEN'];
end
fig_names=strrep(fig_names_long, '(given ', '');
fig_names=strrep(fig_names, '(vintage ', '');
fig_names=regexprep(fig_names, ' ', '_');
fig_names=strrep(fig_names, '.', '');
fig_names=strrep(fig_names, '-', '');
fig_names=strrep(fig_names, ')', '');
fig_names=strrep(fig_names, '(', '');
% fig_names1 = [fig_names];
% fig_names = [fig_names '_'];
fig_name=strrep(fig_name_long, '(given ', '');
fig_name=strrep(fig_name, '(vintage ', '');
fig_name=regexprep(fig_name, ' ', '_');
fig_name=strrep(fig_name, '.', '');
fig_name=strrep(fig_name, '-', '');
fig_name=strrep(fig_name, ')', '');
fig_name=strrep(fig_name, '(', '');
% fig_name1 = [fig_name];
% fig_name = [fig_name '_'];
gend = size(z,3);
if isempty(initial_date)
@ -105,8 +105,8 @@ end
nvar = length(i_var);
%% write LaTeX-Header
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_names '_detail.tex'],'w');
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fidTeX = fopen([GraphDirectoryName, filesep, DynareModel.fname '_shock_decomp' fig_mode1 fig_name '_detail.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by Dynare''s graph_decomp_detail.m.\n');
fprintf(fidTeX,['%% ' datestr(now,0) '\n']);
fprintf(fidTeX,' \n');
@ -151,7 +151,7 @@ for j=1:nvar
continue
end
for jf = 1:nfigs
fhandle = dyn_figure(DynareOptions,'Name',[preamble_txt fig_names_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) ' (detail).'],'position',[200 100 650 850], 'PaperPositionMode', 'auto','PaperOrientation','portrait','renderermode','auto');
fhandle = dyn_figure(DynareOptions.plot_shock_decomp.nodisplay,'Name',[preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': ' deblank(endo_names(i_var(j),:)) ' (detail).'],'position',[200 100 650 850], 'PaperPositionMode', 'auto','PaperOrientation','portrait','renderermode','auto');
a0=zeros(1,4);
a0(3)=inf;
a0(4)=-inf;
@ -179,15 +179,15 @@ for j=1:nvar
set(gca,'ylim',a0(3:4))
hold on, h1=plot(x(2:end),z1(end,:),'k-','LineWidth',2);
if interactive & (~isoctave & use_shock_groups)
mydata.fig_names = DynareOptions.shock_decomp.fig_names(2:end);
mydata.use_shock_groups = DynareOptions.use_shock_groups;
mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end);
mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups;
mydata.shock_group = shock_groups.(shock_ind{ic});
mydata.shock_decomp = DynareOptions.shock_decomp;
mydata.shock_decomp = DynareOptions.plot_shock_decomp;
if ~isempty(mydata.shock_group.shocks{1})
c = uicontextmenu;
hax.UIContextMenu=c;
browse_menu = uimenu(c,'Label','Browse group');
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(endo_names(i_var(j),:)) ''',' int2str(ic) ')']);
expand_menu = uimenu(c,'Label','Expand group','Callback',['expand_group(''' mydata.use_shock_groups ''',''' deblank(mydata.shock_decomp.orig_varlist(j,:)) ''',' int2str(ic) ')']);
set(expand_menu,'UserData',mydata,'Tag',['group' int2str(ic)]);
for jmember = mydata.shock_group.shocks
uimenu('parent',browse_menu,'Label',char(jmember))
@ -224,13 +224,13 @@ for j=1:nvar
else
suffix = ['_detail'];
end
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_names suffix],DynareOptions);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',deblank(endo_names(i_var(j),:)),fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_names suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_names suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_names_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:)));
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[deblank(endo_names(i_var(j),:)) fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode deblank(endo_names(i_var(j),:)) fig_name suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'],deblank(DynareModel.endo_names_tex(i_var(j),:)));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
@ -238,7 +238,7 @@ for j=1:nvar
end
%% write LaTeX-Footer
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,' \n');
fprintf(fidTeX,'%% End of TeX file.\n');
fclose(fidTeX);

View File

@ -14,7 +14,7 @@ function [rmse_MC, ixx] = filt_mc_(OutDir,options_gsa_,dataset_,dataset_info)
% marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2016 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -407,7 +407,7 @@ else
end
if mod(i,9)==1,
ifig=ifig+1;
hh=dyn_figure(options_,'name',[temp_name,' ',int2str(ifig)]);
hh=dyn_figure(options_.nodisplay,'name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(lnprior(ixx(1:nfilt0(i),i)));
@ -423,18 +423,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-prior for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnprior',int2str(ifig) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnprior',int2str(ifig) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnprior',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1))
end
@ -455,7 +455,7 @@ else
end
if mod(i,9)==1,
ifig=ifig+1;
hh = dyn_figure(options_,'Name',[temp_name,' ',int2str(ifig)]);
hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(likelihood(ixx(1:nfilt0(i),i)));
@ -474,18 +474,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-likelihood for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnlik',int2str(ifig) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnprior',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnprior',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnlik',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnlik',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnlik',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnlik',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
@ -506,7 +506,7 @@ else
end
if mod(i,9)==1,
ifig=ifig+1;
hh = dyn_figure(options_,'Name',[temp_name,' ',int2str(ifig)]);
hh = dyn_figure(options_.nodisplay,'Name',[temp_name,' ',int2str(ifig)]);
end
subplot(3,3,i-9*(ifig-1))
h=cumplot(logpo2(ixx(1:nfilt0(i),i)));
@ -525,18 +525,18 @@ else
annotation('textbox', [0.55,0,0.35,0.05],'String', 'Log-posterior for WORSE R2', 'Color','Red','horizontalalignment','center');
end
if options_.opt_gsa.ppost
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_post_lnpost',int2str(ifig) ],ifig,[temp_name,' ',int2str(ifig)],'rmse_post_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_prior_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_lnpost',int2str(ifig)],ifig,[temp_name,' ',int2str(ifig)],'rmse_mc_lnpost',options_.figures.textwidth*min((i-9*(ifig-1))/3,1));
end
@ -794,7 +794,7 @@ else
for iy=1:size(vvarvecm,1),
ipar = find(any(squeeze(PPV(iy,:,:))<alpha));
for ix=1:ceil(length(ipar)/5),
hh = dyn_figure(options_,'name',[temp_name,' observed variable ',deblank(vvarvecm(iy,:))]);
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' observed variable ',deblank(vvarvecm(iy,:))]);
for j=1+5*(ix-1):min(length(ipar),5*ix),
subplot(2,3,j-5*(ix-1))
%h0=cumplot(x(:,nsnam(j)+nshock));
@ -837,18 +837,18 @@ else
%h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_);
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_post_' deblank(vvarvecm(iy,:))],1)
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_' deblank(vvarvecm(iy,:)) '_' int2str(ix) ],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_prior_' deblank(vvarvecm(iy,:))],1)
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_' deblank(vvarvecm(iy,:)) '_' int2str(ix)],ix,[temp_name,' observed variable $',deblank(vvarvecm_tex(iy,:)) '$'],['rmse_mc_' deblank(vvarvecm(iy,:))],1)
end
@ -859,7 +859,7 @@ else
% now I plot by individual parameters
for ix=1:ceil(length(nsnam)/5),
hh = dyn_figure(options_,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
hh = dyn_figure(options_.nodisplay,'name',[temp_name,' estimated params and shocks ',int2str(ix)]);
for j=1+5*(ix-1):min(size(snam2,1),5*ix),
subplot(2,3,j-5*(ix-1))
%h0=cumplot(x(:,nsnam(j)+nshock));
@ -904,18 +904,18 @@ else
%h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_);
dyn_saveas(hh,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[ OutDir filesep fname_ '_rmse_post_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_post_params',1)
end
else
if options_.opt_gsa.pprior
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_prior_params_' int2str(ix) ],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_prior_params',1)
end
else
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],options_);
dyn_saveas(hh,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],options_.nodisplay,options_.graph_format);
if options_.TeX
create_TeX_loader(options_,[OutDir filesep fname_ '_rmse_mc_params_' int2str(ix)],ix,[temp_name,' estimated params and shocks ',int2str(ix)],'rmse_mc_params',1)
end

View File

@ -5,7 +5,7 @@ function map_calibration(OutputDirectoryName, Model, DynareOptions, DynareResult
% marco.ratto@ec.europa.eu
% Copyright (C) 2014-2016 European Commission
% Copyright (C) 2014-2016 Dynare Team
% Copyright (C) 2014-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -191,7 +191,7 @@ if ~isempty(indx_irf),
indx_irf = indx_irf(irestrictions,:);
if ~DynareOptions.nograph,
h1=dyn_figure(DynareOptions,'name',[type ' evaluation of irf restrictions']);
h1=dyn_figure(DynareOptions.nodisplay,'name',[type ' evaluation of irf restrictions']);
nrow=ceil(sqrt(nbr_irf_couples));
ncol=nrow;
if nrow*(nrow-1)>nbr_irf_couples,
@ -325,7 +325,7 @@ if ~isempty(indx_irf),
end
end
if ~DynareOptions.nograph,
dyn_saveas(h1,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],DynareOptions);
dyn_saveas(h1,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],DynareOptions.nodisplay,DynareOptions.graph_format);
create_TeX_loader(DynareOptions,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],[type ' evaluation of irf restrictions'],'irf_restrictions',type,DynareOptions.figures.textwidth*min(ij/ncol,1))
end
skipline()
@ -405,7 +405,7 @@ if ~isempty(indx_moment)
indx_moment = indx_moment(irestrictions,:);
if ~DynareOptions.nograph,
h2=dyn_figure(DynareOptions,'name',[type ' evaluation of moment restrictions']);
h2=dyn_figure(DynareOptions.nodisplay,'name',[type ' evaluation of moment restrictions']);
nrow=ceil(sqrt(nbr_moment_couples));
ncol=nrow;
if nrow*(nrow-1)>nbr_moment_couples,
@ -535,7 +535,7 @@ if ~isempty(indx_moment)
end
end
if ~DynareOptions.nograph,
dyn_saveas(h2,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],DynareOptions);
dyn_saveas(h2,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],DynareOptions.nodisplay,DynareOptions.graph_format);
create_TeX_loader(DynareOptions,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],[type ' evaluation of moment restrictions'],'moment_restrictions',type,DynareOptions.figures.textwidth*min(ij/ncol,1))
end

View File

@ -5,7 +5,7 @@ function map_ident_(OutputDirectoryName,opt_gsa)
% marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2016 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -90,7 +90,7 @@ if opt_gsa.load_ident_files==0,
ifig=0;
for j=1:M_.exo_nbr,
if mod(j,6)==1
hh=dyn_figure(options_,'name',['Variance decomposition shocks']);
hh=dyn_figure(options_.nodisplay,'name',['Variance decomposition shocks']);
ifig=ifig+1;
iplo=0;
end
@ -108,7 +108,7 @@ if opt_gsa.load_ident_files==0,
ylabel(' ')
title(M_.exo_names(j,:),'interpreter','none')
if mod(j,6)==0 | j==M_.exo_nbr,
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_);
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_vdec_exo_',int2str(ifig)],ifig,['Variance decomposition shocks'],'vdec_exo',options_.figures.textwidth*min(iplo/3,1))
end
end
@ -219,7 +219,7 @@ if opt_gsa.morris==1,
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAvdec','vdec','ir_vdec','ic_vdec')
end
hh = dyn_figure(options_,'name','Screening identification: variance decomposition');
hh = dyn_figure(options_.nodisplay,'name','Screening identification: variance decomposition');
% boxplot(SAvdec,'whis',10,'symbol','r.')
myboxplot(SAvdec,[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -232,7 +232,7 @@ if opt_gsa.morris==1,
end
xlabel(' ')
title('Elementary effects variance decomposition')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_);
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_vdec'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_vdec'],1,'Screening identification: variance decomposition','morris_vdec',1)
else
save([OutputDirectoryName,'/',fname_,'_morris_IDE.mat'],'vdec')
@ -325,7 +325,7 @@ if opt_gsa.morris==1,
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'ac','ir_ac','ic_ac')
end
hh=dyn_figure(options_,'name','Screening identification: theoretical moments');
hh=dyn_figure(options_.nodisplay,'name','Screening identification: theoretical moments');
% boxplot(SAcc,'whis',10,'symbol','r.')
myboxplot(SAcc,[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -338,7 +338,7 @@ if opt_gsa.morris==1,
end
xlabel(' ')
title('Elementary effects in the moments')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_);
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_moments'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_moments'],1,'Screening identification: theoretical moments','morris_moments',1)
% close(gcf),
@ -722,7 +722,7 @@ if opt_gsa.morris==1,
else
load([OutputDirectoryName,'/',fname_,'_morris_IDE'],'SAnorm','SAmunorm','SAsignorm')
end
hh=dyn_figure(options_,'name','Screening identification: model'); %bar(SAnorm(:,irel))
hh=dyn_figure(options_.nodisplay,'name','Screening identification: model'); %bar(SAnorm(:,irel))
% boxplot(SAnorm','whis',10,'symbol','r.')
myboxplot(SAnorm',[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -736,10 +736,10 @@ if opt_gsa.morris==1,
end
xlabel(' ')
title('Elementary effects in the model')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_par'],options_);
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morris_par'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_morris_par'],1,'Screening identification: model','morris_par',1)
% hh=dyn_figure(options_); %bar(SAmunorm(:,irel))
% hh=dyn_figure(options_.nodisplay); %bar(SAmunorm(:,irel))
% % boxplot(SAmunorm','whis',10,'symbol','r.')
% myboxplot(SAmunorm',[],'.',[],10)
% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -752,9 +752,9 @@ if opt_gsa.morris==1,
% end
% xlabel(' ')
% title('\mu in the model')
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_);
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrismu_par'],options_.nodisplay,options_.graph_format);
%
% hh=dyn_figure(options_); %bar(SAsignorm(:,irel))
% hh=dyn_figure(options_.nodisplay); %bar(SAsignorm(:,irel))
% % boxplot(SAsignorm','whis',10,'symbol','r.')
% myboxplot(SAsignorm',[],'.',[],10)
% set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
@ -767,7 +767,7 @@ if opt_gsa.morris==1,
% end
% xlabel(' ')
% title('\sigma in the model')
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_);
% dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_morrissig_par'],options_.nodisplay,options_.graph_format);
% figure, bar(SAnorm(:,irel)')
% set(gca,'xtick',[1:j0])
@ -1522,7 +1522,7 @@ else, % main effects analysis
% SAmeanexo=mean(SAmomN(:,1:nshock));
% figure, bar(latent'*SAcc),
hh=dyn_figure(options_,'Name',['Identifiability indices in the ',fsuffix,' moments.']);
hh=dyn_figure(options_.nodisplay,'Name',['Identifiability indices in the ',fsuffix,' moments.']);
bar(sum(SAcc)),
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:npT])
set(gca,'xlim',[0.5 npT+0.5])
@ -1535,7 +1535,7 @@ else, % main effects analysis
end
xlabel(' ')
title(['Identifiability indices in the ',fsuffix,' moments.'],'interpreter','none')
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],options_);
dyn_saveas(hh,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[OutputDirectoryName,'/',fname_,'_ident_ALL',fsuffix],1,['Identifiability indices in the ',fsuffix,' moments.'],['ident_ALL',fsuffix]',1)
% figure, bar(SAmeanexo),

View File

@ -16,7 +16,7 @@ function redform_map(dirname,options_gsa_)
% marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2016 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -165,7 +165,7 @@ for j=1:size(anamendo,1)
if (max(y0)-min(y0))>1.e-10,
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph,
ifig=ifig+1;
hfig = dyn_figure(options_,'name',['Reduced Form Mapping: ', namendo,' vs shocks ',int2str(ifig)]);
hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ', namendo,' vs shocks ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -193,7 +193,7 @@ for j=1:size(anamendo,1)
mkdir(xdir)
end
if ~options_.nograph,
hf=dyn_figure(options_,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs ', namexo]);
hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs ', namexo]);
hc = cumplot(y0);
a=axis; delete(hc);
% hist(mat_moment{ij}),
@ -206,7 +206,7 @@ for j=1:size(anamendo,1)
set(hc,'color','k','linewidth',2)
hold off,
title([namendo,' vs ', namexo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],options_);
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namexo],['Reduced Form Mapping (Monte Carlo Filtering): ',strrep(namendo,'_','\_'),' vs ', strrep(namexo,'_','\_')],[type '_' namendo,'_vs_', namexo])
end
si(:,js) = NaN(np,1);
@ -275,7 +275,7 @@ for j=1:size(anamendo,1)
end
title([logflag,' ',namendo,' vs ',namexo],'interpreter','none')
if iplo==9
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],1)
end
end
@ -284,7 +284,7 @@ for j=1:size(anamendo,1)
end
end
if iplo<9 && iplo>0 && ifig && ~options_.nograph,
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namexo,'_','\_')],['redform_', namendo,'_vs_shocks_',logflag,num2str(ifig)],options_.figures.textwidth*min(iplo/3,1))
end
ifig=0;
@ -301,7 +301,7 @@ for j=1:size(anamendo,1)
if (max(y0)-min(y0))>1.e-10,
if mod(iplo,9)==0 && isempty(threshold) && ~options_.nograph,
ifig=ifig+1;
hfig = dyn_figure(options_,'name',['Reduced Form Mapping: ' namendo,' vs lags ',int2str(ifig)]);
hfig = dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping: ' namendo,' vs lags ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -329,7 +329,7 @@ for j=1:size(anamendo,1)
mkdir(xdir)
end
if ~options_.nograph,
hf=dyn_figure(options_,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs lagged ', namlagendo]);
hf=dyn_figure(options_.nodisplay,'name',['Reduced Form Mapping (Monte Carlo Filtering): ',namendo,' vs lagged ', namlagendo]);
hc = cumplot(y0);
a=axis; delete(hc);
% hist(mat_moment{ij}),
@ -342,7 +342,7 @@ for j=1:size(anamendo,1)
set(hc,'color','k','linewidth',2)
hold off,
title([namendo,' vs lagged ', namlagendo ' - threshold [' num2str(threshold(1)) ' ' num2str(threshold(2)) ']'],'interpreter','none')
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],options_);
dyn_saveas(hf,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[xdir,filesep, fname_ '_' type '_' namendo,'_vs_', namlagendo],['Reduced Form Mapping (Monte Carlo Filtering): ',strrep(namendo,'_','\_'),' vs lagged ', strrep(namlagendo,'_','\_')],[type '_' namendo,'_vs_', namlagendo],1)
end
@ -412,7 +412,7 @@ for j=1:size(anamendo,1)
end
title([logflag,' ',namendo,' vs ',namlagendo,'(-1)'],'interpreter','none')
if iplo==9,
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],1)
end
end
@ -421,14 +421,14 @@ for j=1:size(anamendo,1)
end
end
if iplo<9 && iplo>0 && ifig && ~options_.nograph,
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_', namendo,'_vs_lags_',logflag,num2str(ifig)],[logflag,' ',strrep(namendo,'_','\_'),' vs ',strrep(namlagendo,'_','\_'),'(-1)'],['redform_', namendo,'_vs_lags_',logflag,':',num2str(ifig)],options_.figures.textwidth*min(iplo/3,1));
end
end
if isempty(threshold) && ~options_.nograph,
if ilog==0,
hfig=dyn_figure(options_,'name','Reduced Form GSA'); %bar(si)
hfig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(si)
% boxplot(si','whis',10,'symbol','r.')
myboxplot(si',[],'.',[],10)
xlabel(' ')
@ -440,11 +440,11 @@ if isempty(threshold) && ~options_.nograph,
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
end
title('Reduced form GSA')
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa'],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa'],'Reduced Form GSA','redform_gsa')
else
hfig=dyn_figure(options_,'name','Reduced Form GSA'); %bar(silog)
hfig=dyn_figure(options_.nodisplay,'name','Reduced Form GSA'); %bar(silog)
% boxplot(silog','whis',10,'symbol','r.')
myboxplot(silog',[],'.',[],10)
set(gca,'xticklabel',' ','fontsize',10,'xtick',[1:np])
@ -456,7 +456,7 @@ if isempty(threshold) && ~options_.nograph,
text(ip,-0.02,deblank(pnames(ip,:)),'rotation',90,'HorizontalAlignment','right','interpreter','none')
end
title('Reduced form GSA - Log-transformed elements')
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_);
dyn_saveas(hfig,[dirname,filesep,M_.fname,'_redform_gsa_log'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,filesep,M_.fname,'_redform_gsa_log'],'Reduced form GSA - Log-transformed elements','redform_gsa_log')
end
@ -522,7 +522,7 @@ if iload==0,
y1 = log(y0*isig+lam);
end
if ~options_.nograph,
hfig=dyn_figure(options_,'name',options_map.figtitle);
hfig=dyn_figure(options_.nodisplay,'name',options_map.figtitle);
subplot(221)
if ilog,
hist(y1,30),
@ -634,7 +634,7 @@ end
plot(yn,[yf yn],'.'),
title(['Out-of-sample prediction - R2=' num2str(r2,2)],'interpreter','none')
end
dyn_saveas(hfig,fname,options_);
dyn_saveas(hfig,fname,options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,fname,['Out-of-sample prediction - R2=' num2str(r2,2)],'redform_gsa_log')
if options_.nodisplay
@ -647,10 +647,10 @@ else
load([fname,'_map.mat'],'gsa_')
if ~options_.nograph,
yf = ss_anova_fcast(x0, gsa_);
hfig=dyn_figure(options_,'name',options_map.title);
hfig=dyn_figure(options_.nodisplay,'name',options_map.title);
plot(y0,[yf y0],'.'),
title([namy,' vs ', namx,' pred'],'interpreter','none')
dyn_saveas(hfig,[fname '_pred'],options_);
dyn_saveas(hfig,[fname '_pred'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[fname '_pred'],options_map.title,[namy,' vs ', namx,' pred'])
end
@ -724,7 +724,7 @@ return
function indmcf = redform_mcf(y0, x0, options_mcf, options_)
hfig=dyn_figure(options_,'name',options_mcf.amcf_title);
hfig=dyn_figure(options_.nodisplay,'name',options_mcf.amcf_title);
[post_mean, post_median, post_var, hpd_interval, post_deciles, ...
density] = posterior_moments(y0,1,0.9);
@ -770,7 +770,7 @@ if ~isoctave
'horizontalalignment','center');
end
dyn_saveas(hfig,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_);
dyn_saveas(hfig,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[options_mcf.OutputDirectoryName filesep options_mcf.fname_,'_',options_mcf.amcf_name],strrep(options_mcf.amcf_title,'_','\_'),[options_mcf.fname_,'_',options_mcf.amcf_name])
return

View File

@ -11,7 +11,7 @@ function redform_screen(dirname, options_gsa_)
% marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2016 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -68,7 +68,7 @@ for j=1:size(anamendo,1),
if ~isempty(y0),
if mod(iplo,9)==0,
ifig=ifig+1;
hh=dyn_figure(options_,'name',[namendo,' vs. shocks ',int2str(ifig)]);
hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. shocks ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -87,7 +87,7 @@ for j=1:size(anamendo,1),
end
title([namendo,' vs. ',namexo],'interpreter','none')
if iplo==9,
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_);
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],1)
end
@ -95,7 +95,7 @@ for j=1:size(anamendo,1),
end
end
if iplo<9 && iplo>0 && ifig,
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_);
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_shocks_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_shock_',num2str(ifig)],ifig,[namendo,' vs. shocks ',int2str(ifig)],[namendo,'_vs_shock'],options_.figures.textwidth*min(iplo/3))
end
@ -110,7 +110,7 @@ for j=1:size(anamendo,1),
if ~isempty(y0),
if mod(iplo,9)==0,
ifig=ifig+1;
hh=dyn_figure(options_,'name',[namendo,' vs. lagged endogenous ',int2str(ifig)]);
hh=dyn_figure(options_.nodisplay,'name',[namendo,' vs. lagged endogenous ',int2str(ifig)]);
iplo=0;
end
iplo=iplo+1;
@ -130,19 +130,19 @@ for j=1:size(anamendo,1),
title([namendo,' vs. ',namlagendo,'(-1)'],'interpreter','none')
if iplo==9,
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_);
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],1)
end
end
end
end
if iplo<9 && iplo>0 && ifig,
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_);
dyn_saveas(hh,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_', namendo,'_vs_lags_',num2str(ifig)],ifig,[namendo,' vs. lagged endogenous ',int2str(ifig)],[namendo,'_vs_lags'],options_.figures.textwidth*min(iplo/3))
end
end
hh=dyn_figure(options_,'Name','Reduced form screening');
hh=dyn_figure(options_.nodisplay,'Name','Reduced form screening');
%bar(SA)
% boxplot(SA','whis',10,'symbol','r.')
myboxplot(SA',[],'.',[],10)
@ -156,7 +156,7 @@ end
xlabel(' ')
ylabel('Elementary Effects')
title('Reduced form screening')
dyn_saveas(hh,[dirname,'/',M_.fname,'_redform_screen'],options_);
dyn_saveas(hh,[dirname,'/',M_.fname,'_redform_screen'],options_.nodisplay,options_.graph_format);
create_TeX_loader(options_,[dirname,'/',M_.fname,'_redform_screen'],1,'Reduced form screening','redform_screen',1)

View File

@ -23,7 +23,7 @@ function scatter_callback(K, type)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global oo_ M_
global oo_ M_ options_ bayestopt_ estim_params_
x=get(gcf,'userdata');
r2=x{1};
@ -37,6 +37,6 @@ switch type
case 'eval'
disp('Evaluating smoother ...')
oo_=evaluate_smoother(xparam1,M_.endo_names);
[oo_, M_]=evaluate_smoother(xparam1,M_.endo_names,M_,oo_,options_,bayestopt_,estim_params_);
% [rmse, lnam, r2,vv] = plot_fit(obsname{:});
end

View File

@ -5,7 +5,7 @@ function scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, D
% marco.ratto@ec.europa.eu
% Copyright (C) 2014-2016 European Commission
% Copyright (C) 2014-2016 Dynare Team
% Copyright (C) 2014-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -84,7 +84,7 @@ figtitle_tex=strrep(figtitle,'_','\_');
fig_nam_=[fnam];
if ~nograph,
hh=dyn_figure(DynareOptions,'name',figtitle);
hh=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
end
bf = 0.1;
@ -166,7 +166,7 @@ if ~isoctave
end
if ~nograph,
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions);
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by scatter_mcf.m (Dynare).\n');

View File

@ -1,5 +1,4 @@
function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, DynareOptions)
%
% Written by Marco Ratto
% Joint Research Centre, The European Commission,
@ -53,16 +52,17 @@ if nargin<4 || isempty(plotsymbol)
end
end
if nargin<5
fnam='';
if nargin<5 || isempty(fnam)
fnam='scatter_plot';
end
if nargin<6,
if nargin<6 || isempty(dirname),
dirname='';
nograph=1;
DynareOptions.nodisplay=0;
else
nograph=0;
end
if nargin<7,
if nargin<7 || isempty(figtitle),
figtitle=fnam;
end
if nargin<8,
@ -72,10 +72,9 @@ end
figtitle_tex=strrep(figtitle,'_','\_');
fig_nam_=[fnam];
if ~nograph,
hh=dyn_figure(DynareOptions,'name',figtitle);
hh=dyn_figure(DynareOptions.nodisplay,'name',figtitle);
set(hh,'userdata',{X,xp})
end
bf = 0.1;
ffs = 0.05/(p-1);
@ -173,7 +172,7 @@ end
% end
if ~nograph,
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions);
dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions.nodisplay,DynareOptions.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
fidTeX = fopen([dirname,'/',fig_nam_ '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by scatter_plots.m (Dynare).\n');

View File

@ -21,7 +21,7 @@ function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, i
% marco.ratto@ec.europa.eu
% Copyright (C) 2012-2016 European Commission
% Copyright (C) 2012-2016 Dynare Team
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -82,7 +82,7 @@ if iplot && ~options_.nograph
ftit=bayestopt_.name(ipar+nshock*(1-ishock));
for i=1:ceil(nparplot/12),
hh=dyn_figure(options_,'name',atitle);
hh=dyn_figure(options_.nodisplay,'name',atitle);
for j=1+12*(i-1):min(nparplot,12*i),
subplot(3,4,j-12*(i-1))
if ~isempty(ibehaviour),
@ -98,7 +98,7 @@ if iplot && ~options_.nograph
title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
end
if nparplot>12,
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_);
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA_',int2str(i) '.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_1.m (Dynare).\n');
@ -113,7 +113,7 @@ if iplot && ~options_.nograph
fclose(fidTeX);
end
else
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA'],options_);
dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA'],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fname_,'_',aname,'_SA.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_1.m (Dynare).\n');

View File

@ -6,7 +6,7 @@ function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figti
% marco.ratto@ec.europa.eu
% Copyright (C) 2011-2016 European Commission
% Copyright (C) 2011-2016 Dynare Team
% Copyright (C) 2011-2017 Dynare Team
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
@ -119,7 +119,7 @@ for j=1:npar,
if ~nograph,
if mod(j2,12)==1,
ifig=ifig+1;
hh=dyn_figure(options_,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
hh=dyn_figure(options_.nodisplay,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
end
subplot(3,4,j2-(ifig-1)*12)
% bar(c0(i2,j)),
@ -142,7 +142,7 @@ for j=1:npar,
end
title(['cc = ',num2str(c0(i2(jx),j))])
if (mod(j2,12)==0) && j2>0,
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_);
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');
@ -163,7 +163,7 @@ for j=1:npar,
end
end
if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0),
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_);
dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([dirname,filesep,fig_nam_,int2str(ifig),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by stab_map_2.m (Dynare).\n');

View File

@ -0,0 +1,131 @@
function oo_ = initial_condition_decomposition(M_,oo_,options_,varlist,bayestopt_,estim_params_)
% function oo_ = initial_condition_decomposition(M_,oo_,options_,varlist,bayestopt_,estim_params_)
% Computes initial condition contribution to a simulated trajectory. The field set is
% oo_.initval_decomposition. It is a n_var by n_var+2 by nperiods array. The
% first n_var columns store the respective endogenous initval contribution, column n+1
% stores the role of the shocks, while column n+2 stores the
% value of the smoothed variables. Variables are stored
% in the order of declaration, i.e. M_.endo_names.
%
% INPUTS
% M_: [structure] Definition of the model
% oo_: [structure] Storage of results
% options_: [structure] Options
% varlist: [char] List of variables
% bayestopt_: [structure] describing the priors
% estim_params_: [structure] characterizing parameters to be estimated
%
% OUTPUTS
% oo_: [structure] Storage of results
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options_.plot_shock_decomp.detail_plot = options_.initial_condition_decomp.detail_plot;
options_.plot_shock_decomp.steadystate = options_.initial_condition_decomp.steadystate;
options_.plot_shock_decomp.write_xls = options_.initial_condition_decomp.write_xls;
options_.plot_shock_decomp.type = options_.initial_condition_decomp.type;
options_.plot_shock_decomp.plot_init_date = options_.initial_condition_decomp.plot_init_date;
options_.plot_shock_decomp.plot_end_date = options_.initial_condition_decomp.plot_end_date;
% indices of endogenous variables
if size(varlist,1) == 0
varlist = M_.endo_names(1:M_.orig_endo_nbr,:);
end
[i_var,nvar] = varlist_indices(varlist,M_.endo_names);
% number of variables
endo_nbr = M_.endo_nbr;
% parameter set
parameter_set = options_.parameter_set;
if isempty(parameter_set)
if isfield(oo_,'posterior_mean')
parameter_set = 'posterior_mean';
elseif isfield(oo_,'mle_mode')
parameter_set = 'mle_mode';
elseif isfield(oo_,'posterior')
parameter_set = 'posterior_mode';
else
error(['shock_decomposition: option parameter_set is not specified ' ...
'and posterior mode is not available'])
end
end
if ~isfield(oo_,'initval_decomposition')
options_.selected_variables_only = 0; %make sure all variables are stored
options_.plot_priors=0;
[oo,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
% reduced form
dr = oo.dr;
% data reordering
order_var = dr.order_var;
inv_order_var = dr.inv_order_var;
% coefficients
A = dr.ghx;
B = dr.ghu;
% initialization
gend = size(oo.SmoothedShocks.(deblank(M_.exo_names(1,:))),1); %+options_.forecast;
z = zeros(endo_nbr,endo_nbr+2,gend);
z(:,end,:) = Smoothed_Variables_deviation_from_mean;
for i=1:endo_nbr,
z(i,i,1) = Smoothed_Variables_deviation_from_mean(i,1);
end
maximum_lag = M_.maximum_lag;
k2 = dr.kstate(find(dr.kstate(:,2) <= maximum_lag+1),[1 2]);
i_state = order_var(k2(:,1))+(min(i,maximum_lag)+1-k2(:,2))*M_.endo_nbr;
for i=1:gend
if i > 1 && i <= maximum_lag+1
lags = min(i-1,maximum_lag):-1:1;
end
if i > 1
tempx = permute(z(:,1:endo_nbr,lags),[1 3 2]);
m = min(i-1,maximum_lag);
tempx = [reshape(tempx,endo_nbr*m,endo_nbr); zeros(endo_nbr*(maximum_lag-i+1),endo_nbr)];
z(:,1:endo_nbr,i) = A(inv_order_var,:)*tempx(i_state,:);
lags = lags+1;
end
z(:,endo_nbr+1,i) = z(:,endo_nbr+2,i) - sum(z(:,1:endo_nbr,i),2);
end
oo_.initval_decomposition = z;
end
% if ~options_.no_graph.shock_decomposition
oo=oo_;
oo.shock_decomposition = oo_.initval_decomposition;
M_.exo_names = M_.endo_names;
M_.exo_nbr = M_.endo_nbr;
options_.plot_shock_decomp.screen_shocks=1;
options_.plot_shock_decomp.use_shock_groups = '';
options_.plot_shock_decomp.fig_names='initval';
plot_shock_decomposition(M_,oo,options_,varlist);
% end

View File

@ -165,8 +165,15 @@ elseif imag(fval)
end
if info(1) > 0
if DynareOptions.order>1
[eigenvalues_] = check(Model,DynareOptions, DynareResults);
if any(abs(eigenvalues_)>DynareOptions.qz_criterium)
error('Your model has at least one unit root and you are using a nonlinear filter. Please set nonlinear_filter_initialization=3.')
end
else
disp('Error in computing likelihood for initial parameter values')
print_info(info, DynareOptions.noprint, DynareOptions)
end
end
if DynareOptions.prefilter==1

View File

@ -1 +1 @@
list_of_functions = {'discretionary_policy_1', 'dsge_var_likelihood', 'dyn_first_order_solver', 'dyn_waitbar', 'ep_residuals', 'evaluate_likelihood', 'evaluate_smoother', 'prior_draw_gsa', 'identification_analysis', 'computeDLIK', 'univariate_computeDLIK', 'metropolis_draw', 'flag_implicit_skip_nan', 'moment_function', 'non_linear_dsge_likelihood', 'mr_hessian', 'masterParallel', 'auxiliary_initialization', 'auxiliary_particle_filter', 'conditional_filter_proposal', 'conditional_particle_filter', 'gaussian_filter', 'gaussian_filter_bank', 'gaussian_mixture_filter', 'gaussian_mixture_filter_bank', 'Kalman_filter', 'online_auxiliary_filter', 'sequential_importance_particle_filter', 'solve_model_for_online_filter', 'perfect_foresight_simulation', 'prior_draw', 'priordens', 'smm_objective'};
list_of_functions = {'discretionary_policy_1', 'dsge_var_likelihood', 'dyn_first_order_solver', 'dyn_waitbar', 'ep_residuals', 'evaluate_likelihood', 'prior_draw_gsa', 'identification_analysis', 'computeDLIK', 'univariate_computeDLIK', 'metropolis_draw', 'flag_implicit_skip_nan', 'moment_function', 'non_linear_dsge_likelihood', 'mr_hessian', 'masterParallel', 'auxiliary_initialization', 'auxiliary_particle_filter', 'conditional_filter_proposal', 'conditional_particle_filter', 'gaussian_filter', 'gaussian_filter_bank', 'gaussian_mixture_filter', 'gaussian_mixture_filter_bank', 'Kalman_filter', 'online_auxiliary_filter', 'sequential_importance_particle_filter', 'solve_model_for_online_filter', 'perfect_foresight_simulation', 'prior_draw', 'priordens', 'smm_objective'};

View File

@ -18,7 +18,7 @@ function mh_autocorrelation_function(options_,M_,estim_params_,type,blck,name1,n
%
% SPECIAL REQUIREMENTS
% Copyright (C) 2003-2013 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -91,7 +91,7 @@ if options_.mh_nblck>1
FigureName = [ FigureName , ' (block number' int2str(blck) ').'];
end
hh=dyn_figure(options_,'Name',FigureName);
hh=dyn_figure(options_.nodisplay,'Name',FigureName);
bar(0:options_.mh_autocorrelation_function_size,autocor,'k');
axis tight
@ -104,4 +104,4 @@ if ~exist([M_.fname filesep 'graphs'])
end
plot_name=get_the_name(column,0,M_,estim_params_,options_);
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'MH_Autocorrelation_' plot_name],options_)
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'MH_Autocorrelation_' plot_name],options_.nodisplay,options_.graph_format)

View File

@ -0,0 +1,29 @@
function a = struct2array(s)
% INPUTS
% - s [struct] with N fields, field i contains a n_i*m_i array of doubles.
%
% OUPUTS
% - a [double] column vector with sum(n_i*m_i, i=1,...,N) elements.
% Copyright (C) 2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert(isstruct(s), 'struct2array:: Argument has to be a structure!')
c = cellfun(@vec, struct2cell(s), 'UniformOutput', false);
a = vertcat(c{:});

View File

@ -122,7 +122,11 @@ end
t = 0;
icc=0;
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,1))
newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
end
while newRank && t < smpl
t = t+1;
a(:,t) = a1(:,t);
@ -156,7 +160,11 @@ while newRank && t < smpl
end
end
if newRank
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,t))
oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol);
else
oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
end
else
oldRank = 0;
end
@ -168,7 +176,11 @@ while newRank && t < smpl
Pstar(:,:,t+1) = T*Pstar(:,:,t)*T'+ QQ;
Pinf(:,:,t+1) = T*Pinf(:,:,t)*T';
if newRank
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
if ~isempty(Pinf(:,:,t+1))
newRank = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol);
else
newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
end
end
if oldRank ~= newRank
disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')
@ -367,3 +379,9 @@ if decomp_flag
end
epsilonhat = Y - Z*alphahat;
if (d==smpl)
warning(['missing_DiffuseKalmanSmootherH3_Z:: There isn''t enough information to estimate the initial conditions of the nonstationary variables']);
return
end

View File

@ -40,7 +40,7 @@ function mode_check(fun,x,hessian_mat,DynareDataset,DatasetInfo,DynareOptions,Mo
%! @end deftypefn
%@eod:
% Copyright (C) 2003-2016 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -96,7 +96,7 @@ for plt = 1:nbplt,
NAMES = [];
TeXNAMES = [];
end
hh = dyn_figure(DynareOptions,'Name','Mode check plots');
hh = dyn_figure(DynareOptions.nodisplay,'Name','Mode check plots');
for k=1:min(nstar,length(x)-(plt-1)*nstar)
subplot(nr,nc,k)
kk = (plt-1)*nstar+k;
@ -187,7 +187,7 @@ for plt = 1:nbplt,
text(0.25,0.5,'log-post')
text(0.69,0.5,'log-lik kernel')
end
dyn_saveas(hh,[ Model.fname '_CheckPlots' int2str(plt) ],DynareOptions);
dyn_saveas(hh,[ Model.fname '_CheckPlots' int2str(plt) ],DynareOptions.nodisplay,DynareOptions.graph_format);
if TeX && any(strcmp('eps',cellstr(DynareOptions.graph_format)))
% TeX eps loader file
fprintf(fidTeX,'\\begin{figure}[H]\n');

@ -1 +1 @@
Subproject commit ac6a420a28feeb68b43a8fdb7a6ea9e0bec0b7ae
Subproject commit af39a2c97ea01de6a1451071e58d4fce8f4b9d03

View File

@ -316,7 +316,8 @@ switch DynareOptions.particle.initialization
StateVectorVariance = cov(y_');
DynareOptions.periods = old_DynareOptionsperiods;
clear('old_DynareOptionsperiods','y_');
case 3% Initial state vector covariance is a diagonal matrix.
case 3% Initial state vector covariance is a diagonal matrix (to be used
% if model has stochastic trends).
StateVectorMean = ReducedForm.constant(mf0);
StateVectorVariance = DynareOptions.particle.initial_state_prior_std*eye(number_of_state_variables);
otherwise

@ -1 +1 @@
Subproject commit 79b42ec947aa1dbe009778f3874f074f0d14eb7a
Subproject commit 823d947484675c8d409a4eb2377a57dc59bdf713

View File

@ -17,7 +17,7 @@ function [endogenousvariables, info] = sim1(endogenousvariables, exogenousvariab
% SPECIAL REQUIREMENTS
% None.
% Copyright (C) 1996-2016 Dynare Team
% Copyright (C) 1996-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -165,6 +165,11 @@ for iter = 1:options.simul.maxit
dy = -lin_solve( A, res, verbose );
end
end
if any(~isreal(dy)) || any(isnan(dy)) || any(isinf(dy))
if verbose
display_critical_variables(reshape(dy,[ny periods])', M);
end
end
Y(i_upd) = Y(i_upd) + dy;
end
@ -184,7 +189,12 @@ if stop
if verbose
skipline()
disp(sprintf('Total time of simulation: %s.', num2str(etime(clock,h1))))
disp('Simulation terminated with NaN or Inf in the residuals or endogenous variables.')
if ~isreal(res) || ~isreal(Y)
disp('Simulation terminated with imaginary parts in the residuals or endogenous variables.')
else
disp('Simulation terminated with NaN or Inf in the residuals or endogenous variables.')
end
display_critical_variables(reshape(dy,[ny periods])', M);
disp('There is most likely something wrong with your model. Try model_diagnostics or another simulation method.')
printline(105)
end
@ -296,4 +306,30 @@ function [ x, flag, relres ] = lin_solve_robust( A, b , verbose)
flag = relres > 1e-6;
if flag ~= 0 && verbose
fprintf( 'WARNING : Failed to find a solution to the linear system\n' );
end
end
function display_critical_variables(dyy, M)
if any(isnan(dyy))
indx = find(any(isnan(dyy)));
endo_names=cellstr(M.endo_names(indx,:));
disp('Last iteration provided NaN for the following variables:')
fprintf('%s, ',endo_names{:}),
fprintf('\n'),
end
if any(isinf(dyy))
indx = find(any(isinf(dyy)));
endo_names=cellstr(M.endo_names(indx,:));
disp('Last iteration diverged (Inf) for the following variables:')
fprintf('%s, ',endo_names{:}),
fprintf('\n'),
end
if any(~isreal(dyy))
indx = find(any(~isreal(dyy)));
endo_names=cellstr(M.endo_names(indx,:));
disp('Last iteration provided complex number for the following variables:')
fprintf('%s, ',endo_names{:}),
fprintf('\n'),
end

View File

@ -10,7 +10,7 @@ function plot_icforecast(Variables,periods,options_)
% SPECIAL REQUIREMENTS
% This routine has to be called after imcforecast.m.
% Copyright (C) 2006-2016 Dynare Team
% Copyright (C) 2006-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -57,7 +57,7 @@ for i=1:size(Variables,1)
end
function build_figure(name,cci1,cci2,mm1,mm2,options_,graphoptions)
hh = dyn_figure(options_,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
hh = dyn_figure(options_.nodisplay,'Name',['Conditional forecast (' graphoptions.title ,'): ' name '.']);
H = length(mm1);
h1 = area(1:H,cci1(2,1:H),'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))]),'FaceColor',[.9 .9 .9]);
hold on
@ -68,4 +68,4 @@ plot(1:H,cci2(1,:),'--k','linewidth',1)
plot(1:H,cci2(2,:),'--k','linewidth',1)
axis tight
hold off
dyn_saveas(hh,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',deblank(name)],options_)
dyn_saveas(hh,[graphoptions.OutputDirectoryName '/Conditional_forecast_',strrep(deblank(graphoptions.title),' ','_'),'_',deblank(name)],options_.nodisplay,options_.graph_format)

View File

@ -19,7 +19,7 @@ function plot_identification(params,idemoments,idehess,idemodel, idelre, advance
% SPECIAL REQUIREMENTS
% None
% Copyright (C) 2008-2016 Dynare Team
% Copyright (C) 2008-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -60,7 +60,7 @@ tittxt1=regexprep(tittxt, ' ', '_');
tittxt1=strrep(tittxt1, '.', '');
if SampleSize == 1,
siJ = idemoments.siJ;
hh = dyn_figure(options_,'Name',[tittxt, ' - Identification using info from observables']);
hh = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Identification using info from observables']);
subplot(211)
mmm = (idehess.ide_strength_J);
[ss, is] = sort(mmm);
@ -122,7 +122,7 @@ if SampleSize == 1,
fprintf(fidTeX,'%% End Of TeX file. \n');
fclose(fidTeX);
end
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_);
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_strength_' tittxt1],options_.nodisplay,options_.graph_format);
if advanced,
if ~options_.nodisplay,
@ -132,7 +132,7 @@ if SampleSize == 1,
if all(isnan([siJnorm';siHnorm';siLREnorm']))
fprintf('\nIDENTIFICATION: Skipping sensitivity plot, because standard deviation of parameters is NaN, possibly due to the use of ML.\n')
else
hh = dyn_figure(options_,'Name',[tittxt, ' - Sensitivity plot']);
hh = dyn_figure(options_.nodisplay,'Name',[tittxt, ' - Sensitivity plot']);
subplot(211)
mmm = (siJnorm)'./max(siJnorm);
mmm1 = (siHnorm)'./max(siHnorm);
@ -151,7 +151,7 @@ if SampleSize == 1,
end
legend('Moments','Model','LRE model','Location','Best')
title('Sensitivity bars using derivatives (log-scale)')
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_);
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1 ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_sensitivity_' tittxt1,'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -185,7 +185,7 @@ if SampleSize == 1,
end
% fprintf('%-15s [%s] %10.3f\n',name{i},namx,idemoments.cosnJ(i,j))
end
hh = dyn_figure(options_,'Name',[tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)']);
hh = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)']);
imagesc(pax,[0 1]);
set(gca,'xticklabel','')
set(gca,'yticklabel','')
@ -205,7 +205,7 @@ if SampleSize == 1,
set(gca,'xgrid','on')
set(gca,'ygrid','on')
xlabel([tittxt,' - Collinearity patterns with ', int2str(j) ,' parameter(s)'],'interpreter','none')
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_);
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j) ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_collinearity_' tittxt1 '_' int2str(j),'.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -225,24 +225,24 @@ if SampleSize == 1,
S=diag(S);
if idehess.flag_score,
if nparam<5,
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix)']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (Information matrix)']);
tex_tit_1=[tittxt,' - Identification patterns (Information matrix)'];
else
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): SMALLEST SV']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (Information matrix): SMALLEST SV']);
tex_tit_1=[tittxt,' - Identification patterns (Information matrix): SMALLEST SV'];
f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']);
f2 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (Information matrix): HIGHEST SV']);
tex_tit_2=[tittxt,' - Identification patterns (Information matrix): HIGHEST SV'];
end
else
% S = idemoments.S;
% V = idemoments.V;
if nparam<5,
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix)']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (moments Information matrix)']);
tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix)'];
else
f1 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV']);
tex_tit_1=[tittxt,' - Identification patterns (moments Information matrix): SMALLEST SV'];
f2 = dyn_figure(options_,'Name',[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV']);
f2 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV']);
tex_tit_2=[tittxt,' - Identification patterns (moments Information matrix): HIGHEST SV'];
end
end
@ -270,7 +270,7 @@ if SampleSize == 1,
end
title(['Singular value ',num2str(Stit)])
end
dyn_saveas(f1,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1' ],options_);
dyn_saveas(f1,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_1','.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -285,7 +285,7 @@ if SampleSize == 1,
fclose(fidTeX);
end
if nparam>4,
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2' ],options_);
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_ident_pattern_' tittxt1 '_2.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -303,7 +303,7 @@ if SampleSize == 1,
end
else
hh = dyn_figure(options_,'Name',['MC sensitivities']);
hh = dyn_figure(options_.nodisplay,'Name',['MC sensitivities']);
subplot(211)
mmm = (idehess.ide_strength_J);
[ss, is] = sort(mmm);
@ -329,7 +329,7 @@ else
legend('Moments','Model','LRE model','Location','Best')
end
title('MC mean of sensitivity measures')
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_);
dyn_saveas(hh,[ IdentifDirectoryName '/' M_.fname '_MC_sensitivity' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_sensitivity.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -350,7 +350,7 @@ else
disp('Press ENTER to display advanced diagnostics'), pause(5),
end
% options_.nograph=1;
hh = dyn_figure(options_,'Name','MC Condition Number');
hh = dyn_figure(options_.nodisplay,'Name','MC Condition Number');
subplot(221)
hist(log10(idemodel.cond))
title('log10 of Condition number in the model')
@ -360,7 +360,7 @@ else
subplot(223)
hist(log10(idelre.cond))
title('log10 of Condition number in the LRE model')
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_);
dyn_saveas(hh,[IdentifDirectoryName '/' M_.fname '_ident_COND' ],options_.nodisplay,options_.graph_format);
options_mcf.pvalue_ks = 0.1;
options_mcf.pvalue_corr = 0.001;
options_mcf.alpha2 = 0;
@ -398,12 +398,12 @@ else
% end
if nparam<5,
f1 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
tex_tit_1=[tittxt,' - MC Identification patterns (moments): HIGHEST SV'];
else
f1 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): SMALLEST SV']);
f1 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - MC Identification patterns (moments): SMALLEST SV']);
tex_tit_1=[tittxt,' - MC Identification patterns (moments): SMALLEST SV'];
f2 = dyn_figure(options_,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
f2 = dyn_figure(options_.nodisplay,'Name',[tittxt,' - MC Identification patterns (moments): HIGHEST SV']);
tex_tit_2=[tittxt,' - MC Identification patterns (moments): HIGHEST SV'];
end
nplots=min(nparam,8);
@ -440,7 +440,7 @@ else
end
title(['MEAN Singular value ',num2str(Stit)])
end
dyn_saveas(f1,[IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1' ],options_);
dyn_saveas(f1,[IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_1.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');
@ -455,7 +455,7 @@ else
fclose(fidTeX);
end
if nparam>4,
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2' ],options_);
dyn_saveas(f2,[ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2' ],options_.nodisplay,options_.graph_format);
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fidTeX = fopen([ IdentifDirectoryName '/' M_.fname '_MC_ident_pattern_2.tex'],'w');
fprintf(fidTeX,'%% TeX eps-loader file generated by plot_identification.m (Dynare).\n');

View File

@ -13,7 +13,7 @@ function plot_priors(bayestopt_,M_,estim_params_,options_)
% SPECIAL REQUIREMENTS
% None
% Copyright (C) 2004-2016 Dynare Team
% Copyright (C) 2004-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -43,7 +43,7 @@ if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,' \n');
end
for plt = 1:nbplt,
hplt = dyn_figure(options_,'Name',figurename);
hplt = dyn_figure(options_.nodisplay,'Name',figurename);
if TeX
TeXNAMES = [];
NAMES = [];
@ -70,7 +70,7 @@ for plt = 1:nbplt,
title(nam,'Interpreter','none')
drawnow
end
dyn_saveas(hplt,[M_.fname '_Priors' int2str(plt)],options_);
dyn_saveas(hplt,[M_.fname '_Priors' int2str(plt)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for jj = 1:nstar0,

View File

@ -28,6 +28,11 @@ function [z, steady_state] = plot_shock_decomposition(M_,oo_,options_,varlist)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options_.nodisplay = options_.plot_shock_decomp.nodisplay;
options_.graph_format = options_.plot_shock_decomp.graph_format;
options_.use_shock_groups = options_.plot_shock_decomp.use_shock_groups;
options_.colormap = options_.plot_shock_decomp.colormap;
% indices of endogenous variables
if size(varlist,1) == 0
varlist = M_.endo_names(1:M_.orig_endo_nbr,:);
@ -41,7 +46,7 @@ endo_nbr = M_.endo_nbr;
% number of shocks
nshocks = M_.exo_nbr;
% type = '';
fig_names='';
fig_name='';
% detail_plot=0;
% realtime_=0; % 0 is standard; 1 is realtime (pool/vintage); 2 is conditional (pool/vintage); 3 is forecast (pool/vintage)
% vintage_=0; % 0 pool realtime/conditional; int: forecast/conditional shock decompositions
@ -49,27 +54,31 @@ fig_names='';
% steadystate=0;
% write_xls=0;
if isfield(options_.shock_decomp,'expand'), % private trap for uimenu calls
expand=options_.shock_decomp.expand;
if isfield(options_.plot_shock_decomp,'expand'), % private trap for uimenu calls
expand=options_.plot_shock_decomp.expand;
else
expand=0;
end
if ~isempty(options_.shock_decomp.fig_names)
fig_names=[' ' options_.shock_decomp.fig_names];
if ~isempty(options_.plot_shock_decomp.fig_name)
fig_name=[' ' options_.plot_shock_decomp.fig_name];
end
type=options_.shock_decomp.type;
detail_plot=options_.shock_decomp.detail_plot;
realtime_= options_.shock_decomp.realtime;
vintage_ = options_.shock_decomp.vintage;
type=options_.plot_shock_decomp.type;
detail_plot=options_.plot_shock_decomp.detail_plot;
realtime_= options_.plot_shock_decomp.realtime;
vintage_ = options_.plot_shock_decomp.vintage;
forecast_ = options_.shock_decomp.forecast;
steadystate = options_.shock_decomp.steadystate;
write_xls = options_.shock_decomp.write_xls;
steadystate = options_.plot_shock_decomp.steadystate;
write_xls = options_.plot_shock_decomp.write_xls;
if vintage_,
forecast_ = min(forecast_,options_.nobs-vintage_);
end
initial_date = options_.initial_date;
if isfield(options_.shock_decomp,'q2a'), % private trap for aoa calls
q2a=options_.shock_decomp.q2a;
if isfield(options_.plot_shock_decomp,'q2a'), % private trap for aoa calls
q2a=options_.plot_shock_decomp.q2a;
if isstruct(q2a) && isempty(fieldnames(q2a)),
q2a=0;
end
@ -81,35 +90,35 @@ switch realtime_
case 0
z = oo_.shock_decomposition;
fig_names1=fig_names;
fig_name1=fig_name;
case 1 % realtime
if vintage_
z = oo_.realtime_shock_decomposition.(['time_' int2str(vintage_)]);
fig_names1=[fig_names ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
fig_name1=[fig_name ' realtime (vintage ' char(initial_date+vintage_-1) ')'];
else
z = oo_.realtime_shock_decomposition.pool;
fig_names1=[fig_names ' realtime (rolling)'];
fig_name1=[fig_name ' realtime (rolling)'];
end
case 2 % conditional
if vintage_
z = oo_.realtime_conditional_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = options_.initial_date+vintage_-1;
fig_names1=[fig_names ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead conditional forecast (given ' char(initial_date) ')'];
else
z = oo_.conditional_shock_decomposition.pool;
fig_names1=[fig_names ' 1-step ahead conditional forecast (rolling)'];
fig_name1=[fig_name ' 1-step ahead conditional forecast (rolling)'];
end
case 3 % forecast
if vintage_
z = oo_.realtime_forecast_shock_decomposition.(['time_' int2str(vintage_)]);
initial_date = options_.initial_date+vintage_-1;
fig_names1=[fig_names ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
fig_name1=[fig_name ' ' int2str(forecast_) '-step ahead forecast (given ' char(initial_date) ')'];
else
z = oo_.realtime_forecast_shock_decomposition.pool;
fig_names1=[fig_names ' 1-step ahead forecast (rolling)'];
fig_name1=[fig_name ' 1-step ahead forecast (rolling)'];
end
end
@ -129,7 +138,7 @@ if isequal(type,'aoa') && isstruct(q2a) && realtime_
initial_date1=initial_date0+1;
end
end
t0=min(options_.shock_decomp.save_realtime);
t0=min(options_.plot_shock_decomp.save_realtime);
ini1 = initial_date+t0-1;
t0=t0+(4-ini1.time(2));
if ~isfield(q2a,'var_type'), % private trap for aoa calls
@ -153,7 +162,7 @@ if isequal(type,'aoa') && isstruct(q2a) && realtime_
% if isstruct(q2a.aux) && ischar(q2a.aux.y)
% opts=options_;
% opts.shock_decomp.type='qoq';
% opts.plot_shock_decomp.type='qoq';
% [y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,opts,q2a.aux.y);
% q2a.aux.y=y_aux;
% q2a.aux.yss=steady_state_aux;
@ -170,14 +179,14 @@ end
if ~expand
fig_names = fig_names1;
fig_name = fig_name1;
end
gend = size(z,3);
if options_.use_shock_groups
shock_groups = M_.shock_groups.(options_.use_shock_groups);
if options_.plot_shock_decomp.use_shock_groups
shock_groups = M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups);
shock_ind = fieldnames(shock_groups);
ngroups = length(shock_ind);
fig_names=[fig_names ' group ' options_.use_shock_groups];
fig_name=[fig_name ' group ' options_.plot_shock_decomp.use_shock_groups];
shock_names = shock_ind;
for i=1:ngroups,
shock_names{i} = (shock_groups.(shock_ind{i}).label);
@ -195,7 +204,7 @@ if options_.use_shock_groups
zothers = sum(z(:,1:nshocks,:),2);
shock_groups.(['group' int2str(ngroups+1)]).label = 'Others';
shock_groups.(['group' int2str(ngroups+1)]).shocks = cellstr(M_.exo_names(find(~ismember([1:M_.exo_nbr],kcum)),:))';
M_.shock_groups.(options_.use_shock_groups)=shock_groups;
M_.shock_groups.(options_.plot_shock_decomp.use_shock_groups)=shock_groups;
if any(any(zothers)),
shock_names = [shock_names; {'Others + Initial Values'}];
end
@ -212,8 +221,8 @@ end
MAP(end,:) = [0.7 0.7 0.7];
% MAP = [MAP; [0.7 0.7 0.7]; [0.3 0.3 0.3]];
if isempty(options_.colormap),
options_.colormap = MAP;
if isempty(options_.plot_shock_decomp.colormap),
options_.plot_shock_decomp.colormap = MAP;
end
switch type
@ -269,7 +278,7 @@ switch type
if isstruct(q2a.aux) && ischar(q2a.aux.y)
opts=options_;
opts.shock_decomp.type='qoq';
opts.plot_shock_decomp.type='qoq';
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,opts,q2a.aux.y);
q2a.aux.y=y_aux;
q2a.aux.yss=steady_state_aux;
@ -292,11 +301,11 @@ switch type
z=z(:,:,t0:4:end);
end
if ~isempty(options_.shock_decomp.plot_init_date)
options_.shock_decomp.plot_init_date = dates([int2str(options_.shock_decomp.plot_init_date.time(1)) 'Y']);
if ~isempty(options_.plot_shock_decomp.plot_init_date)
options_.plot_shock_decomp.plot_init_date = dates([int2str(options_.plot_shock_decomp.plot_init_date.time(1)) 'Y']);
end
if ~isempty(options_.shock_decomp.plot_end_date)
options_.shock_decomp.plot_end_date = dates([int2str(options_.shock_decomp.plot_end_date.time(1)) 'Y']);
if ~isempty(options_.plot_shock_decomp.plot_end_date)
options_.plot_shock_decomp.plot_end_date = dates([int2str(options_.plot_shock_decomp.plot_end_date.time(1)) 'Y']);
end
@ -306,7 +315,7 @@ switch type
end
if steadystate
options_.shock_decomp.steady_state=steady_state;
options_.plot_shock_decomp.steady_state=steady_state;
end
if nargout
@ -319,17 +328,18 @@ end
my_initial_date = initial_date;
a = 1;
b = size(z,3);
if ~isempty(options_.shock_decomp.plot_init_date)
my_initial_date = max(initial_date,options_.shock_decomp.plot_init_date);
a = find((initial_date:initial_date+b-1)==options_.shock_decomp.plot_init_date);
if ~isempty(options_.plot_shock_decomp.plot_init_date)
my_initial_date = max(initial_date,options_.plot_shock_decomp.plot_init_date);
a = find((initial_date:initial_date+b-1)==options_.plot_shock_decomp.plot_init_date);
end
if ~isempty(options_.shock_decomp.plot_end_date)
b = find((initial_date:initial_date+b-1)==options_.shock_decomp.plot_end_date);
if ~isempty(options_.plot_shock_decomp.plot_end_date)
b = find((initial_date:initial_date+b-1)==options_.plot_shock_decomp.plot_end_date);
end
z = z(:,:,a:b);
% end crop data
options_.shock_decomp.fig_names=fig_names;
options_.plot_shock_decomp.fig_name=fig_name;
options_.plot_shock_decomp.orig_varlist = varlist;
if detail_plot,
graph_decomp_detail(z,shock_names,M_.endo_names,i_var,my_initial_date,M_,options_)
else
@ -337,5 +347,5 @@ else
end
if write_xls
WriteShockDecomp2Excel(z,shock_names,M_.endo_names,i_var,initial_date,M_,options_,options_.shock_decomp);
end
WriteShockDecomp2Excel(z,shock_names,M_.endo_names,i_var,initial_date,M_,options_,options_.plot_shock_decomp);
end

View File

@ -13,7 +13,7 @@ function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
% SPECIAL REQUIREMENTS.
% None.
% Copyright (C) 2007-2016 Dynare Team
% Copyright (C) 2007-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -64,7 +64,7 @@ end
figunumber = 0;
subplotnum = 0;
hh = dyn_figure(options_,'Name',[tit1 ' ' int2str(figunumber+1)]);
hh = dyn_figure(options_.nodisplay,'Name',[tit1 ' ' int2str(figunumber+1)]);
RemoteFlag = 0;
if whoiam,
if Parallel(ThisMatlab).Local ==0
@ -108,14 +108,14 @@ for i=fpar:nvar
end
if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
dyn_saveas(hh,[M_.dname '/Output/' M_.fname '_' name3 '_' deblank(tit3(i,:))],options_);
dyn_saveas(hh,[M_.dname '/Output/' M_.fname '_' name3 '_' deblank(tit3(i,:))],options_.nodisplay,options_.graph_format);
if RemoteFlag==1,
OutputFileName = [OutputFileName; {[M_.dname, filesep, 'Output',filesep], [M_.fname '_' name3 '_' deblank(tit3(i,:)) '.*']}];
end
subplotnum = 0;
figunumber = figunumber+1;
if (i ~= nvar)
hh = dyn_figure(options_,'Name',[name3 ' ' int2str(figunumber+1)]);
hh = dyn_figure(options_.nodisplay,'Name',[name3 ' ' int2str(figunumber+1)]);
end
end

View File

@ -105,8 +105,7 @@ end
for j=presample+1:nobs,
% evalin('base',['options_.nobs=' int2str(j) ';'])
options_.nobs=j;
clear('evaluate_smoother');
[oo, junk1, junk2, junk3, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
[oo, M_, junk2, junk3, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
% reduced form
dr = oo.dr;
@ -139,11 +138,10 @@ for j=presample+1:nobs,
epsilon=[epsilon zeros(nshocks,forecast_)];
z = zeros(endo_nbr,nshocks+2,gend+forecast_);
Smoothed_Variables_deviation_from_mean
z(:,end,1:gend) = Smoothed_Variables_deviation_from_mean;
maximum_lag = M_.maximum_lag;
lead_lag_incidence = M_.lead_lag_incidence;
k2 = dr.kstate(find(dr.kstate(:,2) <= maximum_lag+1),[1 2]);
i_state = order_var(k2(:,1))+(min(i,maximum_lag)+1-k2(:,2))*M_.endo_nbr;
@ -229,6 +227,18 @@ for j=presample+1:nobs,
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-forecast_)])(:,end,:) = ...
zreal(:,end,j-forecast_:j);
if j==nobs
for my_forecast_=(forecast_-1):-1:1,
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-my_forecast_)]) = ...
zreal(:,:,j-my_forecast_:j) - ...
oo_.realtime_forecast_shock_decomposition.(['time_' int2str(j-my_forecast_)])(:,:,1:my_forecast_+1);
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-my_forecast_)])(:,end-1,:) = ...
oo_.realtime_forecast_shock_decomposition.(['time_' int2str(j-my_forecast_)])(:,end,1:my_forecast_+1);
oo_.realtime_conditional_shock_decomposition.(['time_' int2str(j-my_forecast_)])(:,end,:) = ...
zreal(:,end,j-my_forecast_:j);
end
end
end
end
@ -248,5 +258,4 @@ if forecast_
oo_.realtime_forecast_shock_decomposition.pool = zfrcst;
end
clear('evaluate_smoother');
skipline()

View File

@ -14,7 +14,7 @@ function rplot(s1)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2001-2016 Dynare Team
% Copyright (C) 2001-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -81,7 +81,7 @@ if rplottype == 0
for j = 1:size(y,1)
t = [t s1(j,:) ' '] ;
end
hh=dyn_figure(options_,'Name',['Simulated Trajectory']);
hh=dyn_figure(options_.nodisplay,'Name',['Simulated Trajectory']);
plot(ix(i),y(:,i)) ;
title (t,'Interpreter','none') ;
xlabel('Periods') ;
@ -94,24 +94,24 @@ if rplottype == 0
set(h, 'Interpreter', 'none');
end
end
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(1,:))],options_)
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(1,:))],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,options_,[M_.fname, '/graphs/', 'SimulatedTrajectory_' deblank(s1(1,:))],'Simulated trajectories','SimulatedTrajectory_',deblank(s1(1,:)),1)
end
elseif rplottype == 1
for j = 1:size(y,1)
hh=dyn_figure(options_,'Name',['Simulated Trajectory']);
hh=dyn_figure(options_.nodisplay,'Name',['Simulated Trajectory']);
plot(ix(i),y(j,i)) ;
xlim([min(ix(i)) max(ix(i))])
title(['Plot of ' s1(j,:)],'Interpreter','none') ;
xlabel('Periods') ;
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(j,:))],options_)
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(j,:))],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,options_,[M_.fname, '/graphs/', 'SimulatedTrajectory_' deblank(s1(j,:))],'Simulated trajectories','SimulatedTrajectory_',deblank(s1(j,:)),1);
end
end
elseif rplottype == 2
hh=dyn_figure(options_,'Name',['Simulated Trajectory']);
hh=dyn_figure(options_.nodisplay,'Name',['Simulated Trajectory']);
nl = max(1,fix(size(y,1)/4)) ;
nc = ceil(size(y,1)/nl) ;
for j = 1:size(y,1)
@ -128,7 +128,7 @@ elseif rplottype == 2
title(['Plot of ' s1(j,:)],'Interpreter','none') ;
axis tight;
end
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(1,:))],options_)
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'SimulatedTrajectory_' deblank(s1(1,:))],options_.nodisplay,options_.graph_format)
if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format)))
create_TeX_loader(fidTeX,options_,[M_.fname, '/graphs/', 'SimulatedTrajectory_' deblank(s1(1,:))],'Simulated trajectories','SimulatedTrajectory_',deblank(s1(1,:)),min(j/nc,1));
end

View File

@ -100,6 +100,8 @@ SampleAddress = sortrows(SampleAddress,[3 2]);
% Selected draws in the posterior distribution, and if drsize>0
% reduced form solutions, are saved on disk.
if info
%delete old stale files before creating new ones
delete_stale_file([BaseName '_posterior_draws*.mat'])
if SampleSize*drawsize <= MAX_mega_bytes% The posterior draws are saved in one file.
pdraws = cell(SampleSize,info);
old_mhfile = 0;

View File

@ -36,21 +36,40 @@ function options_=select_qz_criterium_value(options_)
% set by default options_.qz_criterium to 1+1e-6
stack = dbstack;
if isequal(options_.lik_init,1)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1-1e-6;
elseif options_.qz_criterium > 1-eps
error([stack(2).file ': option qz_criterium is too large for estimating/smoothing ' ...
'a stationary model. If your model contains unit roots, use ' ...
'option diffuse_filter'])
end
else
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
else
if options_.qz_criterium <= 1
fprintf('\n%s:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n',stack(2).file)
if options_.particle.status
% Non linear filter
if isequal(options_.particle.initialization, 3)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
else
if options_.qz_criterium <= 1
fprintf('\n%s:: You set nonlinear_filter_initialization equal to 3, it is assumed that you try to estimate a non stationary model. Resetting it to 1+1e-6.\n', stack(2).file)
options_.qz_criterium = 1+1e-6;
end
end
else
if isempty(options_.qz_criterium)
options_.qz_criterium = 1-1e-6;
end
end
end
else
% Linear filter
if isequal(options_.lik_init,1)
if isempty(options_.qz_criterium)
options_.qz_criterium = 1-1e-6;
elseif options_.qz_criterium > 1-eps
error([stack(2).file ': option qz_criterium is too large for estimating/smoothing ' ...
'a stationary model. If your model contains unit roots, use ' ...
'option diffuse_filter'])
end
else
if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6;
else
if options_.qz_criterium <= 1
fprintf('\n%s:: diffuse filter is incompatible with a qz_criterium<=1. Resetting it to 1+1e-6.\n',stack(2).file)
options_.qz_criterium = 1+1e-6;
end
end
end
end

View File

@ -0,0 +1,37 @@
function options = set_default_initial_condition_decomposition_options(options)
%function options = set_default_initial_condition_decomposition_options(options)
% sets the default options for prior_shock_decomposition
%
% INPUTS
% options
%
% OUTPUTS
% options
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options.initial_condition_decomp.detail_plot = 0;
options.initial_condition_decomp.steadystate = 0;
options.initial_condition_decomp.write_xls = 0;
options.initial_condition_decomp.type = '';
options.initial_condition_decomp.plot_init_date = [];
options.initial_condition_decomp.plot_end_date = [];
end

View File

@ -0,0 +1,51 @@
function options = set_default_plot_shock_decomposition_options(options)
%function options = set_default_plot_shock_decomposition_options(options)
% sets the default options for prior_shock_decomposition
%
% INPUTS
% options
%
% OUTPUTS
% options
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options.plot_shock_decomp.use_shock_groups = '';
options.plot_shock_decomp.colormap = '';
options.plot_shock_decomp.nodisplay = 0;
options.plot_shock_decomp.graph_format = 'eps';
options.plot_shock_decomp.detail_plot = 0;
options.plot_shock_decomp.interactive = 0;
options.plot_shock_decomp.screen_shocks = 0;
options.plot_shock_decomp.steadystate = 0;
options.plot_shock_decomp.type = '';
options.plot_shock_decomp.fig_name = '';
options.plot_shock_decomp.write_xls = 0;
options.plot_shock_decomp.realtime = 0; % 0 is standard; 1 is realtime
% (pool/vintage); 2 is conditional
% (pool/vintage); 3 is forecast
% (pool/vintage)
options.plot_shock_decomp.vintage = 0; % 0 pool realtime/conditional; int:
% forecast/conditional shock
% decompositions
options.plot_shock_decomp.plot_init_date = [];
options.plot_shock_decomp.plot_end_date = [];
end

View File

@ -1,6 +1,6 @@
function info=stoch_simul(var_list)
% Copyright (C) 2001-2016 Dynare Team
% Copyright (C) 2001-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -253,10 +253,10 @@ if options_.irf
if nbplt == 0
elseif nbplt == 1
if options_.relative_irf
hh = dyn_figure(options_,'Name',['Relative response to' ...
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to' ...
' orthogonalized shock to ' tit(i,:)]);
else
hh = dyn_figure(options_,'Name',['Orthogonalized shock to' ...
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to' ...
' ' tit(i,:)]);
end
for j = 1:number_of_plots_to_draw
@ -269,7 +269,7 @@ if options_.irf
remove_fractional_xticks;
title(deblank(mylist(j,:)),'Interpreter','none');
end
dyn_saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:))],options_);
dyn_saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:))],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:number_of_plots_to_draw
@ -285,10 +285,10 @@ if options_.irf
else
for fig = 1:nbplt-1
if options_.relative_irf
hh = dyn_figure(options_,'Name',['Relative response to orthogonalized shock' ...
hh = dyn_figure(options_.nodisplay,'Name',['Relative response to orthogonalized shock' ...
' to ' tit(i,:) ' figure ' int2str(fig)]);
else
hh = dyn_figure(options_,'Name',['Orthogonalized shock to ' tit(i,:) ...
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:) ...
' figure ' int2str(fig)]);
end
for plt = 1:nstar
@ -301,7 +301,7 @@ if options_.irf
remove_fractional_xticks
title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter','none');
end
dyn_saveas(hh,[ M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)],options_);
dyn_saveas(hh,[ M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:nstar
@ -321,7 +321,7 @@ if options_.irf
fprintf(fidTeX,' \n');
end
end
hh = dyn_figure(options_,'Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
hh = dyn_figure(options_.nodisplay,'Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
m = 0;
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
m = m+1;
@ -334,7 +334,7 @@ if options_.irf
remove_fractional_xticks
title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter','none');
end
dyn_saveas(hh,[ M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt) ],options_);
dyn_saveas(hh,[ M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt) ],options_.nodisplay,options_.graph_format);
if TeX && any(strcmp('eps',cellstr(options_.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
for j = 1:m

View File

@ -18,7 +18,7 @@ function trace_plot(options_,M_,estim_params_,type,blck,name1,name2)
%
% SPECIAL REQUIREMENTS
% Copyright (C) 2003-2016 Dynare Team
% Copyright (C) 2003-2017 Dynare Team
%
% This file is part of Dynare.
%
@ -95,7 +95,7 @@ if options_.mh_nblck>1
FigureName = [ FigureName , ' (block number ' int2str(blck) ').'];
end
hh=dyn_figure(options_,'Name',FigureName);
hh=dyn_figure(options_.nodisplay,'Name',FigureName);
plot(1:TotalNumberOfMhDraws,PosteriorDraws,'Color',[.7 .7 .7]);
@ -131,7 +131,7 @@ else
end
plot_name=[plot_name,'_blck_',num2str(blck)];
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'TracePlot_' plot_name],options_)
dyn_saveas(hh,[M_.fname, filesep, 'graphs', filesep, 'TracePlot_' plot_name],options_.nodisplay,options_.graph_format)
if options_.TeX
fid=fopen([M_.fname,'/graphs/',M_.fname,'_TracePlot_' plot_name,'.tex'],'w+');

View File

@ -24,8 +24,20 @@
#include <iostream>
#include <sstream>
#include <map>
#include <stack>
#define BYTE_CODE
#include "CodeInterpreter.hh"
#define _USE_MATH_DEFINES
#include <math.h>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif
#ifdef DEBUG_EX
# include <math.h>
# include "mex_interface.hh"
@ -37,15 +49,6 @@
# define CHAR_LENGTH 2
#endif
//Work around for: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
#ifndef __builtin_isnan
# define isnan(x) std::isnan(x)
#endif
#ifndef __builtin_isinf
# define isinf(x) std::isinf(x)
#endif
#ifdef _MSC_VER
#include <limits>
#define M_E 2.71828182845904523536
@ -250,7 +253,7 @@ public:
value2(value2_arg)
{
ostringstream tmp;
if (abs(value1) > 1e-10 )
if (fabs(value1) > 1e-10 )
tmp << " with X=" << value1 << "\n";
else
tmp << " with X=" << value1 << " and a=" << value2 << "\n";
@ -2231,6 +2234,17 @@ public:
it_code_ret = it_code;
return (tmp_out.str());
}
void
inline test_mxMalloc(void* z, int line, string file, string func, int amount)
{
if (!z && (amount > 0))
{
ostringstream tmp;
tmp << " mxMalloc: out of memory " << amount << " bytes required at line " << line << " in function " << func << " (file " << file;
throw FatalExceptionHandling(tmp.str());
}
}
};

View File

@ -140,7 +140,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
if ( utIsInterruptPending() )
throw UserExceptionHandling();
#endif
while (go_on)
{
#ifdef DEBUG
@ -1172,6 +1172,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
case ExternalFunctionWithFirstandSecondDerivative:
{
input_arguments = (mxArray **) mxMalloc(nb_input_arguments * sizeof(mxArray *));
test_mxMalloc(input_arguments, __LINE__, __FILE__, __func__, nb_input_arguments * sizeof(mxArray *));
#ifdef DEBUG
mexPrintf("Stack.size()=%d\n", Stack.size());
mexEvalString("drawnow;");
@ -1188,7 +1189,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
tmp << " external function: " << function_name << " not found";
throw FatalExceptionHandling(tmp.str());
}
double *rr = mxGetPr(output_arguments[0]);
Stack.push(*rr);
if (function_type == ExternalFunctionWithFirstDerivative || function_type == ExternalFunctionWithFirstandSecondDerivative)
@ -1215,6 +1216,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
case ExternalFunctionNumericalFirstDerivative:
{
input_arguments = (mxArray **) mxMalloc((nb_input_arguments+1+nb_add_input_arguments) * sizeof(mxArray *));
test_mxMalloc(input_arguments, __LINE__, __FILE__, __func__, (nb_input_arguments+1+nb_add_input_arguments) * sizeof(mxArray *));
mxArray *vv = mxCreateString(arg_func_name.c_str());
input_arguments[0] = vv;
vv = mxCreateDoubleScalar(fc->get_row());
@ -1254,6 +1256,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
case ExternalFunctionFirstDerivative:
{
input_arguments = (mxArray **) mxMalloc(nb_input_arguments * sizeof(mxArray *));
test_mxMalloc(input_arguments, __LINE__, __FILE__, __func__, nb_input_arguments * sizeof(mxArray *));
for (unsigned int i = 0; i < nb_input_arguments; i++)
{
mxArray *vv = mxCreateDoubleScalar(Stack.top());
@ -1277,6 +1280,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
case ExternalFunctionNumericalSecondDerivative:
{
input_arguments = (mxArray **) mxMalloc((nb_input_arguments+1+nb_add_input_arguments) * sizeof(mxArray *));
test_mxMalloc(input_arguments, __LINE__, __FILE__, __func__, (nb_input_arguments+1+nb_add_input_arguments) * sizeof(mxArray *));
mxArray *vv = mxCreateString(arg_func_name.c_str());
input_arguments[0] = vv;
vv = mxCreateDoubleScalar(fc->get_row());
@ -1315,6 +1319,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int
case ExternalFunctionSecondDerivative:
{
input_arguments = (mxArray **) mxMalloc(nb_input_arguments * sizeof(mxArray *));
test_mxMalloc(input_arguments, __LINE__, __FILE__, __func__, nb_input_arguments * sizeof(mxArray *));
for (unsigned int i = 0; i < nb_input_arguments; i++)
{
mxArray *vv = mxCreateDoubleScalar(Stack.top());
@ -1583,7 +1588,9 @@ void
Evaluate::solve_simple_over_periods(const bool forward)
{
g1 = (double *) mxMalloc(sizeof(double));
test_mxMalloc(g1, __LINE__, __FILE__, __func__, sizeof(double));
r = (double *) mxMalloc(sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, sizeof(double));
start_code = it_code;
if (steady_state)
{

View File

@ -63,13 +63,13 @@ protected:
double solve_tolf;
bool GaussSeidel;
map<pair<pair<int, int>, int>, int> IM_i;
int equation, derivative_equation, derivative_variable;
int equation, derivative_equation, derivative_variable;
string filename;
int stack_solve_algo, solve_algo;
bool global_temporary_terms;
bool print, print_error;
double res1, res2, max_res;
int max_res_idx;
int max_res_idx;
vector<Block_contain_type> Block_Contain;
int size;

View File

@ -77,7 +77,7 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub
GlobalTemporaryTerms = GlobalTemporaryTerms_arg;
print_error = print_error_arg;
//steady_state = steady_state_arg;
print_it = print_it_arg;
print_it = print_it_arg;
}
@ -117,8 +117,10 @@ Interpreter::evaluate_a_block(bool initialization)
}
break;
case SOLVE_FORWARD_SIMPLE:
g1 = (double *) mxMalloc(size*size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
g1 = (double *) mxMalloc(size*size*sizeof(double));
test_mxMalloc(g1, __LINE__, __FILE__, __func__, size*size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
if (steady_state)
{
compute_block_time(0, true, /*block_num, size, steady_state,*/ false);
@ -144,8 +146,8 @@ Interpreter::evaluate_a_block(bool initialization)
for (int j = 0; j < size; j++)
residual[it_*size+j] = r[j];
}
}
mxFree(g1);
}
mxFree(g1);
mxFree(r);
break;
case SOLVE_FORWARD_COMPLETE:
@ -157,7 +159,8 @@ Interpreter::evaluate_a_block(bool initialization)
#ifdef DEBUG
mexPrintf("in SOLVE_FORWARD_COMPLETE r = mxMalloc(%d*sizeof(double))\n", size);
#endif
r = (double *) mxMalloc(size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
if (steady_state)
{
compute_block_time(0, true, /*block_num, size, steady_state,*/ false);
@ -215,8 +218,10 @@ Interpreter::evaluate_a_block(bool initialization)
}
break;
case SOLVE_BACKWARD_SIMPLE:
g1 = (double *) mxMalloc(size*size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
g1 = (double *) mxMalloc(size*size*sizeof(double));
test_mxMalloc(g1, __LINE__, __FILE__, __func__, size*size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
if (steady_state)
{
compute_block_time(0, true, /*block_num, size, steady_state,*/ false);
@ -252,7 +257,8 @@ Interpreter::evaluate_a_block(bool initialization)
fixe_u(&u, u_count_int, u_count_int);
Read_SparseMatrix(bin_base_name, size, 1, 0, 0, false, stack_solve_algo, solve_algo);
}
r = (double *) mxMalloc(size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
if (steady_state)
{
compute_block_time(0, true, /*block_num, size, steady_state,*/ false);
@ -289,7 +295,8 @@ Interpreter::evaluate_a_block(bool initialization)
Read_SparseMatrix(bin_base_name, size, periods, y_kmin, y_kmax, true, stack_solve_algo, solve_algo);
}
u_count = u_count_int*(periods+y_kmax+y_kmin);
r = (double *) mxMalloc(size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
begining = it_code;
for (it_ = y_kmin; it_ < periods+y_kmin; it_++)
{
@ -430,9 +437,12 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c
Read_SparseMatrix(bin_base_name, size, periods, y_kmin, y_kmax, true, stack_solve_algo, solve_algo);
}
u_count = u_count_int*(periods+y_kmax+y_kmin);
r = (double *) mxMalloc(size*sizeof(double));
res = (double *) mxMalloc(size*periods*sizeof(double));
y_save = (double *) mxMalloc(y_size*sizeof(double)*(periods+y_kmax+y_kmin));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
res = (double *) mxMalloc(size*periods*sizeof(double));
test_mxMalloc(res, __LINE__, __FILE__, __func__, size*periods*sizeof(double));
y_save = (double *) mxMalloc(y_size*sizeof(double)*(periods+y_kmax+y_kmin));
test_mxMalloc(y_save, __LINE__, __FILE__, __func__, y_size*sizeof(double)*(periods+y_kmax+y_kmin));
start_code = it_code;
iter = 0;
if (!is_linear)
@ -457,7 +467,7 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c
//mexPrintf("y[%d] = %f\n", it1->var_endo + y_kmin * size, y[it1->var_endo + y_kmin * size]);
y[it1->var_endo + y_kmin * size] = it1->constrained_value;
}
}
}
compute_complete_2b(false, &res1, &res2, &max_res, &max_res_idx);
@ -498,13 +508,19 @@ Interpreter::simulate_a_block(vector_table_conditional_local_type vector_table_c
Simulate_Newton_Two_Boundaries(block_num, symbol_table_endo_nbr, y_kmin, y_kmax, size, periods, cvg, minimal_solving_periods, stack_solve_algo, endo_name_length, P_endo_names, vector_table_conditional_local);
max_res = 0; max_res_idx = 0;
}
it_code = end_code;
mxFree(r);
mxFree(y_save);
mxFree(u);
mxFree(index_vara);
mxFree(index_equa);
mxFree(res);
it_code = end_code;
if (r)
mxFree(r);
if (y_save)
mxFree(y_save);
if (u)
mxFree(u);
if (index_vara)
mxFree(index_vara);
if (index_equa)
mxFree(index_equa);
if (res)
mxFree(res);
memset(direction, 0, size_of_direction);
End_Solver();
break;
@ -558,14 +574,14 @@ Interpreter::print_a_block()
}
}
void
void
Interpreter::ReadCodeFile(string file_name, CodeLoad &code)
{
if (steady_state)
file_name += "_static";
else
file_name += "_dynamic";
//First read and store in memory the code
code_liste = code.get_op_code(file_name);
EQN_block_number = code.get_block_number();
@ -653,9 +669,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
Block_Contain = fb->get_Block_Contain();
it_code++;
if (constrained)
{
check_for_controlled_exo_validity(fb,sconstrained_extended_path);
}
check_for_controlled_exo_validity(fb,sconstrained_extended_path);
set_block(fb->get_size(), fb->get_type(), file_name, bin_basename, Block_Count, fb->get_is_linear(), fb->get_endo_nbr(), fb->get_Max_Lag(), fb->get_Max_Lead(), fb->get_u_count_int(), block);
if (print)
print_a_block();
@ -690,7 +704,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
#ifdef DEBUG
mexPrintf("endo in Block_Count=%d, block=%d, type=%d, steady_state=%d, print_it=%d, Block_Count=%d, fb->get_is_linear()=%d, fb->get_endo_nbr()=%d, fb->get_Max_Lag()=%d, fb->get_Max_Lead()=%d, fb->get_u_count_int()=%d\n",
Block_Count, fb->get_size(), fb->get_type(), steady_state, print_it, Block_Count, fb->get_is_linear(), fb->get_endo_nbr(), fb->get_Max_Lag(), fb->get_Max_Lead(), fb->get_u_count_int());
#endif
#endif
bool result;
if (sconstrained_extended_path.size())
{
@ -702,7 +716,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
jacobian_other_endo_block.push_back(mxCreateDoubleMatrix(fb->get_size(), fb->get_nb_col_other_endo_jacob(), mxREAL));
residual = vector<double>(fb->get_size()*(periods+y_kmin));
result = simulate_a_block(vector_table_conditional_local);
mxDestroyArray(jacobian_block.back());
jacobian_block.pop_back();
mxDestroyArray(jacobian_exo_block.back());
@ -713,10 +727,7 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
jacobian_other_endo_block.pop_back();
}
else
{
result = simulate_a_block(vector_table_conditional_local);
}
result = simulate_a_block(vector_table_conditional_local);
//mexPrintf("OKe\n");
if (max_res > max_res_local)
{
@ -749,8 +760,9 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
#endif
var = ((FDIMT_ *) it_code->second)->get_size();
if (T)
mxFree(T);
T = (double *) mxMalloc(var*(periods+y_kmin+y_kmax)*sizeof(double));
mxFree(T);
T = (double *) mxMalloc(var*(periods+y_kmin+y_kmax)*sizeof(double));
test_mxMalloc(T, __LINE__, __FILE__, __func__, var*(periods+y_kmin+y_kmax)*sizeof(double));
if (block >= 0)
{
it_code = code_liste.begin() + code.get_begin_block(block);
@ -775,8 +787,12 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
GlobalTemporaryTerms = mxCreateDoubleMatrix(var, 1, mxREAL);
T = mxGetPr(GlobalTemporaryTerms);
}
else
T = (double *) mxMalloc(var*sizeof(double));
else
{
T = (double *) mxMalloc(var*sizeof(double));
test_mxMalloc(T, __LINE__, __FILE__, __func__, var*sizeof(double));
}
if (block >= 0)
it_code = code_liste.begin() + code.get_begin_block(block);
@ -842,9 +858,18 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate,
ReadCodeFile(file_name, code);
it_code = code_liste.begin();
it_code_type Init_Code = code_liste.begin();
size_t size_of_direction = y_size*(periods + y_kmax + y_kmin)*sizeof(double);
/*size_t size_of_direction = y_size*(periods + y_kmax + y_kmin)*sizeof(double);
double *y_save = (double *) mxMalloc(size_of_direction);
double *x_save = (double *) mxMalloc((periods + y_kmax + y_kmin) * col_x *sizeof(double));
double *x_save = (double *) mxMalloc((periods + y_kmax + y_kmin) * col_x *sizeof(double));*/
int max_periods = max(periods, nb_periods);
size_t size_of_direction = y_size*(max_periods + y_kmax + y_kmin)*sizeof(double);
double *y_save = (double *) mxMalloc(size_of_direction);
test_mxMalloc(y_save, __LINE__, __FILE__, __func__, size_of_direction);
double *x_save = (double *) mxMalloc((max_periods + y_kmax + y_kmin) * col_x *sizeof(double));
test_mxMalloc(x_save, __LINE__, __FILE__, __func__, (max_periods + y_kmax + y_kmin) * col_x *sizeof(double));
vector_table_conditional_local_type vector_table_conditional_local;
vector_table_conditional_local.clear();
@ -896,7 +921,7 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate,
vector_table_conditional_local = table_conditional_global[t];
if (t < nb_periods)
MainLoop(bin_basename, code, evaluate, block, false, true, sconstrained_extended_path, vector_table_conditional_local);
else
else
MainLoop(bin_basename, code, evaluate, block, true, true, sconstrained_extended_path, vector_table_conditional_local);
for (int j = 0; j < y_size; j++)
{
@ -909,7 +934,7 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate,
x_save[t + y_kmin + j * nb_row_x] = x[y_kmin + j * nb_row_x];
x[y_kmin + j * nb_row_x] = x_save[t + 1 + y_kmin + j * nb_row_x];
}
if (old_print_it)
{
ostringstream res, res1;
@ -921,21 +946,23 @@ Interpreter::extended_path(string file_name, string bin_basename, bool evaluate,
mexPrintf(line.c_str());
mexEvalString("drawnow;");
}
}
}
print_it = old_print_it;
for (int j = 0; j < y_size; j++)
{
for(int k = nb_periods; k < periods; k++)
y_save[j + (k + y_kmin) * y_size] = y[ j + ( k - (nb_periods-1) + y_kmin) * y_size];
}
}
for (int i = 0; i < (y_size*(periods + y_kmax + y_kmin)); i++)
y[i] = y_save[i];
y[i] = y_save[i];
for (int j = 0; j < col_x* nb_row_x; j++)
x[j] = x_save[j];
mxFree(Init_Code->second);
mxFree(y_save);
mxFree(x_save);
if (Init_Code->second)
mxFree(Init_Code->second);
if (y_save)
mxFree(y_save);
if (x_save)
mxFree(x_save);
nb_blocks = Block_Count+1;
if (T && !global_temporary_terms)
mxFree(T);
@ -947,7 +974,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool evaluate
{
CodeLoad code;
ReadCodeFile(file_name, code);
//The big loop on intructions
it_code = code_liste.begin();
it_code_type Init_Code = it_code;
@ -955,8 +982,8 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool evaluate
vector_table_conditional_local_type vector_table_conditional_local_junk;
MainLoop(bin_basename, code, evaluate, block, true, false, s_plan_junk, vector_table_conditional_local_junk);
mxFree(Init_Code->second);
nb_blocks = Block_Count+1;
if (T && !global_temporary_terms)

View File

@ -27,7 +27,7 @@
#define BYTE_CODE
#include "CodeInterpreter.hh"
#include "SparseMatrix.hh"
#include "Evaluate.hh"
#include "Evaluate.hh"
#ifdef LINBCG
# include "linbcg.hh"
#endif

View File

@ -24,7 +24,7 @@ Mem_Mngr::Mem_Mngr()
swp_f = false;
swp_f_b = 0;
}
void
/*void
Mem_Mngr::Print_heap()
{
unsigned int i;
@ -32,7 +32,8 @@ Mem_Mngr::Print_heap()
for (i = 0; i < CHUNK_SIZE; i++)
mexPrintf("%3d ", i);
mexPrintf("\n");
}
}
*/
void
Mem_Mngr::init_Mem()
@ -49,7 +50,7 @@ Mem_Mngr::init_Mem()
void
Mem_Mngr::fixe_file_name(string filename_arg)
{
filename = filename_arg;
filename_mem = filename_arg;
}
void
@ -77,26 +78,26 @@ Mem_Mngr::mxMalloc_NZE()
{
CHUNK_SIZE += CHUNK_BLCK_SIZE;
Nb_CHUNK++;
NZE_Mem = (NonZeroElem *) mxMalloc(CHUNK_BLCK_SIZE*sizeof(NonZeroElem)); /*The block of memory allocated*/
NZE_Mem = (NonZeroElem *) mxMalloc(CHUNK_BLCK_SIZE*sizeof(NonZeroElem)); /*The block of memory allocated*/
error_msg.test_mxMalloc(NZE_Mem, __LINE__, __FILE__, __func__, CHUNK_BLCK_SIZE*sizeof(NonZeroElem));
NZE_Mem_Allocated.push_back(NZE_Mem);
if (!NZE_Mem)
{
mexPrintf("Not enough memory available\n");
mexEvalString("drawnow;");
mexPrintf("Not enough memory available\n");
if (NZE_Mem_add)
{
NZE_Mem_add = (NonZeroElem **) mxRealloc(NZE_Mem_add, CHUNK_SIZE*sizeof(NonZeroElem *)); /*We have to redefine the size of pointer on the memory*/
error_msg.test_mxMalloc(NZE_Mem_add , __LINE__, __FILE__, __func__, CHUNK_SIZE*sizeof(NonZeroElem *));
}
if (NZE_Mem_add)
NZE_Mem_add = (NonZeroElem **) mxRealloc(NZE_Mem_add, CHUNK_SIZE*sizeof(NonZeroElem *)); /*We have to redefine the size of pointer on the memory*/
else
NZE_Mem_add = (NonZeroElem **) mxMalloc(CHUNK_SIZE*sizeof(NonZeroElem *)); /*We have to define the size of pointer on the memory*/
else
{
NZE_Mem_add = (NonZeroElem **) mxMalloc(CHUNK_SIZE*sizeof(NonZeroElem *)); /*We have to define the size of pointer on the memory*/
error_msg.test_mxMalloc(NZE_Mem_add , __LINE__, __FILE__, __func__, CHUNK_SIZE*sizeof(NonZeroElem *));
}
if (!NZE_Mem_add)
{
mexPrintf("Not enough memory available\n");
mexEvalString("drawnow;");
}
mexPrintf("Not enough memory available\n");
for (i = CHUNK_heap_pos; i < CHUNK_SIZE; i++)
{
NZE_Mem_add[i] = (NonZeroElem *) (NZE_Mem+(i-CHUNK_heap_pos));
}
NZE_Mem_add[i] = (NonZeroElem *) (NZE_Mem+(i-CHUNK_heap_pos));
i = CHUNK_heap_pos++;
return (NZE_Mem_add[i]);
}

View File

@ -19,15 +19,16 @@
#ifndef MEM_MNGR_HH_INCLUDED
#define MEM_MNGR_HH_INCLUDED
#include "ErrorHandling.hh"
#include <vector>
#include <fstream>
#ifndef DEBUG_EX
# include <dynmex.h>
#else
# include "mex_interface.hh"
#endif
using namespace std;
#endif
//using namespace std;
struct NonZeroElem
{
@ -41,7 +42,7 @@ typedef vector<NonZeroElem *> v_NonZeroElem;
class Mem_Mngr
{
public:
void Print_heap();
//void Print_heap();
void init_Mem();
void mxFree_NZE(void *pos);
NonZeroElem *mxMalloc_NZE();
@ -49,7 +50,8 @@ public:
void Free_All();
Mem_Mngr();
void fixe_file_name(string filename_arg);
bool swp_f;
bool swp_f;
ErrorMsg error_msg;
private:
v_NonZeroElem Chunk_Stack;
unsigned int CHUNK_SIZE, CHUNK_BLCK_SIZE, Nb_CHUNK;
@ -59,7 +61,7 @@ private:
vector<NonZeroElem *> NZE_Mem_Allocated;
int swp_f_b;
fstream SaveCode_swp;
string filename;
string filename_mem;
};
#endif

View File

@ -183,7 +183,7 @@ dynSparseMatrix::dynSparseMatrix()
}
dynSparseMatrix::dynSparseMatrix(const int y_size_arg, const int y_kmin_arg, const int y_kmax_arg, const bool print_it_arg, const bool steady_state_arg, const int periods_arg,
const int minimal_solving_periods_arg, const double slowc_arg
const int minimal_solving_periods_arg, const double slowc_arg
#ifdef CUDA
, const int CUDA_device_arg, cublasHandle_t cublas_handle_arg, cusparseHandle_t cusparse_handle_arg, cusparseMatDescr_t descr_arg
#endif
@ -206,7 +206,7 @@ dynSparseMatrix::dynSparseMatrix(const int y_size_arg, const int y_kmin_arg, con
IM_i.clear();
lu_inc_tol = 1e-10;
Symbolic = NULL;
Numeric = NULL;
Numeric = NULL;
#ifdef CUDA
CUDA_device = CUDA_device_arg;
cublas_handle = cublas_handle_arg;
@ -621,7 +621,8 @@ dynSparseMatrix::Read_SparseMatrix(string file_name, const int Size, int periods
}
}
}
index_vara = (int *) mxMalloc(Size*(periods+y_kmin+y_kmax)*sizeof(int));
index_vara = (int *) mxMalloc(Size*(periods+y_kmin+y_kmax)*sizeof(int));
test_mxMalloc(index_vara, __LINE__, __FILE__, __func__, Size*(periods+y_kmin+y_kmax)*sizeof(int));
for (int j = 0; j < Size; j++)
SaveCode.read(reinterpret_cast<char *>(&index_vara[j]), sizeof(*index_vara));
if (periods+y_kmin+y_kmax > 1)
@ -630,7 +631,8 @@ dynSparseMatrix::Read_SparseMatrix(string file_name, const int Size, int periods
for (int j = 0; j < Size; j++)
index_vara[j+Size*i] = index_vara[j+Size*(i-1)] + y_size;
}
index_equa = (int *) mxMalloc(Size*sizeof(int));
index_equa = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(index_equa, __LINE__, __FILE__, __func__, Size*sizeof(int));
for (int j = 0; j < Size; j++)
SaveCode.read(reinterpret_cast<char *>(&index_equa[j]), sizeof(*index_equa));
}
@ -641,25 +643,38 @@ dynSparseMatrix::Simple_Init(int Size, map<pair<pair<int, int>, int>, int> &IM,
int i, eq, var, lag;
map<pair<pair<int, int>, int>, int>::iterator it4;
NonZeroElem *first;
pivot = (int *) mxMalloc(Size*sizeof(int));
pivot_save = (int *) mxMalloc(Size*sizeof(int));
pivotk = (int *) mxMalloc(Size*sizeof(int));
pivotv = (double *) mxMalloc(Size*sizeof(double));
pivotva = (double *) mxMalloc(Size*sizeof(double));
b = (int *) mxMalloc(Size*sizeof(int));
pivot = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivot, __LINE__, __FILE__, __func__, Size*sizeof(int));
pivot_save = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivot_save, __LINE__, __FILE__, __func__, Size*sizeof(int));
pivotk = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivotk, __LINE__, __FILE__, __func__, Size*sizeof(int));
pivotv = (double *) mxMalloc(Size*sizeof(double));
test_mxMalloc(pivotv, __LINE__, __FILE__, __func__, Size*sizeof(double));
pivotva = (double *) mxMalloc(Size*sizeof(double));
test_mxMalloc(pivotva, __LINE__, __FILE__, __func__, Size*sizeof(double));
b = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(b, __LINE__, __FILE__, __func__, Size*sizeof(int));
line_done = (bool *) mxMalloc(Size*sizeof(bool));
test_mxMalloc(line_done, __LINE__, __FILE__, __func__, Size*sizeof(bool));
mem_mngr.init_CHUNK_BLCK_SIZE(u_count);
g_save_op = NULL;
g_nop_all = 0;
i = Size*sizeof(NonZeroElem *);
FNZE_R = (NonZeroElem **) mxMalloc(i);
FNZE_C = (NonZeroElem **) mxMalloc(i);
NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i);
NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i);
FNZE_R = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(FNZE_R, __LINE__, __FILE__, __func__, i);
FNZE_C = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i);
NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(*temp_NZE_R, __LINE__, __FILE__, __func__, i);
NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(*temp_NZE_C, __LINE__, __FILE__, __func__, i);
i = Size*sizeof(int);
NbNZRow = (int *) mxMalloc(i);
NbNZCol = (int *) mxMalloc(i);
NbNZRow = (int *) mxMalloc(i);
test_mxMalloc(NbNZRow, __LINE__, __FILE__, __func__, i);
NbNZCol = (int *) mxMalloc(i);
test_mxMalloc(NbNZCol, __LINE__, __FILE__, __func__, i);
it4 = IM.begin();
eq = -1;
for (i = 0; i < Size; i++)
@ -838,7 +853,8 @@ void
dynSparseMatrix::Init_UMFPACK_Sparse_Simple(int Size, map<pair<pair<int, int>, int>, int> &IM, SuiteSparse_long **Ap, SuiteSparse_long **Ai, double **Ax, double **b, bool &zero_solution, mxArray *x0_m)
{
int eq, var;
*b = (double*)mxMalloc(Size * sizeof(double));
*b = (double*)mxMalloc(Size * sizeof(double));
test_mxMalloc(*b, __LINE__, __FILE__, __func__, Size * sizeof(double));
if (!(*b))
{
ostringstream tmp;
@ -852,7 +868,8 @@ dynSparseMatrix::Init_UMFPACK_Sparse_Simple(int Size, map<pair<pair<int, int>, i
tmp << " in Init_UMFPACK_Sparse_Simple, can't retrieve x0 vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ap = (SuiteSparse_long*)mxMalloc((Size+1) * sizeof(SuiteSparse_long));
*Ap = (SuiteSparse_long*)mxMalloc((Size+1) * sizeof(SuiteSparse_long));
test_mxMalloc(*Ap, __LINE__, __FILE__, __func__, (Size+1) * sizeof(SuiteSparse_long));
if (!(*Ap))
{
ostringstream tmp;
@ -860,14 +877,16 @@ dynSparseMatrix::Init_UMFPACK_Sparse_Simple(int Size, map<pair<pair<int, int>, i
throw FatalExceptionHandling(tmp.str());
}
size_t prior_nz = IM.size();
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
test_mxMalloc(*Ai, __LINE__, __FILE__, __func__, prior_nz * sizeof(SuiteSparse_long));
if (!(*Ai))
{
ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, can't allocate Ai index vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
test_mxMalloc(*Ax, __LINE__, __FILE__, __func__, prior_nz * sizeof(double));
if (!(*Ax))
{
ostringstream tmp;
@ -985,12 +1004,12 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
{
int t, eq, var, lag, ti_y_kmin, ti_y_kmax;
double* jacob_exo ;
int row_x;
int row_x = 0;
#ifdef DEBUG
int col_x;
#endif
#endif
int n = periods * Size;
*b = (double*)mxMalloc(n * sizeof(double));
*b = (double*)mxMalloc(n * sizeof(double));
if (!(*b))
{
ostringstream tmp;
@ -1004,22 +1023,25 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
tmp << " in Init_UMFPACK_Sparse_Simple, can't retrieve x0 vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ap = (SuiteSparse_long*)mxMalloc((n+1) * sizeof(SuiteSparse_long));
*Ap = (SuiteSparse_long*)mxMalloc((n+1) * sizeof(SuiteSparse_long));
test_mxMalloc(*Ap, __LINE__, __FILE__, __func__, (n+1) * sizeof(SuiteSparse_long));
if (!(*Ap))
{
ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, can't allocate Ap index vector\n";
throw FatalExceptionHandling(tmp.str());
}
}
size_t prior_nz = IM.size() * periods;
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
test_mxMalloc(*Ai, __LINE__, __FILE__, __func__, prior_nz * sizeof(SuiteSparse_long));
if (!(*Ai))
{
ostringstream tmp;
tmp << " in Init_UMFPACK_Sparse, can't allocate Ai index vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
test_mxMalloc(*Ax, __LINE__, __FILE__, __func__, prior_nz * sizeof(double));
if (!(*Ax))
{
ostringstream tmp;
@ -1046,11 +1068,15 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
#ifdef DEBUG
col_x = mxGetN(jacobian_exo_block[block_num]);
#endif
}
else
{
jacob_exo = NULL;
}
#ifdef DEBUG
int local_index;
#endif
bool fliped = false;
bool fliped_exogenous_derivatives_updated = false;
int flip_exo;
@ -1060,8 +1086,8 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
last_var = -1;
it4 = IM.begin();
var = 0;
while (it4 != IM.end())
{
while (it4 != IM.end())
{
var = it4->first.first.first;
#ifdef DEBUG
if (var < 0 || var >= Size)
@ -1070,7 +1096,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
tmp << " in Init_UMFPACK_Sparse, var (" << var << ") out of range\n";
throw FatalExceptionHandling(tmp.str());
}
#endif
#endif
eq = it4->first.second+Size*t;
#ifdef DEBUG
if (eq < 0 || eq >= Size)
@ -1117,7 +1143,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
(*Ax)[NZE] = jacob_exo[k + row_x*flip_exo];
(*Ai)[NZE] = k;
NZE++;
#ifdef DEBUG
if (local_index < 0 || local_index >= Size * periods)
{
@ -1137,7 +1163,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
tmp << " in Init_UMFPACK_Sparse, index (" << index_vara[var+Size*(y_kmin+t+lag)] << ") out of range for x vector max=" << nb_row_x * this->col_x << "\n";
throw FatalExceptionHandling(tmp.str());
}
#endif
#endif
u[k] -= jacob_exo[k + row_x*flip_exo] * x[t+y_kmin+flip_exo*nb_row_x];
}
}
@ -1151,7 +1177,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
if (max_lag < lag)
max_lag = lag;
}*/
if (var < (periods+y_kmax)*Size)
{
ti_y_kmin = -min(t, y_kmin);
@ -1204,7 +1230,7 @@ dynSparseMatrix::Init_UMFPACK_Sparse(int periods, int y_kmin, int y_kmax, int Si
#endif
(*b)[eq - lag * Size] += u[index] * y[index_vara[var+Size*(y_kmin+t/*+lag*/)]];
}
}
if (lag > ti_y_kmax || lag < ti_y_kmin)
{
@ -1276,7 +1302,8 @@ dynSparseMatrix::Init_CUDA_Sparse_Simple(int Size, map<pair<pair<int, int>, int>
{
int eq, var;
*b = (double*)mxMalloc(Size * sizeof(double));
*b = (double*)mxMalloc(Size * sizeof(double));
test_mxMalloc(*b, __LINE__, __FILE__, __func__, Size * sizeof(double));
if (!(*b))
{
ostringstream tmp;
@ -1290,7 +1317,8 @@ dynSparseMatrix::Init_CUDA_Sparse_Simple(int Size, map<pair<pair<int, int>, int>
tmp << " in Init_CUDA_Sparse_Simple, can't retrieve x0 vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ap = (SuiteSparse_long*)mxMalloc((Size+1) * sizeof(SuiteSparse_long));
*Ap = (SuiteSparse_long*)mxMalloc((Size+1) * sizeof(SuiteSparse_long));
test_mxMalloc(*Ap, __LINE__, __FILE__, __func__, (Size+1) * sizeof(SuiteSparse_long));
if (!(*Ap))
{
ostringstream tmp;
@ -1298,14 +1326,16 @@ dynSparseMatrix::Init_CUDA_Sparse_Simple(int Size, map<pair<pair<int, int>, int>
throw FatalExceptionHandling(tmp.str());
}
size_t prior_nz = IM.size();
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
*Ai = (SuiteSparse_long*)mxMalloc(prior_nz * sizeof(SuiteSparse_long));
test_mxMalloc(*Ai, __LINE__, __FILE__, __func__, prior_nz * sizeof(SuiteSparse_long));
if (!(*Ai))
{
ostringstream tmp;
tmp << " in Init_CUDA_Sparse, can't allocate Ai index vector\n";
throw FatalExceptionHandling(tmp.str());
}
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
*Ax = (double*)mxMalloc(prior_nz * sizeof(double));
test_mxMalloc(*Ax, __LINE__, __FILE__, __func__, prior_nz * sizeof(double));
if (!(*Ax))
{
ostringstream tmp;
@ -1411,6 +1441,7 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
double *Host_b = (double*)mxMalloc(n * sizeof(double));
test_mxMalloc(Host_b, __LINE__, __FILE__, __func__, n * sizeof(double));
cudaChk(cudaMalloc((void**)b, n * sizeof(double)), " in Init_Cuda_Sparse, not enought memory to allocate b vector on the graphic card\n");
double *Host_x0 = mxGetPr(x0_m);
@ -1423,18 +1454,23 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
cudaChk(cudaMalloc((void**)x0, n * sizeof(double)), " in Init_Cuda_Sparse, not enought memory to allocate x0 vector on the graphic card\n");
int* Host_Ap = (int*)mxMalloc((n+1) * sizeof(int));
test_mxMalloc(Host_Ap, __LINE__, __FILE__, __func__, (n+1) * sizeof(int));
int* Host_Ai = (int*)mxMalloc(prior_nz * sizeof(int));
test_mxMalloc(Host_Ai, __LINE__, __FILE__, __func__, prior_nz * sizeof(int));
double* Host_Ax = (double*)mxMalloc(prior_nz * sizeof(double));
test_mxMalloc(Host_Ax, __LINE__, __FILE__, __func__, prior_nz * sizeof(double));
int* Host_Ai_tild, * Host_Ap_tild;
if (preconditioner == 3)
{
Host_Ap_tild = (int*) mxMalloc((n+1)*sizeof(int));
test_mxMalloc(Host_Ap_tild, __LINE__, __FILE__, __func__, (n+1)*sizeof(int));
Host_Ai_tild = (int*) mxMalloc(prior_nz*sizeof(int));
test_mxMalloc(Host_Ai_tild, __LINE__, __FILE__, __func__, prior_nz*sizeof(int));
Host_Ap_tild[0] = 0;
}
@ -1445,6 +1481,7 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
preconditioner_size = prior_nz;
double *Host_A_tild = (double*)mxMalloc(preconditioner_size * sizeof(double));
test_mxMalloc(Host_A_tild, __LINE__, __FILE__, __func__, preconditioner_size * sizeof(double));
map<pair<pair<int, int>, int>, int>::iterator it4;
@ -1595,8 +1632,11 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
if (preconditioner == 3)
{
int* tmp_Ap_tild = (int*) mxMalloc((Size + 1) * sizeof(int) );
test_mxMalloc(tmp_Ap_tild, __LINE__, __FILE__, __func__, (Size + 1) * sizeof(int)) ;
int* tmp_Ai_tild = (int*) mxMalloc(NZE_tild * sizeof(int) );
double* tmp_A_tild = (double*) mxMalloc(NZE_tild * sizeof(double) );
test_mxMalloc(tmp_Ai_tild, __LINE__, __FILE__, __func__, NZE_tild * sizeof(int));
double* tmp_A_tild = (double*) mxMalloc(NZE_tild * sizeof(double));
test_mxMalloc(tmp_A_tild, __LINE__, __FILE__, __func__, NZE_tild * sizeof(double));
memcpy(tmp_Ap_tild, Host_Ap_tild, (Size + 1) * sizeof(int));
memcpy(tmp_Ai_tild, Host_Ai_tild, NZE_tild * sizeof(int));
memcpy(tmp_A_tild, Host_A_tild, NZE_tild * sizeof(double));
@ -1668,10 +1708,11 @@ dynSparseMatrix::Init_CUDA_Sparse(int periods, int y_kmin, int y_kmax, int Size,
void
PrintM(int n, double* Ax, mwIndex *Ap, mwIndex *Ai)
dynSparseMatrix::PrintM(int n, double* Ax, mwIndex *Ap, mwIndex *Ai)
{
int nnz = Ap[n];
double *A = (double*)mxMalloc(n * n * sizeof(double));
test_mxMalloc(A, __LINE__, __FILE__, __func__, n * n * sizeof(double));
memset(A,0,n * n * sizeof(double));
int k = 0;
for (int i = 0; i< n; i++)
@ -1849,23 +1890,36 @@ dynSparseMatrix::Init_GE(int periods, int y_kmin, int y_kmax, int Size, map<pair
map<pair<pair<int, int>, int>, int>::iterator it4;
NonZeroElem *first;
pivot = (int *) mxMalloc(Size*periods*sizeof(int));
pivot_save = (int *) mxMalloc(Size*periods*sizeof(int));
pivotk = (int *) mxMalloc(Size*periods*sizeof(int));
pivotv = (double *) mxMalloc(Size*periods*sizeof(double));
pivotva = (double *) mxMalloc(Size*periods*sizeof(double));
b = (int *) mxMalloc(Size*periods*sizeof(int));
line_done = (bool *) mxMalloc(Size*periods*sizeof(bool));
test_mxMalloc(pivot, __LINE__, __FILE__, __func__, Size*periods*sizeof(int));
pivot_save = (int *) mxMalloc(Size*periods*sizeof(int));
test_mxMalloc(pivot_save, __LINE__, __FILE__, __func__, Size*periods*sizeof(int));
pivotk = (int *) mxMalloc(Size*periods*sizeof(int));
test_mxMalloc(pivotk, __LINE__, __FILE__, __func__, Size*periods*sizeof(int));
pivotv = (double *) mxMalloc(Size*periods*sizeof(double));
test_mxMalloc(pivotv, __LINE__, __FILE__, __func__, Size*periods*sizeof(double));
pivotva = (double *) mxMalloc(Size*periods*sizeof(double));
test_mxMalloc(pivotva, __LINE__, __FILE__, __func__, Size*periods*sizeof(double));
b = (int *) mxMalloc(Size*periods*sizeof(int));
test_mxMalloc(b, __LINE__, __FILE__, __func__, Size*periods*sizeof(int));
line_done = (bool *) mxMalloc(Size*periods*sizeof(bool));
test_mxMalloc(line_done, __LINE__, __FILE__, __func__, Size*periods*sizeof(bool));
mem_mngr.init_CHUNK_BLCK_SIZE(u_count);
g_save_op = NULL;
g_nop_all = 0;
i = (periods+y_kmax+1)*Size*sizeof(NonZeroElem *);
FNZE_R = (NonZeroElem **) mxMalloc(i);
FNZE_C = (NonZeroElem **) mxMalloc(i);
NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i);
NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i);
FNZE_R = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(FNZE_R, __LINE__, __FILE__, __func__, i);
FNZE_C = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(FNZE_C, __LINE__, __FILE__, __func__, i);
NonZeroElem **temp_NZE_R = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(*temp_NZE_R, __LINE__, __FILE__, __func__, i);
NonZeroElem **temp_NZE_C = (NonZeroElem **) mxMalloc(i);
test_mxMalloc(*temp_NZE_C, __LINE__, __FILE__, __func__, i);
i = (periods+y_kmax+1)*Size*sizeof(int);
NbNZRow = (int *) mxMalloc(i);
NbNZCol = (int *) mxMalloc(i);
NbNZRow = (int *) mxMalloc(i);
test_mxMalloc(NbNZRow, __LINE__, __FILE__, __func__, i);
NbNZCol = (int *) mxMalloc(i);
test_mxMalloc(NbNZCol, __LINE__, __FILE__, __func__, i);
for (int i = 0; i < periods*Size; i++)
{
@ -2029,7 +2083,9 @@ dynSparseMatrix::compare(int *save_op, int *save_opa, int *save_opaa, int beg_t,
t_save_op_s *save_op_s, *save_opa_s, *save_opaa_s;
int *diff1, *diff2;
diff1 = (int *) mxMalloc(nop*sizeof(int));
test_mxMalloc(diff1, __LINE__, __FILE__, __func__, nop*sizeof(int));
diff2 = (int *) mxMalloc(nop*sizeof(int));
test_mxMalloc(diff2, __LINE__, __FILE__, __func__, nop*sizeof(int));
int max_save_ops_first = -1;
j = i = 0;
while (i < nop4 && OK)
@ -2180,8 +2236,10 @@ dynSparseMatrix::complete(int beg_t, int Size, int periods, int *b)
int size_of_save_code = (1+y_kmax)*Size*(Size+1+4)/2*4;
save_code = (int *) mxMalloc(size_of_save_code*sizeof(int));
test_mxMalloc(save_code, __LINE__, __FILE__, __func__, size_of_save_code*sizeof(int));
int size_of_diff = (1+y_kmax)*Size*(Size+1+4);
diff = (int *) mxMalloc(size_of_diff*sizeof(int));
test_mxMalloc(diff, __LINE__, __FILE__, __func__, size_of_diff*sizeof(int));
cal_y = y_size*y_kmin;
i = (beg_t+1)*Size-1;
@ -2439,6 +2497,7 @@ dynSparseMatrix::CheckIt(int y_size, int y_kmin, int y_kmax, int Size, int perio
mexPrintf("row(2)=%d\n", row);
double *B;
B = (double *) mxMalloc(row*sizeof(double));
test_mxMalloc(B, __LINE__, __FILE__, __func__, row*sizeof(double));
for (int i = 0; i < row; i++)
SaveResult >> B[i];
SaveResult.close();
@ -3293,8 +3352,11 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
#else
double *Control, *Info, *res;
Control = (double*)mxMalloc(UMFPACK_CONTROL * sizeof(double));
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
Info = (double*)mxMalloc(UMFPACK_INFO * sizeof(double));
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
res = (double*)mxMalloc(n * sizeof(double));
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
#endif
umfpack_dl_defaults(Control);
@ -3397,7 +3459,7 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
y[eq+it_*y_size] += slowc_l * yy;
}
}
mxFree(Ap);
mxFree(Ai);
mxFree(Ax);
@ -3419,8 +3481,11 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
#else
double *Control, *Info, *res;
Control = (double*)mxMalloc(UMFPACK_CONTROL * sizeof(double));
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
Info = (double*)mxMalloc(UMFPACK_INFO * sizeof(double));
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
res = (double*)mxMalloc(n * sizeof(double));
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
#endif
umfpack_dl_defaults(Control);
@ -3503,8 +3568,11 @@ dynSparseMatrix::Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double s
#else
double *Control, *Info, *res;
Control = (double*)mxMalloc(UMFPACK_CONTROL * sizeof(double));
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
Info = (double*)mxMalloc(UMFPACK_INFO * sizeof(double));
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
res = (double*)mxMalloc(n * sizeof(double));
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
#endif
void *Symbolic, *Numeric ;
umfpack_dl_defaults (Control) ;
@ -3561,6 +3629,7 @@ printM(int n,double *Ax, int* Ap, int* Ai, cusparseMatDescr_t descrA, cusparseH
cusparseChk(cusparseDcsr2dense(cusparse_handle, n, n, descrA,
Ax, Ap,Ai, A_dense, n), "cusparseDcsr2dense has failed\n");
double *A_dense_hoste = (double*)mxMalloc(n * n * sizeof(double));
test_mxMalloc(A_dense_hoste, __LINE__, __FILE__, __func__, n * n * sizeof(double));
cudaChk(cudaMemcpy(A_dense_hoste, A_dense, n * n * sizeof(double),cudaMemcpyDeviceToHost), " cudaMemcpy(A_dense_hoste, A_dense) has failed\n");
mexPrintf("----------------------\n");
mexPrintf("FillMode=%d, IndexBase=%d, MatType=%d, DiagType=%d\n",cusparseGetMatFillMode(descrA), cusparseGetMatIndexBase(descrA), cusparseGetMatType(descrA), cusparseGetMatDiagType(descrA));
@ -3731,6 +3800,7 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
int periods = n / Size;
double * tmp_vect_host = (double*)mxMalloc(n * sizeof(double));
test_mxMalloc(tmp_vect_host, __LINE__, __FILE__, __func__, n * sizeof(double));
cublasChk(cublasDnrm2(cublas_handle, n,b, 1, &bnorm),
" in Solve_Cuda_BiCGStab, cublasDnrm2(b) has failed\n");
@ -3856,10 +3926,15 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
// we have to transpose it to get a CSR format used by CUDA
mwIndex* Awi, *Awp;
double* A_tild_host = (double*)mxMalloc(nnz*sizeof(double));
test_mxMalloc(A_tild_host, __LINE__, __FILE__, __func__, nnz*sizeof(double));
Awi = (mwIndex*)mxMalloc(nnz * sizeof(mwIndex));
test_mxMalloc(Awi, __LINE__, __FILE__, __func__, nnz * sizeof(mwIndex));
Awp = (mwIndex*)mxMalloc((n + 1) * sizeof(mwIndex));
test_mxMalloc(Awp, __LINE__, __FILE__, __func__, (n + 1) * sizeof(mwIndex));
int* Aii = (int*)mxMalloc(nnz * sizeof(int));
test_mxMalloc(Aii, __LINE__, __FILE__, __func__, nnz * sizeof(int));
int* Aip = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Aip, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
cudaChk(cudaMemcpy(A_tild_host, A_tild, nnz*sizeof(double), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy A_tild_host = A_tild has failed\n");
cudaChk(cudaMemcpy(Aii, Ai, nnz*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aii = Ai has failed\n");
cudaChk(cudaMemcpy(Aip, Ap, (n+1)*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aip = Ai has failed\n");
@ -3941,7 +4016,9 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
mwIndex* Wi = mxGetIr(W);
mwIndex* Wp = mxGetJc(W);
int *Wii = (int*)mxMalloc(nnz * sizeof(int));
test_mxMalloc(Wii, __LINE__, __FILE__, __func__, nnz * sizeof(int));
int *Wip = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Wip, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
for (int i = 0; i < nnz; i++)
Wii[i] = Wi[i];
for (int i = 0; i < n + 1; i++)
@ -3968,10 +4045,15 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
{
mwIndex* Aowi, *Aowp;
double* A_host = (double*)mxMalloc(nnz*sizeof(double));
test_mxMalloc(A_host, __LINE__, __FILE__, __func__, nnz*sizeof(double));
Aowi = (mwIndex*)mxMalloc(nnz * sizeof(mwIndex));
test_mxMalloc(Aowi, __LINE__, __FILE__, __func__, nnz * sizeof(mwIndex));
Aowp = (mwIndex*)mxMalloc((n + 1) * sizeof(mwIndex));
test_mxMalloc(Aowp, __LINE__, __FILE__, __func__, (n + 1) * sizeof(mwIndex));
int* Aoii = (int*)mxMalloc(nnz * sizeof(int));
test_mxMalloc(Aoii, __LINE__, __FILE__, __func__, nnz * sizeof(int));
int* Aoip = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Aoip, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
cudaChk(cudaMemcpy(A_host, Ax, nnz*sizeof(double), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy A_tild_host = A_tild has failed\n");
cudaChk(cudaMemcpy(Aoii, Ai, nnz*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aii = Ai_tild has failed\n");
cudaChk(cudaMemcpy(Aoip, Ap, (n+1)*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aip = Ap_tild has failed\n");
@ -3996,10 +4078,15 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
// we have to transpose it to get a CSR format used by CUDA
mwIndex* Awi, *Awp;
double* A_tild_host = (double*)mxMalloc(nnz_tild*sizeof(double));
test_mxMalloc(A_tild_host, __LINE__, __FILE__, __func__, nnz_tild*sizeof(double));
Awi = (mwIndex*)mxMalloc(nnz_tild * sizeof(mwIndex));
test_mxMalloc(Awi, __LINE__, __FILE__, __func__, nnz_tild * sizeof(mwIndex));
Awp = (mwIndex*)mxMalloc((Size + 1) * sizeof(mwIndex));
test_mxMalloc(Awp, __LINE__, __FILE__, __func__, (Size + 1) * sizeof(mwIndex));
int* Aii = (int*)mxMalloc(nnz_tild * sizeof(int));
test_mxMalloc(Aii, __LINE__, __FILE__, __func__, nnz_tild * sizeof(int));
int* Aip = (int*)mxMalloc((Size + 1) * sizeof(int));
test_mxMalloc(Aip, __LINE__, __FILE__, __func__, (Size + 1) * sizeof(int));
cudaChk(cudaMemcpy(A_tild_host, A_tild, nnz_tild*sizeof(double), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy A_tild_host = A_tild has failed\n");
cudaChk(cudaMemcpy(Aii, Ai_tild, nnz_tild*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aii = Ai_tild has failed\n");
cudaChk(cudaMemcpy(Aip, Ap_tild, (Size+1)*sizeof(int), cudaMemcpyDeviceToHost), " in Solve_Cuda_BiCGStab, cudaMemcpy Aip = Ap_tild has failed\n");
@ -4060,8 +4147,11 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
Q_nnz = Qjw_host[Size];
mexPrintf("Q_nnz=%d\n",Q_nnz);
int *Qi_host = (int*)mxMalloc(Q_nnz * periods * sizeof(int));
test_mxMalloc(Qi_host, __LINE__, __FILE__, __func__, Q_nnz * periods * sizeof(int));
double *Q_x_host = (double*)mxMalloc(Q_nnz * periods * sizeof(double));
test_mxMalloc(Q_x_host, __LINE__, __FILE__, __func__, Q_nnz * periods * sizeof(double));
int *Qj_host = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Qj_host, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
for (int t = 0; t < periods; t++)
{
for (int i = 0; i < Q_nnz; i++)
@ -4120,8 +4210,11 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
double* Px_host = mxGetPr(P);
P_nnz = Pjw_host[Size];
int *Pi_host = (int*)mxMalloc(P_nnz * periods * sizeof(int));
test_mxMalloc(Pi_host, __LINE__, __FILE__, __func__, P_nnz * periods * sizeof(int));
double *P_x_host = (double*)mxMalloc(P_nnz * periods * sizeof(double));
test_mxMalloc(P_x_host, __LINE__, __FILE__, __func__, P_nnz * periods * sizeof(double));
int *Pj_host = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Pj_host, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
for (int t = 0; t < periods; t++)
{
for (int i = 0; i < P_nnz; i++)
@ -4202,8 +4295,11 @@ dynSparseMatrix::Solve_CUDA_BiCGStab(int *Ap, int *Ai, double *Ax, int *Ap_tild,
int U_nnz = Ujw_host[Size];
double *pW = (double*)mxMalloc((L_nnz + U_nnz - Size) * periods * sizeof(double));
test_mxMalloc(pW, __LINE__, __FILE__, __func__, (L_nnz + U_nnz - Size) * periods * sizeof(double));
int *Wi = (int*)mxMalloc((L_nnz + U_nnz - Size) * periods * sizeof(int));
test_mxMalloc(Wi, __LINE__, __FILE__, __func__, (L_nnz + U_nnz - Size) * periods * sizeof(int));
int *Wj = (int*)mxMalloc((n + 1) * sizeof(int));
test_mxMalloc(Wj, __LINE__, __FILE__, __func__, (n + 1) * sizeof(int));
Wj[0] = 0;
W_nnz = 0;
for (int t = 0; t < periods; t++)
@ -4865,7 +4961,10 @@ dynSparseMatrix::Solve_Matlab_BiCGStab(mxArray *A_m, mxArray *b_m, int Size, dou
/* precond = 0 => Jacobi
precond = 1 => Incomplet LU decomposition*/
size_t n = mxGetM(A_m);
mxArray *L1, *U1, *Diag;
mxArray *L1, *U1, *Diag;
L1 = NULL;
U1 = NULL;
Diag = NULL;
mxArray *rhs0[4];
if (preconditioner == 0)
@ -4919,7 +5018,8 @@ dynSparseMatrix::Solve_Matlab_BiCGStab(mxArray *A_m, mxArray *b_m, int Size, dou
mxDestroyArray(Setup);
}
double flags = 2;
mxArray *z;
mxArray *z;
z = NULL;
if (steady_state) /*Octave BicStab algorihtm involves a 0 division in case of a preconditionner equal to the LU decomposition of A matrix*/
{
mxArray *res = mult_SAT_B(Sparse_transpose(A_m), x0_m);
@ -5151,10 +5251,15 @@ dynSparseMatrix::Solve_ByteCode_Sparse_GaussianElimination(int Size, int blck, i
double piv_abs;
NonZeroElem **bc;
bc = (NonZeroElem **) mxMalloc(Size*sizeof(*bc));
test_mxMalloc(bc, __LINE__, __FILE__, __func__, Size*sizeof(*bc));
piv_v = (double *) mxMalloc(Size*sizeof(double));
test_mxMalloc(piv_v, __LINE__, __FILE__, __func__, Size*sizeof(double));
pivj_v = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivj_v, __LINE__, __FILE__, __func__, Size*sizeof(int));
pivk_v = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivk_v, __LINE__, __FILE__, __func__, Size*sizeof(int));
NR = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(NR, __LINE__, __FILE__, __func__, Size*sizeof(int));
for (int i = 0; i < Size; i++)
{
@ -5419,12 +5524,17 @@ dynSparseMatrix::Solve_ByteCode_Symbolic_Sparse_GaussianElimination(int Size, bo
int tbreak = 0, last_period = periods;
piv_v = (double *) mxMalloc(Size*sizeof(double));
test_mxMalloc(piv_v, __LINE__, __FILE__, __func__, Size*sizeof(double));
pivj_v = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivj_v, __LINE__, __FILE__, __func__, Size*sizeof(int));
pivk_v = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(pivk_v, __LINE__, __FILE__, __func__, Size*sizeof(int));
NR = (int *) mxMalloc(Size*sizeof(int));
test_mxMalloc(NR, __LINE__, __FILE__, __func__, Size*sizeof(int));
//clock_t time00 = clock();
NonZeroElem **bc;
bc = (NonZeroElem **) mxMalloc(Size*sizeof(first));
test_mxMalloc(bc, __LINE__, __FILE__, __func__, Size*sizeof(first));
for (int t = 0; t < periods; t++)
{
@ -5443,6 +5553,7 @@ dynSparseMatrix::Solve_ByteCode_Symbolic_Sparse_GaussianElimination(int Size, bo
save_op = NULL;
}*/
save_op = (int *) mxMalloc(nop*sizeof(int));
test_mxMalloc(save_op, __LINE__, __FILE__, __func__, nop*sizeof(int));
nopa = nop;
}
nop = 0;
@ -6111,6 +6222,7 @@ dynSparseMatrix::Check_and_Correct_Previous_Iteration(int block_num, int y_size,
{
double *p = (double*)mxMalloc(size * sizeof(double));
test_mxMalloc(p, __LINE__, __FILE__, __func__, size * sizeof(double));
Grad_f_product(size, b_m_save, p, A_m_save, Ap_save, Ai_save, Ax_save, b_save);
double slope=0.0;
for (int i = 1; i < size; i++)
@ -6337,7 +6449,9 @@ dynSparseMatrix::Simulate_One_Boundary(int block_num, int y_size, int y_kmin, in
mxFree(Ai_save);
mxFree(Ax_save);
Ai_save = (SuiteSparse_long*)mxMalloc(Ap[size] * sizeof(SuiteSparse_long));
test_mxMalloc(Ai_save, __LINE__, __FILE__, __func__, Ap[size] * sizeof(SuiteSparse_long));
Ax_save = (double*)mxMalloc(Ap[size] * sizeof(double));
test_mxMalloc(Ax_save, __LINE__, __FILE__, __func__, Ap[size] * sizeof(double));
}
memcpy(Ap_save, Ap, (size + 1) * sizeof(SuiteSparse_long));
memcpy(Ai_save, Ai, Ap[size] * sizeof(SuiteSparse_long));
@ -6420,15 +6534,21 @@ void
dynSparseMatrix::Simulate_Newton_One_Boundary(const bool forward)
{
g1 = (double *) mxMalloc(size*size*sizeof(double));
test_mxMalloc(g1, __LINE__, __FILE__, __func__, size*size*sizeof(double));
r = (double *) mxMalloc(size*sizeof(double));
test_mxMalloc(r, __LINE__, __FILE__, __func__, size*sizeof(double));
iter = 0;
if ((solve_algo == 6 && steady_state) || ((stack_solve_algo == 0 || stack_solve_algo == 1 || stack_solve_algo == 4) && !steady_state))
{
Ap_save = (SuiteSparse_long*)mxMalloc((size + 1) * sizeof(SuiteSparse_long));
test_mxMalloc(Ap_save, __LINE__, __FILE__, __func__, (size + 1) * sizeof(SuiteSparse_long));
Ap_save[size] = 0;
Ai_save = (SuiteSparse_long*)mxMalloc(1 * sizeof(SuiteSparse_long));
test_mxMalloc(Ai_save, __LINE__, __FILE__, __func__, 1 * sizeof(SuiteSparse_long));
Ax_save = (double*)mxMalloc(1 * sizeof(double));
test_mxMalloc(Ax_save, __LINE__, __FILE__, __func__, 1 * sizeof(double));
b_save = (double*)mxMalloc((size) * sizeof(SuiteSparse_long));
test_mxMalloc(b_save, __LINE__, __FILE__, __func__, (size) * sizeof(SuiteSparse_long));
}
if (steady_state)
{
@ -6491,7 +6611,7 @@ dynSparseMatrix::preconditioner_print_out(string s, int preconditioner, bool ss)
case 1:
if (ss)
tmp.append("incomplet lutp on static jacobian");
else
else
tmp.append("incomplet lu0 on dynamic jacobian");
break;
case 2:
@ -6540,7 +6660,8 @@ dynSparseMatrix::Simulate_Newton_Two_Boundaries(int blck, int y_size, int y_kmin
if (isnan(res1) || isinf(res1) || (res2 > 12*g0 && iter > 0))
{
if (iter == 0 || fabs(slowc_save) < 1e-8)
{
{
mexPrintf("res1 = %f, res2 = %f g0 = %f iter = %d\n", res1, res2, g0, iter);
for (int j = 0; j < y_size; j++)
{
ostringstream res;
@ -6781,6 +6902,7 @@ dynSparseMatrix::fixe_u(double **u, int u_count_int, int max_lag_plus_max_lead_p
mexPrintf("fixe_u : alloc(%d double)\n", u_count_alloc);
#endif
(*u) = (double *) mxMalloc(u_count_alloc*sizeof(double));
test_mxMalloc(*u, __LINE__, __FILE__, __func__, u_count_alloc*sizeof(double));
#ifdef DEBUG
mexPrintf("*u=%d\n", *u);
#endif

View File

@ -146,7 +146,7 @@ private:
void Solve_Matlab_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double slowc_l, bool is_two_boundaries, int it_);
void Print_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, int n);
void Printfull_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, double *b, int n);
void PrintM(int n, double* Ax, mwIndex *Ap, mwIndex *Ai);
void Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double slowc_l, bool is_two_boundaries, int it_);
void Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, double *b, int n, int Size, double slowc_l, bool is_two_boundaries, int it_, vector_table_conditional_local_type vector_table_conditional_local);
void Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, double *b, int n, int Size, double slowc_l, bool is_two_boundaries, int it_);
@ -245,7 +245,7 @@ protected:
int u_count_alloc, u_count_alloc_save;
vector<double *> jac;
double *jcb;
double slowc_save, prev_slowc_save, markowitz_c;
double slowc_save, prev_slowc_save, markowitz_c;
int y_decal;
int *index_equa;
int u_count, tbreak_g;

View File

@ -91,9 +91,9 @@ Get_Argument(const mxArray *prhs)
#endif
//#include <windows.h>
#include <stdio.h>
//#include <windows.h>
#include <stdio.h>
#ifdef CUDA
int
@ -449,7 +449,8 @@ main(int nrhs, const char *prhs[])
char *plhs[1];
load_global((char *) prhs[1]);
#endif
mxArray *pfplan_struct = NULL;
mxArray *pfplan_struct = NULL;
ErrorMsg error_msg;
size_t i, row_y = 0, col_y = 0, row_x = 0, col_x = 0, nb_row_xd = 0;
size_t steady_row_y, steady_col_y;
int y_kmin = 0, y_kmax = 0, y_decal = 0;
@ -527,7 +528,7 @@ main(int nrhs, const char *prhs[])
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
}
int nb_periods = mxGetM(date_str) * mxGetN(date_str);
mxArray* constrained_vars_ = mxGetField(extended_path_struct, 0, "constrained_vars_");
if (constrained_vars_ == NULL)
{
@ -556,7 +557,7 @@ main(int nrhs, const char *prhs[])
tmp.insert(0,"The extended_path description structure does not contain the member: ");
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
}
mxArray* shock_var_ = mxGetField(extended_path_struct, 0, "shock_vars_");
if (shock_var_ == NULL)
{
@ -621,7 +622,7 @@ main(int nrhs, const char *prhs[])
table_conditional_global[i] = vector_conditional_local;
}
}
vector_table_conditional_local_type vv3 = table_conditional_global[0];
for (int i = 0; i < nb_constrained; i++)
{
@ -632,6 +633,7 @@ main(int nrhs, const char *prhs[])
double *specific_constrained_int_date_ = mxGetPr(mxGetCell(constrained_int_date_, i));
int nb_local_periods = mxGetM(Array_constrained_paths_) * mxGetN(Array_constrained_paths_);
int* constrained_int_date = (int*)mxMalloc(nb_local_periods * sizeof(int));
error_msg.test_mxMalloc(constrained_int_date, __LINE__, __FILE__, __func__, nb_local_periods * sizeof(int));
if (nb_periods < nb_local_periods)
{
ostringstream oss;
@ -642,7 +644,7 @@ main(int nrhs, const char *prhs[])
oss << nb_local_periods;
string tmp1 = oss.str();
tmp.append(tmp1);
tmp.append(")");
tmp.append(")");
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
}
(sconditional_extended_path[i]).per_value.resize(nb_local_periods);
@ -685,7 +687,7 @@ main(int nrhs, const char *prhs[])
oss << nb_local_periods;
string tmp1 = oss.str();
tmp.append(tmp1);
tmp.append(")");
tmp.append(")");
DYN_MEX_FUNC_ERR_MSG_TXT(tmp.c_str());
}
(sextended_path[i]).per_value.resize(nb_local_periods);
@ -713,7 +715,7 @@ main(int nrhs, const char *prhs[])
dates.push_back(string(buf));//string(Dates[i]);
mxFree(buf);
}
}
}
if (plan.length()>0)
{
mxArray* plan_struct = mexGetVariable("base", plan.c_str());
@ -1057,14 +1059,19 @@ main(int nrhs, const char *prhs[])
#else
if (stack_solve_algo == 7 && !steady_state)
DYN_MEX_FUNC_ERR_MSG_TXT("bytecode has not been compiled with CUDA option. Bytecode Can't use options_.stack_solve_algo=7\n");
#endif
#endif
size_t size_of_direction = col_y*row_y*sizeof(double);
double *y = (double *) mxMalloc(size_of_direction);
error_msg.test_mxMalloc(y, __LINE__, __FILE__, __func__, size_of_direction);
double *ya = (double *) mxMalloc(size_of_direction);
error_msg.test_mxMalloc(ya, __LINE__, __FILE__, __func__, size_of_direction);
direction = (double *) mxMalloc(size_of_direction);
memset(direction, 0, size_of_direction);
error_msg.test_mxMalloc(direction, __LINE__, __FILE__, __func__, size_of_direction);
memset(direction, 0, size_of_direction);
/*mexPrintf("col_x : %d, row_x : %d\n",col_x, row_x);*/
double *x = (double *) mxMalloc(col_x*row_x*sizeof(double));
error_msg.test_mxMalloc(x, __LINE__, __FILE__, __func__, col_x*row_x*sizeof(double));
for (i = 0; i < row_x*col_x; i++)
{
x[i] = double (xd[i]);
@ -1075,7 +1082,7 @@ main(int nrhs, const char *prhs[])
ya[i] = double (yd[i]);
}
size_t y_size = row_y;
size_t nb_row_x = row_x;
size_t nb_row_x = row_x;
clock_t t0 = clock();
Interpreter interprete(params, y, ya, x, steady_yd, steady_xd, direction, y_size, nb_row_x, nb_row_xd, periods, y_kmin, y_kmax, maxit_, solve_tolf, size_of_direction, slowc, y_decal,
markowitz_c, file_name, minimal_solving_periods, stack_solve_algo, solve_algo, global_temporary_terms, print, print_error, GlobalTemporaryTerms, steady_state,

View File

@ -1681,15 +1681,16 @@ IdentificationStatement::writeOutput(ostream &output, const string &basename, bo
output << "dynare_identification(options_ident);" << endl;
}
WriteLatexDynamicModelStatement::WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg) :
dynamic_model(dynamic_model_arg)
WriteLatexDynamicModelStatement::WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg, bool write_equation_tags_arg) :
dynamic_model(dynamic_model_arg),
write_equation_tags(write_equation_tags_arg)
{
}
void
WriteLatexDynamicModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
dynamic_model.writeLatexFile(basename);
dynamic_model.writeLatexFile(basename, write_equation_tags);
}
WriteLatexStaticModelStatement::WriteLatexStaticModelStatement(const StaticModel &static_model_arg) :
@ -1744,6 +1745,37 @@ RealtimeShockDecompositionStatement::writeOutput(ostream &output, const string &
output << "oo_ = realtime_shock_decomposition(M_,oo_,options_,var_list_,bayestopt_,estim_params_);" << endl;
}
PlotShockDecompositionStatement::PlotShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg)
{
}
void
PlotShockDecompositionStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
output << "options_ = set_default_plot_shock_decomposition_options(options_);" << endl;
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
output << "plot_shock_decomposition(M_, oo_, options_, var_list_);" << endl;
}
InitialConditionDecompositionStatement::InitialConditionDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg) :
symbol_list(symbol_list_arg),
options_list(options_list_arg)
{
}
void
InitialConditionDecompositionStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
{
output << "options_ = set_default_initial_condition_decomposition_options(options_);" << endl;
options_list.writeOutput(output);
symbol_list.writeOutput("var_list_", output);
output << "initial_condition_decomposition(M_, oo_, options_, var_list_, bayestopt_, estim_params_);" << endl;
}
ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &options_list_arg) :
options_list(options_list_arg)

View File

@ -570,8 +570,9 @@ class WriteLatexDynamicModelStatement : public Statement
{
private:
const DynamicModel &dynamic_model;
const bool write_equation_tags;
public:
WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg);
WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg, bool write_equation_tags_arg);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};
@ -611,9 +612,32 @@ private:
const OptionsList options_list;
public:
RealtimeShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg);
const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};
class PlotShockDecompositionStatement : public Statement
{
private:
const SymbolList symbol_list;
const OptionsList options_list;
public:
PlotShockDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};
class InitialConditionDecompositionStatement : public Statement
{
private:
const SymbolList symbol_list;
const OptionsList options_list;
public:
InitialConditionDecompositionStatement(const SymbolList &symbol_list_arg,
const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};
class ConditionalForecastStatement : public Statement
{
private:

View File

@ -4477,9 +4477,9 @@ DynamicModel::writeChainRuleDerivative(ostream &output, int eqr, int varr, int l
}
void
DynamicModel::writeLatexFile(const string &basename) const
DynamicModel::writeLatexFile(const string &basename, const bool write_equation_tags) const
{
writeLatexModelFile(basename + "_dynamic", oLatexDynamicModel);
writeLatexModelFile(basename + "_dynamic", oLatexDynamicModel, write_equation_tags);
}
void

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2016 Dynare Team
* Copyright (C) 2003-2017 Dynare Team
*
* This file is part of Dynare.
*
@ -288,7 +288,7 @@ public:
size_t dynamicOnlyEquationsNbr() const;
//! Writes LaTeX file with the equations of the dynamic model
void writeLatexFile(const string &basename) const;
void writeLatexFile(const string &basename, const bool write_equation_tags) const;
//! Writes LaTeX file with the equations of the dynamic model (for the original model)
void writeLatexOriginalFile(const string &basename) const;

View File

@ -86,12 +86,12 @@ class ParsingDriver;
%token AIM_SOLVER ANALYTIC_DERIVATION ANALYTIC_DERIVATION_MODE AR AUTOCORR POSTERIOR_SAMPLING_METHOD
%token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION SILENT_OPTIMIZER
%token BVAR_DENSITY BVAR_FORECAST NODECOMPOSITION DR_DISPLAY_TOL HUGE_NUMBER
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN
%token BVAR_REPLIC BYTECODE ALL_VALUES_REQUIRED PROPOSAL_DISTRIBUTION
%token BVAR_DENSITY BVAR_FORECAST NODECOMPOSITION DR_DISPLAY_TOL HUGE_NUMBER FIG_NAME WRITE_XLS
%token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA INTERACTIVE SCREEN_SHOCKS STEADYSTATE
%token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN DETAIL_PLOT TYPE
%token BVAR_REPLIC BYTECODE ALL_VALUES_REQUIRED PROPOSAL_DISTRIBUTION REALTIME VINTAGE
%token CALIB_SMOOTHER CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF CYCLE_REDUCTION LOGARITHMIC_REDUCTION
%token CONSIDER_ALL_ENDOGENOUS CONSIDER_ONLY_OBSERVED
%token CONSIDER_ALL_ENDOGENOUS CONSIDER_ONLY_OBSERVED INITIAL_CONDITION_DECOMPOSITION
%token DATAFILE FILE SERIES DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR
%token FILENAME DIRNAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME OSR_PARAMS_BOUNDS KEEP_KALMAN_ALGO_IF_SINGULARITY_IS_DETECTED
@ -103,15 +103,15 @@ class ParsingDriver;
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
%token <string_val> INT_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
%token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF TOLX
%token FAST_KALMAN_FILTER KALMAN_ALGO KALMAN_TOL DIFFUSE_KALMAN_TOL SUBSAMPLES OPTIONS TOLF TOLX PLOT_INIT_DATE PLOT_END_DATE
%token LAPLACE LIK_ALGO LIK_INIT LINEAR LOAD_IDENT_FILES LOAD_MH_FILE LOAD_RESULTS_AFTER_LOAD_MH LOAD_PARAMS_AND_STEADY_STATE LOGLINEAR LOGDATA LYAPUNOV LINEAR_APPROXIMATION
%token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL LOG_DEFLATOR LOG_TREND_VAR LOG_GROWTH_FACTOR MARKOWITZ MARGINAL_DENSITY MAX MAXIT
%token MFS MH_CONF_SIG MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER POSTERIOR_MAX_SUBSAMPLE_DRAWS MIN MINIMAL_SOLVING_PERIODS
%token MODE_CHECK MODE_CHECK_NEIGHBOURHOOD_SIZE MODE_CHECK_SYMMETRIC_PLOTS MODE_CHECK_NUMBER_OF_POINTS MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN
%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO CONTEMPORANEOUS_CORRELATION DIFFUSE_FILTER SUB_DRAWS TAPER_STEPS GEWEKE_INTERVAL RAFTERY_LEWIS_QRS RAFTERY_LEWIS_DIAGNOSTICS MCMC_JUMPING_COVARIANCE MOMENT_CALIBRATION
%token NUMBER_OF_PARTICLES RESAMPLING SYSTEMATIC GENERIC RESAMPLING_THRESHOLD RESAMPLING_METHOD KITAGAWA STRATIFIED SMOOTH
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW METHOD
%token FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
%token CPF_WEIGHTS AMISANOTRISTANI MURRAYJONESPARSLOW WRITE_EQUATION_TAGS METHOD
%token NONLINEAR_FILTER_INITIALIZATION FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION
%token <string_val> NAME
%token USE_PENALIZED_OBJECTIVE_FOR_HESSIAN INIT_STATE
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY
@ -129,9 +129,9 @@ class ParsingDriver;
%token TEX RAMSEY_MODEL RAMSEY_POLICY RAMSEY_CONSTRAINTS PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token <string_val> TEX_NAME
%token UNIFORM_PDF UNIT_ROOT_VARS USE_DLL USEAUTOCORR GSA_SAMPLE_FILE USE_UNIVARIATE_FILTERS_IF_SINGULARITY_IS_DETECTED
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION
%token VALUES VAR VAREXO VAREXO_DET VAROBS VAREXOBS PREDETERMINED_VARIABLES VAR_EXPECTATION PLOT_SHOCK_DECOMPOSITION
%token WRITE_LATEX_DYNAMIC_MODEL WRITE_LATEX_STATIC_MODEL WRITE_LATEX_ORIGINAL_MODEL
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL
%token XLS_SHEET XLS_RANGE LMMCP OCCBIN BANDPASS_FILTER COLORMAP VAR_MODEL QOQ YOY AOA
%left COMMA
%left EQUAL_EQUAL EXCLAMATION_EQUAL
%left LESS GREATER LESS_EQUAL GREATER_EQUAL
@ -264,6 +264,8 @@ statement : parameters
| write_latex_original_model
| shock_decomposition
| realtime_shock_decomposition
| plot_shock_decomposition
| initial_condition_decomposition
| conditional_forecast
| conditional_forecast_paths
| plot_conditional_forecast
@ -1836,6 +1838,7 @@ estimation_options : o_datafile
| o_resampling_threshold
| o_resampling_method
| o_filter_algorithm
| o_nonlinear_filter_initialization
| o_cpf_weights
| o_proposal_approximation
| o_distribution_approximation
@ -2138,7 +2141,9 @@ ramsey_policy_options : stoch_simul_primary_options
;
write_latex_dynamic_model : WRITE_LATEX_DYNAMIC_MODEL ';'
{ driver.write_latex_dynamic_model(); }
{ driver.write_latex_dynamic_model(false); }
| WRITE_LATEX_DYNAMIC_MODEL '(' WRITE_EQUATION_TAGS ')' ';'
{ driver.write_latex_dynamic_model(true); }
;
write_latex_static_model : WRITE_LATEX_STATIC_MODEL ';'
@ -2169,6 +2174,26 @@ realtime_shock_decomposition : REALTIME_SHOCK_DECOMPOSITION ';'
{ driver.realtime_shock_decomposition(); }
;
plot_shock_decomposition : PLOT_SHOCK_DECOMPOSITION ';'
{driver.plot_shock_decomposition(); }
| PLOT_SHOCK_DECOMPOSITION '(' plot_shock_decomposition_options_list ')' ';'
{ driver.plot_shock_decomposition(); }
| PLOT_SHOCK_DECOMPOSITION symbol_list ';'
{ driver.plot_shock_decomposition(); }
| PLOT_SHOCK_DECOMPOSITION '(' plot_shock_decomposition_options_list ')' symbol_list ';'
{ driver.plot_shock_decomposition(); }
;
initial_condition_decomposition : INITIAL_CONDITION_DECOMPOSITION ';'
{driver.initial_condition_decomposition(); }
| INITIAL_CONDITION_DECOMPOSITION '(' initial_condition_decomposition_options_list ')' ';'
{ driver.initial_condition_decomposition(); }
| INITIAL_CONDITION_DECOMPOSITION symbol_list ';'
{ driver.initial_condition_decomposition(); }
| INITIAL_CONDITION_DECOMPOSITION '(' initial_condition_decomposition_options_list ')' symbol_list ';'
{ driver.initial_condition_decomposition(); }
;
bvar_prior_option : o_bvar_prior_tau
| o_bvar_prior_decay
| o_bvar_prior_lambda
@ -2554,6 +2579,39 @@ realtime_shock_decomposition_option : o_parameter_set
| o_save_realtime
;
plot_shock_decomposition_options_list : plot_shock_decomposition_option COMMA plot_shock_decomposition_options_list
| plot_shock_decomposition_option
;
plot_shock_decomposition_option : o_psd_use_shock_groups
| o_psd_colormap
| o_psd_nodisplay
| o_psd_graph_format
| o_psd_detail_plot
| o_psd_interactive
| o_psd_screen_shocks
| o_psd_steadystate
| o_psd_type
| o_psd_fig_name
| o_psd_write_xls
| o_psd_realtime
| o_psd_vintage
| o_psd_plot_init_date
| o_psd_plot_end_date
;
initial_condition_decomposition_options_list : initial_condition_decomposition_option COMMA initial_condition_decomposition_options_list
| initial_condition_decomposition_option
;
initial_condition_decomposition_option : o_icd_type
| o_icd_detail_plot
| o_icd_steadystate
| o_icd_write_xls
| o_icd_plot_init_date
| o_icd_plot_end_date
;
homotopy_setup: HOMOTOPY_SETUP ';' homotopy_list END ';'
{ driver.end_homotopy();};
@ -2901,11 +2959,17 @@ o_shock_decomposition_presample : PRESAMPLE EQUAL INT_NUMBER { driver.option_num
o_shock_decomposition_forecast : FORECAST EQUAL INT_NUMBER { driver.option_num("shock_decomp.forecast", $3); };
o_save_realtime : SAVE_REALTIME EQUAL vec_int { driver.option_vec_int("shock_decomp.save_realtime", $3); };
o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); };
o_psd_nodisplay : NODISPLAY { driver.option_num("plot_shock_decomp.nodisplay","1"); };
o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats
{ driver.process_graph_format_option(); }
| GRAPH_FORMAT EQUAL '(' list_allowed_graph_formats ')'
{ driver.process_graph_format_option(); }
;
o_psd_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats
{ driver.plot_shock_decomp_process_graph_format_option(); }
| GRAPH_FORMAT EQUAL '(' list_allowed_graph_formats ')'
{ driver.plot_shock_decomp_process_graph_format_option(); }
;
allowed_graph_formats : EPS
{ driver.add_graph_format("eps"); }
| FIG
@ -3011,7 +3075,35 @@ o_dr : DR EQUAL CYCLE_REDUCTION {driver.option_num("dr_cycle_reduction", "1"); }
o_dr_cycle_reduction_tol : DR_CYCLE_REDUCTION_TOL EQUAL non_negative_number {driver.option_num("dr_cycle_reduction_tol",$3);};
o_dr_logarithmic_reduction_tol : DR_LOGARITHMIC_REDUCTION_TOL EQUAL non_negative_number {driver.option_num("dr_logarithmic_reduction_tol",$3);};
o_dr_logarithmic_reduction_maxiter : DR_LOGARITHMIC_REDUCTION_MAXITER EQUAL INT_NUMBER {driver.option_num("dr_logarithmic_reduction_maxiter",$3);};
o_psd_detail_plot : DETAIL_PLOT { driver.option_num("plot_shock_decomp.detail_plot", "1"); };
o_icd_detail_plot : DETAIL_PLOT { driver.option_num("initial_condition_decomp.detail_plot", "1"); };
o_psd_interactive : INTERACTIVE { driver.option_num("plot_shock_decomp.interactive", "1"); };
o_psd_screen_shocks : SCREEN_SHOCKS { driver.option_num("plot_shock_decomp.screen_shocks", "1"); };
o_psd_steadystate : STEADYSTATE { driver.option_num("plot_shock_decomp.steadystate", "1"); };
o_icd_steadystate : STEADYSTATE { driver.option_num("initial_condition_decomp.steadystate", "1"); };
o_psd_fig_name : FIG_NAME EQUAL filename { driver.option_str("plot_shock_decomp.fig_name", $3); };
o_psd_type : TYPE EQUAL QOQ
{ driver.option_str("plot_shock_decomp.type", "qoq"); }
| TYPE EQUAL YOY
{ driver.option_str("plot_shock_decomp.type", "qoq"); }
| TYPE EQUAL AOA
{ driver.option_str("plot_shock_decomp.type", "qoq"); }
;
o_icd_type : TYPE EQUAL QOQ
{ driver.option_str("initial_condition_decomp.type", "qoq"); }
| TYPE EQUAL YOY
{ driver.option_str("initial_condition_decomp.type", "qoq"); }
| TYPE EQUAL AOA
{ driver.option_str("initial_condition_decomp.type", "qoq"); }
;
o_icd_plot_init_date : PLOT_INIT_DATE EQUAL date_expr { driver.option_date("initial_condition_decomp.plot_init_date", $3); } ;
o_icd_plot_end_date : PLOT_END_DATE EQUAL date_expr { driver.option_date("initial_condition_decomp.plot_end_date", $3); } ;
o_psd_plot_init_date : PLOT_INIT_DATE EQUAL date_expr { driver.option_date("plot_shock_decomp.plot_init_date", $3); } ;
o_psd_plot_end_date : PLOT_END_DATE EQUAL date_expr { driver.option_date("plot_shock_decomp.plot_end_date", $3); } ;
o_icd_write_xls : WRITE_XLS { driver.option_num("initial_condition_decomp.write_xls", "1"); };
o_psd_write_xls : WRITE_XLS { driver.option_num("plot_shock_decomp.write_xls", "1"); };
o_psd_realtime : REALTIME EQUAL INT_NUMBER { driver.option_num("plot_shock_decomp.realtime", $3); };
o_psd_vintage : VINTAGE EQUAL INT_NUMBER { driver.option_num("plot_shock_decomp.vintage", $3); };
o_bvar_prior_tau : BVAR_PRIOR_TAU EQUAL signed_number { driver.option_num("bvar_prior_tau", $3); };
o_bvar_prior_decay : BVAR_PRIOR_DECAY EQUAL non_negative_number { driver.option_num("bvar_prior_decay", $3); };
o_bvar_prior_lambda : BVAR_PRIOR_LAMBDA EQUAL signed_number { driver.option_num("bvar_prior_lambda", $3); };
@ -3032,6 +3124,7 @@ o_resampling_method : RESAMPLING_METHOD EQUAL KITAGAWA {driver.option_num("parti
o_cpf_weights : CPF_WEIGHTS EQUAL AMISANOTRISTANI {driver.option_num("particle.cpf_weights_method.amisanotristani", "1"); driver.option_num("particle.cpf_weights_method.murrayjonesparslow", "0"); }
| CPF_WEIGHTS EQUAL MURRAYJONESPARSLOW {driver.option_num("particle.cpf_weights_method.amisanotristani", "0"); driver.option_num("particle.cpf_weights_method.murrayjonesparslow", "1"); };
o_filter_algorithm : FILTER_ALGORITHM EQUAL symbol { driver.option_str("particle.filter_algorithm", $3); };
o_nonlinear_filter_initialization : NONLINEAR_FILTER_INITIALIZATION EQUAL INT_NUMBER { driver.option_num("particle.initialization", $3); };
o_proposal_approximation : PROPOSAL_APPROXIMATION EQUAL CUBATURE {driver.option_num("particle.proposal_approximation.cubature", "1"); driver.option_num("particle.proposal_approximation.unscented", "0"); driver.option_num("particle.proposal_approximation.montecarlo", "0");}
| PROPOSAL_APPROXIMATION EQUAL UNSCENTED {driver.option_num("particle.proposal_approximation.cubature", "0"); driver.option_num("particle.proposal_approximation.unscented", "1"); driver.option_num("particle.proposal_approximation.montecarlo", "0");}
| PROPOSAL_APPROXIMATION EQUAL MONTECARLO {driver.option_num("particle.proposal_approximation.cubature", "0"); driver.option_num("particle.proposal_approximation.unscented", "0"); driver.option_num("particle.proposal_approximation.montecarlo", "1");} ;
@ -3321,7 +3414,11 @@ o_sampling_draws : SAMPLING_DRAWS EQUAL INT_NUMBER { driver.option_num("sampling
o_use_shock_groups : USE_SHOCK_GROUPS { driver.option_str("use_shock_groups","default"); }
| USE_SHOCK_GROUPS EQUAL symbol { driver.option_str("use_shock_groups", $3); }
;
o_psd_use_shock_groups : USE_SHOCK_GROUPS { driver.option_str("plot_shock_decomp.use_shock_groups","default"); }
| USE_SHOCK_GROUPS EQUAL symbol { driver.option_str("plot_shock_decomp.use_shock_groups", $3); }
;
o_colormap : COLORMAP EQUAL symbol { driver.option_num("colormap",$3); };
o_psd_colormap : COLORMAP EQUAL symbol { driver.option_num("plot_shock_decomp.colormap",$3); };
range : symbol ':' symbol
{

View File

@ -153,6 +153,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<INITIAL>forecast {BEGIN DYNARE_STATEMENT; return token::FORECAST;}
<INITIAL>shock_decomposition {BEGIN DYNARE_STATEMENT; return token::SHOCK_DECOMPOSITION;}
<INITIAL>realtime_shock_decomposition {BEGIN DYNARE_STATEMENT; return token::REALTIME_SHOCK_DECOMPOSITION;}
<INITIAL>plot_shock_decomposition {BEGIN DYNARE_STATEMENT; return token::PLOT_SHOCK_DECOMPOSITION;}
<INITIAL>initial_condition_decomposition {BEGIN DYNARE_STATEMENT; return token::INITIAL_CONDITION_DECOMPOSITION;}
<INITIAL>sbvar {BEGIN DYNARE_STATEMENT; return token::SBVAR;}
<INITIAL>ms_estimation {BEGIN DYNARE_STATEMENT; return token::MS_ESTIMATION;}
<INITIAL>ms_simulation {BEGIN DYNARE_STATEMENT; return token::MS_SIMULATION;}
@ -377,6 +379,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>indxscalesstates {return token::INDXSCALESSTATES;}
<DYNARE_STATEMENT>fixed_point {return token::FIXED_POINT;}
<DYNARE_STATEMENT>doubling {return token::DOUBLING;}
<DYNARE_STATEMENT>plot_init_date {return token::PLOT_INIT_DATE;}
<DYNARE_STATEMENT>plot_end_date {return token::PLOT_END_DATE;}
<DYNARE_STATEMENT>square_root_solver {return token::SQUARE_ROOT_SOLVER;}
<DYNARE_STATEMENT>cycle_reduction {return token::CYCLE_REDUCTION;}
<DYNARE_STATEMENT>logarithmic_reduction {return token::LOGARITHMIC_REDUCTION;}
@ -398,6 +402,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>amisanotristani {return token::AMISANOTRISTANI;}
<DYNARE_STATEMENT>murrayjonesparslow {return token::MURRAYJONESPARSLOW;}
<DYNARE_STATEMENT>filter_algorithm {return token::FILTER_ALGORITHM;}
<DYNARE_STATEMENT>nonlinear_filter_initialization {return token::NONLINEAR_FILTER_INITIALIZATION;}
<DYNARE_STATEMENT>proposal_approximation {return token::PROPOSAL_APPROXIMATION;}
<DYNARE_STATEMENT>cubature {return token::CUBATURE;}
<DYNARE_STATEMENT>unscented {return token::UNSCENTED;}
@ -464,6 +469,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
yylval->string_val = new string(yytext);
return token::ABAND;
}
<DYNARE_STATEMENT>write_equation_tags {return token::WRITE_EQUATION_TAGS;}
<DYNARE_STATEMENT>indxap {return token::INDXAP;}
<DYNARE_STATEMENT>apband {return token::APBAND;}
<DYNARE_STATEMENT>indximf {return token::INDXIMF;}
@ -577,6 +583,18 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>parameter_set {return token::PARAMETER_SET; }
<DYNARE_STATEMENT>init_state {return token::INIT_STATE; }
<DYNARE_STATEMENT>save_realtime {return token::SAVE_REALTIME;}
<DYNARE_STATEMENT>detail_plot {return token::DETAIL_PLOT;}
<DYNARE_STATEMENT>interactive {return token::INTERACTIVE;}
<DYNARE_STATEMENT>screen_shocks {return token::SCREEN_SHOCKS;}
<DYNARE_STATEMENT>steadystate {return token::STEADYSTATE;}
<DYNARE_STATEMENT>type {return token::TYPE;}
<DYNARE_STATEMENT>qoq {return token::QOQ; }
<DYNARE_STATEMENT>yoy {return token::YOY; }
<DYNARE_STATEMENT>aoa {return token::AOA; }
<DYNARE_STATEMENT>fig_name {return token::FIG_NAME;}
<DYNARE_STATEMENT>write_xls {return token::WRITE_XLS;}
<DYNARE_STATEMENT>realtime {return token::REALTIME;}
<DYNARE_STATEMENT>vintage {return token::VINTAGE;}
<DYNARE_STATEMENT>prior_mode {return token::PRIOR_MODE; }
<DYNARE_STATEMENT>prior_mean {return token::PRIOR_MEAN; }
<DYNARE_STATEMENT>posterior_mode {return token::POSTERIOR_MODE; }

View File

@ -277,6 +277,19 @@ ModFile::checkPass(bool nostrict)
|| 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;
if (linear &&
(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 have declared your model 'linear' but you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which potentially makes it non-linear." << endl;
// Test if some estimated parameters are used within the values of shocks
// statements (see issue #469)
set<int> parameters_intersect;

View File

@ -1529,7 +1529,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &basename,
}
void
ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output_type) const
ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags) const
{
ofstream output, content_output;
string filename = basename + ".tex";
@ -1573,8 +1573,31 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
for (int eq = 0; eq < (int) equations.size(); eq++)
{
content_output << "\\begin{dmath}" << endl
<< "% Equation " << eq+1 << endl;
content_output << "% Equation " << eq + 1 << endl;
bool wrote_eq_tag = false;
if (write_equation_tags)
{
for (vector<pair<int,pair<string,string> > >::const_iterator iteqt = equation_tags.begin();
iteqt != equation_tags.end(); iteqt++)
if (iteqt->first == eq)
{
if (!wrote_eq_tag)
content_output << "\\noindent[";
else
content_output << ", ";
content_output << iteqt->second.first;
if (!empty(iteqt->second.second))
content_output << "= `" << iteqt->second.second << "'";
wrote_eq_tag = true;
}
}
if (wrote_eq_tag)
content_output << "]";
content_output << "\\begin{dmath}" << endl;
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(content_output, output_type);
content_output << endl << "\\end{dmath}" << endl;

View File

@ -196,7 +196,7 @@ protected:
void compileModelEquations(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, const map_idx_t &map_idx, bool dynamic, bool steady_dynamic) const;
//! Writes LaTeX model file
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type) const;
void writeLatexModelFile(const string &basename, ExprNodeOutputType output_type, const bool write_equation_tags = false) const;
//! Sparse matrix of double to store the values of the Jacobian
/*! First index is equation number, second index is endogenous type specific ID */

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2016 Dynare Team
* Copyright (C) 2003-2017 Dynare Team
*
* This file is part of Dynare.
*
@ -279,8 +279,6 @@ HistValStatement::HistValStatement(const hist_values_t &hist_values_arg,
void
HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
{
mod_file_struct.histval_present = true;
if (all_values_required)
{
set<int> unused_endo = symbol_table.getEndogenous();

View File

@ -1993,9 +1993,9 @@ ParsingDriver::discretionary_policy()
}
void
ParsingDriver::write_latex_dynamic_model()
ParsingDriver::write_latex_dynamic_model(bool write_equation_tags)
{
mod_file->addStatement(new WriteLatexDynamicModelStatement(mod_file->dynamic_model));
mod_file->addStatement(new WriteLatexDynamicModelStatement(mod_file->dynamic_model, write_equation_tags));
}
void
@ -2163,6 +2163,22 @@ ParsingDriver::realtime_shock_decomposition()
options_list.clear();
}
void
ParsingDriver::plot_shock_decomposition()
{
mod_file->addStatement(new PlotShockDecompositionStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
void
ParsingDriver::initial_condition_decomposition()
{
mod_file->addStatement(new InitialConditionDecompositionStatement(symbol_list, options_list));
symbol_list.clear();
options_list.clear();
}
void
ParsingDriver::conditional_forecast()
{
@ -2255,7 +2271,7 @@ ParsingDriver::declare_and_init_model_local_variable(string *name, expr_t rhs)
// It can have already been declared in a steady_state_model block, check that it is indeed a ModelLocalVariable
symb_id = mod_file->symbol_table.getID(*name);
if (mod_file->symbol_table.getType(symb_id) != eModelLocalVariable)
error(*name + " has wrong type, you cannot use it within as left-hand side of a pound ('#') expression");
error(*name + " has wrong type or was already used on the right-hand side. You cannot use it on the left-hand side of a pound ('#') expression");
}
try
@ -2856,6 +2872,13 @@ ParsingDriver::process_graph_format_option()
graph_formats.clear();
}
void
ParsingDriver::plot_shock_decomp_process_graph_format_option()
{
options_list.symbol_list_options["plot_shock_decomp.graph_format"] = graph_formats;
graph_formats.clear();
}
void
ParsingDriver::model_diagnostics()
{

View File

@ -565,7 +565,7 @@ public:
//! Discretionary policy statement
void discretionary_policy();
//! Adds a write_latex_dynamic_model statement
void write_latex_dynamic_model();
void write_latex_dynamic_model(bool write_equation_tags);
//! Adds a write_latex_static_model statement
void write_latex_static_model();
//! Adds a write_latex_original_model statement
@ -598,6 +598,10 @@ public:
void shock_decomposition();
//! Realtime Shock decomposition
void realtime_shock_decomposition();
//! Plot Shock decomposition
void plot_shock_decomposition();
//! Initial Condition decomposition
void initial_condition_decomposition();
//! Conditional forecast statement
void conditional_forecast();
//! Conditional forecast paths block
@ -730,6 +734,8 @@ public:
void add_graph_format(const string &name);
//! Add the graph_format option to the OptionsList structure
void process_graph_format_option();
//! Add the graph_format option to the plot_shock_decomp substructure of the OptionsList structure
void plot_shock_decomp_process_graph_format_option();
//! Model diagnostics
void model_diagnostics();
//! Processing the parallel_local_files option

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2015 Dynare Team
* Copyright (C) 2006-2017 Dynare Team
*
* This file is part of Dynare.
*
@ -40,7 +40,6 @@ ModFileStructure::ModFileStructure() :
identification_present(false),
estimation_analytic_derivation(false),
partial_information(false),
histval_present(false),
k_order_solver(false),
calibrated_measurement_errors(false),
dsge_prior_weight_in_estimated_params(false),

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2016 Dynare Team
* Copyright (C) 2006-2017 Dynare Team
*
* This file is part of Dynare.
*
@ -72,9 +72,6 @@ public:
bool estimation_analytic_derivation;
//! Whether the option partial_information is given to stoch_simul/estimation/osr/ramsey_policy
bool partial_information;
//! Whether a histval bloc is present
/*! Used for the workaround for trac ticket #157 */
bool histval_present;
//! Whether the "k_order_solver" option is used (explictly, or implicitly if order >= 3)
bool k_order_solver;
//! Whether there is a calibrated measurement error

View File

@ -12,6 +12,8 @@ MODFILES = \
observation_trends_and_prefiltering/MCMC/Trend_loglin_prefilt_first_obs_MC.mod \
observation_trends_and_prefiltering/MCMC/Trend_prefilter_MC.mod \
observation_trends_and_prefiltering/MCMC/Trend_prefilter_first_obs_MC.mod \
dates/dseries_interact.mod \
dates/fs2000.mod \
estimation/slice/fs2000_slice.mod \
optimizers/fs2000_9.mod \
optimizers/fs2000_10.mod \
@ -339,6 +341,10 @@ MODFILES = \
observation_trends_and_prefiltering/calib_smoother/Tr_prefil_f_obs_loglin_cal_smoother.mod \
observation_trends_and_prefiltering/ML/Trend_no_prefilter_selected_var.mod
PARTICLEFILES = \
particle/dsge_base2.mod \
particle/dsge_unit_root.mod
XFAIL_MODFILES = ramst_xfail.mod \
estim_param_in_shock_value_xfail.mod \
@ -695,6 +701,10 @@ gradient: m/gradient o/gradient
m/gradient: $(patsubst %.mod, %.m.trs, $(filter gradient/%.mod, $(MODFILES)))
o/gradient: $(patsubst %.mod, %.o.trs, $(filter gradient/%.mod, $(MODFILES)))
particle: m/particle o/particle
m/particle: $(patsubst %.mod, %.m.trs, $(PARTICLEFILES))
o/particle: $(patsubst %.mod, %.o.trs, $(PARTICLEFILES))
# Matlab TRS Files
M_TRS_FILES = $(patsubst %.mod, %.m.trs, $(MODFILES))
M_TRS_FILES += run_block_byte_tests_matlab.m.trs run_reporting_test_matlab.m.trs run_all_unitary_tests.m.trs
@ -711,8 +721,6 @@ M_TLS_FILES = $(patsubst %.m, %.m.tls, $(MFILES))
# Octave TLS Files
O_TLS_FILES = $(patsubst %.m, %.o.tls, $(MFILES))
EXTRA_DIST = \
read_trs_files.sh \
run_test_matlab.m \
@ -745,6 +753,7 @@ EXTRA_DIST = \
AIM/fsdat.m \
block_bytecode/run_ls2003.m \
bvar_a_la_sims/bvar_sample.m \
dates/fsdat_simul.m \
external_function/extFunDeriv.m \
external_function/extFunNoDerivs.m \
external_function/extFunWithFirstAndSecondDerivs.m \

View File

@ -71,7 +71,9 @@ del = 0.02;
options_.TeX=1;
model;
[name='technology growth: $\Delta A_{t}$', eq='\#1']
dA = exp(gam+e_a);
[name='money supply rule']
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
@ -82,8 +84,11 @@ c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
[name='Production function']
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
[name='observed output growth']
gy_obs = dA*y/y(-1);
[name='observed inflation']
gp_obs = (P/P(-1))*m(-1)/dA;
end;
@ -134,7 +139,7 @@ stoch_simul(order=1,irf=20,graph_format=eps,periods=0,contemporaneous_correlatio
write_latex_original_model;
write_latex_static_model;
write_latex_dynamic_model;
write_latex_dynamic_model(write_equation_tags);
write_latex_parameter_table;
write_latex_definitions;

View File

@ -0,0 +1,57 @@
%% Mod-file tests interaction between estimation and shock_decomposition when dseries is used or not
var hh nn log_nn;
varexo eps_a;
parameters alfa nbar lambda betta rho_a std_a nn_init;
nn_init = -0.1;
alfa = 0.05;
lambda = 0.054;
betta = 0.99;
nbar = 1;
rho_a = 0;
std_a = 1;
model(linear);
hh = - alfa * nn + betta * ( hh(+1) + 0 * eps_a(+1) ) + eps_a;
log_nn = log_nn(-1) + hh * lambda / (1-lambda);
log_nn = ln(nbar) + nn;
end;
steady_state_model;
log_nn = log(nbar);
nn = 0;
hh = 0;
end;
shocks;
var eps_a; stderr 1;
end;
estimated_params;
alfa, beta_pdf, 0.1, 0.05;
std_a, inv_gamma_pdf, 0.05, 1;
end;
varobs log_nn;
if ~isoctave() && ~matlab_ver_less_than('8.4')
websave('data_uav.xlsx','http://www.dynare.org/Datasets/data_uav.xlsx', weboptions('Timeout', 30))
else
urlwrite('http://www.dynare.org/Datasets/data_uav.xlsx','data_uav.xlsx')
end
%reading Excel sheet from column A on creates quarterly dseries starting in
%1950
estimation(first_obs=2,datafile=data_uav, xls_sheet=Tabelle1, xls_range=a1:b54, mh_replic=2, mh_nblocks=1, mh_jscale=1.1, mh_drop=0.8, plot_priors=0, smoother) log_nn nn hh ;
shock_decomposition( parameter_set=posterior_median ) nn hh;
%reading Excel sheet from column B on creates annual dseries starting with 1
estimation(first_obs=2,datafile=data_uav, xls_sheet=Tabelle1, xls_range=b1:b54, mh_replic=2, mh_nblocks=1, mh_jscale=1.1, mh_drop=0.8, plot_priors=0, smoother) log_nn nn hh ;
shock_decomposition( parameter_set=posterior_median ) nn hh;
delete('data_uav.xlsx')

View File

@ -1,12 +1,8 @@
// See fs2000.mod in the examples/ directory for details on the model
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
set_time(1950Q1);
alp = 0.33;
bet = 0.99;
gam = 0.003;
@ -79,19 +75,18 @@ stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
// List the observed variables.
varobs gp_obs gy_obs;
options_.solve_tolf = 1e-12;
//data(file=fsdat_simul, first_obs=1950Q3, last_obs=1998Q1);
// Instantiate a dseries object from an m file. Note that the dseries object has more than two variables.
ts = dseries('fsdat_simul.m');
rr = 1950Q3:(1950Q1+ts.nobs);
nn = length(rr);
ds = ts(rr);
ds.save('fsdat_simul2','m');
estimation(order=1,datafile=fsdat_simul2,loglinear,mh_replic=0);
// Load directly the dseries object as data for the estimation. The declared observed variables must be in the dseries object ts.
data(series=ts, first_obs=1950Q3, last_obs=2000Q3);
// Print the first date of the sample.
disp('First date is $1950Q3') // disp('First date is 1950Q3'), without the $ symbol, would trigger an error because of the substitution of 1950Q3 by dates('1950Q3')
// Run the estimation. Note that we do not have a datafile option, because of the data command used above.
estimation(order=1, loglinear, mh_replic=0);
disp('First date is $1950Q3')
// disp('Last date is 2000Q1') // This line would trigger an error because of the substitution of 2000Q1 by dates('2000Q1')

View File

@ -1,27 +1,51 @@
// This file deals with the resolution and estimation of a basic DSGE model with
//employment for comparison with the benchmark in Gauss which solves with
//the same particular filter but global methodology.
//
// Juin 2015
// DGP
@#ifndef RISKY_CALIBRATION
@#define RISKY_CALIBRATION = 0
@#endif
@#ifndef EXTREME_CALIBRATION
@#define EXTREME_CALIBRATION = 1
@#endif
@#ifndef BENCHMARK_CALIBRATION
@#define BENCHMARK_CALIBRATION = 0
@#endif
// ALGORITHM
@#define LINEAR_KALMAN = 1
@#ifndef LINEAR_KALMAN
@#define LINEAR_KALMAN = 0
@#endif
@#ifndef ALGO_SIR
@#define ALGO_SIR = 0
@#endif
@#ifndef ALGO_SISmoothR
@#define ALGO_SISmoothR = 0
@#endif
@#ifndef ALGO_APF
@#define ALGO_APF = 0
@#endif
@#ifndef ALGO_GPF
@#define ALGO_GPF = 0
@#endif
@#ifndef ALGO_GCF
@#define ALGO_GCF = 0
@#define ALGO_GUF = 0
@#endif
@#ifndef ALGO_GUF
@#define ALGO_GUF = 1
@#endif
@#ifndef ALGO_GMPF
@#define ALGO_GMPF = 0
@#endif
@#ifndef ALGO_GMCF
@#define ALGO_GMCF = 0
@#endif
@#ifndef ALGO_ONLINE_1
@#define ALGO_ONLINE_1 = 0
@#endif
@#ifndef ALGO_ONLINE_2
@#define ALGO_ONLINE_2 = 0
@#endif
@#ifndef MCMC
@#define MCMC = 0
@#endif
var k A c l i y;
varexo e_a;
@ -164,7 +188,9 @@ options_.mode_check.number_of_points = 250;
estimation(order=1,number_of_particles=1000,mode_compute=11);
@#endif
options_.mh_nblck = 10 ;
options_.posterior_sampling_method = 'RWGMH';
options_.rwgmh_scale_shock = (1e-5)*[10 10 1 1 10 10 10 1000 10 10] ;
estimation(order=1,mh_replic=5000,mode_compute=0,mode_file=dsge_base2_mode);
@#if MCMC
options_.mh_nblck = 10 ;
options_.posterior_sampling_method = 'RWGMH';
options_.rwgmh_scale_shock = (1e-5)*[10 10 1 1 10 10 10 1000 10 10] ;
estimation(order=1,mh_replic=5000,mode_compute=0,mode_file=dsge_base2_mode);
@#endif

View File

@ -0,0 +1,221 @@
// DGP
@#ifndef RISKY_CALIBRATION
@#define RISKY_CALIBRATION = 0
@#endif
@#ifndef EXTREME_CALIBRATION
@#define EXTREME_CALIBRATION = 1
@#endif
@#ifndef BENCHMARK_CALIBRATION
@#define BENCHMARK_CALIBRATION = 0
@#endif
// ALGORITHM
@#ifndef LINEAR_KALMAN
@#define LINEAR_KALMAN = 0
@#endif
@#ifndef ALGO_SIR
@#define ALGO_SIR = 0
@#endif
@#ifndef ALGO_SISmoothR
@#define ALGO_SISmoothR = 0
@#endif
@#ifndef ALGO_APF
@#define ALGO_APF = 0
@#endif
@#ifndef ALGO_GPF
@#define ALGO_GPF = 0
@#endif
@#ifndef ALGO_GCF
@#define ALGO_GCF = 0
@#endif
@#ifndef ALGO_GUF
@#define ALGO_GUF = 1
@#endif
@#ifndef ALGO_GMPF
@#define ALGO_GMPF = 0
@#endif
@#ifndef ALGO_GMCF
@#define ALGO_GMCF = 0
@#endif
@#ifndef ALGO_ONLINE_1
@#define ALGO_ONLINE_1 = 0
@#endif
@#ifndef ALGO_ONLINE_2
@#define ALGO_ONLINE_2 = 0
@#endif
@#ifndef MCMC
@#define MCMC = 0
@#endif
var k A c l i y;
varexo e_a;
parameters alp bet tet tau delt rho ;
alp = 0.4;
bet = 0.99;
tet = 0.357 ;
tau = 50 ;
delt = 0.02;
rho = 1.0;
model;
c = ((1 - alp)*tet/(1-tet))*A*(1-l)*((k(-1)/l)^alp) ;
y = A*(k(-1)^alp)*(l^(1-alp)) ;
i = y-c ;
k = (1-delt)*k(-1) + i ;
log(A) = rho*log(A(-1)) + e_a ;
(((c^(tet))*((1-l)^(1-tet)))^(1-tau))/c - bet*((((c(+1)^(tet))*((1-l(+1))^(1-tet)))^(1-tau))/c(+1))*(1 -delt+alp*(A(1)*(k^alp)*(l(1)^(1-alp)))/k)=0 ;
end;
shocks;
var e_a; stderr 0.035;
end;
steady(nocheck);
stoch_simul(periods=5000, irf=0, noprint);
@#if EXTREME_CALIBRATION
verbatim;
y = y + randn(size(y))*.0175;
l = l + randn(size(l))*.00312;
i = i + randn(size(i))*.00465;
end;
ds = dseries([y, l, i, c, A], 1900Q1, {'y'; 'l'; 'i'; 'c'; 'A'});
@#endif
@#if RISKY_CALIBRATION
verbatim;
y = y + randn(size(y))*.00158;
l = l + randn(size(l))*.0011;
i = i + randn(size(i))*.000866;
end;
ds = dseries([y, l, i, c, A], 1900Q1, {'y'; 'l'; 'i'; 'c'; 'A'});
@#endif
@#if BENCHMARK_CALIBRATION
// TODO: This section is to be completed (measurement are missing)
ds = dseries([y, l, i, c, A], 1900Q1, {'y'; 'l'; 'i'; 'c'; 'A'});
@#endif
estimated_params;
alp, uniform_pdf,,, 0.0001, 0.99;
bet, uniform_pdf,,, 0.0001, 0.99999;
tet, uniform_pdf,,, 0.0001, .999;
tau, uniform_pdf,,, 0.0001, 100;
delt, uniform_pdf,,, 0.0001, 0.05;
stderr e_a, uniform_pdf,,, 0.00001, 0.1;
stderr y, uniform_pdf,,, 0.00001, 0.1;
stderr l, uniform_pdf,,, 0.00001, 0.1;
stderr i, uniform_pdf,,, 0.00001, 0.1;
end;
@#if RISKY_CALIBRATION
estimated_params_init;
alp, 0.4;
bet, 0.99;
tet, 0.357;
tau, 50;
delt, 0.02;
stderr e_a, .035;
stderr y, .00158;
stderr l, .0011;
stderr i, .000866;
end;
@#endif
@#if EXTREME_CALIBRATION
estimated_params_init;
alp, 0.4;
bet, 0.99;
tet, 0.357;
tau, 50;
delt, 0.02;
stderr e_a, .035;
stderr y, .0175;
stderr l, .00312;
stderr i, .00465;
end;
@#endif
varobs y l i ;
options_.mode_check.neighbourhood_size = .01 ;
options_.mode_check.number_of_points = 250;
//options_.particle.initialization = 3;
@#if EXTREME_CALIBRATION
data(series=ds, nobs=200, first_obs=1973Q1);
@#endif
@#if RISKY_CALIBRATION
data(series=ds, nobs=200, first_obs=1973Q1);
@#endif
@#if BENCHMARK_CALIBRATION
data(series=ds, nobs = 200, first_obs=1973Q1);
@#endif
@#if LINEAR_KALMAN
% estimation(nograph,order=1,mode_compute=8,mh_replic=0,mode_check);
@#endif
@#if ALGO_SIR
estimation(order=2,nonlinear_filter_initialization=3,nograph,number_of_particles=1000,mh_replic=0,mode_compute=8,mode_check);
@#endif
@#if ALGO_SISmoothR
estimation(order=2,nonlinear_filter_initialization=3,nograph,number_of_particles=1000,resampling_method=smooth,mode_compute=8,mh_replic=0);
estimation(order=2,nonlinear_filter_initialization=3,nograph,number_of_particles=1000,resampling_method=smooth,mode_compute=8,mode_file=dsge_unit_root_mode,mh_replic=0);
estimation(order=2,nonlinear_filter_initialization=3,nograph,number_of_particles=1000,resampling_method=smooth,mode_compute=4,mode_file=dsge_unit_root_mode,mh_replic=0,mode_check);
@#endif
@#if ALGO_APF
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=apf,number_of_particles=1000,mh_replic=0,mode_compute=8,mode_check);
@#endif
@#if ALGO_GPF
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,distribution_approximation=montecarlo,number_of_particles=1000,mh_replic=0,mode_compute=8);
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,distribution_approximation=montecarlo,number_of_particles=1000,mode_file=dsge_unit_root_mode,mh_replic=0,mode_compute=4,mode_check);
@#endif
@#if ALGO_GCF
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,mh_replic=0,mode_compute=8);
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,mh_replic=0,mode_compute=4,mode_file=dsge_unit_root_mode,mode_check);
@#endif
@#if ALGO_GUF
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,proposal_approximation=unscented,distribution_approximation=unscented,mh_replic=0,mode_compute=4);
estimation(order=2,nonlinear_filter_initialization=3,nograph,filter_algorithm=gf,proposal_approximation=unscented,distribution_approximation=unscented,mode_file=dsge_unit_root_mode,mh_replic=0,mode_compute=8,mode_check);
@#endif
@#if ALGO_GMPF
estimation(nograph,order=2,nonlinear_filter_initialization=3,filter_algorithm=gmf,distribution_approximation=montecarlo,number_of_particles=1000,mh_replic=0,mode_compute=8);
estimation(nograph,order=2,nonlinear_filter_initialization=3,filter_algorithm=gmf,distribution_approximation=montecarlo,number_of_particles=1000,mh_replic=0,mode_file=dsge_unit_root_mode,mode_compute=8);
estimation(nograph,order=2,nonlinear_filter_initialization=3,filter_algorithm=gmf,distribution_approximation=montecarlo,number_of_particles=1000,mh_replic=0,mode_file=dsge_unit_root_mode,mode_compute=4,mode_check);
@#endif
@#if ALGO_GMCF
estimation(nograph,order=2,nonlinear_filter_initialization=3,filter_algorithm=gmf,mh_replic=0,mode_compute=8);
estimation(nograph,order=2,nonlinear_filter_initialization=3,filter_algorithm=gmf,mh_replic=0,mode_compute=4,mode_file=dsge_unit_root_mode,mode_check);
@#endif
@#if ALGO_ONLINE_2
options_.particle.liu_west_delta = 0.9 ;
estimation(order=2,number_of_particles=1000,mode_compute=11);
@#endif
@#if ALGO_ONLINE_1
options_.particle.liu_west_delta = 0.9 ;
estimation(order=1,number_of_particles=1000,mode_compute=11);
@#endif
@#if MCMC
options_.mh_nblck = 10 ;
options_.posterior_sampling_method = 'RWGMH';
options_.rwgmh_scale_shock = (1e-5)*[10 10 1 1 10 10 10 1000 10 10] ;
estimation(order=1,mh_replic=5000,mode_compute=0,mode_file=dsge_base2_mode);
@#endif

View File

@ -81,13 +81,11 @@ shock_decomposition(use_shock_groups=trade) y_obs R_obs pie_obs dq de;
// various tests for plot_shock_decompositions
// standard plot [using trade group defined before]
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition;
// test datailed, custom name and yoy plots
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.fig_names = 'MR';
options_.shock_decomp.type='yoy';
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(detail_plot, fig_name = MR, type = yoy);
close all,
@ -96,80 +94,42 @@ close all,
// first compute realtime decompositions [pre-processor not yet available]
realtime_shock_decomposition(forecast=8, save_realtime=[5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77]);
options_.shock_decomp.detail_plot = 0;
options_.shock_decomp.type='';
options_.use_shock_groups='';
options_.shock_decomp.fig_names = '';
//realtime pooled
options_.shock_decomp.realtime=1;
options_.shock_decomp.vintage=0;
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(realtime = 1);
//conditional pooled
options_.shock_decomp.realtime=2;
plot_shock_decomposition(M_,oo_,options_,var_list_);
options_.shock_decomp.realtime=2;
plot_shock_decomposition(realtime = 2);
// conditional 8-step ahead decomposition, given 1989q4
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.vintage=29;
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(detail_plot, realtime = 2, vintage = 29);
close all,
//forecast pooled
options_.shock_decomp.detail_plot = 0;
options_.shock_decomp.realtime=3;
options_.shock_decomp.vintage=0;
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(realtime = 3);
// forecast 8-step ahead decomposition, given 1989q4
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.realtime=3;
options_.shock_decomp.vintage=29;
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(detail_plot, realtime = 3, vintage = 29);
close all,
// now I test annualized variables
options_.shock_decomp.realtime=0;
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.interactive=0;
options_.use_shock_groups='';
options_.shock_decomp.type='aoa';
options_.shock_decomp.q2a=1;
options_.shock_decomp.islog=1;
plot_shock_decomposition(M_,oo_,options_,'y');
options_.plot_shock_decomp.q2a=1;
options_.plot_shock_decomp.islog=1;
plot_shock_decomposition(detail_plot, type = aoa) y;
options_.shock_decomp.realtime=1;
options_.shock_decomp.vintage=0;
plot_shock_decomposition(M_,oo_,options_,'y');
options_.shock_decomp.vintage=29;
options_.shock_decomp.realtime=1;
plot_shock_decomposition(M_,oo_,options_,'y');
options_.shock_decomp.realtime=2;
plot_shock_decomposition(M_,oo_,options_,'y');
options_.shock_decomp.realtime=3;
plot_shock_decomposition(M_,oo_,options_,'y');
plot_shock_decomposition(realtime = 1) y;
plot_shock_decomposition(realtime = 1, vintage = 29) y;
plot_shock_decomposition(realtime = 2, vintage = 29) y;
plot_shock_decomposition(realtime = 3, vintage = 29) y;
close all
//test uimenu for groups
options_.shock_decomp.realtime=0;
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.interactive=1;
options_.use_shock_groups='row';
options_.shock_decomp.type='qoq';
plot_shock_decomposition(M_,oo_,options_,var_list_);
options_.shock_decomp.detail_plot = 1;
options_.shock_decomp.realtime=3;
options_.shock_decomp.vintage=29;
plot_shock_decomposition(M_,oo_,options_,var_list_);
plot_shock_decomposition(detail_plot, interactive, use_shock_groups = row, type = qoq);
plot_shock_decomposition(detail_plot, interactive, realtime = 3, vintage = 29);
collect_latex_files;
if system(['pdflatex -halt-on-error -interaction=batchmode ' M_.fname '_TeX_binder.tex'])
error('TeX-File did not compile.')
end
end