Commit 0262f26d authored by Houtan Bastani's avatar Houtan Bastani
Browse files

Merge branch 'master' into dmm

Conflicts:
	preprocessor/DynareBison.yy
parents e9ab56d5 811877aa
......@@ -10,3 +10,14 @@
[submodule "contrib/dmm"]
path = contrib/dmm
url = http://www.dynare.org/git/dmm.git
[submodule "matlab/utilities/tests"]
path = matlab/utilities/tests
url = https://github.com/DynareTeam/m-unit-tests.git
[submodule "matlab/modules/dates"]
path = matlab/modules/dates
url = https://github.com/DynareTeam/dates.git
branch = old-oop-syntax
[submodule "matlab/modules/dseries"]
path = matlab/modules/dseries
url = https://github.com/DynareTeam/dseries.git
branch = old-oop-style
TZcode @ 4be47034
Subproject commit b642763676536c148ad827a0286862be87c5ae8e
Subproject commit 4be470341a73bb22d58bb0d930ff624a5bf1a7f6
......@@ -356,8 +356,8 @@ 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 (JRC)
and Sébastien Villemot (Cepremap).
Perendia, Johannes Pfeifer (University of Mannheim), 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
support is provided by Cepremap, Banque de France and DSGE-net (an
......@@ -3599,6 +3599,9 @@ Threshold size for plotting IRFs. All IRFs for a particular variable with a maxi
@item nocorr
Don't print the correlation matrix (printing them is the default).
@item nodecomposition
Don't compute (and don't print) unconditional variance decomposition.
@item nofunctions
Don't print the coefficients of the approximated solution (printing
them is the default).
......@@ -3707,7 +3710,7 @@ period(s). The periods must be strictly positive. Conditional variances are give
decomposition provides the decomposition of the effects of shocks upon
impact. The results are stored in
@code{oo_.conditional_variance_decomposition}
(@pxref{oo_.conditional_variance_decomposition}). The variance decomposition is only conducted, if theoretical moments are requested, i.e. using the @code{periods=0}-option. In case of @code{order=2}, Dynare provides a second-order accurate approximation to the true second moments based on the linear terms of the second-order solution (see @cite{Kim, Kim, Schaumburg and Sims (2008)}). Note that the unconditional variance decomposition (i.e. at horizon infinity) is automatically conducted if theoretical moments are requested (@pxref{oo_.variance_decomposition})
(@pxref{oo_.conditional_variance_decomposition}). The variance decomposition is only conducted, if theoretical moments are requested, i.e. using the @code{periods=0}-option. In case of @code{order=2}, Dynare provides a second-order accurate approximation to the true second moments based on the linear terms of the second-order solution (see @cite{Kim, Kim, Schaumburg and Sims (2008)}). Note that the unconditional variance decomposition (i.e. at horizon infinity) is automatically conducted if theoretical moments are requested and if @code{nodecomposition} is not set (@pxref{oo_.variance_decomposition})
@item pruning
Discard higher order terms when iteratively computing simulations of
......@@ -4615,7 +4618,7 @@ The name of the sheet with the data in an Excel file
@item xls_range = @var{RANGE}
@anchor{xls_range}
The range with the data in an Excel file
The range with the data in an Excel file. For example, @code{xls_range=B2:D200}
@item nobs = @var{INTEGER}
@anchor{nobs}
......@@ -5158,13 +5161,14 @@ See below.
@item filter_step_ahead = [@var{INTEGER1} @var{INTEGER2} @dots{}]
@anchor{filter_step_ahead}
Triggers the computation k-step ahead filtered values. Stores results in
Triggers the computation k-step ahead filtered values, i.e. @math{E_{t}{y_{t+k}}}. Stores results in
@code{oo_.FilteredVariablesKStepAhead} and
@code{oo_.FilteredVariablesKStepAheadVariances}.
@item filter_decomposition
@anchor{filter_decomposition} Triggers the computation of the shock
decomposition of the above k-step ahead filtered values.
decomposition of the above k-step ahead filtered values. Stores results in @code{oo_.FilteredVariablesShockDecomposition}.
@item diffuse_filter
Uses the diffuse Kalman filter (as described in
......@@ -5183,8 +5187,9 @@ any value of @math{\bar a} of @math{a} is a deterministic steady state for pro
Note that the nonstationary variables in the model must be integrated processes (their first difference or k-difference must be stationary).
@item selected_variables_only
@anchor{selected_variables_only}
Only run the smoother on the variables listed just after the
@code{estimation} command. Default: run the smoother on all the
@code{estimation} command. This options is incompatible with requesting classical frequentist forecasts and will be overridden in this case. Default: run the smoother on all the
declared endogenous variables.
@item cova_compute = @var{INTEGER}
......@@ -5483,6 +5488,7 @@ After an estimation without Metropolis, fields are of the form:
@code{oo_.FilteredVariables.@var{VARIABLE_NAME}}
@end example
After an estimation with Metropolis, fields are of the form:
@example
@code{oo_.FilteredVariables.@var{MOMENT_NAME}.@var{VARIABLE_NAME}}
......@@ -5491,12 +5497,23 @@ After an estimation with Metropolis, fields are of the form:
@defvr {MATLAB/Octave variable} oo_.FilteredVariablesKStepAhead
Variable set by the @code{estimation} command, if it is used with the
@code{filter_step_ahead} option. The k-steps are stored along the rows while the columns indicate the respective variables. The third dimension of the array provides the observation for which the forecast has been made. For example, if @code{filter_step_ahead=[1 2 4]} and @code{nobs=200}, the element (3,5,204) stores the four period ahead filtered value of variable 5 computed at time t=200 for time t=204. The periods at the beginning and end of the sample for which no forecasts can be made, e.g. entries (1,5,1) and (1,5,204) in the example, are set to zero.
@code{filter_step_ahead} option. The k-steps are stored along the rows while the columns
indicate the respective variables. The third dimension of the array provides the
observation for which the forecast has been made. For example, if @code{filter_step_ahead=[1 2 4]}
and @code{nobs=200}, the element (3,5,204) stores the four period ahead filtered
value of variable 5 computed at time t=200 for time t=204. The periods at the beginning
and end of the sample for which no forecasts can be made, e.g. entries (1,5,1) and
(1,5,204) in the example, are set to zero. Note that in case of Bayesian estimation
the variables will be ordered in the order of declaration after the estimation
command (or in general declaration order if no variables are specified here). In case
of running the classical smoother, the variables will always be ordered in general
declaration order. If the @xref{selected_variables_only} option is specified with the classical smoother,
non-requested variables will be simply left out in this order.
@end defvr
@defvr {MATLAB/Octave variable} oo_.FilteredVariablesKStepAheadVariances
Variable set by the @code{estimation} command, if it is used with the
@code{filter_step_ahead} option.
@code{filter_step_ahead} option. It is a 4 dimensional array where the k-steps are stored along the first dimension, while the fourth dimension of the array provides the observation for which the forecast has been made. The second and third dimension provide the respective variables. For example, if @code{filter_step_ahead=[1 2 4]} and @code{nobs=200}, the element (3,4,5,204) stores the four period ahead forecast error covariance between variable 4 and variable 5, computed at time t=200 for time t=204. Padding with zeros is analogous to @code{oo_.FilteredVariablesKStepAhead}.
@end defvr
@defvr {MATLAB/Octave variable} oo_.Filtered_Variables_X_step_ahead
......@@ -6402,7 +6419,7 @@ parameters in the @code{params}-command and be entered in the
@item
@math{e} are the exogenous stochastic shocks, specified in the
@code{var_exo}-command;
@code{varexo}-command;
@item
@math{W} is the weighting matrix;
......@@ -7137,7 +7154,7 @@ The threshold @math{pvalue} for significant Kolmogorov-Smirnov test (@i{i.e.} pl
@item pvalue_corr = @var{DOUBLE}
The threshold @math{pvalue} for significant correlation in filtered samples
(@i{i.e.} plot bivariate samples when @math{pvalue<} @code{pvalue_corr}). Default: @code{0.001}
(@i{i.e.} plot bivariate samples when @math{pvalue<} @code{pvalue_corr}). Default: @code{1e-5}
@end table
@customhead{Reduced Form Mapping Options}
......@@ -7166,7 +7183,7 @@ are filtered. Default: @code{0.1}
@item alpha2_redform = @var{DOUBLE}
Critical value for correlations @math{\rho} when reduced form entries
are filtered. Default: @code{0.3}
are filtered. Default: @code{1e-5}
@item namendo = (@var{VARIABLE_NAME}@dots{})
List of endogenous variables. `@code{:}' indicates all endogenous variables.
......@@ -7213,7 +7230,7 @@ Critical value for Smirnov statistics @math{d}: plot parameters with
@item alpha2_rmse = @var{DOUBLE}
Critical value for correlation @math{\rho}: plot couples of parmaters with
@math{\left|\rho\right|=} @code{alpha2_rmse}. Default: @code{1.0}
@math{\left|\rho\right|=} @code{alpha2_rmse}. Default: @code{1e-5}
@item datafile = @var{FILENAME}
@xref{datafile}.
......@@ -10236,6 +10253,31 @@ Overloads the Matlab/Octave @code{exp} function for @dseries objects.
@sp 1
@deftypefn{dseries} {@var{l} =} exist (@var{A}, @var{varname})
Tests if @var{variable} exists in @dseries object @var{A}. Returns 1 (true) iff @var{variable} exists in @var{A}.
@exampleshead
@example
>> ts = dseries(randn(100,1));
>> ts.exist('Variable_1')
ans =
1
>> ts.exist('Variable_2')
ans =
0
@end example
@end deftypefn
@sp 1
@deftypefn{dseries} {@var{C} =} extract (@var{A}, @var{B}[, ...])
Extracts some variables from a @dseries object @var{A} and returns a @dseries object @var{C}. The input arguments following @var{A} are strings representing the variables to be selected in the new @dseries object @var{C}. To simplify the creation of sub-objects, the @dseries class overloads the curly braces (@code{D = extract (A, B, C)} is equivalent to @code{D = A@{B,C@}}) and allows implicit loops (defined between a pair of @@ symbol, see examples below) or Matlab/Octave's regular expressions (introduced by square brackets).
......
......@@ -80,15 +80,17 @@ Copyright: 1995-2007 Kurt Hornik
2008-2009 Dynare Team
License: GPL-3+
Files: matlab/missing/bicgstab/bicgstab.m
Copyright: 2008 Radek Salac
License: GPL-3+
Files: matlab/missing/strjoin/strjoin.m
Copyright: 2007 Muthiah Annamalai <muthiah.annamalai@uta.edu>
2013 Dynare Team
License: GPL-3+
Files: matlab/missing/corrcoef/corrcoef.m matlab/missing/corrcoef/sumskipnan.m
matlab/missing/corrcoef/flag_implicit_skip_nan.m matlab/missing/corrcoef/tcdf.m
Copyright: 2000-2005,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
2014 Dynare Team
License: GPL-3+
Files: matlab/lmmcp/catstruct.m
Copyright: 2005 Jos van der Geest <jos@jasen.nl>
2013 Christophe Gouel
......
function B = append(A,a) % --*-- Unitary tests --*--
% append method for dates class.
%
% INPUTS
% o A dates object.
% o a dates object with one element or string that can be interpreted as a date.
%
% OUTPUTS
% o B dates object containing dates defined in A and a.
%
% EXAMPLE 1
% If A is a dates object with quarterly frequency, then B = A.append(dates('1950Q2')) and
% B = A.append('1950Q2') are equivalent syntaxes.
% Copyright (C) 2012-2013 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isa(a,'dates')
if ~isequal(length(a),1)
error(['dates::append: Input argument ' inputname(2) ' has to be a dates object with one element.'])
end
if isempty(a)
B = A;
return
end
elseif isdate(a)
a = dates(a);
end
if ~isequal(A.freq, a.freq)
error(['dates::append: A and a must have common frequency!'])
end
B = dates();
B.ndat = A.ndat+1;
B.freq = A.freq;
B.time = NaN(B.ndat,2);
B.time(1:A.ndat,:) = A.time;
B.time(A.ndat+1,:) = a.time;
%@test:1
%$ % Define some dates
%$ B1 = '1953Q4';
%$ B2 = '1950Q2';
%$ B3 = '1950Q1';
%$ B4 = '1945Q3';
%$ B5 = '2009Q2';
%$
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2,B1);
%$ d = d.append(dates(B5));
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ t(3) = dyn_assert(d.ndat,e.ndat);
%$ T = all(t);
%@eof:1
%@test:2
%$ % Define some dates
%$ B1 = '1953Q4';
%$ B2 = '1950Q2';
%$ B3 = '1950Q1';
%$ B4 = '1945Q3';
%$ B5 = '2009q2';
%$
%$ % Define expected results.
%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4; 2009 2];
%$ e.freq = 4;
%$ e.ndat = 5;
%$
%$ % Call the tested routine.
%$ d = dates(B4,B3,B2,B1);
%$ d = d.append(B5);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ t(3) = dyn_assert(d.ndat,e.ndat);
%$ T = all(t);
%@eof:2
\ No newline at end of file
function s = char(dd)
% Given a one element dates object, returns a string with the formatted date.
%
% INPUTS
% o dd dates object with one element
%
% OUTPUTS
% o s a string
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2014 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/>.
if length(dd)>1
error('The input argument must be a singleton dates object!')
end
s = date2string(dd.time, dd.freq);
\ No newline at end of file
function C = colon(varargin) % --*-- Unitary tests --*--
% Overloads the colon operator (:). This method can be used to create ranges of dates.
%
% INPUTS
% o A dates object with one element.
% o d integer scalar, number of periods between each date (default value, if nargin==2, is one)
% o B dates object with one element.
%
% OUTPUTS
% o C dates object with length(B-A) elements (if d==1).
%
% REMARKS
% B must be greater than A if d>0.
% Copyright (C) 2013 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if isequal(nargin,2)
A = varargin{1};
B = varargin{2};
d = 1;
if ~(isa(A,'dates') && isa(B,'dates') && isequal(length(A),1) && isequal(length(B),1))
error('dates::colon: In an expression like A:B, A and B must be dates objects!')
end
elseif isequal(nargin,3)
A = varargin{1};
B = varargin{3};
d = varargin{2};
if ~(isa(A,'dates') && isa(B,'dates') && isequal(length(A),1) && isequal(length(B),1))
error('dates::colon: In an expression like A:d:B, A and B must be dates objects and d a scalar integer (number of periods)!')
end
if ~(isscalar(d) && isint(d))
error('dates::colon: In an expression like A:d:B, A and B must be dates objects and d a scalar integer (number of periods)!')
end
if isequal(d,0)
error('dates::colon: In an expression like A:d:B, d (the incremental number of periods) must nonzero!')
end
else
error('dates::colon: Wrong calling sequence! See the manual for the colon (:) operator and dates objects.')
end
if ~isequal(A.freq,B.freq)
error(['dates::colon: Input arguments ' inputname(1) ' and ' inputname(2) ' must have common frequency!'])
end
if A>B && d>0
error(['dates::colon: ' inputname(1) ' must precede ' inputname(2) '!' ])
end
if B>A && d<0
error(['dates::colon: ' inputname(2) ' must precede ' inputname(1) '!' ])
end
C = dates();
n = (B-A)+1;
m = n;
if d>1
m = length(1:d:n);
end
C.freq = A.freq;
if isequal(C.freq,1)
C.ndat = m;
C.time = NaN(m,2);
C.time(:,1) = A.time(1)+transpose(0:d:n-1);
C.time(:,2) = 1;
else
C.time = NaN(n,2);
initperiods = min(C.freq-A.time(2)+1,n);
C.time(1:initperiods,1) = A.time(1);
C.time(1:initperiods,2) = transpose(A.time(2)-1+(1:initperiods));
if n>initperiods
p = n-initperiods;
if p<=C.freq
C.time(initperiods+(1:p),1) = A.time(1)+1;
C.time(initperiods+(1:p),2) = transpose(1:p);
else
q = fix(p/C.freq);
r = rem(p,C.freq);
C.time(initperiods+(1:C.freq*q),2) = repmat(transpose(1:C.freq),q,1);
C.time(initperiods+(1:C.freq*q),1) = kron(A.time(1)+transpose(1:q),ones(C.freq,1));
if r>0
C.time(initperiods+C.freq*q+(1:r),1) = C.time(initperiods+C.freq*q,1)+1;
C.time(initperiods+C.freq*q+(1:r),2) = transpose(1:r);
end
end
end
if d>1
C.time = C.time(1:d:n,:);
C.ndat = m;
else
C.ndat = n;
end
end
%@test:1
%$ % Define two dates
%$ date_1 = '1950Q2';
%$ date_2 = '1951Q4';
%$
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4];
%$
%$ % Call the tested routine.
%$ d1 = dates(date_1);
%$ d2 = dates(date_2);
%$ d3 = d1:d2;
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d3.time,e.time);
%$ t(2) = dyn_assert(d3.freq,e.freq);
%$ T = all(t);
%@eof:1
%@test:2
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4];
%$
%$ % Call the tested routine.
%$ d = dates('1950Q2'):dates('1951Q4');
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t);
%@eof:2
%@test:3
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 2; 1950 4; 1951 2; 1951 4];
%$
%$ % Call the tested routine.
%$ d = dates('1950Q2'):2:dates('1951Q4');
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t);
%@eof:3
%$ @test:3
%$ % Create an empty dates object for quaterly data
%$ qq = dates('Q');
%$
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4];
%$
%$ % Call the tested routine.
%$ d = qq(1950,2):qq(1951,4);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t);
%$ @eof:3
%$ @test:4
%$ % Create an empty dates object for quaterly data
%$ qq = dates('Q');
%$
%$ % Define expected results.
%$ e.freq = 4;
%$ e.time = [1950 1; 1950 2; 1950 3];
%$
%$ % Call the tested routine.
%$ d = qq(1950,1):qq(1950,3);
%$
%$ % Check the results.
%$ t(1) = dyn_assert(d.time,e.time);
%$ t(2) = dyn_assert(d.freq,e.freq);
%$ T = all(t);
%$ @eof:4
\ No newline at end of file
function dd = dates(varargin) % --*-- Unitary tests --*--
%@info:
%! @deftypefn {Function File} {@var{dd} =} dates (@var{a},@var{b},...)
%! @anchor{dates}
%! @sp 1
%! Constructor for the Dynare dates class (unordered sequence of dates).
%! @sp 2
%! @strong{Inputs}
%! @sp 1
%! @table @ @var
%! @item a
%! String, date.
%! @item b
%! @end table
%! @sp 2
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item dd
%! Dynare dates object.
%! @end table
%! @sp 1
%! @strong{Properties}
%! @sp 1
%! The constructor defines the following properties:
%! @sp 1
%! @table @ @var
%! @item ndate
%! Scalar integer, the number of dates.
%! @item freq
%! Scalar integer, the frequency of the time series. @var{freq} is equal to 1 if data are on a yearly basis or if
%! frequency is unspecified. @var{freq} is equal to 4 if data are on a quaterly basis. @var{freq} is equal to
%! 12 if data are on a monthly basis. @var{freq} is equal to 52 if data are on a weekly basis.
%! @item time
%! Array of integers (nobs*2). The first column defines the years associated to each date. The second column,
%! depending on the frequency, indicates the week, month or quarter numbers. For yearly data or unspecified frequency
%! the second column is filled by ones.
%! @end table
%! @sp 2
%! @strong{This function is called by:}
%! @sp 2
%! @strong{This function calls:}
%!
%! @end deftypefn
%@eod:
% Copyright (C) 2011-2014 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/>.
% Initialization.
if nargin>0 && ischar(varargin{1}) && isequal(varargin{1},'initialize')
dd = struct('ndat', 0, 'freq', NaN(0), 'time', NaN(0,2));
dd = class(dd,'dates');
assignin('base','emptydatesobject',dd);
return
end