diff --git a/.gitmodules b/.gitmodules
index 67e0b82edcab02f0c3949f500672dbba291522bc..3c608c798ab324f069ceb926299dae0ab48b624c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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
diff --git a/contrib/ms-sbvar/TZcode b/contrib/ms-sbvar/TZcode
index b642763676536c148ad827a0286862be87c5ae8e..4be470341a73bb22d58bb0d930ff624a5bf1a7f6 160000
--- a/contrib/ms-sbvar/TZcode
+++ b/contrib/ms-sbvar/TZcode
@@ -1 +1 @@
-Subproject commit b642763676536c148ad827a0286862be87c5ae8e
+Subproject commit 4be470341a73bb22d58bb0d930ff624a5bf1a7f6
diff --git a/doc/dynare.texi b/doc/dynare.texi
index 12ed8982f0f080429627dc562396ab23a9ea522a..be8d36ec5b2453554805314e497719605e189910 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -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).
diff --git a/license.txt b/license.txt
index 64f84a2d671869c19398249724b6fedf783b6586..27122feb62a644eb287fd64444356008477e6cd0 100644
--- a/license.txt
+++ b/license.txt
@@ -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
diff --git a/matlab/@dates/append.m b/matlab/@dates/append.m
deleted file mode 100644
index c818294ed6cb5e99d3b7041863f404d39d68f386..0000000000000000000000000000000000000000
--- a/matlab/@dates/append.m
+++ /dev/null
@@ -1,102 +0,0 @@
-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
diff --git a/matlab/@dates/char.m b/matlab/@dates/char.m
deleted file mode 100644
index bdde032dc39e4353ee21c3e48c99bbdc07fcafe9..0000000000000000000000000000000000000000
--- a/matlab/@dates/char.m
+++ /dev/null
@@ -1,35 +0,0 @@
-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
diff --git a/matlab/@dates/colon.m b/matlab/@dates/colon.m
deleted file mode 100644
index 03dc9220e0f10a9821976518c62c37d95665f72a..0000000000000000000000000000000000000000
--- a/matlab/@dates/colon.m
+++ /dev/null
@@ -1,192 +0,0 @@
-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
diff --git a/matlab/@dates/dates.m b/matlab/@dates/dates.m
deleted file mode 100644
index ecc55ef511b2dacd4bfd29d7ac357637319b0b5d..0000000000000000000000000000000000000000
--- a/matlab/@dates/dates.m
+++ /dev/null
@@ -1,311 +0,0 @@
-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
-
-dd = evalin('base','emptydatesobject');
-
-if isequal(nargin, 0)
-    % Return an empty dates obect
-    return
-end
-
-if all(cellfun(@isdates, varargin))
-    % Concatenates dates in a dates object.
-    dd = horzcat(varargin{:});
-    return
-end
-
-if all(cellfun(@isstringdate,varargin))
-    % Concatenates dates in a dates object.
-    tmp = cellfun(@string2date,varargin);
-    if all([tmp.freq]-tmp(1).freq==0)
-        dd.freq = tmp(1).freq;
-    else
-        error('dates::dates: Wrong calling sequence of the constructor! All dates must have common frequency.')
-    end
-    dd.ndat = length(tmp);
-    dd.time = transpose(reshape([tmp.time],2,dd.ndat));
-    return
-end
-
-if isequal(nargin,1) && isfreq(varargin{1})
-    % Instantiate an empty dates object (only set frequency)
-    if ischar(varargin{1})
-        dd.freq = string2freq(varargin{1});
-    else
-        dd.freq = varargin{1};
-    end
-    return
-end
-
-if isequal(nargin,3) && isfreq(varargin{1})
-    if ischar(varargin{1})
-        dd.freq = string2freq(varargin{1});
-    else
-        dd.freq = varargin{1};
-    end
-    if (isnumeric(varargin{2}) && isvector(varargin{2}) && all(isint(varargin{2})))
-        if isnumeric(varargin{3}) && isvector(varargin{3}) && all(isint(varargin{3}))
-            if all(varargin{3}>=1) && all(varargin{3}<=dd.freq)
-                dd.time = [varargin{2}(:), varargin{3}(:)];
-                dd.ndat = size(dd.time,1);
-            else
-                error(sprintf('dates::dates: Wrong calling sequence of the constructor! Third input must contain integers between 1 and %i.',dd.freq))
-            end
-        else
-            error('dates::dates: Wrong calling sequence of the constructor! Third input must be a vector of integers.')
-        end
-    else
-        error('dates::dates: Wrong calling sequence of the constructor! Second input must be a vector of integers.')
-    end
-    return
-end
-
-if isequal(nargin,2) && isfreq(varargin{1})
-    if ischar(varargin{1})
-        dd.freq = string2freq(varargin{1});
-    else
-        dd.freq = varargin{1};
-    end
-    if isequal(dd.freq, 1)
-        if (isnumeric(varargin{2}) && isvector(varargin{2}) && isint(varargin{2}))
-            dd.time = [varargin{2}, ones(length(varargin{2}),1)];
-            dd.ndat = size(dd.time,1);
-            return
-        else
-            error('dates::dates: Wrong calling sequence of the constructor! Second input must be a vector of integers.')
-        end
-    else
-        if isequal(size(varargin{2},2), 2)
-            if all(isint(varargin{2}(:,1))) && all(isint(varargin{2}(:,1)))
-                if all(varargin{2}(:,2)>=1) && all(varargin{2}(:,2)<=dd.freq)
-                    dd.time = [varargin{2}(:,1), varargin{2}(:,2)];
-                    dd.ndat = size(dd.time,1);
-                else
-                    error(sprintf('dates::dates: Wrong calling sequence of the constructor! Second column of the last input must contain integers between 1 and %i.',dd.freq))
-                end
-            else
-                error('dates::dates: Wrong calling sequence! Second input argument must be an array of integers.')
-            end
-        else
-            error('dates::dates: Wrong calling sequence!')
-        end
-    end
-    return
-end
-
-error('dates::dates: Wrong calling sequence!')
-
-%@test:1
-%$ % Define some dates
-%$ B1 = '1945Q3';
-%$ B2 = '1950Q2';
-%$ B3 = '1950q1';
-%$ B4 = '1953Q4';
-%$
-%$ % Define expected results.
-%$ e.time = [1945 3; 1950 2; 1950 1; 1953 4];
-%$ e.freq = 4;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4);
-%$
-%$ % 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 = '1945M3';
-%$ B2 = '1950M2';
-%$ B3 = '1950M10';
-%$ B4 = '1953M12';
-%$
-%$ % Define expected results.
-%$ e.time = [1945 3; 1950 2; 1950 10; 1953 12];
-%$ e.freq = 12;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4);
-%$
-%$ % 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
-
-%@test:3
-%$ % Define some dates
-%$ B1 = '1945y';
-%$ B2 = '1950Y';
-%$ B3 = '1950a';
-%$ B4 = '1953A';
-%$
-%$ % Define expected results.
-%$ e.time = [1945 1; 1950 1; 1950 1; 1953 1];
-%$ e.freq = 1;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4);
-%$
-%$ % 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:3
-
-%@test:4
-%$ % Define a dates object
-%$ B = dates('1950Q1'):dates('1960Q3');
-%$
-%$
-%$ % Call the tested routine.
-%$ d = B(2);
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2]);
-%$ end
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a dates object
-%$ B = dates(4,1950,1):dates(4,1960,3);
-%$
-%$ % Call the tested routine.
-%$ d = B(2);
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2]);
-%$ end
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ % Define a dates object
-%$ B = dates(4,[1950 1]):dates(4,[1960 3]);
-%$
-%$ % Call the tested routine.
-%$ d = B(2);
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2]);
-%$ end
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ try
-%$   B = dates(4,[1950; 1950], [1; 2]);
-%$   t = 1;
-%$ catch
-%$   t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:7
-
-%@test:8
-%$ try
-%$   B = dates(4,[1950, 1950], [1, 2]);
-%$   t = 1;
-%$ catch
-%$   t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:8
\ No newline at end of file
diff --git a/matlab/@dates/disp.m b/matlab/@dates/disp.m
deleted file mode 100644
index 9c012fea451cf02dd3ccd9234cb116fba74d43d8..0000000000000000000000000000000000000000
--- a/matlab/@dates/disp.m
+++ /dev/null
@@ -1,49 +0,0 @@
-function disp(dd)
-
-% 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 isempty(dd)
-    fprintf('Empty dates object.\n');
-    return
-end
-    
-max_displayed = 5;
-first_displayed = 2;
-    
-fprintf('<dates: ');
-    
-if dd.ndat<=max_displayed
-    for i=1:dd.ndat
-        fprintf(date2string(dd.time(i,:),dd.freq))
-        if i<dd.ndat
-            fprintf(', ')
-        else
-            fprintf('>\n')
-        end
-    end
-else
-    for i=1:first_displayed
-        fprintf(date2string(dd.time(i,:),dd.freq))
-        fprintf(', ')
-    end
-    fprintf(' ..., ')
-    fprintf(date2string(dd.time(dd.ndat-1,:),dd.freq))
-    fprintf(', ')
-    fprintf(date2string(dd.time(dd.ndat,:),dd.freq))
-    fprintf('>\n')
-end
diff --git a/matlab/@dates/display.m b/matlab/@dates/display.m
deleted file mode 100644
index 2d230dc8510fd4e828228f4b102b287699e81f52..0000000000000000000000000000000000000000
--- a/matlab/@dates/display.m
+++ /dev/null
@@ -1,49 +0,0 @@
-function display(dd)
-
-% 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 isempty(dd)
-    fprintf('%s is an empty dates object.\n', inputname(1));
-    return
-end
-
-max_displayed = 5;
-first_displayed = 2;
-    
-fprintf('%s = <dates: ', inputname(1));
-
-if dd.ndat<=max_displayed
-    for i=1:dd.ndat
-        fprintf(date2string(dd.time(i,:),dd.freq))
-        if i<dd.ndat
-            fprintf(', ')
-        else
-            fprintf('>\n')
-        end
-    end
-else
-    for i=1:first_displayed
-        fprintf(date2string(dd.time(i,:),dd.freq))
-        fprintf(', ')
-    end
-    fprintf(' ..., ')
-    fprintf(date2string(dd.time(dd.ndat-1,:),dd.freq))
-    fprintf(', ')
-    fprintf(date2string(dd.time(dd.ndat,:),dd.freq))
-    fprintf('>\n')
-end
\ No newline at end of file
diff --git a/matlab/@dates/double.m b/matlab/@dates/double.m
deleted file mode 100644
index 4306199b5a1f85546e61487c30700e6e7f5ce687..0000000000000000000000000000000000000000
--- a/matlab/@dates/double.m
+++ /dev/null
@@ -1,81 +0,0 @@
-function [B, C]  = double(A) % --*-- Unitary tests --*--
-
-% Returns a vector of doubles with the fractional part corresponding
-% to the subperiod. Used for plots and to store dates in a matrix.
-%
-% INPUTS 
-%  o A     dates object.
-%
-% OUTPUTS  
-%  o B     A.ndat*1 vector of doubles.
-%  o C     integer scalar, the frequency (1, 4, 12 or 52).
-%
-% REMARKS 
-%  Obviously the frequency is lost during the conversion.
-    
-% 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/>.
-
-B = A.time(:,1)+(A.time(:,2)-1)/A.freq;
-if nargout>1
-    C = A.freq;
-end
-
-%@test:1
-%$ % Define a dates object
-%$ qq = dates('Q');
-%$ B = qq(1950,1):qq(1951,1);
-%$
-%$ % Call the tested routine.
-%$ try
-%$     C = double(B);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Define expected results.
-%$ E = [ones(4,1)*1950; 1951];
-%$ E = E + [(transpose(1:4)-1)/4; 0];
-%$ if t(1)
-%$     t(2) = dyn_assert(isequal(C,E),1);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a dates object
-%$ qq = dates('Q');
-%$
-%$ % Call the tested routine.
-%$ try
-%$     C = NaN(2,1);
-%$     C(1) = double(qq(1950,1));
-%$     C(2) = double(qq(1950,2));
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Define expected results.
-%$ E = ones(2,1)*1950;
-%$ E = E + [0; .25];
-%$ if t(1)
-%$     t(2) = dyn_assert(isequal(C,E),1);
-%$ end
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/end.m b/matlab/@dates/end.m
deleted file mode 100644
index d1f04449f98c07d3ac7987dcea8fd91f071a9cf1..0000000000000000000000000000000000000000
--- a/matlab/@dates/end.m
+++ /dev/null
@@ -1,34 +0,0 @@
-function lastIndex = end(o, k, n)
-
-% Overloads end keyword.
-%
-% INPUTS
-%   o              [dates] dates object
-%   k              [integer]  index where end appears
-%   n              [integer]  number of indices
-%
-% OUTPUTS
-%   lastIndex      [integer] last dates index
-%
-% SPECIAL REQUIREMENTS
-%   none
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-assert(k==1 && n==1, 'dates::end: dates only has one dimension');
-lastIndex = o.ndat;
\ No newline at end of file
diff --git a/matlab/@dates/eq.m b/matlab/@dates/eq.m
deleted file mode 100644
index 16983d184badf4ca7ab1897c91874428792d376b..0000000000000000000000000000000000000000
--- a/matlab/@dates/eq.m
+++ /dev/null
@@ -1,102 +0,0 @@
-function C = eq(A,B) % --*-- Unitary tests --*--
-
-% Overloads == operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::eq: I need exactly two input arguments!')
-end
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::eq: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be a dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = transpose(all(transpose(eq(A.time,B.time))));
-else
-    if isequal(A.ndat,1) || isequal(B.ndat,1)
-        C = transpose(all(transpose(bsxfun(@eq,A.time,B.time))));
-    else
-        C = 0;
-    end
-end
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4') ;
-%$ d2 = dates('1960Q1','1960Q2','1960Q3','1960Q4') ;
-%$ d3 = dates('1950Q1','1960Q2','1950Q3','1960Q4') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1==d1;
-%$ t2 = d1==d2;
-%$ t3 = d1==d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,ones(4,1));
-%$ t(2) = dyn_assert(t2,zeros(4,1));
-%$ t(2) = dyn_assert(t3,[1; 0; 1; 0]);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1') ;
-%$ d2 = dates('1960Q1') ;
-%$ d3 = dates('1960Q1') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1==d1;
-%$ t2 = d1==d2;
-%$ t3 = d1==d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,1);
-%$ t(2) = dyn_assert(t2,0);
-%$ t(2) = dyn_assert(t3,0);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4') ;
-%$ d2 = dates('1950Q2') ;
-%$ d3 = dates('1970Q1') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1==d2;
-%$ t2 = d1==d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,[0; 1; 0; 0]);
-%$ t(2) = dyn_assert(t2,zeros(4,1));
-%$ T = all(t);
-%@eof:3
diff --git a/matlab/@dates/ge.m b/matlab/@dates/ge.m
deleted file mode 100644
index 625f1bbdf2edc98c77b4771cfbef0afa6d36345c..0000000000000000000000000000000000000000
--- a/matlab/@dates/ge.m
+++ /dev/null
@@ -1,127 +0,0 @@
-function C = ge(A,B)  % --*-- Unitary tests --*--
-
-% Overloads the >= operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::ge: I need exactly two input arguments!')
-end
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::ge: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be a dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = (A==B);
-    idx = find(C==0);
-    for i=1:length(idx)
-        C(idx(i)) = greaterorequal(A.time(idx(i),:), B.time(idx(i),:));
-    end
-else
-    if isequal(A.ndat,1)
-        C = NaN(B.ndat,1);
-        for i=1:B.ndat
-            C(i) = greaterorequal(A.time, B.time(i,:));
-        end
-    elseif isequal(B.ndat,1)
-        C = NaN(A.ndat,1);
-        for i=1:A.ndat
-            C(i) = greaterorequal(A.time(i,:), B.time);
-        end
-    else
-        C = 0;
-    end
-end
-
-
-function c = greaterorequal(a,b)
-    if a(1)>b(1)
-        c = 1;
-    else
-        if a(1)<b(1)
-            c = 0;
-        else
-            if a(2)>=b(2)
-                c = 1;
-            else
-                c = 0;
-            end
-        end
-    end
-
-
-%@test:1
-%$ % Define some dates
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q3';
-%$ date_4 = '1950Q1';
-%$ date_5 = '1949Q2';
-%$
-%$ % Call the tested routine.
-%$ d2 = dates(date_2);
-%$ d3 = dates(date_3);
-%$ d4 = dates(date_4);
-%$ d5 = dates(date_5);
-%$ i1 = (d2>=d3);
-%$ i2 = (d3>=d4);
-%$ i3 = (d4>=d2);
-%$ i4 = (d5>=d4);
-%$ i5 = (d5>=d5); 
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,0);
-%$ t(2) = dyn_assert(i2,1);
-%$ t(3) = dyn_assert(i3,0);
-%$ t(4) = dyn_assert(i4,0);
-%$ t(5) = dyn_assert(i5,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ B1 = '1945Q1';
-%$ B2 = '1945Q2';
-%$ B3 = '1945Q3';
-%$ B4 = '1945Q4';
-%$ B5 = '1950Q1';
-%$
-%$ % Create dates objects.
-%$ dd = dates(B1,B2,B3,B4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(dates(B1)>=dates(B2),0);
-%$ t(2) = dyn_assert(dates(B2)>=dates(B1),1);
-%$ t(3) = dyn_assert(dates(B2)>=dates(B2),1);
-%$ t(4) = dyn_assert(dd>=dates(B5),zeros(4,1));
-%$ t(5) = dyn_assert(dates(B5)>=dd,ones(4,1));
-%$ t(6) = dyn_assert(dates(B1)>=dd,[1; zeros(3,1)]);
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/gt.m b/matlab/@dates/gt.m
deleted file mode 100644
index 7960388850c099835cb9de72dbe7ea5ef78285ae..0000000000000000000000000000000000000000
--- a/matlab/@dates/gt.m
+++ /dev/null
@@ -1,123 +0,0 @@
-function C = gt(A,B)  % --*-- Unitary tests --*--
-
-% Overloads the > operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::gt: I need exactly two input arguments!')
-end
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::gt: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be a dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = NaN(A.ndat,1);
-    for i=1:A.ndat
-        C(i) = greaterthan(A.time(i,:), B.time(i,:));
-    end
-else
-    if isequal(A.ndat,1)
-        C = NaN(B.ndat,1);
-        for i=1:B.ndat
-            C(i) = greaterthan(A.time, B.time(i,:));
-        end
-    elseif isequal(B.ndat,1)
-        C = NaN(A.ndat,1);
-        for i=1:A.ndat
-            C(i) = greaterthan(A.time(i,:), B.time);
-        end
-    else
-        C = 0;
-    end
-end
-
-
-function c = greaterthan(a,b)
-    if a(1)>b(1)
-        c = 1;
-    else
-        if a(1)<b(1)
-            c = 0;
-        else
-            if a(2)>b(2)
-                c = 1;
-            else
-                c = 0;
-            end
-        end
-    end
-
-%@test:1
-%$ % Define some dates
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q3';
-%$ date_4 = '1950Q1';
-%$ date_5 = '1949Q2';
-%$
-%$ % Call the tested routine.
-%$ d2 = dates(date_2);
-%$ d3 = dates(date_3);
-%$ d4 = dates(date_4);
-%$ d5 = dates(date_5);
-%$ i1 = (d2>d3);
-%$ i2 = (d3>d4);
-%$ i3 = (d4>d2);
-%$ i4 = (d5>d4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,0);
-%$ t(2) = dyn_assert(i2,1);
-%$ t(3) = dyn_assert(i3,0);
-%$ t(4) = dyn_assert(i4,0);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ B1 = '1945Q1';
-%$ B2 = '1945Q2';
-%$ B3 = '1945Q3';
-%$ B4 = '1945Q4';
-%$ B5 = '1950Q1';
-%$
-%$ % Create dates objects.
-%$ dd = dates(B1,B2,B3,B4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(dates(B1)>dates(B2),0);
-%$ t(2) = dyn_assert(dates(B2)>dates(B1),1);
-%$ t(3) = dyn_assert(dates(B5)>dates(B1),1);
-%$ t(4) = dyn_assert(dd>dates(B5),zeros(4,1));
-%$ t(5) = dyn_assert(dates(B5)>dd,ones(4,1));
-%$ t(6) = dyn_assert(dates(B1)>dd,[0; zeros(3,1)]);
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/horzcat.m b/matlab/@dates/horzcat.m
deleted file mode 100644
index 8bc1eddd33c5a824b7f9eefeaeccaa551ba17400..0000000000000000000000000000000000000000
--- a/matlab/@dates/horzcat.m
+++ /dev/null
@@ -1,152 +0,0 @@
-function B = horzcat(varargin) % --*-- Unitary tests --*--
-
-% Overloads the horzcat method for dates objects.
-%
-% INPUTS 
-%  o A1    dates object.
-%  o A2    dates object.
-%  o ...
-%
-% OUTPUTS 
-%  o B    dates object containing dates defined in A1, A2, ...
-%
-% EXAMPLE 1 
-%  If A, B and C are dates objects the following syntax:
-%    
-%    D = [A, B, C] ;
-%
-%  Defines a dates object D containing the dates appearing in A, B and C.
-    
-% 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 ~all(cellfun(@isdates,varargin))
-    error('dates::horzcat: All input arguments must be dates objects.')
-end
-
-n = nargin;
-B = varargin{1};
-
-if isequal(n,1), return, end
-
-for i=2:n
-    C = varargin{i};
-    if isequal(B.freq,C.freq)
-        if ~isempty(C)
-            B.ndat = B.ndat + C.ndat;
-            B.time = [B.time; C.time];
-        end
-    else
-        error('dates::horzcat: All input arguments must have the same frequency!')
-    end
-end
-
-%@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, 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);
-%$ d = [d, dates(B1), 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:2
-
-%@test:3
-%$ % 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);
-%$ d = [d, dates(B1,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:3
-
-%@test:4
-%$ % 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);
-%$ d = [d, [dates(B1), 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:4
\ No newline at end of file
diff --git a/matlab/@dates/intersect.m b/matlab/@dates/intersect.m
deleted file mode 100644
index cd427918c572cf521509740d4ed5d2cffe4e3222..0000000000000000000000000000000000000000
--- a/matlab/@dates/intersect.m
+++ /dev/null
@@ -1,88 +0,0 @@
-function C = intersect(A,B) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{C} =} intersect (@var{A},@var{B})
-%! @anchor{@dates/intersect}
-%! @sp 1
-%! C of B and A.
-%! if A and B are not disjoints.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! @ref{dates} object.
-%! @item B
-%! @ref{dates} object.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item C
-%! @ref{dates} object.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::plus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' must be dates objects!'])
-end
-
-if eq(A,B)
-    C = A;
-    return
-end
-
-if ~isequal(A.freq,B.freq)
-    C = dates();
-    return
-end
-
-if isoctave || matlab_ver_less_than('8.1.0')
-    time = intersect(A.time,B.time,'rows');
-else
-    time = intersect(A.time,B.time,'rows','legacy');
-end
-
-C = dates();
-if isempty(time)
-    return
-end
-
-C.freq = A.freq;
-C.time = time;
-C.ndat = rows(time); 
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1'):dates('1969Q4') ;
-%$ d2 = dates('1960Q1'):dates('1969Q4') ;
-%$ d3 = dates('1970Q1'):dates('1979Q4') ;
-%$
-%$ % Call the tested routine.
-%$ c1 = intersect(d1,d2);
-%$ c2 = intersect(d1,d3);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(c1,d2),1);
-%$ t(2) = dyn_assert(isempty(c2),1);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dates/isempty.m b/matlab/@dates/isempty.m
deleted file mode 100644
index 859f7a785ed3e8a364d9a8e07e2b175a3cf6422b..0000000000000000000000000000000000000000
--- a/matlab/@dates/isempty.m
+++ /dev/null
@@ -1,50 +0,0 @@
-function B = isempty(A) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{B} =} isempty (@var{A})
-%! @anchor{@dates/isempty}
-%! @sp 1
-%! Overloads the isempty function for the @ref{dates} class.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! @ref{dates} object.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item b
-%! Integer scalar (equal to zero if @var{A} is not empty).
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-    
-B = isequal(A.ndat,0);
-
-%@test:1
-%$ % Instantiate an empty dates object
-%$ d = dates();
-%$ % Test if this object is empty
-%$ t(1) = isempty(d);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dates/isequal.m b/matlab/@dates/isequal.m
deleted file mode 100644
index 1e436b96901356f1656cb720d1ce1ed9d4c6c7df..0000000000000000000000000000000000000000
--- a/matlab/@dates/isequal.m
+++ /dev/null
@@ -1,36 +0,0 @@
-function C = isequal(A,B)
-
-% Overloads isequal function for dates objects.
-    
-% 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 ~isa(A,'dates') || ~isa(B,'dates')
-    error('dates::isequal: Both inputs must be dates objects!')
-end
-
-if ~isequal(A.freq, B.freq)
-    C = 0;
-    return
-end
-
-if ~isequal(A.ndat, B.ndat)
-    C = 0;
-    return
-end
-
-C = isequal(A.time,B.time);
\ No newline at end of file
diff --git a/matlab/@dates/le.m b/matlab/@dates/le.m
deleted file mode 100644
index 3056785fe7f630b4e48aafb7d6b32b3c7353ffd1..0000000000000000000000000000000000000000
--- a/matlab/@dates/le.m
+++ /dev/null
@@ -1,127 +0,0 @@
-function C = le(A,B)  % --*-- Unitary tests --*--
-
-% Overloads the <= operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::le: I need exactly two input arguments!')
-end
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::le: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be a dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = (A==B);
-    idx = find(C==0);
-    for i=1:length(idx)
-        C(idx(i)) = lessorequal(A.time(idx(i),:), B.time(idx(i),:));
-    end
-else
-    if isequal(A.ndat,1)
-        C = NaN(B.ndat,1);
-        for i=1:B.ndat
-            C(i) = lessorequal(A.time, B.time(i,:));
-        end
-    elseif isequal(B.ndat,1)
-        C = NaN(A.ndat,1);
-        for i=1:A.ndat
-            C(i) = lessorequal(A.time(i,:), B.time);
-        end
-    else
-        C = 0;
-    end
-end
-
-
-function c = lessorequal(a, b)
-    if a(1)<b(1)
-        c = 1;
-    else
-        if a(1)>b(1)
-            c = 0;
-        else
-            if a(2)<=b(2)
-                c = 1;
-            else
-                c = 0;
-            end
-        end
-    end
-
-
-%@test:1
-%$ % Define some dates
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q3';
-%$ date_4 = '1950Q1';
-%$ date_5 = '1949Q2';
-%$
-%$ % Call the tested routine.
-%$ d2 = dates(date_2);
-%$ d3 = dates(date_3);
-%$ d4 = dates(date_4);
-%$ d5 = dates(date_5);
-%$ i1 = (d2<=d3);
-%$ i2 = (d3<=d4);
-%$ i3 = (d4<=d2);
-%$ i4 = (d5<=d4);
-%$ i5 = (d5<=d5);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,1);
-%$ t(2) = dyn_assert(i2,0);
-%$ t(3) = dyn_assert(i3,1);
-%$ t(4) = dyn_assert(i4,1);
-%$ t(5) = dyn_assert(i5,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ B1 = '1945Q1';
-%$ B2 = '1945Q2';
-%$ B3 = '1945Q3';
-%$ B4 = '1945Q4';
-%$ B5 = '1950Q1';
-%$
-%$ % Create dates objects.
-%$ dd = dates(B1,B2,B3,B4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(dates(B1)<=dates(B2),1);
-%$ t(2) = dyn_assert(dates(B2)<=dates(B1),0);
-%$ t(3) = dyn_assert(dates(B2)<=dates(B2),1);
-%$ t(4) = dyn_assert(dd<=dates(B5),ones(4,1));
-%$ t(5) = dyn_assert(dates(B5)<=dd,zeros(4,1));
-%$ t(6) = dyn_assert(dates(B1)<=dd,ones(4,1));
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/length.m b/matlab/@dates/length.m
deleted file mode 100644
index 26c24d13affcfdbdccf3812eeadd413c564fe43c..0000000000000000000000000000000000000000
--- a/matlab/@dates/length.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function n = length(A)
-
-% Returns the number of elements in a dates object.
-
-% 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/>.
-
-n = A.ndat;
\ No newline at end of file
diff --git a/matlab/@dates/lt.m b/matlab/@dates/lt.m
deleted file mode 100644
index 97bddcff8aec921db81cc243dcc36a217e361734..0000000000000000000000000000000000000000
--- a/matlab/@dates/lt.m
+++ /dev/null
@@ -1,122 +0,0 @@
-function C = lt(A,B)  % --*-- Unitary tests --*--
-
-% Overloads the < operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::lt: I need exactly two input arguments!')
-end
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::lt: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be a dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = NaN(A.ndat,1);
-    for i=1:A.ndat
-        C(i) = lessthan(A.time(i,:),B.time(i,:));
-    end
-else
-    if isequal(A.ndat,1)
-        C = NaN(B.ndat,1);
-        for i=1:B.ndat
-            C(i) = lessthan(A.time,B.time(i,:));
-        end
-    elseif isequal(B.ndat,1)
-        C = NaN(A.ndat,1);
-        for i=1:A.ndat
-            C(i) =  lessthan(A.time(i,:),B.time);
-        end
-    else
-        C = 0;
-    end
-end
-
-function c = lessthan(a,b)
-    if a(1)<b(1)
-        c = 1;
-    else
-        if a(1)>b(1)
-            c = 0;
-        else
-            if a(2)<b(2)
-                c = 1;
-            else
-                c = 0;
-            end
-        end
-    end
-
-%@test:1
-%$ % Define some dates
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q3';
-%$ date_4 = '1950Q1';
-%$ date_5 = '1949Q2';
-%$
-%$ % Call the tested routine.
-%$ d2 = dates(date_2);
-%$ d3 = dates(date_3);
-%$ d4 = dates(date_4);
-%$ d5 = dates(date_5);
-%$ i1 = (d2<d3);
-%$ i2 = (d3<d4);
-%$ i3 = (d4<d2);
-%$ i4 = (d5<d4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,1);
-%$ t(2) = dyn_assert(i2,0);
-%$ t(3) = dyn_assert(i3,1);
-%$ t(4) = dyn_assert(i4,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ B1 = '1945Q1';
-%$ B2 = '1945Q2';
-%$ B3 = '1945Q3';
-%$ B4 = '1945Q4';
-%$ B5 = '1950Q1';
-%$
-%$ % Create dates objects.
-%$ dd = dates(B1,B2,B3,B4);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(dates(B1)<dates(B2),1);
-%$ t(2) = dyn_assert(dates(B2)<dates(B1),0);
-%$ t(3) = dyn_assert(dates(B2)<dates(B1),0);
-%$ t(4) = dyn_assert(dd<dates(B5),ones(4,1));
-%$ t(5) = dyn_assert(dates(B5)<dd,zeros(4,1));
-%$ t(6) = dyn_assert(dates(B1)<dd,[0; ones(3,1)]);
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dates/max.m b/matlab/@dates/max.m
deleted file mode 100644
index e7af8c4b81cfa22b5aaeecac77b135d5f6076ee6..0000000000000000000000000000000000000000
--- a/matlab/@dates/max.m
+++ /dev/null
@@ -1,86 +0,0 @@
-function C = max(varargin)
-    
-% Overloads the max function for dates objects.
-    
-% 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/>.
-
-switch nargin
-  case 1
-    switch length(varargin{1})
-      case 0
-        C= dates();
-      case 1
-        C = varargin{1};
-      otherwise
-        tmp = sortrows(varargin{1}.time);
-        C = dates();
-        C.freq = varargin{1}.freq;
-        C.ndat = 1;
-        C.time = tmp(varargin{1}.ndat,:);
-    end
-  otherwise
-    C = max(horzcat(varargin{:}));
-end
-
-%@test:1
-%$ % Define some dates
-%$ d3 = dates('1950q2');
-%$ d4 = dates('1950Q3');
-%$ d5 = dates('1950m1');
-%$ d6 = dates('1948M6');
-%$ m2 = max(d3,d4);
-%$ i2 = (m2==d4);
-%$ m3 = max(d5,d6);
-%$ i3 = (m3==d5);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i2,1);
-%$ t(2) = dyn_assert(i3,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ d = dates('1950Q2','1951Q3','1949Q1','1950Q4');
-%$ m = max(d);
-%$ i = (m==dates('1951Q3'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates
-%$ m = max(dates('1950Q2','1951Q3'),dates('1949Q1'),dates('1950Q4'));
-%$ i = (m==dates('1951Q3'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define some dates
-%$ m = max(dates('1950Q2'),dates('1951Q3'),dates('1949Q1'),dates('1950Q4'));
-%$ i = (m==dates('1951Q3'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:4
\ No newline at end of file
diff --git a/matlab/@dates/min.m b/matlab/@dates/min.m
deleted file mode 100644
index 1bdfe3c57fe25f8d6e77faf7d1859035513bad05..0000000000000000000000000000000000000000
--- a/matlab/@dates/min.m
+++ /dev/null
@@ -1,86 +0,0 @@
-function C = min(varargin)
-    
-% Overloads the min function for dates objects.
-    
-% 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/>.
-
-switch nargin
-  case 1
-    switch length(varargin{1})
-      case 0
-        C= dates();
-      case 1
-        C = varargin{1};
-      otherwise
-        tmp = sortrows(varargin{1}.time);
-        C = dates();
-        C.freq = varargin{1}.freq;
-        C.ndat = 1;
-        C.time = tmp(1,:);
-    end
-  otherwise
-    C = min(horzcat(varargin{:}));
-end
-
-%@test:1
-%$ % Define some dates
-%$ d3 = dates('1950q2');
-%$ d4 = dates('1950Q3');
-%$ d5 = dates('1950m1');
-%$ d6 = dates('1948M6');
-%$ m2 = min(d3,d4);
-%$ i2 = (m2==d3);
-%$ m3 = min(d5,d6);
-%$ i3 = (m3==d6);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i2,1);
-%$ t(2) = dyn_assert(i3,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ d = dates('1950Q2','1951Q3','1949Q1','1950Q4');
-%$ m = min(d);
-%$ i = (m==dates('1949Q1'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates
-%$ m = min(dates('1950Q2','1951Q3'),dates('1949Q1'),dates('1950Q4'));
-%$ i = (m==dates('1949Q1'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define some dates
-%$ m = min(dates('1950Q2'),dates('1951Q3'),dates('1949Q1'),dates('1950Q4'));
-%$ i = (m==dates('1949Q1'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i,1);
-%$ T = all(t);
-%@eof:4
\ No newline at end of file
diff --git a/matlab/@dates/minus.m b/matlab/@dates/minus.m
deleted file mode 100644
index 4c90ff566af0f1762e6ccc1d6203308e93859112..0000000000000000000000000000000000000000
--- a/matlab/@dates/minus.m
+++ /dev/null
@@ -1,154 +0,0 @@
-function C = minus(A,B) % --*-- Unitary tests --*--
-
-% Overloads the minus operator (-). If A and B are dates objects, the method returns the number of periods between A and B (so that A+C=B). If 
-% one of the inputs is an integer or a vector of integers, the method shifts the dates object by X (the interger input) periods backward.
-
-% 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 isa(B,'dates')
-    if ~isequal(A.freq,B.freq)
-        error(['dates::minus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' must have common frequencies!'])
-    end
-    if isempty(A) || isempty(B)
-        error(['dates::minus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' must not be empty!'])
-    end
-    if ~isequal(length(A),length(B))
-        if length(A)==1
-            A.time = repmat(A.time,B.ndat,1);
-            A.ndat = B.ndat;
-        elseif length(B)==1
-            B.time = repmat(B.time,A.ndat,1);
-            B.ndat = A.ndat;
-        else
-            error(['dates::minus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' lengths are not consistent!'])
-        end
-    end
-    C = zeros(length(A),1);
-    id = find(~(A==B));
-    if isempty(id)
-        return
-    end
-    C(id) = A.time(id,2)-B.time(id,2) + (A.time(id,1)-B.time(id,1))*A.freq;
-elseif (isvector(B) && isequal(length(B),A.ndat) && all(isint(B))) || isscalar(B) && isint(B) || isequal(length(A),1) && isvector(B) && all(isint(B))
-    C = dates();
-    C.freq = A.freq;
-    C.time = add_periods_to_array_of_dates(A.time, A.freq, -B);
-    C.ndat = rows(C.time);
-else
-    error('dates::plus: I don''t understand what you want to do! Check the manual.')
-end
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2','1960Q1');
-%$ d2 = dates('1950Q3','1950Q4','1960Q1');
-%$ d3 = dates('2000Q1');
-%$ d4 = dates('2002Q2');
-%$ % Call the tested routine.
-%$ try
-%$   e1 = d2-d1;
-%$   e2 = d4-d3;
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(e1,[2; 2; 0]);
-%$   t(3) = dyn_assert(e2,9);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates objects
-%$ d1 = dates('1950Y','1951Y','1953Y');
-%$ d2 = dates('1951Y','1952Y','1953Y');
-%$ d3 = dates('2000Y');
-%$ d4 = dates('1999Y');
-%$ % Call the tested routine.
-%$ try
-%$   e1 = d2-d1;
-%$   e2 = d4-d3;
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(e1,[1; 1; 0]);
-%$   t(3) = dyn_assert(e2,-1);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates objects
-%$ d1 = dates('2000Y');
-%$ d2 = dates('1999Y');
-%$ % Call the tested routine.
-%$ try
-%$   e1 = d1-1;
-%$   e2 = d2-(-1);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(isequal(e1,d2),1);
-%$   t(3) = dyn_assert(isequal(e2,d1),1);
-%$ end
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define some dates objects
-%$ d1 = dates('2000Q1');
-%$ e1 = dates('1999Q4','1999Q3','1999Q2','1999Q1','1998Q4');
-%$ % Call the tested routine.
-%$ try
-%$   f1 = d1-transpose(1:5);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(isequal(e1,f1),1);
-%$ end
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define some dates objects
-%$ d1 = dates('1999Q4','1999Q3','1999Q2','1999Q1','1998Q4');
-%$ e1 = dates('2000Q1')*5;
-%$ % Call the tested routine.
-%$ try
-%$   f1 = d1-(-transpose(1:5));
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(isequal(e1,f1),1);
-%$ end
-%$ T = all(t);
-%@eof:5
\ No newline at end of file
diff --git a/matlab/@dates/mtimes.m b/matlab/@dates/mtimes.m
deleted file mode 100644
index 513915b3283f7210ce25f53063de36a56709c75f..0000000000000000000000000000000000000000
--- a/matlab/@dates/mtimes.m
+++ /dev/null
@@ -1,39 +0,0 @@
-function B = mtimes(A,n)
-
-% Overloads the times operator (*). Returns dates object A replicated n times.
-%
-% INPUTS 
-%  o A    dates object with m elements.
-%
-% OUTPUTS 
-%  o B    dates object with m*n elements.
-%
-% EXAMPLE 1
-%  If A = dates('2000Q1'), then B=A*3 is a dates object equal to dates('2000Q1','2000Q1','2000Q1')  
-%
-% EXAMPLE 2
-%  If A = dates('2003Q1','2009Q2'), then B=A*2 is a dates object equal to dates('2003Q1','2009Q2','2003Q1','2009Q2')
-
-% 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 ~(isscalar(n) && isint(n))
-    error('dates::m: First and second input arguments have to be a dates object and a scalar integer!')
-end
-B = A;
-B.time = repmat(A.time,n,1);
-B.ndat = A.ndat*n;
\ No newline at end of file
diff --git a/matlab/@dates/ne.m b/matlab/@dates/ne.m
deleted file mode 100644
index a5bab143b67cbe3b761f25a9bcd1b26adb4f2111..0000000000000000000000000000000000000000
--- a/matlab/@dates/ne.m
+++ /dev/null
@@ -1,102 +0,0 @@
-function C = ne(A,B) % --*-- Unitary tests --*--
-
-% Overloads ~= operator for dates objects.
-%
-% INPUTS 
-%  o A    dates object with n or 1 elements.
-%  o B    dates object with n or 1 elements.
-%
-% OUTPUTS 
-%  o C    column vector of max(n,1) elements (zeros or ones).
-
-% 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)
-    error('dates::ne: I need exactly two input arguments!')
-end
-
-if ~isdates(A) || ~isdates(B)
-    error(['dates::ne: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' have to be dates objects!'])
-end
-
-if ~isequal(A.freq,B.freq)
-    C = 0;
-    return
-end
-
-if isequal(A.ndat, B.ndat)
-    C = transpose(any(transpose(ne(A.time,B.time))));
-else
-    if isequal(A.ndat,1) || isequal(B.ndat,1)
-        C = transpose(any(transpose(bsxfun(@ne,A.time,B.time))));
-    else
-        C = 0;
-    end
-end
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4') ;
-%$ d2 = dates('1960Q1','1960Q2','1960Q3','1960Q4') ;
-%$ d3 = dates('1950Q1','1960Q2','1950Q3','1960Q4') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1~=d1;
-%$ t2 = d1~=d2;
-%$ t3 = d1~=d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,zeros(4,1));
-%$ t(2) = dyn_assert(t2,ones(4,1));
-%$ t(3) = dyn_assert(t3,[0; 1; 0; 1]);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1') ;
-%$ d2 = dates('1960Q1') ;
-%$ d3 = dates('1960Q1') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1~=d1;
-%$ t2 = d1~=d2;
-%$ t3 = d1~=d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,0);
-%$ t(2) = dyn_assert(t2,1);
-%$ t(3) = dyn_assert(t3,1);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4') ;
-%$ d2 = dates('1950Q2') ;
-%$ d3 = dates('1970Q1') ;
-%$
-%$ % Call the tested routine.
-%$ t1 = d1~=d2;
-%$ t2 = d1~=d3;
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(t1,[1; 0; 1; 1]);
-%$ t(2) = dyn_assert(t2,ones(4,1));
-%$ T = all(t);
-%@eof:3
diff --git a/matlab/@dates/plus.m b/matlab/@dates/plus.m
deleted file mode 100644
index 4f1e222ed39bc298679f830f0290fd8fb324159d..0000000000000000000000000000000000000000
--- a/matlab/@dates/plus.m
+++ /dev/null
@@ -1,132 +0,0 @@
-function C = plus(A,B) % --*-- Unitary tests --*--
-
-% Overloads the plus operator. If A and B are dates objects the method combines A and B without removing repetitions. If
-% one of the inputs is an integer or a vector of integers, the method shifts the dates object by X (the interger input)
-% periods forward.
-
-% 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 isa(B,'dates')
-    % Concatenate dates objects without removing repetitions if A and B are not disjoint sets of dates.
-    if ~isequal(A.freq,B.freq) && A.ndat>0 && B.ndat>0
-        error(['dates::plus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' must have common frequencies!'])
-    end
-    if isempty(B)
-        C = A;
-        return
-    end
-    if isempty(A)
-        C = B;
-        return
-    end
-    C = dates();
-    C.freq = A.freq;
-    C.time = [A.time; B.time];
-    C.ndat = A.ndat+B.ndat;
-elseif (isvector(B) && isequal(length(B),A.ndat) && all(isint(B))) || isscalar(B) && isint(B) || isequal(length(A),1) && isvector(B) && all(isint(B))
-    C = dates();
-    C.freq = A.freq;
-    C.time = add_periods_to_array_of_dates(A.time, A.freq, B);
-    C.ndat = rows(C.time);
-else
-    error('dates::plus: I don''t understand what you want to do! Check the manual.')
-end
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1','1950Q2') ;
-%$ d2 = dates('1950Q3','1950Q4') ;
-%$ d3 = dates('1950Q1','1950Q2','1950Q3','1950Q4') ;
-%$
-%$ % Call the tested routine.
-%$ try
-%$   e1 = d1+d2;
-%$   e2 = d1+d2+d3;
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1) 
-%$   t(2) = dyn_assert(isequal(e1,d3),1);
-%$   t(3) = dyn_assert(isequal(e2,dates('1950Q1','1950Q2','1950Q3','1950Q4','1950Q1','1950Q2','1950Q3','1950Q4')),1);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1');
-%$ e1 = dates('1950Q2');
-%$ e2 = dates('1950Q3');
-%$ e3 = dates('1950Q4');
-%$ e4 = dates('1951Q1');
-%$ e5 = dates('1950Q2','1950Q3','1950Q4','1951Q1');
-%$
-%$ % Call the tested routine.
-%$ try
-%$   f1 = d1+1;
-%$   f2 = d1+2;
-%$   f3 = d1+3;
-%$   f4 = d1+4;
-%$   f5 = d1+transpose(1:4);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(isequal(e1,f1),1);
-%$   t(3) = dyn_assert(isequal(e2,f2),1);
-%$   t(4) = dyn_assert(isequal(e3,f3),1);
-%$   t(5) = dyn_assert(isequal(e4,f4),1);
-%$   t(6) = dyn_assert(isequal(e5,f5),1);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1');
-%$ e1 = dates('1949Q4');
-%$ e2 = dates('1949Q3');
-%$ e3 = dates('1949Q2');
-%$ e4 = dates('1949Q1');
-%$ e5 = dates('1948Q4');
-%$
-%$ % Call the tested routine.
-%$ try
-%$   f1 = d1+(-1);
-%$   f2 = d1+(-2);
-%$   f3 = d1+(-3);
-%$   f4 = d1+(-4);
-%$   f5 = d1+(-5);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(isequal(e1,f1),1);
-%$   t(3) = dyn_assert(isequal(e2,f2),1);
-%$   t(4) = dyn_assert(isequal(e3,f3),1);
-%$   t(5) = dyn_assert(isequal(e4,f4),1);
-%$   t(6) = dyn_assert(isequal(e5,f5),1);
-%$ end
-%$ T = all(t);
-%@eof:3
\ No newline at end of file
diff --git a/matlab/@dates/pop.m b/matlab/@dates/pop.m
deleted file mode 100644
index 2aec07a405adae82d3731f6d111f93ec8464669a..0000000000000000000000000000000000000000
--- a/matlab/@dates/pop.m
+++ /dev/null
@@ -1,119 +0,0 @@
-function B = pop(A,a) % --*-- Unitary tests --*--
-
-% pop method for dates class (removes a date).
-%
-% INPUTS 
-%  o A     dates object.
-%  o a     dates object with one element, string which can be interpreted as a date or integer scalar.
-%
-% OUTPUTS 
-%  o B     dates object (with B.ndat==A.ndat-1).
-%
-% REMARKS 
-%  If a is a date appearing more than once in A, then only the last occurence is removed. If one wants to
-%  remove all the occurences of a in A, the setdiff function should be used instead.
-
-% 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 nargin<2
-    % Remove last date
-    B = dates();
-    B.ndat = A.ndat-1;
-    B.freq = A.freq;
-    B.time = NaN(B.ndat,2);
-    B.time = A.time(1:end-1,:);
-    return
-end
-
-if ~( isdates(a) || isdate(a) || (isscalar(a) && isint(a)) )
-    error(['dates::pop: Input argument ' inputname(2) ' has to be a dates object with a single element, a string (which can be interpreted as a date) or an integer.'])
-end
-
-if ischar(a)
-    a = dates(a);
-end
-
-B = dates();
-B.ndat = A.ndat-1;
-B.freq = A.freq;
-B.time = NaN(B.ndat,2);
-
-if isscalar(a) && isint(a)
-    idx = find(transpose(1:A.ndat)~=a);
-    B.time = A.time(idx,:);
-else
-    if ~isequal(A.freq,a.freq)
-        error('dates::pop: Inputs must have common frequency!')
-    end
-    idx = find(A==a);
-    jdx = find(transpose(1:A.ndat)~=idx(end));
-    B.time = A.time(jdx,:);
-end
-
-%@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));
-%$ f = d.pop();
-%$ t(1) = dyn_assert(f.time,e.time(1:end-1,:));
-%$ t(2) = dyn_assert(f.freq,e.freq);
-%$ t(3) = dyn_assert(f.ndat,e.ndat-1);
-%$ f = d.pop(B1);
-%$ t(4) = dyn_assert(f.time,[1945 3; 1950 1; 1950 2; 2009 2]);
-%$ t(5) = dyn_assert(f.freq,e.freq);
-%$ t(6) = dyn_assert(f.ndat,e.ndat-1);
-%$ f = d.pop(dates(B1));
-%$ t(7) = dyn_assert(f.time,[1945 3; 1950 1; 1950 2; 2009 2]);
-%$ t(8) = dyn_assert(f.freq,e.freq);
-%$ t(9) = dyn_assert(f.ndat,e.ndat-1);
-%$
-%$ % Check the results.
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define some dates
-%$ B1 = '1950Q1';
-%$ B2 = '1950Q2';
-%$ B3 = '1950Q1';
-%$ B4 = '1945Q3';
-%$ B5 = '2009Q2';
-%$
-%$ % Call the tested routine
-%$ d = dates(B1,B2,B3,B4);
-%$ d = d.append(dates(B5));
-%$ f = d.pop();
-%$ t(1) = dyn_assert(isequal(f,dates(B1,B2,B3,B4)),1);
-%$ f = d.pop(B1);
-%$ t(2) = dyn_assert(isequal(f,dates(B1,B2,B4,B5)),1);
-%$ g = f.pop(1);
-%$ t(3) = dyn_assert(isequal(g,dates(B2,B4,B5)),1);
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/setdiff.m b/matlab/@dates/setdiff.m
deleted file mode 100644
index fb0228c0e8983afabb7a89f07739f8302ca1d420..0000000000000000000000000000000000000000
--- a/matlab/@dates/setdiff.m
+++ /dev/null
@@ -1,88 +0,0 @@
-function C = setdiff(A,B) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{C} =} setdiff (@var{A},@var{B})
-%! @anchor{@dates/intersect}
-%! @sp 1
-%! C of B and A.
-%! if A and B are not disjoints.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! @ref{dates} object.
-%! @item B
-%! @ref{dates} object.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item C
-%! @ref{dates} object.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if ~isa(A,'dates') || ~isa(B,'dates')
-    error(['dates::plus: Input arguments ''' inputname(1) ''' and ''' inputname(2) ''' must be dates objects!'])
-end
-
-if eq(A,B)
-    C = A;
-    return
-end
-
-if ~isequal(A.freq,B.freq)
-    C = dates();
-    return
-end
-
-if isoctave || matlab_ver_less_than('8.1.0')
-    time = setdiff(A.time,B.time,'rows');
-else
-    time = setdiff(A.time,B.time,'rows','legacy');
-end
-
-C = dates();
-if isempty(time)
-    return
-end
-
-C.freq = A.freq;
-C.time = time;
-C.ndat = rows(time); 
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1'):dates('1969Q4') ;
-%$ d2 = dates('1960Q1'):dates('1969Q4') ;
-%$ d3 = dates('1970Q1'):dates('1979Q4') ;
-%$
-%$ % Call the tested routine.
-%$ c1 = intersect(d1,d2);
-%$ c2 = intersect(d1,d3);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(c1,d2),1);
-%$ t(2) = dyn_assert(isempty(c2),1);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dates/size.m b/matlab/@dates/size.m
deleted file mode 100644
index 02df260705529d3dc2e8b039c16bec6d580d6385..0000000000000000000000000000000000000000
--- a/matlab/@dates/size.m
+++ /dev/null
@@ -1,35 +0,0 @@
-function varargout = size(o)
-
-% Copyright (C) 2013 -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/>.
-
-switch nargout
-  case 0
-    if isempty(o)
-        size([])
-    else
-        size(o.time)
-    end
-  case 1
-    if isempty(o)
-        varargout{1} = size([]);
-    else
-        varargout{1} = size(o.time);
-    end
-  otherwise
-    error('dates::size: Wrong calling sequence! Cannot return more than one argument.')
-end
\ No newline at end of file
diff --git a/matlab/@dates/sort.m b/matlab/@dates/sort.m
deleted file mode 100644
index d86c73901d530f1f089eb03f4947662fd05a0006..0000000000000000000000000000000000000000
--- a/matlab/@dates/sort.m
+++ /dev/null
@@ -1,78 +0,0 @@
-function dd = sort(dd) % --*-- Unitary tests --*--
-
-% Sort method for dates class.
-%
-% INPUTS 
-%  o dd    dates object.
-%
-% OUTPUTS 
-%  o dd    dates object (with dates sorted by increasing order).
-
-% Copyright (C) 2011-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(dd.ndat,1)
-    return
-end
-
-dd.time = sortrows(dd.time,[1,2]);
-
-%@test:1
-%$ % Define some dates
-%$ B1 = '1953Q4';
-%$ B2 = '1950Q2';
-%$ B3 = '1950Q1';
-%$ B4 = '1945Q3';
-%$
-%$ % Define expected results.
-%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4];
-%$ e.freq = 4;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4);
-%$ d = d.sort;
-%$ 
-%$ % 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:1
-%$ % Define some dates
-%$ B1 = '1953Q4';
-%$ B2 = '1950Q2';
-%$ B3 = '1950Q1';
-%$ B4 = '1945Q3';
-%$
-%$ % Define expected results.
-%$ e.time = [1945 3; 1950 1; 1950 2; 1953 4];
-%$ e.freq = 4;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4);
-%$ d = d.sort();
-%$
-%$ % 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
\ No newline at end of file
diff --git a/matlab/@dates/strings.m b/matlab/@dates/strings.m
deleted file mode 100644
index 94ccefa1129fe12e64bc4588ca2b4f1f9a0b10ec..0000000000000000000000000000000000000000
--- a/matlab/@dates/strings.m
+++ /dev/null
@@ -1,35 +0,0 @@
-function m = strings(dd)
-
-% Returns a cell array of strings containing the dates
-%
-% INPUTS 
-%   o dd   dates object
-%
-% OUTPUTS
-%   o m    cell array of strings
-%
-% SPECIAL REQUIREMENTS
-%   none
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-m = cell(1,dd.ndat);
-
-for i = 1:dd.ndat
-    m(i) = { date2string(dd.time(i,:), dd.freq) };
-end
\ No newline at end of file
diff --git a/matlab/@dates/subsasgn.m b/matlab/@dates/subsasgn.m
deleted file mode 100644
index 4b910070496d3443e50d27abc1ac70e811219f03..0000000000000000000000000000000000000000
--- a/matlab/@dates/subsasgn.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function val = subsasgn(val, idx, rhs)
-
-% 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/>.
-
-error('dates::subsasgn: Members of dates class are private')
\ No newline at end of file
diff --git a/matlab/@dates/subsref.m b/matlab/@dates/subsref.m
deleted file mode 100644
index e966fc1e958e65bbe3ae23fe937453a3002cb3f9..0000000000000000000000000000000000000000
--- a/matlab/@dates/subsref.m
+++ /dev/null
@@ -1,333 +0,0 @@
-function B = subsref(A,S) % --*-- Unitary tests --*--
-
-% Overload the subsref method for dates objects.
-%
-% INPUTS 
-%  o A     dates object.
-%  o S     matlab's structure.
-%
-% OUTPUTS 
-%  o B     dates object.
-%
-% REMARKS 
-%  See the matlab's documentation about the subsref method.
-
-% 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/>.
-
-switch S(1).type
-  case '.'
-    switch S(1).subs
-      case {'time','freq','ndat'}% Access public members.
-        if length(S)>1 && isequal(S(2).type,'()') && isempty(S(2).subs)
-            error(['dates::subsref: ' S(1).subs ' is not a method but a member!'])
-        end
-        B = builtin('subsref', A, S(1));
-      case {'sort','unique','double','isempty','length','char'}% Public methods (without input arguments)
-        B = feval(S(1).subs,A);
-        if length(S)>1 && isequal(S(2).type,'()') && isempty(S(2).subs)
-           S = shiftS(S,1);
-        end
-      case {'append','pop'}% Public methods (with arguments).
-        if isequal(S(2).type,'()')
-            B = feval(S(1).subs,A,S(2).subs{:});
-            S = shiftS(S,1);
-        else
-            error('dates::subsref: Something is wrong in your syntax!')
-        end
-      case {'disp'}
-        feval(S(1).subs,A);
-        return
-      otherwise
-        error('dates::subsref: Unknown public member or method!')
-    end
-  case '()'
-    if isempty(A)
-        if isempty(A.freq)
-            % Populate an empty dates object with time member (freq is not specified). Needs two or three inputs. First input is an integer
-            % scalar specifying the frequency. Second input is either the time member (a n*2 array of integers) or a column vector with n
-            % elements (the first column of the time member --> years). If the the second input is a row vector and if A.freq~=1 a third input
-            % is necessary. The third input is n*1 vector of integers between 1 and A.freq (second column of the time member --> subperiods).
-            B = dates();
-            % First input is the frequency.
-            if isfreq(S(1).subs{1})
-                if ischar(S(1).subs{1})
-                    B.freq = string2freq(S(1).subs{1});
-                else
-                    B.freq = S(1).subs{1};
-                end
-            else
-                error('dates::subsref: First input must be a frequency!')
-            end
-            if isequal(length(S(1).subs),2)
-                % If two inputs are provided, the second input must be a n*2 array except if frequency is annual.
-                [n, m] = size(S(1).subs{2});
-                if m>2
-                    error('dates::subsref: Second input argument array cannot have more than two columns!')
-                end
-                if ~isequal(m,2) && ~isequal(B.freq,1)
-                    error('dates::subsref: Second argument has to be a n*2 array for non annual frequency!')
-                end
-                if ~all(all(S(1).subs{2}))
-                    error('dates::subsref: Second argument has be an array of intergers!')
-                end
-                if m>1 && ~issubperiod(S(1).subs{2}(:,2),B.freq)
-                    error(['dates::subsref: Elements in the second column of the first input argument are not legal subperiods (should be integers betwwen 1 and ' num2str(B.freq) ')!'])
-                end
-                if isequal(m,2)
-                    B.time = S(1).subs{2};
-                elseif isequal(m,1)
-                    B.time = [S(1).subs{2}, ones(n,1)];
-                else
-                    error('dates::subsref: This is a bug!')
-                end
-                B.ndat = rows(B.time);
-            elseif isequal(length(S(1).subs),3)
-                % If three inputs are provided, the second and third inputs are column verctors of integers (years and subperiods).
-                if ~iscolumn(S(1).subs{2}) && ~all(isint(S(1).subs{2}))
-                    error('dates::subsref: Second input argument must be a column vector of integers!')
-                end
-                n1 = size(S(1).subs{2},1);
-                if ~iscolumn(S(1).subs{3}) && ~issubperiod(S(1).subs{3}, B.freq)
-                    error(['dates::subsref: Third input argument must be a column vector of subperiods (integers between 1 and ' num2str(B.freq) ')!'])
-                end
-                n2 = size(S(1).subs{3},1);
-                if ~isequal(n1,n2)
-                    error('dates::subsref: Second and third input arguments must have the same number of elements!')
-                end
-                B.time = [S(1).subs{2}, S(1).subs{3}];
-                B.ndat = rows(B.time);
-            else
-                error('dates::subsref: Wrong calling sequence!')
-            end
-        else
-            % Populate an empty dates object with time member (freq is already specified).
-            % Needs one (time) or two (first and second columns of time for years and subperiods) inputs.
-            B = A;
-            if isequal(length(S(1).subs),2)
-                if ~iscolumn(S(1).subs{1}) && ~all(isint(S(1).subs{1}))
-                    error('dates::subsref: First argument has to be a column vector of integers!')
-                end
-                n1 = size(S(1).subs{1},1);
-                if ~iscolumn(S(1).subs{2}) && ~issubperiod(S(1).subs{2}, B.freq)
-                    error(['dates::subsref: Second argument has to be a column vector of subperiods (integers between 1 and ' num2str(B.freq) ')!'])
-                end
-                n2 = size(S(1).subs{2},1);
-                if ~isequal(n2,n1)
-                    error('dates::subsref: First and second argument must have the same number of rows!')
-                end
-                B.time = [S(1).subs{1}, S(1).subs{2}];
-                B.ndat = rows(B.time);
-            elseif isequal(length(S(1).subs),1)
-                [n, m] = size(S(1).subs{1});
-                if ~isequal(m,2) && ~isequal(B.freq,1)
-                    error('dates::subsref: First argument has to be a n*2 array!')
-                end
-                if ~all(isint(S(1).subs{1}(:,1)))
-                    error('dates::subsref: First column of the first argument has to be a column vector of integers!')
-                end
-                if m>1 && issubperiod(S(1).subs{1}(:,1), B.freq)
-                    error(['dates::subsref: The second column of the first input argument has to be a column  vector of subperiods (integers between 1 and ' num2str(B.freq) ')!'])
-                end
-                if isequal(m,2)
-                    B.time = S(1).subs{1};
-                elseif isequal(m,1) && isequal(B.freq,1)
-                    B.time = [S(1).subs{1}, ones(n,1)];
-                else
-                    error('dates::subsref: This is a bug!')
-                end
-                B.ndat = rows(B.time);
-            else
-                error('dates::subsref: Wrong number of inputs!')
-            end
-        end
-    else
-        % dates object A is not empty. We extract some dates
-        if isvector(S(1).subs{1}) && all(isint(S(1).subs{1})) && all(S(1).subs{1}>0) && all(S(1).subs{1}<=A.ndat)
-            B = dates();
-            B.freq = A.freq;
-            B.time = A.time(S(1).subs{1},:);
-            B.ndat = rows(B.time);
-        else
-            error(['dates::subsref: indices has to be a vector of positive integers less than or equal to ' int2str(A.ndat) '!'])
-        end
-    end
-  otherwise
-    error('dates::subsref: Something is wrong in your syntax!')
-end
-
-S = shiftS(S,1);
-if ~isempty(S)
-    B = subsref(B, S);
-end
-
-%@test:1
-%$ % Define a dates object
-%$ B = dates('1950Q1','1950Q2','1950Q3','1950Q4','1951Q1');
-%$
-%$ % Try to extract a sub-dates object.
-%$ d = B(2:3);
-%$
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2; 1950 3]);
-%$     t(4) = dyn_assert(d.ndat,2);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a dates object
-%$ B = dates('1950Q1'):dates('1960Q3');
-%$
-%$ % Try to extract a sub-dates object and apply a method
-%$ 
-%$ d = B(2:3).sort ;
-%$
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2; 1950 3]);
-%$     t(4) = dyn_assert(d.ndat,2);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a dates object
-%$ B = dates('1950Q1'):dates('1960Q3');
-%$
-%$ % Try to extract a sub-dates object and apply a method
-%$
-%$ d = B(2:3).sort() ;
-%$
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2; 1950 3]);
-%$     t(4) = dyn_assert(d.ndat,2);
-%$ end
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a dates object
-%$ B = dates('1950Q1','1950Q2','1950Q3','1950Q4','1951Q1');
-%$
-%$ % Try to extract a sub-dates object.
-%$ d = B(2);
-%$
-%$ if isa(d,'dates')
-%$     t(1) = 1;
-%$ else
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(d.freq,B.freq);
-%$     t(3) = dyn_assert(d.time,[1950 2]);
-%$     t(4) = dyn_assert(d.ndat,1);
-%$ end
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define an empty dates object with quaterly frequency.
-%$ qq = dates('Q');
-%$
-%$ % Define a ranges of dates using qq.
-%$ try
-%$     r1 = qq(1950,1):qq(1950,3);%qq([1950, 3]);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$ if t(1)
-%$     try
-%$         r2 = qq([1950, 1; 1950, 2; 1950, 3]);
-%$         t(2) = 1;
-%$     catch
-%$         t(2) = 0;
-%$     end
-%$ end
-%$ if t(1) && t(2)
-%$     try
-%$         r3 = qq(1950*ones(3,1), transpose(1:3));
-%$         t(3) = 1;
-%$     catch
-%$         t(3) = 0;
-%$     end
-%$ end
-%$
-%$ if t(1) && t(2) && t(3)
-%$     t(4) = dyn_assert(isequal(r1,r2),1);
-%$     t(5) = dyn_assert(isequal(r1,r3),1);
-%$ end
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ % Define an empty dates object with quaterly frequency.
-%$ date = dates();
-%$
-%$ % Define a ranges of dates using qq.
-%$ try
-%$     r1 = date(4,1950,1):date(4,[1950, 3]);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$ if t(1)
-%$     try
-%$         r2 = date(4,[1950, 1; 1950, 2; 1950, 3]);
-%$         t(2) = 1;
-%$     catch
-%$         t(2) = 0;
-%$     end
-%$ end
-%$ if t(1) && t(2)
-%$     try
-%$         r3 = date(4,1950*ones(3,1), transpose(1:3));
-%$         t(3) = 1;
-%$     catch
-%$         t(3) = 0;
-%$     end
-%$ end
-%$
-%$ if t(1) && t(2) && t(3)
-%$     t(4) = dyn_assert(isequal(r1,r2),1);
-%$     t(5) = dyn_assert(isequal(r1,r3),1);
-%$ end
-%$ T = all(t);
-%@eof:6
-
diff --git a/matlab/@dates/uminus.m b/matlab/@dates/uminus.m
deleted file mode 100644
index fd3a79c1806065eead5e62169ea91919f016b309..0000000000000000000000000000000000000000
--- a/matlab/@dates/uminus.m
+++ /dev/null
@@ -1,78 +0,0 @@
-function B = uminus(A)  % --*-- Unitary tests --*--
-
-% Overloads the unary minus operator for dates objects. Shifts all the elements by one period.
-%
-% INPUTS 
-%  o A    dates object with n elements.
-%
-% OUTPUTS 
-%  o B    dates object with n elements.
-
-% 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/>.
-
-B = dates(A);
-B.time(:,2) = B.time(:,2)-1;
-idx = find(B.time(:,2)==0);
-B.time(idx,1) = B.time(idx,1)-1;
-B.time(idx,2) = B.freq;
-
-%@test:1
-%$ % Define some dates
-%$ date_1 = '1950Y';
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q1';
-%$ date_4 = '1950M2';
-%$ date_5 = '1950M1';
-%$
-%$ % Call the tested routine.
-%$ d1 = dates(date_1); d1 = -d1;
-%$ d2 = dates(date_2); d2 = -d2;
-%$ d3 = dates(date_3); d3 = -d3;
-%$ d4 = dates(date_4); d4 = -d4;
-%$ d5 = dates(date_5); d5 = -d5;
-%$ i1 = (d1==dates('1949Y'));
-%$ i2 = (d2==dates('1950Q1'));
-%$ i3 = (d3==dates('1949Q4'));
-%$ i4 = (d4==dates('1950M1'));
-%$ i5 = (d5==dates('1949M12'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,1);
-%$ t(2) = dyn_assert(i2,1);
-%$ t(3) = dyn_assert(i3,1);
-%$ t(4) = dyn_assert(i4,1);
-%$ t(5) = dyn_assert(i5,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4','1951Q1');
-%$ d2 = dates('1949Q4','1950Q1','1950Q2','1950Q3','1950Q4');
-%$ try
-%$   d3 = -d1;
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(all(d2==d3),1);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/union.m b/matlab/@dates/union.m
deleted file mode 100644
index ab3d393abb2c3728af1a41fa3edae1d5274a7c3d..0000000000000000000000000000000000000000
--- a/matlab/@dates/union.m
+++ /dev/null
@@ -1,58 +0,0 @@
-function D = union(varargin) % --*-- Unitary tests --*--
-
-% Overloads union function for dates objects (removes repetitions if any).
-%
-% INPUTS 
-%  o A    dates object.
-%  o B    dates object.
-%  o C    dates object.
-%  o ...
-%
-% OUPUTS 
-%  o D    dates object (elements are sorted by increasing order).
-
-% 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,1)
-    D = sort(unique(varargin{1}));
-    return;
-end
-
-D = sort(unique(horzcat(varargin{:})));
-
-%@test:1
-%$ % Define some dates objects
-%$ d1 = dates('1950Q1'):dates('1959Q4') ;
-%$ d2 = dates('1960Q1'):dates('1969Q4') ;
-%$ d3 = dates('1970Q1'):dates('1979Q4') ;
-%$
-%$ % Call the tested routine.
-%$ e1 = union(d1);
-%$ e2 = union(d1,d2);
-%$ e3 = union(d1,d2,d3);
-%$ e4 = union(d1,d2,d3,d2+d3);
-%$ e5 = union(d1,d2,d3,d2);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(e1,d1),1);
-%$ t(2) = dyn_assert(isequal(e2,d1+d2),1);
-%$ t(3) = dyn_assert(isequal(e3,d1+d2+d3),1);
-%$ t(4) = dyn_assert(isequal(e4,d1+d2+d3),1);
-%$ t(5) = dyn_assert(isequal(e5,d1+d2+d3),1);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dates/unique.m b/matlab/@dates/unique.m
deleted file mode 100644
index 66ee5d067cb4a1de572059962550f782395a7049..0000000000000000000000000000000000000000
--- a/matlab/@dates/unique.m
+++ /dev/null
@@ -1,65 +0,0 @@
-function B = unique(A) % --*-- Unitary tests --*--
-
-% Overloads the unique function for dates objects.
-%
-% INPUTS 
-%  o A    dates object.
-%
-% OUTPUTS 
-%  o B    dates object (a copy of A without repetitions, only the last occurence of a date is kept).
-
-% 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 isequal(A.ndat,1)
-    return
-end
-
-B = A;
-
-if isoctave || matlab_ver_less_than('8.1.0')
-    [tmp, id, jd] = unique(A.time,'rows');
-else
-    [tmp, id, jd] = unique(A.time,'rows','legacy');
-end
-
-B.time = A.time(sort(id),:);
-B.ndat = size(B.time,1);
-
-%@test:1
-%$ % Define some dates
-%$ B1 = '1953Q4';
-%$ B2 = '1950Q2';
-%$ B3 = '1950q1';
-%$ B4 = '1945Q3';
-%$ B5 = '1950Q2'; 
-%$
-%$ % Define expected results.
-%$ e.time = [1953 4; 1950 1; 1945 3; 1950 2];
-%$ e.freq = 4;
-%$ e.ndat = 4;
-%$
-%$ % Call the tested routine.
-%$ d = dates(B1,B2,B3,B4,B5);
-%$ d = d.unique();
-%$ 
-%$ % 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
\ No newline at end of file
diff --git a/matlab/@dates/uplus.m b/matlab/@dates/uplus.m
deleted file mode 100644
index 33bf6ff2be94db41505ece985c687c88d07eed6e..0000000000000000000000000000000000000000
--- a/matlab/@dates/uplus.m
+++ /dev/null
@@ -1,78 +0,0 @@
-function B = uplus(A)  % --*-- Unitary tests --*--
-
-% Overloads the unary plus operator for dates objects. Shifts all the elements by one period.
-%
-% INPUTS 
-%  o A    dates object with n elements.
-%
-% OUTPUTS 
-%  o B    dates object with n elements.
-
-% 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/>.
-
-B = dates(A);
-B.time(:,2) = B.time(:,2)+1;
-idx = find(B.time(:,2)>B.freq); % Happy new year!
-B.time(idx,1) = B.time(idx,1)+1;
-B.time(idx,2) = 1;
-
-%@test:1
-%$ % Define some dates
-%$ date_1 = '1950Y';
-%$ date_2 = '1950Q2';
-%$ date_3 = '1950Q4';
-%$ date_4 = '1950M2';
-%$ date_5 = '1950M12';
-%$
-%$ % Call the tested routine.
-%$ d1 = dates(date_1); d1 = +d1;
-%$ d2 = dates(date_2); d2 = +d2;
-%$ d3 = dates(date_3); d3 = +d3;
-%$ d4 = dates(date_4); d4 = +d4;
-%$ d5 = dates(date_5); d5 = +d5;
-%$ i1 = (d1==dates('1951Y'));
-%$ i2 = (d2==dates('1950Q3'));
-%$ i3 = (d3==dates('1951Q1'));
-%$ i4 = (d4==dates('1950M3'));
-%$ i5 = (d5==dates('1951M1'));
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(i1,1);
-%$ t(2) = dyn_assert(i2,1);
-%$ t(3) = dyn_assert(i3,1);
-%$ t(4) = dyn_assert(i4,1);
-%$ t(5) = dyn_assert(i5,1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ d1 = dates('1950Q1','1950Q2','1950Q3','1950Q4','1951Q1');
-%$ d2 = dates('1950Q2','1950Q3','1950Q4','1951Q1','1951Q2');
-%$ try
-%$   d3 = +d1;
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(all(d2==d3),1);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dates/vertcat.m b/matlab/@dates/vertcat.m
deleted file mode 100644
index 6cf21743dd5dd027f0b5c7fbfa634b15b716f08b..0000000000000000000000000000000000000000
--- a/matlab/@dates/vertcat.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function B = vertcat(varargin)
-    
-% Overloads the vertcat method for dates objects.
-%
-% INPUTS 
-%  o A1    dates object.
-%  o A2    dates object.
-%  o ...
-%
-% OUTPUTS 
-%  o B    dates object containing dates defined in A1, A2, ...
-%
-% EXAMPLE 1 
-%  If A, B and C are dates object the following syntax:
-%    
-%    D = [A; B; C] ;
-%
-%  Defines a dates object D containing the dates appearing in A, B and C.
-    
-% 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/>.
-
-B = horzcat(varargin{:});
\ No newline at end of file
diff --git a/matlab/@dseries/abs.m b/matlab/@dseries/abs.m
deleted file mode 100644
index ba4da3faba03f57f264ab76525020259b29e9373..0000000000000000000000000000000000000000
--- a/matlab/@dseries/abs.m
+++ /dev/null
@@ -1,107 +0,0 @@
-function A = abs(B) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} abs (@var{B})
-%! @anchor{@dseries/uminus}
-%! @sp 1
-%! Overloads the abs method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-A = dseries();
-
-A.data = abs(B.data);
-A.dates = B.dates;
-
-A.name = cell(vobs(A), 1);
-A.tex = cell(vobs(A), 1);
-for i = 1:vobs(A)
-    A.name(i) = {[ 'abs(' B.name{i} ')']};
-    A.tex(i) = {[ '|' B.tex{i} '|']};
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = randn(10,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ A_tex = {'A_1';'A_2'};
-%$ t = zeros(6,1);
-%$
-%$ % Instantiate a time series object and compute the absolute value.
-%$ try
-%$    ts1 = dseries(A,[],A_name,A_tex);
-%$    ts2 = abs(ts1);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,abs(A),1e-15);
-%$    t(5) = dyn_assert(ts2.name,{'abs(A1)';'abs(A2)'});
-%$    t(6) = dyn_assert(ts2.tex,{'|A_1|';'|A_2|'});
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = randn(10,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ A_tex = {'A_1';'A_2'};
-%$ t = zeros(6,1);
-%$
-%$ % Instantiate a time series object and compute the absolute value.
-%$ try
-%$    ts1 = dseries(A,[],A_name,A_tex);
-%$    ts2 = ts1.abs();
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,abs(A),1e-15);
-%$    t(5) = dyn_assert(ts2.name,{'abs(A1)';'abs(A2)'});
-%$    t(6) = dyn_assert(ts2.tex,{'|A_1|';'|A_2|'});
-%$ end
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dseries/align.m b/matlab/@dseries/align.m
deleted file mode 100644
index 32878127ec1631bb97778a330544bc569086d3e0..0000000000000000000000000000000000000000
--- a/matlab/@dseries/align.m
+++ /dev/null
@@ -1,182 +0,0 @@
-function [a,b] = align(a, b) % --*-- Unitary tests --*--
-    
-%@info:
-%! @deftypefn {Function File} {[@var{a}, @var{b}] =} align (@var{a}, @var{b})
-%! @anchor{dseries/align}
-%! @sp 1
-%! If dseries objects @var{a} and @var{b} are defined on different time ranges, extend @var{a} and/or
-%! @var{b} with NaNs so that they are defined on the same time range.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item a
-%! Object instantiated by @ref{dseries}.
-%! @item b
-%! Object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item a
-%! Object instantiated by @ref{dseries}.
-%! @item b
-%! Object instantiated by @ref{dseries}.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if ~isequal(frequency(a),frequency(b))
-    error(['dseries::align: ''' inputname(1) ''' and ''' inputname(2) ''' dseries objects must have common frequencies!'])
-end
-
-init = min(firstdate(a),firstdate(b));
-last = max(lastdate(a),lastdate(b));
-
-if isempty(intersect(a.dates,b.dates))
-    error(['dseries::align: ''' inputname(1) ''' and ''' inputname(2) ''' dseries object must have at least one common date!'])
-end
-
-a_init = init;
-b_init = init;
-a_last = last;
-b_last = last;
-
-if firstdate(b)>init
-    n = firstdate(b)-init;
-    b.data = [NaN(n, vobs(b)); b.data];
-    b_init = init;
-end
-
-if firstdate(a)>init
-    n = firstdate(a)-init;
-    a.data = [NaN(n, vobs(a)); a.data];
-    a_init = init;
-end
-
-if lastdate(b)<last
-    n = last-lastdate(b);
-    b.data = [b.data; NaN(n, vobs(b))];
-end
-
-if lastdate(a)<last
-    n = last-lastdate(a);
-    a.data = [a.data; NaN(n, vobs(a))];
-end
-
-a.dates = a_init:a_init+(nobs(a)-1);
-b.dates = b_init:b_init+(nobs(b)-1);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(8,3); B = rand(7,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial dates
-%$ A_init = '1990Q1';
-%$ B_init = '1989Q2';
-%$
-%$ % Instantiate two dseries objects
-%$ ts1 = dseries(A,A_init,A_name);
-%$ ts2 = dseries(B,B_init,B_name);
-%$
-%$ try
-%$   [ts1, ts2] = align(ts1, ts2);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(ts1.nobs,ts2.nobs);
-%$   t(3) = dyn_assert(isequal(ts1.init,ts2.init),1);
-%$   t(4) = dyn_assert(ts1.data,[NaN(3,3); A], 1e-15);
-%$   t(5) = dyn_assert(ts2.data,[B; NaN(4,2)], 1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(8,3); B = rand(7,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial dates
-%$ A_init = '1990Q1';
-%$ B_init = '1990Q1';
-%$
-%$ % Instantiate two dseries objects
-%$ ts1 = dseries(A,A_init,A_name);
-%$ ts2 = dseries(B,B_init,B_name);
-%$
-%$ try
-%$   [ts1, ts2] = align(ts1, ts2);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(ts1.nobs,ts2.nobs);
-%$   t(3) = dyn_assert(isequal(ts1.init,ts2.init),1);
-%$   t(4) = dyn_assert(ts1.data,A, 1e-15);
-%$   t(5) = dyn_assert(ts2.data,[B; NaN(1,2)], 1e-15);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(8,3); B = rand(7,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial dates
-%$ A_init = '1990Q1';
-%$ B_init = '1990Q1';
-%$
-%$ % Instantiate two dseries objects
-%$ ts1 = dseries(A,A_init,A_name);
-%$ ts2 = dseries(B,B_init,B_name);
-%$
-%$ try
-%$   [ts2, ts1] = align(ts2, ts1);
-%$   t(1) = 1;
-%$ catch
-%$   t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(ts1.nobs,ts2.nobs);
-%$   t(3) = dyn_assert(isequal(ts1.init,ts2.init),1);
-%$   t(4) = dyn_assert(ts1.data,A, 1e-15);
-%$   t(5) = dyn_assert(ts2.data,[B; NaN(1,2)], 1e-15);
-%$ end
-%$ T = all(t);
-%@eof:3
\ No newline at end of file
diff --git a/matlab/@dseries/baxter_king_filter.m b/matlab/@dseries/baxter_king_filter.m
deleted file mode 100644
index 1943668310ea1f8f89bab4ed1bc0151828db8376..0000000000000000000000000000000000000000
--- a/matlab/@dseries/baxter_king_filter.m
+++ /dev/null
@@ -1,148 +0,0 @@
-function ts = baxter_king_filter(ts, high_frequency, low_frequency, K) % --*-- Unitary tests --*--
-
-% ts = baxter_king_filter(ts, high_frequency, low_frequency, K)
-%
-% Implementation of Baxter and King (1999) band pass filter for dseries objects. The code is adapted from
-% the one provided by Baxter and King. This filter isolates business cycle fluctuations with a period of length 
-% ranging between high_frequency to low_frequency (quarters).
-%
-% INPUTS 
-%  o ts                 dseries object.
-%  o high_frequency     positive scalar, period length (default value is 6).
-%  o low_frequency      positive scalar, period length (default value is 32).
-%  o K                  positive scalar integer, truncation parameter (default value is 12).
-%
-% OUTPUTS 
-%  o ts                 dseries object.
-%
-% REMARKS 
-% This filter use a (symmetric) moving average smoother, so that K observations at the beginning and at the end of the 
-% sample are lost in the computation of the filter.
-
-% 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 nargin<4 || isempty(truncature)
-    K = 12;
-    if nargin<3 || isempty(low_frequency)
-        % Set default number of periods corresponding to the lowest frequency.
-        low_frequency = 32;
-        if nargin<2 || isempty(high_frequency)
-            % Set default number of periods corresponding to the highest frequency.
-            high_frequency = 6;
-            if nargin<1
-                error('dseries::baxter_king_filter: I need at least one argument')
-            end
-        else
-            if high_frequency<2
-                error('dseries::baxter_king_filter: Second argument must be greater than 2!')
-            end
-            if high_frequency>low_frequency
-                error('dseries::baxter_king_filter: Second argument must be smaller than the third argument!')
-            end
-        end
-    end
-end
-       
-% translate periods into frequencies.
-hf=2.0*pi/high_frequency;
-lf=2.0*pi/low_frequency;
-
-% Set weights for the band-pass filter's lag polynomial.
-weights = zeros(K+1,1); lpowers = transpose(1:K);
-weights(2:K+1) = (sin(lpowers*hf)-sin(lpowers*lf))./(lpowers*pi);
-weights(1) = (hf-lf)/pi;
-
-% Set the constraint on the sum of weights.
-if low_frequency>1000
-    % => low pass filter.
-    sum_of_weights_constraint = 1.0;
-else
-    sum_of_weights_constraint = 0.0;
-end
-
-% Compute the sum of weights.
-sum_of_weights = weights(1) + 2*sum(weights(2:K+1));
-
-% Correct the weights.
-weights = weights + (sum_of_weights_constraint - sum_of_weights)/(2*K+1);
-
-% Weights are symmetric!
-weights = [flipud(weights(2:K+1)); weights];
-
-tmp = zeros(size(ts.data));
-
-% Filtering step.
-for t = K+1:nobs(ts)-K
-    tmp(t,:)  = weights'*ts.data(t-K:t+K,:);    
-end
-
-% Update dseries object.
-ts.data = tmp(K+1:end-K,:);
-init = firstdate(ts)+K;
-ts.dates = init:init+(nobs(ts)-1);
-
-%@test:1
-%$ plot_flag = 0;
-%$
-%$ % Create a dataset.
-%$ e = .2*randn(200,1);
-%$ u = randn(200,1);
-%$ stochastic_trend = cumsum(e); 
-%$ deterministic_trend = .1*transpose(1:200);
-%$ x = zeros(200,1);
-%$ for i=2:200
-%$    x(i) = .75*x(i-1) + e(i);
-%$ end
-%$ y = x + stochastic_trend + deterministic_trend;
-%$
-%$ % Test the routine.
-%$ try
-%$     ts = dseries(y,'1950Q1');
-%$     ts = ts.baxter_king_filter();
-%$     xx = dseries(x,'1950Q1');
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1953, 1]);
-%$     t(5) = dyn_assert(ts.vobs,1);
-%$     t(6) = dyn_assert(ts.nobs,176);
-%$ end
-%$
-%$ % Show results
-%$ if plot_flag
-%$     plot(xx(ts.dates).data,'-k');
-%$     hold on
-%$     plot(ts.data,'--r');
-%$     hold off
-%$     axis tight
-%$     id = get(gca,'XTick');
-%$     set(gca,'XTickLabel',strings(ts.dates(id)));
-%$     legend({'Stationary component of y', 'Filtered y'})
-%$     print('-depsc2','../doc/dynare.plots/BaxterKingFilter.eps')
-%$     system('convert -density 300 ../doc/dynare.plots/BaxterKingFilter.eps ../doc/dynare.plots/BaxterKingFilter.png');
-%$     system('convert -density 300 ../doc/dynare.plots/BaxterKingFilter.eps ../doc/dynare.plots/BaxterKingFilter.pdf');
-%$     system('convert -density 300 ../doc/dynare.plots/BaxterKingFilter.eps ../doc/dynare.plots/BaxterKingFilter.jpg');
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/chain.m b/matlab/@dseries/chain.m
deleted file mode 100644
index fae59f0523d92f84feb1bdbe1749d39150f9d41c..0000000000000000000000000000000000000000
--- a/matlab/@dseries/chain.m
+++ /dev/null
@@ -1,61 +0,0 @@
-function vs = chain(ts,us)  % --*-- Unitary tests --*--
-
-% 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 vobs(ts)-vobs(us)
-    error(['dseries::chain: dseries objects ' inputname(1) ' and ' inputname(2) ' must have the same number of variables!'])
-end
-
-if frequency(ts)-frequency(us)
-    error(['dseries::chain: dseries objects ' inputname(1) ' and ' inputname(2) ' must have common frequencies!'])
-end
-
-if lastdate(ts)<firstdate(us)
-    error(['dseries::chain: The last date in ' inputname(1) ' (' date2string(ts.dates(end)) ') must not preceed the first date in ' inputname(2) ' (' date2string(us.dates(1)) ')!'])
-end
-
-tdx = find(sum(bsxfun(@eq,us.dates.time,ts.dates.time(end,:)),2)==2);
-GrowthFactor = us.data(tdx+1:end,:)./us.data(tdx:end-1,:);
-CumulatedGrowthFactors = cumprod(GrowthFactor);
-
-vs = ts;
-vs.data = [vs.data; bsxfun(@times,CumulatedGrowthFactors,vs.data(end,:))];
-
-vs.dates = firstdate(vs):firstdate(vs)+nobs(vs);
-
-%@test:1
-%$ try
-%$     ts = dseries([1; 2; 3; 4],dates('1950Q1')) ;
-%$     us = dseries([3; 4; 5; 6],dates('1950Q3')) ;
-%$     vs = chain(ts,us);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(vs.freq,4);
-%$     t(3) = dyn_assert(vs.init.freq,4);
-%$     t(4) = dyn_assert(vs.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,1);
-%$     t(6) = dyn_assert(vs.nobs,6);
-%$     t(7) = isequal(vs.data,transpose(1:6));
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/check.m b/matlab/@dseries/check.m
deleted file mode 100644
index c4bfce37a40008176eaed90794a31e953cfa01f6..0000000000000000000000000000000000000000
--- a/matlab/@dseries/check.m
+++ /dev/null
@@ -1,86 +0,0 @@
-function [error_flag,message] = check(A)
-
-% 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/>.
-
-error_flag = 0;
-
-[n,m] = size(A.data);
-
-if ~isequal(m, vobs(A));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: Wrong number of variables in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
-
-if ~isequal(n,nobs(A));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: Wrong number of observations in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
-
-if ~isequal(m,numel(A.name));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: Wrong number of variable names in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
-
-if ~isequal(m,numel(A.tex));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: Wrong number of variable tex names in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
-
-if ~isequal(numel(A.name),numel(A.tex));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: The number of variable tex names has to be equal to the number of variable names in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
-
-if ~isequal(numel(unique(A.name)),numel(A.name));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: The variable names in dseries object ''' inputname(1) ''' are not unique!'];
-    end
-    return
-end
-
-if ~isequal(numel(unique(A.tex)),numel(A.tex));
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: The variable tex names in dseries object ''' inputname(1) ''' are not unique!'];
-    end
-    return
-end
-
-if ~isequal(A.dates,firstdate(A):firstdate(A)+nobs(A))
-    error_flag = 1;
-    if nargout>1
-        message = ['dseries: Wrong definition of the dates member in dseries object ''' inputname(1) '''!'];
-    end
-    return
-end
\ No newline at end of file
diff --git a/matlab/@dseries/cumprod.m b/matlab/@dseries/cumprod.m
deleted file mode 100644
index 4e98d38b1ad3ca6177e80cfa19baa3d5a263b515..0000000000000000000000000000000000000000
--- a/matlab/@dseries/cumprod.m
+++ /dev/null
@@ -1,234 +0,0 @@
-function B = cumprod(varargin) % --*-- Unitary tests --*--
-
-% Overloads matlab's cumprod function for dseries objects.
-%
-% INPUTS
-%  o A     dseries object [mandatory].
-%  o d     dates object [optional]
-%  o v     dseries object with one observation [optional]
-%
-% OUTPUTS
-%  o B     dseries object.
-
-% 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/>.
-
-% Get indices of the columns without NaNs
-idx = find(~any(isnan(varargin{1}.data)));
-
-if isempty(idx)
-    error('dseries::cumprod: All the variables have NaNs. The cumulated product cannot be computed!')
-end
-
-if ~isequal(idx(:),transpose(1:vobs(varargin{1})))
-    warning('dseries::cumprod: The cumulated product is not computed for some variables because they have NaNs!')
-end
-
-switch nargin
-    case 1
-      % Initialize the output.
-      B = varargin{1};
-      % Perform the cumulated sum
-      B.data(:,idx) = cumprod(B.data(:,idx));
-      % Change the name of the variables
-      for i=1:vobs(B)
-          B.name(i) = {['cumprod(' B.name{i} ')']};
-          B.tex(i) = {['\prod_t ' B.tex{i}]};
-      end
-  case 2
-    if isdseries(varargin{2})
-        if ~isequal(vobs(varargin{1}), vobs(varargin{2}))
-            error('dseries::cumprod: First and second input arguments must be dseries objects with the same number of variables!')
-        end
-        if ~isequal(varargin{1}.name, varargin{2}.name)
-            warning('dseries::cumprod: First and second input arguments must be dseries objects do not have the same variables!')
-        end
-        if ~isequal(nobs(varargin{2}),1)
-            error('dseries::cumprod: Second input argument must be a dseries object with only one observation!')
-        end
-        B = cumprod(varargin{1});
-        B.data = bsxfun(@rdivide,B.data,B.data(1,:));
-        B.data = bsxfun(@times,B.data,varargin{2}.data);
-    elseif isdates(varargin{2})
-        B = cumprod(varargin{1});
-        t = find(B.dates==varargin{2});
-        if isempty(t)
-            if varargin{2}==(firstdate(B)-1)
-                return
-            else
-                error(['dseries::cumprod: date ' date2string(varargin{2}) ' is not in the sample!'])
-            end
-        end
-        B.data = bsxfun(@rdivide,B.data,B.data(t,:));
-    else
-        error('dseries::cumprod: Second input argument must be a dseries object or a dates object!')
-    end
-  case 3
-    if ~isdates(varargin{2})
-        error('dseries::cumprod: Second input argument must be a dates object!')
-    end
-    if ~isdseries(varargin{3})
-        error('dseries::cumprod: Third input argument must be a dseries object!')
-    end
-    if ~isequal(vobs(varargin{1}), vobs(varargin{3}))
-        error('dseries::cumprod: First and third input arguments must be dseries objects with the same number of variables!')
-    end
-    if ~isequal(varargin{1}.name, varargin{3}.name)
-        warning('dseries::cumprod: First and third input arguments must be dseries objects do not have the same variables!')
-    end
-    if ~isequal(nobs(varargin{3}),1)
-        error('dseries::cumprod: Third input argument must be a dseries object with only one observation!')
-    end
-    B = cumprod(varargin{1});
-    t = find(B.dates==varargin{2});
-    if isempty(t)
-        if varargin{2}==(firstdate(B)-1)
-            B.data = bsxfun(@times,B.data,varargin{3}.data);
-            return
-        else
-            error(['dseries::cumprod: date ' date2string(varargin{2}) ' is not in the sample!'])
-        end
-    end
-    B.data = bsxfun(@rdivide, B.data, B.data(t,:));
-    B.data = bsxfun(@times, B.data, varargin{3}.data);
-  otherwise
-    error('dseries::cumprod: Wrong number of input arguments!')
-end
-
-%@test:1
-%$ % Define a data set.
-%$ A = 2*ones(4,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ try
-%$     ts = cumprod(ts);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = isequal(ts.data,cumprod(A));
-%$     t(3) = isequal(ts.name{1},'cumprod(A1)');
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a data set.
-%$ A = 2*ones(4,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ try
-%$     ts = ts.cumprod();
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = isequal(ts.data,cumprod(A));
-%$     t(3) = isequal(ts.name{1},'cumprod(A1)');
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-
-%@test:3
-%$ % Define a data set.
-%$ A = 2*ones(7,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts = cumprod(ts,dates('3Y'));
-%$
-%$ % Expected results.
-%$ ds = dseries([.25; .5; 1; 2; 4; 8; 16], [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts,ts),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a data set.
-%$ A = 2*ones(7,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(pi, [], A_name, []);
-%$
-%$ % Call the tested method.
-%$ ts3 = cumprod(ts1,dates('3Y'),ts2);
-%$
-%$ % Expected results.
-%$ ts4 = dseries([.25; .5; 1; 2; 4; 8; 16]*pi, [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts3,ts4),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a data set.
-%$ A = 2*ones(7,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(pi, [], A_name, []);
-%$
-%$ % Call the tested method.
-%$ ts3 = ts1.cumprod(dates('3Y'),ts2);
-%$
-%$ % Expected results.
-%$ ts4 = dseries([.25; .5; 1; 2; 4; 8; 16]*pi, [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts3,ts4),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:5
\ No newline at end of file
diff --git a/matlab/@dseries/cumsum.m b/matlab/@dseries/cumsum.m
deleted file mode 100644
index 6dfb73c284dfd166d59b91cb08e2f375dc306b42..0000000000000000000000000000000000000000
--- a/matlab/@dseries/cumsum.m
+++ /dev/null
@@ -1,225 +0,0 @@
-function B = cumsum(varargin) % --*-- Unitary tests --*--
-
-% Overloads matlab's cumsum function for dseries objects.
-%
-% INPUTS 
-%  o A     dseries object [mandatory].
-%  o d     dates object [optional]
-%  o v     dseries object with one observation [optional]
-%
-% OUTPUTS 
-%  o B     dseries object.
-
-% 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/>.
-
-% Get indices of the columns without NaNs
-idx = find(~any(isnan(varargin{1}.data)));
-
-if isempty(idx)
-    error('dseries::cumsum: All the variables have NaNs. The cumulated sum cannot be computed!')
-end
-
-if ~isequal(idx(:),transpose(1:vobs(varargin{1})))
-    warning('dseries::cumsum: The cumulated sum is not computed for some variables because they have NaNs!')
-end
-
-switch nargin
-    case 1
-      % Initialize the output.
-      B = varargin{1};
-      % Perform the cumulated sum
-      B.data(:,idx) = cumsum(B.data(:,idx));
-      % Change the name of the variables
-      for i=1:vobs(B)
-          B.name(i) = {['cumsum(' B.name{i} ')']};
-          B.tex(i) = {['\sum_t ' B.tex{i}]};
-      end
-  case 2
-    if isdseries(varargin{2})
-        if ~isequal(vobs(varargin{1}), vobs(varargin{2}))
-            error('dseries::cumsum: First and second input arguments must be dseries objects with the same number of variables!')
-        end
-        if ~isequal(varargin{1}.name, varargin{2}.name)
-            warning('dseries::cumsum: First and second input arguments must be dseries objects do not have the same variables!')
-        end
-        if ~isequal(nobs(varargin{2}),1)
-            error('dseries::cumsum: Second input argument must be a dseries object with only one observation!')
-        end
-        B = cumsum(varargin{1});
-        B.data = bsxfun(@plus,B.data,varargin{2}.data);
-    elseif isdates(varargin{2})
-        B = cumsum(varargin{1});
-        t = find(B.dates==varargin{2});
-        if isempty(t)
-            if varargin{2}==(firstdate(B)-1)
-                return
-            else
-                error(['dseries::cumsum: date ' date2string(varargin{2}) ' is not in the sample!'])
-            end
-        end
-        B.data = bsxfun(@minus,B.data,B.data(t,:));
-    else
-        error('dseries::cumsum: Second input argument must be a dseries object or a dates object!')
-    end
-  case 3
-    if ~isdates(varargin{2})
-        error('dseries::cumsum: Second input argument must be a dates object!')
-    end
-    if ~isdseries(varargin{3})
-        error('dseries::cumsum: Third input argument must be a dseries object!')
-    end
-    if ~isequal(vobs(varargin{1}), vobs(varargin{3}))
-        error('dseries::cumsum: First and third input arguments must be dseries objects with the same number of variables!')
-    end
-    if ~isequal(varargin{1}.name, varargin{3}.name)
-        warning('dseries::cumsum: First and third input arguments must be dseries objects do not have the same variables!')
-    end
-    if ~isequal(nobs(varargin{3}),1)
-        error('dseries::cumsum: Third input argument must be a dseries object with only one observation!')
-    end
-    B = cumsum(varargin{1});
-    t = find(B.dates==varargin{2});
-    if isempty(t)
-        if varargin{2}==(firstdate(B)-1)
-            B.data = bsxfun(@plus,B.data,varargin{3}.data);
-            return
-        else
-            error(['dseries::cumsum: date ' date2string(varargin{2}) ' is not in the sample!'])
-        end
-    end
-    B.data = bsxfun(@plus,B.data,varargin{3}.data-B.data(t,:));
-  otherwise
-    error('dseries::cumsum: Wrong number of input arguments!')
-end
-
-%@test:1
-%$ % Define a data set.
-%$ A = ones(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts1 = cumsum(ts1);
-%$
-%$ % Expected results.
-%$ ts2 = dseries(transpose(1:10), [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts1,ts2),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a data set.
-%$ A = ones(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts1 = ts1.cumsum();
-%$
-%$ % Expected results.
-%$ ts2 = dseries(transpose(1:10), [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts1,ts2),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a data set.
-%$ A = ones(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ 
-%$ % Call the tested method.
-%$ ts1 = cumsum(ts1,dates('3Y'));
-%$
-%$ % Expected results.
-%$ ts2 = dseries([-2; -1; 0; 1; 2; 3; 4; 5; 6; 7], [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts1,ts2),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a data set.
-%$ A = ones(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(pi, [], A_name, []);
-%$
-%$ % Call the tested method.
-%$ ts3 = cumsum(ts1,dates('3Y'),ts2);
-%$
-%$ % Expected results.
-%$ ts4 = dseries([-2; -1; 0; 1; 2; 3; 4; 5; 6; 7]+pi, [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts3,ts4),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a data set.
-%$ A = ones(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(pi, [], A_name, []);
-%$
-%$ % Call the tested method.
-%$ ts3 = ts1.cumsum(dates('3Y'),ts2);
-%$
-%$ % Expected results.
-%$ ts4 = dseries([-2; -1; 0; 1; 2; 3; 4; 5; 6; 7]+pi, [], A_name, []);
-%$
-%$ % Check the results.
-%$ warning off, % Because the names of the variables are not the same...
-%$ t(1) = dyn_assert(isequal(ts3,ts4),1);
-%$ warning_config
-%$ T = all(t);
-%@eof:5
\ No newline at end of file
diff --git a/matlab/@dseries/detrend.m b/matlab/@dseries/detrend.m
deleted file mode 100644
index fa6a193f102c93a7593cfb475f663b58483fa063..0000000000000000000000000000000000000000
--- a/matlab/@dseries/detrend.m
+++ /dev/null
@@ -1,110 +0,0 @@
-function o = detrend(o, model) % --*-- Unitary tests --*--
-
-% 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/>.
-
-% Set default for the order of the polynomial trend (constant).
-if nargin<2
-    model = 0;
-end
-
-data = o.data;
-
-if isnumeric(model)
-    if isscalar(model) && isint(model)
-        switch model
-          case 0
-            data = demean(data);
-          otherwise
-            x = NaN(nobs(o), model+1);
-            x(:,1) = ones(nobs(o), 1);
-            x(:,2) = transpose(1:nobs(o));
-            for c=3:model+1
-                x(:,c) = x(:,c-1).*x(:,2);
-            end
-            data = data - x*(x\data);
-        end
-    else
-        error('dseries::detrend: Second argument must be a positive integer scalar!')
-    end
-else
-    error('dseries::detrend: Second argument must be a positive integer scalar!')
-end
-
-o = dseries(data, o.dates, o.name, o.tex);
-
-%@test:1
-%$ % Define a dataset.
-%$ a = dseries(randn(1000,3));
-%$
-%$ % detrend (default).
-%$ try
-%$    b1 = a.detrend();
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ % detrend (constant).
-%$ if t(1)
-%$    try
-%$       b2 = a.detrend(0);
-%$       t(2) = 1;
-%$    catch
-%$       t(2) = 0;
-%$    end
-%$ end
-%$
-%$ % detrend (linear).
-%$ if t(2)
-%$    try
-%$       b3 = a.detrend(1);
-%$       t(3) = 1;
-%$    catch
-%$       t(3) = 0;
-%$    end
-%$ end
-%$
-%$ % detrend (quadratic).
-%$ if t(3)
-%$    try
-%$       b4 = a.detrend(2);
-%$       t(4) = 1;
-%$    catch
-%$       t(4) = 0;
-%$    end
-%$ end
-%$
-%$ % detrend (cubic).
-%$ if t(4)
-%$    try
-%$       b5 = a.detrend(3);
-%$       t(5) = 1;
-%$    catch
-%$       t(5) = 0;
-%$    end
-%$ end
-%$
-%$ if t(5)
-%$    t(6) = dyn_assert(max(mean(b1.data)),0,1e-12);
-%$    t(7) = dyn_assert(max(mean(b2.data)),0,1e-12);
-%$    t(8) = dyn_assert(max(mean(b3.data)),0,1e-12);
-%$    t(9) = dyn_assert(max(mean(b4.data)),0,1e-12);
-%$    t(10) = dyn_assert(max(mean(b5.data)),0,1e-12);
-%$ end
-%$ T = all(t);
-%@eof:1
diff --git a/matlab/@dseries/disp.m b/matlab/@dseries/disp.m
deleted file mode 100644
index 5bd38f464e997b25ec3fdc661bff2a2900096b19..0000000000000000000000000000000000000000
--- a/matlab/@dseries/disp.m
+++ /dev/null
@@ -1,40 +0,0 @@
-function disp(A)
-
-%@info:
-%! @deftypefn {Function File} disp (@var{A})
-%! @anchor{@dseries/disp}
-%! @sp 1
-%! Overloads the disp method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! None
-%! @end deftypefn
-%@eod:
-
-separator = repmat(' | ', nobs(A)+1,1);
-vspace = ' ';
-TABLE = ' ';
-for t=1:nobs(A)
-    TABLE = char(TABLE, date2string(A.dates(t)));
-end
-for i = 1:vobs(A)
-    TABLE = horzcat(TABLE,separator);
-    tmp = A.name{i};
-    for t=1:nobs(A)
-        tmp = char(tmp,num2str(A.data(t,i)));
-    end
-    TABLE = horzcat(TABLE, tmp);
-end
-disp(vspace)
-disp([inputname(1) ' is a dseries object:'])
-disp(vspace);
-disp(TABLE);
-disp(vspace);
\ No newline at end of file
diff --git a/matlab/@dseries/display.m b/matlab/@dseries/display.m
deleted file mode 100644
index d6826a801354b943a64438e15e15982629873f37..0000000000000000000000000000000000000000
--- a/matlab/@dseries/display.m
+++ /dev/null
@@ -1,128 +0,0 @@
-function display(A)
-%@info:
-%! @deftypefn {Function File} display (@var{A})
-%! @anchor{@dseries/display}
-%! @sp 1
-%! Overloads the disp method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! None
-%! @end deftypefn
-%@eod:
-
-vspace = ' ';
-TABLE = ' ';
-
-if vobs(A)<=10
-    if nobs(A)<=40
-        separator = repmat(' | ', nobs(A)+1,1);
-        for t=1:nobs(A)
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        for i = 1:vobs(A)
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-    else
-        n = 10;
-        separator = repmat(' | ',2*n+3,1);
-        for t=1:n
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        TABLE = char(TABLE,vspace);
-        for t = nobs(A)-n:nobs(A)
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        for i=1:vobs(A)
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:10
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            tmp = char(tmp,vspace);
-            for t=nobs(A)-10:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-    end
-else
-    m = 4;
-    if nobs(A)<=40
-        separator = repmat(' | ', nobs(A)+1,1);
-        for t=1:nobs(A)
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        for i = 1:m
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-        TABLE = horzcat(TABLE, separator, repmat(' ... ', nobs(A)+1,1));
-        for i = vobs(A)-m+1:vobs(A)
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-    else
-        n = 10;
-        separator = repmat(' | ',2*n+3,1);
-        for t=1:n
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        TABLE = char(TABLE,vspace);
-        for t = nobs(A)-n:nobs(A)
-            TABLE = char(TABLE, date2string(A.dates(t)));
-        end
-        for i=1:m
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:10
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            tmp = char(tmp,vspace);
-            for t=nobs(A)-10:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-        TABLE = horzcat(TABLE, separator, repmat(' ... ', 2*n+3,1));
-        for i=vobs(A)-m+1:vobs(A)
-            TABLE = horzcat(TABLE,separator);
-            tmp = A.name{i};
-            for t=1:10
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            tmp = char(tmp,vspace);
-            for t=nobs(A)-10:nobs(A)
-                tmp = char(tmp,num2str(A.data(t,i)));
-            end
-            TABLE = horzcat(TABLE, tmp);
-        end
-    end
-end
-disp(vspace)
-disp([inputname(1) ' is a dseries object:'])
-disp(vspace);
-if ~isempty(strtrim(TABLE))
-    disp(TABLE);
-    disp(vspace);
-end
diff --git a/matlab/@dseries/dseries.m b/matlab/@dseries/dseries.m
deleted file mode 100644
index 320855da1107c8e9f8114ade37b7ae60895560ff..0000000000000000000000000000000000000000
--- a/matlab/@dseries/dseries.m
+++ /dev/null
@@ -1,546 +0,0 @@
-function ts = dseries(varargin) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} dseries (@var{a},@var{b},@var{c},@var{d})
-%! @anchor{dseries}
-%! @sp 1
-%! Constructor for the Dynare time series class.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 2
-%! If @code{nargin==0} then an empty dseries object is created. The object can be populated with data subsequently using the overloaded subsref method.
-%! @sp 2
-%! If @code{nargin==1} and if the input argument is a @ref{dates} object, then a dseries object without data is created. This object can be populated with the overload subsref method.
-%! @sp 2
-%! If @code{nargin==1} and if the input argument is a string for the name of a csv, m or mat file containing data, then a dseries object is created from these data.
-%! @sp 2
-%! If @code{nargin>1}:
-%! @sp 1
-%! @table @ @var
-%! @item a
-%! T*1 vector or T*N matrix of data.
-%! @item b
-%! Initial date. For Quaterly, Monthly or Weekly data, b must be a string. For yearly data or if the frequence is not defined b must be an integer.
-%! @item c
-%! N*1 cell array of strings or N*q array of strings. Names of the N time series.
-%! @item d
-%! N*1 cell array of strings or N*p array of characters. TeX names of the N time series.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Dynare time series object.
-%! @end table
-%! @sp 2
-%! @strong{Properties}
-%! @sp 1
-%! The constructor defines the following properties:
-%! @sp 1
-%! @table @ @var
-%! @item data
-%! Array of doubles (nobs*vobs).
-%! @item nobs
-%! Scalar integer, the number of observations.
-%! @item vobs
-%! Scalar integer, the number of variables.
-%! @item name
-%! Cell array of strings, names of the variables.
-%! @item tex
-%! Cell array of strings, tex names of the variables.
-%! @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 init
-%! @ref{dates} object, initial date of the dataset.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2011-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 nargin>0 && ischar(varargin{1}) && isequal(varargin{1},'initialize')
-    ts = struct;
-    ts.data  = [];
-    ts.name  = {};
-    ts.tex   = {};
-    ts.dates = dates();
-    ts = class(ts,'dseries');
-    assignin('base','emptydseriesobject',ts);
-    return
-end
-
-ts = evalin('base','emptydseriesobject');
-
-switch nargin
-  case 0
-    %  Create an empty dseries object.
-    return
-  case 1
-    if isdates(varargin{1})
-        switch length(varargin{1})
-          case 0
-            error(['dseries::dseries: Input (identified as a dates object) must be non empty!'])
-          case 1
-            % Create an empty dseries object with an initial date.
-            ts.dates = varargin{1};
-          otherwise
-            % A range of dates is passed to the constructor
-            ts.dates = varargin{1};
-        end
-        return
-    elseif ischar(varargin{1})
-        % Create a dseries object loading data in a file (*.csv, *.m, *.mat).
-        if isempty(varargin{1})
-            error('dseries:: Wrong calling sequence! Input argument cannot be an empty string.')
-        elseif check_file_extension(varargin{1},'m')
-            [freq,init,data,varlist,tex] = load_m_file_data(varargin{1});
-        elseif check_file_extension(varargin{1},'mat')
-            [freq,init,data,varlist,tex] = load_mat_file_data(varargin{1});
-        elseif check_file_extension(varargin{1},'csv')
-            [freq,init,data,varlist] = load_csv_file_data(varargin{1});
-            tex = [];
-        elseif check_file_extension(varargin{1},'xls') || check_file_extension(varargin{1},'xlsx')
-            if isglobalinbase('options_')
-                % Check that the object is instantiated within a dynare session so that options_ global structure exists.
-                % Should provide latter a mechanism to pass range and sheet to dseries constructor...
-                range = evalin('base','options_.xls_range');
-                sheet = evalin('base','options_.xls_sheet');
-            else
-                % By default only the (whole) first sheet is loaded.
-                range = [];
-                sheet = [];
-            end
-            [freq,init,data,varlist] = load_xls_file_data(varargin{1}, sheet, range);
-            tex = [];
-        else
-            error(['dseries:: I''m not able to load data from ' varargin{1} '!'])
-        end
-        ts.data = data;
-        ts.name = varlist;
-        ts.dates = init:init+(nobs(ts)-1);
-        if isempty(tex)
-            ts.tex = name2tex(varlist);
-        else
-            ts.tex = tex;
-        end
-    elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2)
-        ts.data = varargin{1};
-        ts.name = default_name(vobs(ts));
-        ts.tex = name2tex(ts.name);
-        ts.dates = dates(1,1):dates(1,1)+(nobs(ts)-1);
-    end
-  case {2,3,4}
-    if isequal(nargin,2) && ischar(varargin{1}) && isdates(varargin{2})
-        % Instantiate dseries object with a data file and force the initial date to be as given by the second input argument.
-        ds = dseries(varargin{1});
-        ts = dseries(ds.data, varargin{2}, ds.name, ds.tex);
-        return
-    end
-    if isequal(nargin,2) && ischar(varargin{1}) && ischar(varargin{2}) && isdate(varargin{2})
-        % Instantiate dseries object with a data file and force the initial date to be as given by the second input argument.
-        ds = dseries(varargin{1});
-        ts = dseries(ds.data, dates(varargin{2}), ds.name, ds.tex);
-        return
-    end
-    a = varargin{1};
-    b = varargin{2};
-    if nargin<4
-        d = {};
-    else
-        d = varargin{4};
-        if ~iscell(d) && ~isempty(d)
-            d = cellstr(d);
-        end
-    end
-    if nargin<3
-        c = {};
-    else
-        c = varargin{3};
-        if ~iscell(c) && ~isempty(c)
-            c = cellstr(c);
-        end
-    end
-    % Get data, number of observations and number of variables.
-    ts.data = a;
-    % Get the first date and set the frequency.
-    if isempty(b)
-        init = dates(1,1);
-    elseif (isdates(b) && isequal(length(b),1))
-        init = b;
-    elseif ischar(b) && isdate(b)% Weekly, Monthly, Quaterly or Annual data (string).
-        init = dates(b);
-    elseif (isnumeric(b) && isscalar(b) && isint(b)) % Yearly data.
-        init = dates([num2str(b) 'Y']);
-    elseif isdates(b) % Range of dates
-        init = b(1);
-        if nobs(ts)>1 && ~isequal(b.ndat,nobs(ts))
-            message =   'dseries::dseries: If second input is a range, its number of elements must match ';
-            message = char(message, '                  the number of rows in the first input, unless the first input');
-            message = char(message, '                  has only one row.');
-            skipline()
-            disp(message);
-            error(' ');
-        elseif isequal(nobs(ts), 1)
-            ts.data = repmat(ts.data,b.ndat,1);
-        end
-        ts.dates = b;
-    elseif (isnumeric(b) && isint(b)) % Range of yearly dates.
-        message = 'dseries::dseries: Not implemented! If you need to define a range of years';
-        message = char(message, '                  you have to pass a dates object as the second input argument.');
-        disp(message)
-        error(' ')
-    else
-        error('dseries::dseries: Wrong calling sequence!');
-    end
-    % Get the names of the variables.
-    if ~isempty(c)
-        if vobs(ts)==length(c)
-            for i=1:vobs(ts)
-                ts.name = vertcat(ts.name, c(i));
-            end
-        else
-            error('dseries::dseries: The number of declared names does not match the number of variables!')
-        end
-    else
-        ts.name = default_name(vobs(ts));
-    end
-    if ~isempty(d)
-        if vobs(ts)==length(d)
-            for i=1:vobs(ts)
-                ts.tex = vertcat(ts.tex, d(i));
-            end
-        else
-            error('dseries::dseries: The number of declared tex names does not match the number of variables!')
-        end
-    else
-        ts.tex = name2tex(ts.name);
-    end
-  otherwise
-    error('dseries::dseries: Can''t instantiate the class, wrong calling sequence!')
-end
-
-if isempty(ts.dates)
-    ts.dates = init:init+(nobs(ts)-1);
-end
-
-%@test:1
-%$ % Test if we can instantiate an empty dseries object.
-%$ try
-%$     ts = dseries();
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     aa = dates('1938M11');
-%$     ts = dseries(aa);
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,12);
-%$     t(3) = dyn_assert(ts.init.freq,12);
-%$     t(4) = dyn_assert(ts.init.time,[1938, 11]);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ t = zeros(6,1);
-%$
-%$ try
-%$     ts = dseries('dynseries_test_data.m');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1994, 3]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,100);
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ t = zeros(6,1);
-%$
-%$ try
-%$     ts = dseries('dynseries_test_data.mat');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1994, 3]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,100);
-%$ end
-%$
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries('dynseries_test_data.csv');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1990, 1]);
-%$     t(5) = dyn_assert(ts.vobs,4);
-%$     t(6) = dyn_assert(ts.nobs,4);
-%$     t(7) = dyn_assert(ts.name,{'azert';'yuiop';'qsdfg';'jklm'});
-%$     t(8) = dyn_assert(ts.tex,{'azert';'yuiop';'qsdfg';'jklm'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:5),[]);
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,1);
-%$     t(3) = dyn_assert(ts.init.freq,1);
-%$     t(4) = dyn_assert(ts.init.time,[1, 1]);
-%$     t(5) = dyn_assert(ts.vobs,1);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Variable_1'});
-%$     t(8) = dyn_assert(ts.tex,{'Variable\\_1'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:5),'1950Q1');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,1);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Variable_1'});
-%$     t(8) = dyn_assert(ts.tex,{'Variable\\_1'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:7
-
-%@test:8
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Output'; 'Consumption'});
-%$     t(8) = dyn_assert(ts.tex,{'Y_t'; 'C_t'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:8
-
-%@test:9
-%$ try
-%$     ts = dseries('dynseries_test_data-1.xls');
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1990, 1]);
-%$     t(5) = dyn_assert(ts.vobs,3);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'GDP';'Consumption';'CPI'});
-%$     t(8) = dyn_assert(ts.tex,{'GDP';'Consumption';'CPI'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:9
-
-%@test:10
-%$ try
-%$     ts = dseries('dynseries_test_data-2.xls');
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1990, 1]);
-%$     t(5) = dyn_assert(ts.vobs,3);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
-%$     t(8) = dyn_assert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:10
-
-%@test:11
-%$ try
-%$     ts = dseries('dynseries_test_data-3.xls');
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts.freq,1);
-%$     t(3) = dyn_assert(ts.init.freq,1);
-%$     t(4) = dyn_assert(ts.init.time,[1, 1]);
-%$     t(5) = dyn_assert(ts.vobs,3);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
-%$     t(8) = dyn_assert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:11
-
-%@test:12
-%$ try
-%$     ts = dseries('dynseries_test_data-4.xls');
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts.freq,1);
-%$     t(3) = dyn_assert(ts.init.freq,1);
-%$     t(4) = dyn_assert(ts.init.time,[1, 1]);
-%$     t(5) = dyn_assert(ts.vobs,3);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'GDP';'Consumption';'CPI'});
-%$     t(8) = dyn_assert(ts.tex,{'GDP';'Consumption';'CPI'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:12
-
-%@test:13
-%$ t = zeros(6,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:4),dates('1990Q1'):dates('1990Q4'));
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1990, 1]);
-%$     t(5) = dyn_assert(ts.vobs,1);
-%$     t(6) = dyn_assert(ts.nobs,4);
-%$ end
-%$
-%$ T = all(t);
-%@eof:13
-
-%@test:14
-%$ t = zeros(7,1);
-%$
-%$ try
-%$     ts = dseries([1, 2],dates('1990Q1'):dates('1990Q4'));
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1990, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,4);
-%$     t(7) = dyn_assert(ts.data, [ones(4,1), 2*ones(4,1)]);
-%$ end
-%$
-%$ T = all(t);
-%@eof:14
-
-%@test:15
-%$ try
-%$     ts = dseries([1; 2],dates('1990Q1'):dates('1990Q4'));
-%$     t = 0;
-%$ catch
-%$     t = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:15
diff --git a/matlab/@dseries/end.m b/matlab/@dseries/end.m
deleted file mode 100644
index 8f60971367a15c179134630fbabde65724df11c6..0000000000000000000000000000000000000000
--- a/matlab/@dseries/end.m
+++ /dev/null
@@ -1,21 +0,0 @@
-function lastIndex = end(o, k, n)
-
-% 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/>.
-
-assert(k==1 && n==1, 'dseries::end: Wrong indexing!');
-lastIndex = vobs(o);
\ No newline at end of file
diff --git a/matlab/@dseries/eq.m b/matlab/@dseries/eq.m
deleted file mode 100644
index 7664cb094a2bbb221c10d1ce09e8ac01a81f65d0..0000000000000000000000000000000000000000
--- a/matlab/@dseries/eq.m
+++ /dev/null
@@ -1,89 +0,0 @@
-function C = eq(A,B) % --*-- Unitary tests --*--
-
-% Overloads eq (==) operator.
-%
-% INPUTS 
-%  o A      dseries object (T periods, N variables).
-%  o B      dseries object (T periods, N variables).
-%
-% OUTPUTS 
-%  o C      T*N matrix of zeros and ones. Element C(t,n) is nonzero iff observation t of variable n in A and B are equal.  
-%
-% REMARKS 
-%  If the number of variables, the number of observations or the frequencies are different in A and B, the function returns a zero scalar. 
-
-% 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 nargin~=2
-    error('dseries::eq: I need exactly two input arguments!')
-end
-
-if ~(isdseries(A) && isdseries(B))
-    error('dseries::eq: Both input arguments must be dseries objects!')
-end
-
-if ~isequal(nobs(A), nobs(B))
-    warning('dseries::eq: Both input arguments should have the same number of observations!')
-    C = 0;
-    return
-end
-
-if ~isequal(vobs(A), vobs(B))
-    warning('dseries::eq: Both input arguments should have the same number of observations!')
-    C = 0;
-    return
-end
-
-if ~isequal(frequency(A),frequency(B))
-    warning('dseries::eq: Both input arguments should have the same frequencies!')
-    C = 0;
-    return
-end
-
-if ~isequal(firstdate(A),firstdate(B))
-    warning('dseries::eq: Both input arguments should have the same initial period!')
-    C = 0;
-    return
-end
-
-C = eq(A.data, B.data);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$
-%$ t = zeros(2,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = ts1;
-%$    a = eq(ts1,ts2);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(a,ones(10,3));
-%$ end
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/exp.m b/matlab/@dseries/exp.m
deleted file mode 100644
index 06ed6a1f03291cb11d51ea5fcd35855c87987cab..0000000000000000000000000000000000000000
--- a/matlab/@dseries/exp.m
+++ /dev/null
@@ -1,52 +0,0 @@
-function ts = exp(ts)
-% Apply the exponential function to a Dynare time series object.
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} log(@var{ts})
-%! @anchor{exp}
-%! Apply the exponential function to a Dynare time series object.
-%!
-%! @strong{Inputs}
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%!
-%! @strong{Outputs}
-%! @table @var
-%! @item ts
-%! Dynare time series object with transformed data field.
-%! @end table
-%!
-%! @strong{This function is called by:}
-%! None.
-%!
-%! @strong{This function calls:}
-%! None.
-%!
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2011-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/>.
-
-ts.data = exp(ts.data);
-
-for i=1:vobs(ts)
-    ts.name(i) = {['exp(' ts.name{i} ')']};
-    ts.tex(i) = {['\exp(' ts.tex{i} ')']};
-end
\ No newline at end of file
diff --git a/matlab/@dseries/extract.m b/matlab/@dseries/extract.m
deleted file mode 100644
index c280115ee4f4e515f62a21ce189251816468cfa8..0000000000000000000000000000000000000000
--- a/matlab/@dseries/extract.m
+++ /dev/null
@@ -1,230 +0,0 @@
-function A = extract(B,varargin) % --*-- Unitary tests --*--
-
-% Extract some variables from a database.
-    
-% 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/>.
-
-A = dseries();
-
-% Get the names of the variables to be extracted from dseries object B.
-VariableName_ = {};
-for i=1:nargin-1
-    VariableName = varargin{i};
-    idArobase = strfind(VariableName,'@');
-    if mod(length(idArobase),2)
-        error('dseries::extract: (Implicit loops) The number of @ symbols must be even!')
-    end
-    idBracket.open = strfind(VariableName,'[');
-    idBracket.close = strfind(VariableName,']');
-    if ~isequal(length(idBracket.open),length(idBracket.open))
-        error('dseries::extract: (Matlab/Octave''s regular expressions) Check opening and closing square brackets!')
-    end
-    if length(idArobase)
-        NumberOfImplicitLoops = .5*length(idArobase);
-        idComma = cell(NumberOfImplicitLoops,1);
-        expressions = cell(NumberOfImplicitLoops,1);
-        for i=0:NumberOfImplicitLoops-1
-            idComma(i+1) = { strfind(VariableName(idArobase(2*i+1)+1:idArobase(2*i+2)-1),',') };
-            expressions(i+1) = { VariableName(idArobase(2*i+1)+1:idArobase(2*i+2)-1) };
-        end
-        if any(cellfun(@isempty,idComma))
-            error('dseries::extract: (Implicit loops) Wrong syntax!')
-        end
-        switch NumberOfImplicitLoops
-          case 1
-            expression = expressions{1};
-            idVariables_ = [];
-            while ~isempty(expression)
-                [token, expression] = strtok(expression,',');             
-                candidate = [VariableName(1:idArobase(1)-1), token, VariableName(idArobase(2)+1:end)];
-                id = find(strcmp(candidate,B.name));
-                if isempty(id)
-                    error(['dseries::extract: (Implicit loops) Variable ''' candidate ''' does not exist in dseries object ''' inputname(1) '''!'])
-                else
-                    idVariables_ = [idVariables_; id];
-                end
-            end
-            VariableName = B.name(idVariables_);
-          case 2
-            idVariables_ = [];
-            expression_1 = expressions{1};
-            while ~isempty(expression_1)
-                [token_1, expression_1] = strtok(expression_1,',');
-                expression_2 = expressions{2};
-                while ~isempty(expression_2)
-                    [token_2, expression_2] = strtok(expression_2,',');
-                    candidate = [VariableName(1:idArobase(1)-1), token_1, VariableName(idArobase(2)+1:idArobase(3)-1),  token_2, VariableName(idArobase(4)+1:end)];
-                    id = find(strcmp(candidate,B.name));
-                    if isempty(id)
-                        error(['dseries::extract: (Implicit loops) Variable ''' candidate ''' does not exist in dseries object ''' inputname(1) '''!'])
-                    else
-                        idVariables_ = [idVariables_; id];
-                    end
-                end
-            end
-            VariableName = B.name(idVariables_);
-          otherwise
-            error('dseries::extract: (Implicit loops) Cannot unroll more than two implicit loops!')
-        end
-        VariableName_ = vertcat(VariableName_,VariableName);
-    elseif length(idBracket.open)
-        % Matlab/Octave's regular expressions.
-        first_block_id = 0;
-        last_block_id = 0;
-        idVariables = find(isnotempty_cell(regexp(B.name,VariableName,'match')));
-        if isempty(idVariables)
-            error(['dseries::extract: Can''t find any variable matching ' VariableName ' pattern!'])
-        end
-        idVariables_ = [];
-        for j = 1:length(idVariables)
-            first_block_flag = 0;
-            if (first_block_id && strcmp(B.name{idVariables(j)}(1:first_block_id),VariableName(1:first_block_id))) || ~first_block_id
-                first_block_flag = 1;
-            end
-            last_block_flag = 0;
-            if (last_block_id && strcmp(B.name{idVariables(j)}(end-last_block_id:end),VariableName(end-last_block_id:end))) || ~last_block_id
-                last_block_flag = 1;
-            end
-            if first_block_flag && last_block_flag
-                idVariables_ = [idVariables_; idVariables(j)];
-            end
-        end
-        VariableName = B.name(idVariables_);
-        VariableName_ = vertcat(VariableName_,VariableName);
-    else
-        VariableName_ = varargin(:);
-    end
-end
-
-% Remove trailing white spaces if any
-VariableName_ = strtrim(VariableName_);
-
-% Get indices of the selected variables
-idVariableName = NaN(length(VariableName_),1);
-for i = 1:length(idVariableName)
-    idx = find(strcmp(VariableName_{i},B.name));
-    if isempty(idx)
-        error(['dseries::extract: Variable ' VariableName_{i} ' is not a member of ' inputname(1) '!'])
-    end
-    idVariableName(i) = idx;
-end
-
-A.data = B.data(:,idVariableName);
-A.dates = B.dates;
-A.name = B.name(idVariableName);
-A.tex = B.tex(idVariableName);
-
-function b = isnotempty_cell(CellArray)
-    CellArrayDimension = size(CellArray);
-    b = NaN(CellArrayDimension);
-    for i=1:CellArrayDimension(1)
-        for j = 1:CellArrayDimension(2)
-            b(i,j) = ~isempty(CellArray{i,j});
-        end
-    end
-    
-    
-%@test:1
-%$ % Define a data set.
-%$ A = rand(10,24);
-%$
-%$ % Define names
-%$ A_name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; 'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'; 'HICP_1';'HICP_2';'HICP_3'; 'HICP_4'; 'HICP_5'; 'HICP_6'; 'HICP_7'; 'HICP_8'; 'HICP_9'; 'HICP_10'; 'HICP_11'; 'HICP_12';};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1{'GDP_@1,2,3,4,5@'};
-%$ b = ts1{'@GDP,HICP@_1'};
-%$
-%$ % Expected results.
-%$ e1.data = A(:,1:5);
-%$ e1.nobs = 10;
-%$ e1.vobs = 5;
-%$ e1.name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'};
-%$ e1.freq = 1;
-%$ e1.init = dates(1,1);
-%$ e2.data = A(:,[1, 13]);
-%$ e2.nobs = 10;
-%$ e2.vobs = 2;
-%$ e2.name = {'GDP_1';'HICP_1'};
-%$ e2.freq = 1;
-%$ e2.init = dates(1,1);
-%$
-%$ % Check results.
-%$ t(1) = dyn_assert(e1.data,a.data);
-%$ t(2) = dyn_assert(e1.nobs,a.nobs);
-%$ t(3) = dyn_assert(e1.vobs,a.vobs);
-%$ t(4) = dyn_assert(e1.name,a.name);
-%$ t(5) = dyn_assert(isequal(e1.init,a.init),1);
-%$ t(6) = dyn_assert(e2.data,b.data);
-%$ t(7) = dyn_assert(e2.nobs,b.nobs);
-%$ t(8) = dyn_assert(e2.vobs,b.vobs);
-%$ t(9) = dyn_assert(e2.name,b.name);
-%$ t(10) = dyn_assert(isequal(e2.init,b.init),1);
-%$ T = all(t);
-%@eof:1
-
-
-%@test:2
-%$ % Define a data set.
-%$ A = rand(10,24);
-%$
-%$ % Define names
-%$ A_name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; 'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'; 'HICP_1';'HICP_2';'HICP_3'; 'HICP_4'; 'HICP_5'; 'HICP_6'; 'HICP_7'; 'HICP_8'; 'HICP_9'; 'HICP_10'; 'HICP_11'; 'HICP_12';};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ try
-%$   a = ts1{'GDP_@1,2,3,4,55@'};
-%$   t = 0;
-%$ catch
-%$   t = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-
-%@test:3
-%$ % Define a data set.
-%$ A = rand(10,24);
-%$
-%$ % Define names
-%$ A_name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; 'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'; 'HICP_1';'HICP_2';'HICP_3'; 'HICP_4'; 'HICP_5'; 'HICP_6'; 'HICP_7'; 'HICP_8'; 'HICP_9'; 'HICP_10'; 'HICP_11'; 'HICP_12';};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ try
-%$   a = ts1{'@GDP,HICP@_@1,2,3,4,5@'};
-%$   t = 1;
-%$ catch
-%$   t = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(a.name,{'GDP_1';'GDP_2';'GDP_3';'GDP_4';'GDP_5';'HICP_1';'HICP_2';'HICP_3';'HICP_4';'HICP_5'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
diff --git a/matlab/@dseries/firstdate.m b/matlab/@dseries/firstdate.m
deleted file mode 100644
index 9a7db50ea427161d35e0a58e8a83900a07d14349..0000000000000000000000000000000000000000
--- a/matlab/@dseries/firstdate.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function f = firstdate(o)
-
-% 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/>.
-
-f = o.dates(1);
\ No newline at end of file
diff --git a/matlab/@dseries/frequency.m b/matlab/@dseries/frequency.m
deleted file mode 100644
index c2befb5477059cc992cc9f2fb4d0efd95f9fb892..0000000000000000000000000000000000000000
--- a/matlab/@dseries/frequency.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function f = frequency(o)
-
-% 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/>.
-
-f = o.dates.freq;
\ No newline at end of file
diff --git a/matlab/@dseries/horzcat.m b/matlab/@dseries/horzcat.m
deleted file mode 100644
index e4d9cbee7b7dc51235cbc23c074745e5f3dcac6b..0000000000000000000000000000000000000000
--- a/matlab/@dseries/horzcat.m
+++ /dev/null
@@ -1,317 +0,0 @@
-function B = horzcat(varargin) % --*-- Unitary tests --*--
-
-% Overloads horzcat method for dseries objects.
-%
-% INPUTS 
-%  o A1    dseries object.
-%  o A2    dseries object.
-%  o ...
-%
-% OUTPUTS 
-%  o B     dseries object.
-%
-% EXAMPLE 1 
-%  If A, B and C are dseries objects the following syntax:
-%    
-%    D = [A, B, C] ;
-%
-%  Defines a dseries object D containing the variables appearing in A, B and C.
-%
-% REMARKS 
-%  o A1, A2, ... must not have common variables.
-    
-% Copyright (C) 2011-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/>.
-
-switch nargin
-  case 0
-    B = dseries();
-  case 1
-    B = varargin{1};
-  otherwise
-    B = concatenate(varargin{1}, varargin{2});
-    if nargin>2
-        B = horzcat(B, varargin{3:end});
-    end
-end
-
-function a = concatenate(b,c)
-    [n,message] = common_strings_in_cell_arrays(b.name,c.name);
-    if isempty(b)
-        a = c;
-        return
-    end
-    if isempty(c)
-        a = b;
-        return
-    end
-    if n
-        error(['dseries::horzcat: I cannot concatenate dseries objects with common variable names (' message ')!'])
-    end
-    if ~isequal(frequency(b),frequency(c))
-        error('dseries::horzcat: All time series objects must have common frequency!')
-    else
-        a = dseries();
-    end
-    d_nobs_flag = 0;
-    if ~isequal(nobs(b),nobs(c))
-        d_nobs_flag = 1;
-    end
-    d_init_flag = 0;
-    if ~isequal(firstdate(b),firstdate(c))
-        d_init_flag = 1;
-    end
-    a.name = vertcat(b.name,c.name);
-    a.tex  = vertcat(b.tex,c.tex);
-    if ~( d_nobs_flag(1) || d_init_flag(1) )
-        a.data = [b.data,c.data];
-        a.dates = b.dates;
-    else
-        nobs_b = nobs(b);
-        nobs_c = nobs(c);
-        if firstdate(b)<=firstdate(c)
-            if firstdate(b)<firstdate(c)
-                c.data = [NaN(firstdate(c)-firstdate(b), vobs(c)); c.data];
-            end
-        else
-            b.data = [NaN(firstdate(b)-firstdate(c), vobs(b)); b.data];
-        end
-        b_last_date = firstdate(b)+nobs_b;
-        c_last_date = firstdate(c)+nobs_c;
-        if b_last_date<c_last_date
-            b.data = [b.data; NaN(c_last_date-b_last_date, vobs(b))];
-        elseif b_last_date>c_last_date
-            c.data = [c.data; NaN(b_last_date-c_last_date, vobs(c))];
-        end
-        a.data = [b.data, c.data];
-        a.dates = unique([b.dates, c.dates]);
-    end
-
-%@test:1
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define expected results.
-%$ e.init = dates(1,1);
-%$ e.freq = 1;
-%$ e.name = {'A1';'A2';'B1';'B2'};
-%$ e.data = [A,B];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(B,[],B_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts3 = [ts1,ts2];
-%$
-%$ % Check the results.
-%$
-%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
-%$ t(2) = dyn_assert(ts3.freq,e.freq);
-%$ t(3) = dyn_assert(ts3.data,e.data);
-%$ t(4) = dyn_assert(ts3.name,e.name);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(5:12),2*transpose(5:12)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial date
-%$ A_init = 2001;
-%$ B_init = 2005;
-%$
-%$ % Define expected results.
-%$ e.init = dates('2001Y');
-%$ e.freq = 1;
-%$ e.name = {'A1';'A2';'B1';'B2'};
-%$ e.data = [ [A; NaN(2,2)], [NaN(4,2); B]];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,A_init,A_name,[]);
-%$ ts2 = dseries(B,B_init,B_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts3 = [ts1,ts2];
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
-%$ t(2) = dyn_assert(ts3.freq,e.freq);
-%$ t(3) = dyn_assert(ts3.data,e.data);
-%$ t(4) = dyn_assert(ts3.name,e.name);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a data set.
-%$ A = [transpose(1:7),2*transpose(1:7)];
-%$ B = [transpose(5:11),2*transpose(5:11)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial date
-%$ A_init = '1950Q1';
-%$ B_init = '1950Q3';
-%$
-%$ % Define expected results.
-%$ e.freq = 4;
-%$ e.init = dates('1950Q1');
-%$ e.name = {'A1';'A2';'B1';'B2'};
-%$ e.data = [ [A; NaN(2,2)], [NaN(2,2); B]];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,A_init,A_name,[]);
-%$ ts2 = dseries(B,B_init,B_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts3 = [ts1,ts2];
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
-%$ t(2) = dyn_assert(ts3.freq,e.freq);
-%$ t(3) = dyn_assert(ts3.data,e.data);
-%$ t(4) = dyn_assert(ts3.name,e.name);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a data set.
-%$ A = [transpose(1:7),2*transpose(1:7)];
-%$ B = [transpose(5:9),2*transpose(5:9)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'B2'};
-%$
-%$ % Define initial date
-%$ A_init = '1950Q1';
-%$ B_init = '1950Q3';
-%$
-%$ % Define expected results.
-%$ e.init = dates(A_init);
-%$ e.freq = 4;
-%$ e.name = {'A1';'A2';'B1';'B2'};
-%$ e.data = [ A, [NaN(2,2); B]];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,A_init,A_name,[]);
-%$ ts2 = dseries(B,B_init,B_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts3 = [ts1,ts2];
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
-%$ t(2) = dyn_assert(ts3.freq,e.freq);
-%$ t(3) = dyn_assert(ts3.data,e.data);
-%$ t(4) = dyn_assert(ts3.name,e.name);
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(1:10),3*transpose(1:10)];
-%$ C = [transpose(1:10),4*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'B2'};
-%$ C_name = {'C1';'C2'};
-%$
-%$ % Define expected results.
-%$ e.init = dates(1,1);
-%$ e.freq = 1;
-%$ e.name = {'A1';'A2';'B1';'B2';'C1';'C2'};
-%$ e.data = [A,B,C];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(B,[],B_name,[]);
-%$ ts3 = dseries(C,[],C_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts4 = [ts1,ts2,ts3];
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(isequal(ts4.init,e.init),1);
-%$ t(2) = dyn_assert(ts4.freq,e.freq);
-%$ t(3) = dyn_assert(ts4.data,e.data);
-%$ t(4) = dyn_assert(ts4.name,e.name);
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'B1';'A2'};
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(B,[],B_name,[]);
-%$
-%$ % Call the tested method.
-%$ try
-%$   ts3 = [ts1,ts2];
-%$   t = 0;
-%$ catch
-%$   t = 1;
-%$ end
-%$
-%$ T = t;
-%@eof:6
-
-%@test:7
-%$ % Define X
-%$ X = randn(30,2);
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries();
-%$ ts2 = dseries(randn(30,2),'1950Q2');
-%$
-%$ % Call the tested method.
-%$ try
-%$   ts3 = [ts1,ts2];
-%$   t = 1;
-%$ catch
-%$   t = 0;
-%$ end
-%$
-%$ if t(1)
-%$   t(2) = dyn_assert(ts3.freq,4);
-%$   t(3) = dyn_assert(ts3.data,X);
-%$   t(4) = dyn_assert(isequal(ts3.dates(1),dates('1950Q2')),1);
-%$ end
-%$
-%$ T = t;
-%@eof:7
diff --git a/matlab/@dseries/hpcycle.m b/matlab/@dseries/hpcycle.m
deleted file mode 100644
index ad1ec56fa389003b32d40d98e4336877d24781d6..0000000000000000000000000000000000000000
--- a/matlab/@dseries/hpcycle.m
+++ /dev/null
@@ -1,96 +0,0 @@
-function ts = hpcycle(ts, lambda) % --*-- Unitary tests --*--
-
-% ts = hpcycle(ts, lambda)
-%
-% Extracts the cycle component from a dseries object using Hodrick Prescott filter.
-%
-% INPUTS 
-%  o ts         dseries object.
-%  o lambda     positive scalar, trend smoothness parameter.
-%
-% OUTPUTS 
-%  o ts         dseries object, with time series replaced by the cyclical component of the original time series.
-
-% 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 nargin>1 
-    if lambda<=0
-        error(['dseries::hpcycle: Lambda must be a positive integer!'])
-    end
-else
-    lambda = [];
-end 
-
-for i=1:vobs(ts)
-    ts.name(i) = {['hpcycle(' ts.name{i} ')']};
-    ts.tex(i) = {['\text{hpcycle}(' ts.tex{i} ')']};
-end
-
-[junk, data] = sample_hp_filter(ts.data,lambda);
-ts.data = data;
-
-%@test:1
-%$ plot_flag = 0;
-%$
-%$ % Create a dataset.
-%$ e = .2*randn(200,1);
-%$ u = randn(200,1);
-%$ stochastic_trend = cumsum(e); 
-%$ deterministic_trend = .1*transpose(1:200);
-%$ x = zeros(200,1);
-%$ for i=2:200
-%$    x(i) = .9*x(i-1) + e(i);
-%$ end
-%$ y = x + stochastic_trend + deterministic_trend;
-%$
-%$ % Test the routine.
-%$ try
-%$     ts0 = dseries(y,'1950Q1');
-%$     ts1 = dseries(x,'1950Q1');
-%$     ts2 = ts0.hpcycle();
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts2.freq,4);
-%$     t(3) = dyn_assert(ts2.init.freq,4);
-%$     t(4) = dyn_assert(ts2.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts2.vobs,1);
-%$     t(6) = dyn_assert(ts2.nobs,200);
-%$ end
-%$
-%$ % Show results
-%$ if plot_flag
-%$     plot(ts1.data,'-k'); % Plot of the stationary component.
-%$     hold on
-%$     plot(ts2.data,'--r');          % Plot of the filtered y.
-%$     hold off
-%$     axis tight
-%$     id = get(gca,'XTick');
-%$     set(gca,'XTickLabel',strings(ts1.dates(id)));
-%$     legend({'Stationary component of y', 'Filtered y'})
-%$     print('-depsc2','../doc/dynare.plots/HPCycle.eps')
-%$     system('convert -density 300 ../doc/dynare.plots/HPCycle.eps ../doc/dynare.plots/HPCycle.png');
-%$     system('convert -density 300 ../doc/dynare.plots/HPCycle.eps ../doc/dynare.plots/HPCycle.pdf');
-%$     system('convert -density 300 ../doc/dynare.plots/HPCycle.eps ../doc/dynare.plots/HPCycle.jpg');
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/hptrend.m b/matlab/@dseries/hptrend.m
deleted file mode 100644
index 754b3212a430b2961ab04328d07900300ef1688f..0000000000000000000000000000000000000000
--- a/matlab/@dseries/hptrend.m
+++ /dev/null
@@ -1,94 +0,0 @@
-function ts = hptrend(ts, lambda) % --*-- Unitary tests --*--
-
-% ts = hptrend(ts, lambda)
-%
-% Extracts the trend component from a dseries object using Hodrick Prescott filter.
-%
-% INPUTS 
-%  o ts         dseries object.
-%  o lambda     positive scalar, trend smoothness parameter.
-%
-% OUTPUTS 
-%  o ts         dseries object, with time series replaced by the trend component of the original time series.
-
-% 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 nargin>1 
-    if lambda<=0
-        error(['dseries::hptrend: Lambda must be a positive integer!'])
-    end
-else
-    lambda = [];
-end
-
-for i=1:vobs(ts)
-    ts.name(i) = {['hptrend(' ts.name{i} ')']};
-    ts.tex(i) = {['\text{hptrend}(' ts.tex{i} ')']};
-end
-
-ts.data = sample_hp_filter(ts.data,lambda);
-
-%@test:1
-%$ plot_flag = 0; 
-%$
-%$ % Create a dataset.
-%$ e = .2*randn(200,1);
-%$ u = randn(200,1);
-%$ stochastic_trend = cumsum(e); 
-%$ deterministic_trend = .1*transpose(1:200);
-%$ x = zeros(200,1);
-%$ for i=2:200
-%$    x(i) = .75*x(i-1) + e(i);
-%$ end
-%$ y = x + stochastic_trend + deterministic_trend;
-%$
-%$ % Test the routine.
-%$ try
-%$     ts0 = dseries(y,'1950Q1');
-%$     ts1 = dseries(stochastic_trend+deterministic_trend,'1950Q1');
-%$     ts2 = ts0.hptrend(1600);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$     t(2) = dyn_assert(ts2.freq,4);
-%$     t(3) = dyn_assert(ts2.init.freq,4);
-%$     t(4) = dyn_assert(ts2.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts2.vobs,1);
-%$     t(6) = dyn_assert(ts2.nobs,200);
-%$ end
-%$
-%$ % Show results
-%$ if plot_flag
-%$     plot(ts1.data,'-k'); % Plot of the stationary component.
-%$     hold on
-%$     plot(ts2.data,'--r');          % Plot of the filtered y.
-%$     hold off
-%$     axis tight
-%$     id = get(gca,'XTick');
-%$     set(gca,'XTickLabel',strings(ts1.dates(id)));
-%$     legend({'Nonstationary component of y', 'Estimated trend of y'})
-%$     print('-depsc2','../doc/dynare.plots/HPTrend.eps')
-%$     system('convert -density 300 ../doc/dynare.plots/HPTrend.eps ../doc/dynare.plots/HPTrend.png');
-%$     system('convert -density 300 ../doc/dynare.plots/HPTrend.eps ../doc/dynare.plots/HPTrend.pdf');
-%$     system('convert -density 300 ../doc/dynare.plots/HPTrend.eps ../doc/dynare.plots/HPTrend.jpg');
-%$ end
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/insert.m b/matlab/@dseries/insert.m
deleted file mode 100644
index e1550861413540b531fe78123329f95e06a77008..0000000000000000000000000000000000000000
--- a/matlab/@dseries/insert.m
+++ /dev/null
@@ -1,107 +0,0 @@
-function ts = insert(ts,us,id) % --*-- Unitary tests --*--
-
-% Add a variable in a dseries object.
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} insert (@var{ts}, @var{us}, @var{id})
-%! @anchor{dseries/insert}
-%! @sp 1
-%! Insert method for the dseries class. Insert new variables (@var{us}) in a dseries object (@var{ts}) at
-%! positions @var{id}.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}.
-%! @item us
-%! Object instantiated by @ref{dseries}.
-%! @item id
-%! vector of integers.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}, without variable (@var{a}).
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-[n,message] = common_strings_in_cell_arrays(ts.name,us.name);
-
-if n
-    error(['dseries::insert: Variable(s) ' message ' already exist in ''' inputname(1) '''!'])
-end
-
-if ~isequal(frequency(ts),frequency(us))
-    error(['dseries::insert: ''' inputname(1) ''' and ''' inputname(2) ''' dseries objects must have common frequencies!'])
-end
-
-[ts,us] = align(ts, us);
-
-n = length(id);
-
-if n>1
-   [id, jd] = sort(id);
-   us.data = us.data(:,jd);
-   us.name = us.name(jd);
-   us.tex = us.tex(jd);
-end
-
-for i=1:n
-    ts.data = insert_column_vector_in_a_matrix(ts.data,us.data(:,i),id(i));
-    ts.name = insert_object_in_a_one_dimensional_cell_array(ts.name,us.name{i},id(i));
-    ts.tex = insert_object_in_a_one_dimensional_cell_array(ts.tex,us.tex{i},id(i));
-    id = id+1;
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(5,2);
-%$
-%$ % Define names.
-%$ A_name = {'A1'; 'A2';'A3'};
-%$ B_name = {'B1'; 'B2'};
-%$
-%$ % Define initial dates.
-%$ A_init = '1950Q1';
-%$ B_init = '1950Q3';
-%$
-%$ % Instantiate two dseries objects.
-%$ ts1 = dseries(A, A_init, A_name,[]);
-%$ ts2 = dseries(B, B_init, B_name,[]);
-%$
-%$ try
-%$    ts1 = insert(ts1,ts2,[1,2]);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts1.vobs,{'B1';'A1';'B2';'A3'});
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    eB = [NaN(2,2); B; NaN(3,2)];
-%$    t(4) = dyn_assert(ts1.data,[eB(:,1), A(:,1), eB(:,2), A(:,2:3)], 1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/isempty.m b/matlab/@dseries/isempty.m
deleted file mode 100644
index 5df634e46ee8ab8a70499adf1b3d79950c281f98..0000000000000000000000000000000000000000
--- a/matlab/@dseries/isempty.m
+++ /dev/null
@@ -1,40 +0,0 @@
-function b = isempty(A)
-%@info:
-%! @deftypefn {Function File} {@var{b} =} isempty (@var{A})
-%! @anchor{@dseries/isempty}
-%! @sp 1
-%! Overloads the isempty function for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item 1
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item b
-%! Scalar integer (0 or 1).
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2011-2012 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/>.
-
-b = isempty(A.data);
\ No newline at end of file
diff --git a/matlab/@dseries/isequal.m b/matlab/@dseries/isequal.m
deleted file mode 100644
index d57150551ee819bb3931c83fbd62b311c01ed4f8..0000000000000000000000000000000000000000
--- a/matlab/@dseries/isequal.m
+++ /dev/null
@@ -1,65 +0,0 @@
-function C = isequal(A,B)
-
-% Overloads the isequal Matlab/Octave's function.
-%
-% INPUTS 
-%  o A      dseries object (T periods, N variables).
-%  o B      dseries object (T periods, N variables).
-%
-% OUTPUTS 
-%  o C      Integer scalar equal to zero or one.
-
-% 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 nargin~=2
-    error('dseries::isequal: I need exactly two input arguments!')
-end
-
-if ~isdseries(B)
-    error('dseries::isequal: Both input arguments must be dseries objects!')
-end
-
-if ~isequal(nobs(A), nobs(B))
-    C = 0;
-    return
-end
-
-if ~isequal(vobs(A), vobs(B))
-    C = 0;
-    return
-end
-
-if ~isequal(frequency(A),frequency(B))
-    C = 0;
-    return
-end
-
-if ~isequal(A.dates,B.dates)
-    C = 0;
-    return
-end
-
-if ~isequal(A.name,B.name)
-    warning('dseries::isequal: Both input arguments do not have the same variables!')
-end
-
-if ~isequal(A.tex,B.tex)
-    warning('dseries::isequal: Both input arguments do not have the same tex names!')
-end
-
-C = isequal(A.data, B.data);
\ No newline at end of file
diff --git a/matlab/@dseries/lag.m b/matlab/@dseries/lag.m
deleted file mode 100644
index 4a2069599b543033c096a8a2eb3ad11072e34396..0000000000000000000000000000000000000000
--- a/matlab/@dseries/lag.m
+++ /dev/null
@@ -1,85 +0,0 @@
-function us = lag(ts,p) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} lag (@var{ts})
-%! @anchor{lag}
-%! @sp 1
-%! Computes lagged time series.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-% Set default number of lags
-if nargin<2
-    p = 1;
-end
-
-if p<=0
-    error('dseries::lag: Second input argument must be strictly positive! Use lead method instead.')
-end
-
-% Copy of ts dseries object
-us = ts;
-
-% Update data member
-us.data = [NaN(p, vobs(ts));  ts.data(1:end-p,:)];
-
-for i=1:vobs(ts)
-    us.name(i) = {[ 'lag(' ts.name{i} ',' int2str(p) ')']};
-    us.tex(i) = {[ ts.tex{i} '_{-' int2str(p) '}']};
-end
-
-%@test:1
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     data = transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     a = ts.lag;
-%$     b = ts.lag.lag;
-%$     c = lag(ts,2);
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = [NaN(1,ts.vobs); transpose(0:1:49)];
-%$     t(2) = dyn_assert(a.data,DATA,1e-15);
-%$     DATA = [NaN(2,ts.vobs); transpose(0:1:48)];
-%$     t(3) = dyn_assert(b.data,DATA,1e-15);
-%$     t(4) = dyn_assert(b.data,c.data,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/lastdate.m b/matlab/@dseries/lastdate.m
deleted file mode 100644
index 972a70e1899f3ea255d10db1522466c0da7e21d3..0000000000000000000000000000000000000000
--- a/matlab/@dseries/lastdate.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function l = lastdate(o)
-
-% 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/>.
-
-l = o.dates(end);
\ No newline at end of file
diff --git a/matlab/@dseries/lead.m b/matlab/@dseries/lead.m
deleted file mode 100644
index c4eba7a230226d87007943f673c4c8c93d790890..0000000000000000000000000000000000000000
--- a/matlab/@dseries/lead.m
+++ /dev/null
@@ -1,85 +0,0 @@
-function us = lead(ts,p) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} lead (@var{ts})
-%! @anchor{lag}
-%! @sp 1
-%! Computes leaded time series.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-% Set default number of leads
-if nargin<2
-    p = 1;
-end
-
-if p<=0
-    error('dseries::lead: Second input argument must be strictly positive! Use lag method instead.')
-end
-
-% Copy of ts dseries object
-us = ts;
-
-% Update data member
-us.data = [  ts.data(p+1:end,:); NaN(p, vobs(ts));];
-
-for i=1:vobs(ts)
-    us.name(i) = {[ 'lead(' ts.name{i} ',' int2str(p) ')']};
-    us.tex(i) = {[ ts.tex{i} '_{+' int2str(p) '}']};
-end
-
-%@test:1
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     data = transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     a = ts.lead;
-%$     b = ts.lead.lead;
-%$     c = lead(ts,2);
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = [transpose(1:50); NaN(1,ts.vobs)];
-%$     t(2) = dyn_assert(a.data,DATA,1e-15);
-%$     DATA = [transpose(2:50); NaN(2,ts.vobs)];
-%$     t(3) = dyn_assert(b.data,DATA,1e-15);
-%$     t(4) = dyn_assert(b.data,c.data,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/log.m b/matlab/@dseries/log.m
deleted file mode 100644
index 2ff8e6488572bc1bf7497ca771f996beb34a4962..0000000000000000000000000000000000000000
--- a/matlab/@dseries/log.m
+++ /dev/null
@@ -1,55 +0,0 @@
-function ts = log(ts)
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} log(@var{ts})
-%! @anchor{log}
-%! Apply the logarithm function to a Dynare time series object.
-%!
-%! @strong{Inputs}
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%!
-%! @strong{Outputs}
-%! @table @var
-%! @item ts
-%! Dynare time series object with transformed data field.
-%! @end table
-%!
-%! @strong{This function is called by:}
-%! None.
-%!
-%! @strong{This function calls:}
-%! None.
-%!
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2011-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 any(ts.data<eps)
-    error('dseries::log: Input argument has to be strictly positive!')
-end
-
-for i=1:vobs(ts)
-    ts.name(i) = {['log(' ts.name{i} ')']};
-    ts.tex(i) = {['\log(' ts.tex{i} ')']};
-end
-
-ts.data = log(ts.data);
\ No newline at end of file
diff --git a/matlab/@dseries/merge.m b/matlab/@dseries/merge.m
deleted file mode 100644
index 1ab70b389299c6f5bd9daf114c0e26f58468f305..0000000000000000000000000000000000000000
--- a/matlab/@dseries/merge.m
+++ /dev/null
@@ -1,146 +0,0 @@
-function A = merge(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} merge (@var{B},@var{C})
-%! @anchor{@dseries/plus}
-%! @sp 1
-%! Overloads the merge method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if ~isdseries(C)
-    error('dseries::merge: Both inputs must be dseries objects!')
-end
-
-if ~isequal(frequency(B),frequency(C))
-    error(['dseries::merge: Cannot merge ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
-end
-
-A = dseries();
-[A.name, IBC, junk] = unique([B.name; C.name], 'last');
-tex = [B.tex; C.tex];
-A.tex = tex(IBC);
-
-if nobs(B) == 0
-    A = C;
-elseif nobs(C) == 0
-    A = B;
-elseif firstdate(B) >= firstdate(C)
-    diff = firstdate(B) - firstdate(C);
-    A_nobs = max(nobs(B) + diff, nobs(C));
-    A.data = NaN(A_nobs, vobs(A));
-    Z1 = [NaN(diff, vobs(B));B.data];
-    if nobs(A) > nobs(B) + diff
-        Z1 = [Z1; NaN(nobs(A)-(nobs(B) + diff), vobs(B))];
-    end;
-    Z2 = C.data;
-    if nobs(A) > nobs(C)
-        Z2 = [Z2; NaN(nobs(A) - nobs(C), vobs(C))];
-    end;
-    Z = [Z1 Z2];
-    A.data = Z(:,IBC);
-    A_init = firstdate(C);
-else
-    diff = firstdate(C) - firstdate(B);
-    A_nobs = max(nobs(C) + diff, nobs(B));
-    A.data = NaN(A_nobs, vobs(A));
-    Z1 = [NaN(diff, vobs(C)); C.data];
-    if nobs(A) > nobs(C) + diff
-        Z1 = [Z1; NaN(nobs(A)-(nobs(C) + diff), vobs(C))];
-    end
-    Z2 = B.data;
-    if nobs(A) > nobs(B)
-        Z2 = [Z2; NaN(nobs(A) - nobs(B), vobs(B))];
-    end;
-    Z = [Z2 Z1];
-    A.data = Z(:,IBC);
-    A_init = B.init;
-end
-
-A.dates = A_init:A_init+(nobs(A)-1);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'A1'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = merge(ts1,ts2);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[B, A(:,2)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = merge(ts1,ts2);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,3);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A, B],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dseries/minus.m b/matlab/@dseries/minus.m
deleted file mode 100644
index 4f3309d8d2840a469350db34a5a348e9271fb120..0000000000000000000000000000000000000000
--- a/matlab/@dseries/minus.m
+++ /dev/null
@@ -1,196 +0,0 @@
-function A = minus(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} minus (@var{B},@var{C})
-%! @anchor{@dseries/minus}
-%! @sp 1
-%! Overloads the minus method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2012-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 isnumeric(B) && (isscalar(B) ||  isvector(B))
-    if ~isdseries(C)
-        error('dseries::minus: Second input argument must be a dseries object!')
-    end
-    A = C;
-    A.data = bsxfun(@minus,B,C.data);
-    return;
-end
-
-if isnumeric(C) && (isscalar(C) || isvector(C))
-    if ~isdseries(B)
-        error('dseries::minus: First input argument must be a dseries object!')
-    end
-    A = B;
-    A.data = bsxfun(@minus,B.data,C);
-    return
-end
-
-if ~isequal(vobs(B), vobs(C)) && ~(isequal(vobs(B),1) || isequal(vobs(C),1))
-    error(['dseries::minus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (wrong number of variables)!'])
-else
-    if vobs(B)>vobs(C)
-        idB = 1:vobs(B);
-        idC = ones(1:vobs(B));
-    elseif vobs(B)<vobs(C)
-        idB = ones(1,vobs(C));
-        idC = 1:vobs(C);
-    else
-        idB = 1:vobs(B);
-        idC = 1:vobs(C);
-    end
-end
-
-if ~isequal(frequency(B),frequency(C))
-    error(['dseries::plus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
-end
-
-if ~isequal(nobs(B), nobs(C)) || ~isequal(firstdate(B),firstdate(C))
-    [B, C] = align(B, C);
-end
-
-if isempty(B)
-    A = -C;
-    return
-end
-
-if isempty(C)
-    A = B;
-    return
-end
-
-A = dseries();
-
-A.dates = B.dates;
-A_vobs = max(vobs(B), vobs(C));
-A.name = cell(A_vobs,1);
-A.tex = cell(A_vobs,1);
-for i=1:A_vobs
-    A.name(i) = {['minus(' B.name{idB(i)} ';' C.name{idC(i)} ')']};
-    A.tex(i) = {['(' B.tex{idB(i)} '-' C.tex{idC(i)} ')']};
-end
-A.data = bsxfun(@minus,B.data,C.data);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(5,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1-ts2;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(:,1)-B, A(:,2)-B],1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'minus(A1;B1)';'minus(A2;B1)'});
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(5,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(5,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1-ts2;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(1:5,1)-B(1:5), A(1:5,2)-B(1:5) ; NaN(5,2)],1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'minus(A1;B1)';'minus(A2;B1)'});
-%$ end
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ ts1 = dseries(ones(3,1));
-%$ ts2 = ts1-1;
-%$ ts3 = 2-ts1;
-%$ t(1) = isequal(ts2.data, zeros(3,1));
-%$ t(2) = isequal(ts3.data, ts1.data);
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1-1;
-%$ ts3 = 2-ts1;
-%$ t(1) = isequal(ts2.data, zeros(3,2));
-%$ t(2) = isequal(ts3.data, ts1.data);
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1-ones(3,1);
-%$ ts3 = 2*ones(3,1)-ts1;
-%$ t(1) = isequal(ts2.data, zeros(3,2));
-%$ t(2) = isequal(ts3.data, ts1.data);
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1-ones(1,2);
-%$ ts3 = 2*ones(1,2)-ts1;
-%$ t(1) = isequal(ts2.data, zeros(3,2));
-%$ t(2) = isequal(ts3.data, ts1.data);
-%$ T = all(t);
-%@eof:7
diff --git a/matlab/@dseries/mpower.m b/matlab/@dseries/mpower.m
deleted file mode 100644
index 283705243c4106c1144c118de0391c1b34cf98ba..0000000000000000000000000000000000000000
--- a/matlab/@dseries/mpower.m
+++ /dev/null
@@ -1,168 +0,0 @@
-function A = mpower(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} mpower (@var{B},@var{C})
-%! @anchor{@dseries/mpower}
-%! @sp 1
-%! Overloads the mpower method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}, with T observations and N variables.
-%! @item C
-%! Real scalar or a dseries object with T observations and N variables.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! dseries object with T observations and N variables.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if isnumeric(B) && isvector(B) && length(B)>1
-    if ~isdseries(C)
-        error('dseries::mpower: Second input argument must be a dseries object!')
-    end
-    A = C;
-    A.data = bsxfun(@power,C.data,B);
-    return;
-end
-
-if isnumeric(C) && isvector(C) && length(C)>1
-    if ~isdseries(B)
-        error('dseries::mpower: First input argument must be a dseries object!')
-    end
-    A = B;
-    A.data = bsxfun(@power,B.data,C);
-    return
-end
-
-if isdseries(B) && isnumeric(C) && isreal(C) &&  isscalar(C)
-    A = dseries();
-    A.dates = B.dates;
-    A.data = B.data.^C;
-    A.name = cell(vobs(A),1);
-    A.tex = cell(vobs(A),1);
-    for i=1:vobs(A)
-        A.name(i) = {['power(' B.name{i} ';' num2str(C) ')']};
-        A.tex(i) = {[B.tex{i} '^' num2str(C) ]};
-    end
-    return
-end
-
-if isdseries(B) && isdseries(C)
-    if isequal(nobs(B),nobs(C)) && isequal(vobs(B), vobs(C)) && isequal(frequency(B),frequency(C))
-        A = dseries();
-        A.data = B.data.^C.data;
-        A.dates = B.dates;
-        A.name = cell(vobs(A),1);
-        A.tex = cell(vobs(A),1);
-        for i=1:vobs(A)
-            A.name(i) = {['power(' B.name{i} ';' C.name{i} ')']};
-            A.tex(i) = {[B.tex{i} '^{' C.tex{i} '}']};
-        end
-    else
-        error('dseries::mpower: If both input arguments are dseries objects, they must have the same numbers of variables and observations and common frequency!')
-    end
-    return
-end
-
-error(['dseries::mpower: Wrong calling sequence!'])
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1';'B2'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1^ts2;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,A.^B,1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'power(A1;B1)';'power(A2;B2)'});
-%$    t(6) = dyn_assert(ts3.tex,{'A1^{B1}';'A2^{B2}'});
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts3 = ts1^2;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,A.^2,1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'power(A1;2)';'power(A2;2)'});
-%$    t(6) = dyn_assert(ts3.tex,{'A1^2';'A2^2'});
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a dseries object
-%$ ts1=dseries([1 1;2 2;3 3], '1999y', {'MyVar1','MyVar2'});
-%$
-%$ % Use the power
-%$ try
-%$    ts2 = ts1^transpose(1:3);
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,3);
-%$    t(4) = dyn_assert(ts2.data,bsxfun(@power,ts1.data,transpose(1:3)),1e-15);
-%$    t(5) = dyn_assert(ts2.name,{'MyVar1';'MyVar2'});
-%$    t(6) = dyn_assert(ts2.tex,{'MyVar1';'MyVar2'});
-%$ end
-%$ T = all(t);
-%@eof:3
\ No newline at end of file
diff --git a/matlab/@dseries/mrdivide.m b/matlab/@dseries/mrdivide.m
deleted file mode 100644
index 3d4377e82403b4810bfa9a781b7f0431ed7be11e..0000000000000000000000000000000000000000
--- a/matlab/@dseries/mrdivide.m
+++ /dev/null
@@ -1,174 +0,0 @@
-function A = mrdivide(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} mrdivide (@var{B},@var{C})
-%! @anchor{@dseries/mrdivide}
-%! @sp 1
-%! Overloads the mrdivide method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2012-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 isnumeric(B) && (isscalar(B) ||  isvector(B))
-    if ~isdseries(C)
-        error('dseries::mrdivide: Second input argument must be a dseries object!')
-    end
-    A = C;
-    A.data = bsxfun(@rdivide,B,C.data);
-    return;
-end
-
-if isnumeric(C) && (isscalar(C) || isvector(C))
-    if ~isdseries(B)
-        error('dseries::mrdivide: First input argument must be a dseries object!')
-    end
-    A = B;
-    A.data = bsxfun(@rdivide,B.data,C);
-    return
-end    
-
-if isdseries(B) && isdseries(C)
-    % Element by element divisions of two dseries object
-    if ~isequal(vobs(B), vobs(C)) && ~(isequal(vobs(B),1) || isequal(vobs(C),1))
-        error(['dseries::times: Cannot divide ' inputname(1) ' and ' inputname(2) ' (wrong number of variables)!'])
-    else
-        if vobs(B)>vobs(C)
-            idB = 1:vobs(B);
-            idC = ones(1:vobs(B));
-        elseif vobs(B)<vobs(C)
-            idB = ones(1,vobs(C));
-            idC = 1:vobs(C);
-        else
-            idB = 1:vobs(B);
-            idC = 1:vobs(C);
-        end
-    end
-    if ~isequal(frequency(B),frequency(C))
-        error(['dseries::times: Cannot divide ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
-    end
-    if ~isequal(nobs(B), nobs(C)) || ~isequal(firstdate(B),firstdate(C))
-        [B, C] = align(B, C);
-    end
-    A = dseries();
-    A.dates = B.dates;
-    A_vobs = max(vobs(B),vobs(C));
-    A.name = cell(A_vobs,1);
-    A.tex = cell(A_vobs,1);
-    for i=1:A_vobs
-        A.name(i) = {['divide(' B.name{idB(i)} ';' C.name{idC(i)} ')']};
-        A.tex(i) = {['(' B.tex{idB(i)} '/' C.tex{idC(i)} ')']};
-    end
-    A.data = bsxfun(@rdivide,B.data,C.data);
-else
-    error()
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1/ts2;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(:,1)./B, A(:,2)./B],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,2); B = pi;
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = ts1/B;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,A/B,1e-15);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(10,2); B = pi;
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = B/ts1;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,B./A,1e-15);
-%$ end
-%$ T = all(t);
-%@eof:3
diff --git a/matlab/@dseries/mtimes.m b/matlab/@dseries/mtimes.m
deleted file mode 100644
index db5695aa02efa1eb149c0d1da8076af633b26818..0000000000000000000000000000000000000000
--- a/matlab/@dseries/mtimes.m
+++ /dev/null
@@ -1,197 +0,0 @@
-function A = mtimes(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} mtimes (@var{B},@var{C})
-%! @anchor{@dseries/mtimes}
-%! @sp 1
-%! Overloads the mtimes method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2012-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 isnumeric(B) && (isscalar(B) ||  isvector(B))
-    if ~isdseries(C)
-        error('dseries::mtimes: Second input argument must be a dseries object!')
-    end
-    A = C;
-    A.data = bsxfun(@times,C.data,B);
-    return;
-end
-
-if isnumeric(C) && (isscalar(C) || isvector(C))
-    if ~isdseries(B)
-        error('dseries::mtimes: First input argument must be a dseries object!')
-    end
-    A = B;
-    A.data = bsxfun(@times,B.data,C);
-    return
-end
-
-if isdseries(B) && isdseries(C)
-    % Element by element multiplication of two dseries object
-    if ~isequal(vobs(B), vobs(C)) && ~(isequal(vobs(B),1) || isequal(vobs(C),1))
-        error(['dseries::times: Cannot multiply ' inputname(1) ' and ' inputname(2) ' (wrong number of variables)!'])
-    else
-        if vobs(B)>vobs(C)
-            idB = 1:vobs(B);
-            idC = ones(1:vobs(B));
-        elseif vobs(B)<vobs(C)
-            idB = ones(1,vobs(C));
-            idC = 1:vobs(C);
-        else
-            idB = 1:vobs(B);
-            idC = 1:vobs(C);
-        end
-    end
-    if ~isequal(frequency(B),frequency(C))
-        error(['dseries::times: Cannot multiply ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
-    end
-    if ~isequal(nobs(B), nobs(C)) || ~isequal(firstdate(B),firstdate(C))
-        [B, C] = align(B, C);
-    end
-    A = dseries();
-    A.dates = B.dates;
-    A_vobs = max(vobs(B),vobs(C));
-    A.name = cell(A_vobs,1);
-    A.tex = cell(A_vobs,1);
-    for i=1:A_vobs
-        A.name(i) = {['multiply(' B.name{idB(i)} ';' C.name{idC(i)} ')']};
-        A.tex(i) = {['(' B.tex{idB(i)} '*' C.tex{idC(i)} ')']};
-    end
-    A.data = bsxfun(@times,B.data,C.data);
-else
-    error()
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1*ts2;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(:,1).*B, A(:,2).*B],1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'multiply(A1;B1)';'multiply(A2;B1)'});
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,2); B = pi;
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = ts1*B;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,A*B,1e-15);
-%$ end
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(10,2); B = pi;
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = B*ts1;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,A*B,1e-15);
-%$ end
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a datasets.
-%$ A = rand(10,2); B = A(1,:);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = B*ts1;
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if t(1)
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,bsxfun(@times,A,B),1e-15);
-%$ end
-%$ T = all(t);
-%@eof:4
diff --git a/matlab/@dseries/ne.m b/matlab/@dseries/ne.m
deleted file mode 100644
index ed6e98adce51c669a1637561aa2746caae543c0c..0000000000000000000000000000000000000000
--- a/matlab/@dseries/ne.m
+++ /dev/null
@@ -1,100 +0,0 @@
-function C = ne(A,B) % --*-- Unitary tests --*--
-
-% Overloads ne (~=) operator.
-%
-% INPUTS 
-%  o A      dseries object (T periods, N variables).
-%  o B      dseries object (T periods, N variables).
-%
-% OUTPUTS 
-%  o C      T*N matrix of zeros and ones. Element C(t,n) is nonzero iff observation t of variable n in A and B are different.  
-%
-% REMARKS 
-%  If the number of variables, the number of observations or the frequencies are different in A and B, the function returns one. 
-
-% 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 nargin~=2
-    error('dseries::ne: I need exactly two input arguments!')
-end
-
-if ~(isdseries(A) && isdseries(B))
-    error('dseries::ne: Both input arguments must be dseries objects!')
-end
-
-if ~isequal(nobs(A), nobs(B))
-    warning('dseries::ne: Both input arguments should have the same number of observations!')
-    C = 1;
-    return
-end
-
-if ~isequal(vobs(A), vobs(B))
-    warning('dseries::ne: Both input arguments should have the same number of observations!')
-    C = 1;
-    return
-end
-
-if ~isequal(frequency(A),frequency(B))
-    warning('dseries::ne: Both input arguments should have the same frequencies!')
-    C = 1;
-    return
-end
-
-if ~isequal(firstdate(A),firstdate(B))
-    warning('dseries::ne: Both input arguments should have the same initial period!')
-    C = 1;
-    return
-end
-
-if ~isequal(A.name,B.name)
-    warning('dseries::ne: Both input arguments do not have the same variables!')
-end
-
-if ~isequal(A.tex,B.tex)
-    warning('dseries::ne: Both input arguments do not have the same tex names!')
-end
-
-C = ne(A.data, B.data);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$ B = A;
-%$ B(:,3) = rand(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'}; B_name = A_name;
-%$
-%$ t = zeros(2,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts2 = ts1;
-%$    a = eq(ts1,ts2);
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(a,[ones(10,2), ones(10,1)]);
-%$ end
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/@dseries/nobs.m b/matlab/@dseries/nobs.m
deleted file mode 100644
index dc6fc76536d5d8a5d86fc3c731c80a70694fbc28..0000000000000000000000000000000000000000
--- a/matlab/@dseries/nobs.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function s = nobs(ts)
-
-% Returns the number of observations in a @dseries object.
-
-% 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/>.
-
-s = rows(ts.data);
\ No newline at end of file
diff --git a/matlab/@dseries/numel.m b/matlab/@dseries/numel.m
deleted file mode 100644
index 85cd84962a05b56f411ca3f60de28d691a09dd2f..0000000000000000000000000000000000000000
--- a/matlab/@dseries/numel.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function n = numel(obj, varargin)
-
-% 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/>.
-
-n = 1;
diff --git a/matlab/@dseries/plot.m b/matlab/@dseries/plot.m
deleted file mode 100644
index 058a44dd0cf1a08af81def389fb0ac868f5dd42b..0000000000000000000000000000000000000000
--- a/matlab/@dseries/plot.m
+++ /dev/null
@@ -1,84 +0,0 @@
-function h = plot(ts, varargin)
-
-% Overloads Matlab/Octave's plot function for dseries objects. 
-
-% 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/>.
-
-% Get the number of dseries objects
-if isequal(nargin,1)
-    ndseries = 1;
-    nvariables = vobs(ts);
-    nobservations = nobs(ts);
-else
-    if isdseries(varargin{1})
-        ndseries = 2;
-        nvariables = vobs(ts);
-        nobservations = nobs(ts);
-        if nargin>2 && any(cellfun(@isdseries,varargin(2:end)))
-            error('dseries::plot: You cannot pass more two dseries objects!')
-        end
-        if ~isequal(nvariables, vobs(varargin{1}))
-            error('dseries::plot: The two dseries objects must have the same number of variables!')
-        end
-        if ~isequal(nobservations, nobs(varargin{1}))
-            error('dseries::plot: The two dseries objects must have the same number of observations!')
-        end
-    else
-        ndseries = 1;
-        nvariables = vobs(ts);
-        nobservations = nobs(ts);
-    end
-end
-
-switch ndseries
-  case 1
-    if isequal(nvariables,1)
-        hh = plot(ts.data,varargin{:});
-    else
-        if length(varargin)
-            message = sprintf('dseries::plot: dseries object %s has %d>1 variables but you passed additional arguments to the plot function.\n                        These additional arguments won''t ne interpreted. Use the Matlab/Octave set command and the plot\n                        handle instead if you wish to modify the properties of the plotted time series.',inputname(1),nvariables);
-            warning(message)
-        end
-        hh = plot(ts.data);
-    end
-    axis tight;
-    id = get(gca,'XTick');
-    if isequal(id(1),0)
-        dates = strings([ts.dates(1)-1,ts.dates(id(2:end))]);
-    else
-        dates = strings(ts.dates(id));
-    end
-    set(gca,'XTickLabel',dates);
-  case 2
-    [ts0, ts1] = align(ts, varargin{1});
-    if isequal(nvariables,1)
-        hh = plot(ts0.data, ts1.data, varargin{2:end});
-    else
-        if length(varargin)>1
-             message = sprintf('dseries::plot: dseries objects %s and %s have %d>1 variables but you passed additional arguments to the plot function.\n                        These additional arguments won''t ne interpreted. Use the Matlab/Octave set command and the plot\n                        handle instead if you wish to modify the properties of the plotted time series.',inputname(1),inputname(2),nvariables);
-            warning(message)
-        end
-        hh = plot(ts0.data, ts1.data);
-    end
-  otherwise
-    error('dseries::plot: This is a bug! Please report the bug to the authors of Dynare.')
-end
-
-if nargout
-     h = hh;
-end
\ No newline at end of file
diff --git a/matlab/@dseries/plus.m b/matlab/@dseries/plus.m
deleted file mode 100644
index 850d6ef1102243ec61dc8427d9a1eb7d847733b3..0000000000000000000000000000000000000000
--- a/matlab/@dseries/plus.m
+++ /dev/null
@@ -1,325 +0,0 @@
-function A = plus(B,C) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C})
-%! @anchor{@dseries/plus}
-%! @sp 1
-%! Overloads the plus method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @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/>.
-
-if isnumeric(B) && (isscalar(B) ||  isvector(B))
-    if ~isdseries(C)
-        error('dseries::plus: Second input argument must be a dseries object!')
-    end
-    A = C;
-    A.data = bsxfun(@plus,C.data,B);
-    return;
-end
-
-if isnumeric(C) && (isscalar(C) || isvector(C))
-    if ~isdseries(B)
-        error('dseries::plus: First input argument must be a dseries object!')
-    end
-    A = B;
-    A.data = bsxfun(@plus,B.data,C);
-    return
-end
-
-if ~isequal(vobs(B), vobs(C)) && ~(isequal(vobs(B), 1) || isequal(vobs(C), 1))
-    error(['dseries::plus: Cannot add ' inputname(1) ' and ' inputname(2) ' (wrong number of variables)!'])
-else
-    if vobs(B)>vobs(C)
-        idB = 1:vobs(B);
-        idC = ones(1,vobs(B));
-    elseif vobs(B)<vobs(C)
-        idB = ones(1,vobs(C));
-        idC = 1:vobs(C);
-    else
-        idB = 1:vobs(B);
-        idC = 1:vobs(C);
-    end
-end
-
-if ~isequal(frequency(B),frequency(C))
-    error(['dseries::plus: Cannot add ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
-end
-
-if ~isequal(nobs(B), nobs(C)) || ~isequal(firstdate(B),firstdate(C))
-    [B, C] = align(B, C);
-end
-
-if isempty(B)
-    A = C;
-    return
-end
-
-if isempty(C)
-    A = B;
-    return
-end
-
-A = dseries();
-
-A.data = bsxfun(@plus,B.data,C.data);
-A.dates = B.dates;
-
-A_vobs = max(vobs(B), vobs(C));
-A.name = cell(A_vobs,1);
-A.tex = cell(A_vobs,1);
-for i=1:A_vobs
-    A.name(i) = {['plus(' B.name{idB(i)} ';' C.name{idC(i)} ')']};
-    A.tex(i) = {['(' B.tex{idB(i)} '+' C.tex{idC(i)} ')']};
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(5,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1+ts2;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(:,1)+B, A(:,2)+B],1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'plus(A1;B1)';'plus(A2;B1)'});
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(10,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(5,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1+ts2;
-%$    ts4 = ts3+ts1; 
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts4.vobs,2);
-%$    t(3) = dyn_assert(ts4.nobs,10);
-%$    t(4) = dyn_assert(ts4.data,[A(:,1)+B, A(:,2)+B]+A,1e-15);
-%$    t(5) = dyn_assert(ts4.name,{'plus(plus(A1;B1);A1)';'plus(plus(A2;B1);A2)'});
-%$ end
-%$ T = all(t);
-%@eof:2
-
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(10,2); B = randn(5,1);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'}; B_name = {'B1'};
-%$
-%$ t = zeros(5,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = dseries(B,[],B_name,[]);
-%$    ts3 = ts1+ts2;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts3.vobs,2);
-%$    t(3) = dyn_assert(ts3.nobs,10);
-%$    t(4) = dyn_assert(ts3.data,[A(1:5,1)+B(1:5), A(1:5,2)+B(1:5) ; NaN(5,2)],1e-15);
-%$    t(5) = dyn_assert(ts3.name,{'plus(A1;B1)';'plus(A2;B1)'});
-%$ end
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ t = zeros(7,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:5),'1950q1',{'Output'}, {'Y_t'});
-%$     us = dseries(transpose(1:5),'1949q4',{'Consumption'}, {'C_t'});
-%$     vs = ts+us;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(us.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(us.init.time,[1949, 4]);
-%$     t(6) = dyn_assert(vs.init.time,[1949, 4]);
-%$     t(7) = dyn_assert(vs.nobs,6);
-%$ end
-%$
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ t = zeros(7,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:5),'1950q1',{'Output'}, {'Y_t'});
-%$     us = dseries(transpose(1:7),'1950q1',{'Consumption'}, {'C_t'});
-%$     vs = ts+us;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(us.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(us.init.time,[1950, 1]);
-%$     t(6) = dyn_assert(vs.init.time,[1950, 1]);
-%$     t(7) = dyn_assert(vs.nobs,7);
-%$ end
-%$
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries(transpose(1:5),'1950q1',{'Output'}, {'Y_t'});
-%$     us = dseries(transpose(1:7),'1950q1',{'Consumption'}, {'C_t'});
-%$     vs = ts+us('1950q1').data;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(us.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(us.init.time,[1950, 1]);
-%$     t(6) = dyn_assert(vs.init.time,[1950, 1]);
-%$     t(7) = dyn_assert(vs.nobs,5);
-%$     t(8) = dyn_assert(vs.data,ts.data+1);
-%$ end
-%$
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ t = zeros(8,1);
-%$
-%$ try
-%$     ts = dseries([transpose(1:5), transpose(1:5)],'1950q1');
-%$     us = dseries([transpose(1:7),2*transpose(1:7)],'1950q1');
-%$     vs = ts+us('1950q1').data;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(us.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(us.init.time,[1950, 1]);
-%$     t(6) = dyn_assert(vs.init.time,[1950, 1]);
-%$     t(7) = dyn_assert(vs.nobs,5);
-%$     t(8) = dyn_assert(vs.data,bsxfun(@plus,ts.data,[1, 2]));
-%$ end
-%$
-%$ T = all(t);
-%@eof:7
-
-%@test:8
-%$ ts1 = dseries(ones(3,1));
-%$ ts2 = ts1+1;
-%$ ts3 = 1+ts1;
-%$ t(1) = isequal(ts2.data, 2*ones(3,1));
-%$ t(2) = isequal(ts3.data, 2*ones(3,1));
-%$ T = all(t);
-%@eof:8
-
-%@test:9
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1+1;
-%$ ts3 = 1+ts1;
-%$ t(1) = isequal(ts2.data, 2*ones(3,2));
-%$ t(2) = isequal(ts3.data, 2*ones(3,2));
-%$ T = all(t);
-%@eof:9
-
-%@test:10
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1+ones(3,1);
-%$ ts3 = ones(3,1)+ts1;
-%$ t(1) = isequal(ts2.data, 2*ones(3,2));
-%$ t(2) = isequal(ts3.data, 2*ones(3,2));
-%$ T = all(t);
-%@eof:10
-
-%@test:11
-%$ ts1 = dseries(ones(3,2));
-%$ ts2 = ts1+ones(1,2);
-%$ ts3 = ones(1,2)+ts1;
-%$ t(1) = isequal(ts2.data, 2*ones(3,2));
-%$ t(2) = isequal(ts3.data, 2*ones(3,2));
-%$ T = all(t);
-%@eof:11
diff --git a/matlab/@dseries/pop.m b/matlab/@dseries/pop.m
deleted file mode 100644
index eb398322b3e43b23ed1695353cc5a3eeb8a98780..0000000000000000000000000000000000000000
--- a/matlab/@dseries/pop.m
+++ /dev/null
@@ -1,113 +0,0 @@
-function [ts,id] = pop(ts,a) % --*-- Unitary tests --*--
-
-% Removes a variable from a dseries object.
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} pop (@var{ts}, @var{a})
-%! @anchor{dseries/pop}
-%! @sp 1
-%! Pop method for the dseries class. Removes a variable from a dseries object.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}.
-%! @item a
-%! String, name of the variable to be removed.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}, without variable (@var{a}).
-%! @item id
-%! Scalar integer, position of variable (@var{a}) in the original dseries object @var{ts}.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if nargin<2
-    % Removes the last variable
-    id = vobs(ts);
-else
-    id = find(strcmp(a,ts.name));
-end
-
-if isempty(id)
-    id = 0;
-    return
-end
-
-ts.data(:,id) = [];
-ts.name(id) = [];
-ts.tex(id) = [];
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = pop(ts1,'A2');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,[A(:,1), A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$
-%$ t = zeros(2,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    [ts2,id] = pop(ts1,'A4');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(id,0);
-%$    t(2) = dyn_assert(isequal(ts1,ts2),1);
-%$ end
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/private/default_name.m b/matlab/@dseries/private/default_name.m
deleted file mode 100644
index 1711195c4313ddca8d499cd4d4b2f49f7cedb867..0000000000000000000000000000000000000000
--- a/matlab/@dseries/private/default_name.m
+++ /dev/null
@@ -1,27 +0,0 @@
-function names = default_name(dim)
-
-% 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/>.
-
-    
-names = {};
-for i=1:dim
-    names = vertcat(names, {['Variable_' int2str(i)]});
-end
-
-
-
diff --git a/matlab/@dseries/qdiff.m b/matlab/@dseries/qdiff.m
deleted file mode 100644
index e6ca19ca8d61c2ad4f792b8da5e81cfde5bd3f3d..0000000000000000000000000000000000000000
--- a/matlab/@dseries/qdiff.m
+++ /dev/null
@@ -1,107 +0,0 @@
-function us = qdiff(ts) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} qdiff (@var{ts})
-%! @anchor{qdiff}
-%! @sp 1
-%! Computes quaterly differences.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 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/>.
-
-us = ts;
-
-switch frequency(ts)
-  case 1
-    error('dseries::qgrowth: I cannot compute quaterly differences from yearly data!')
-  case 4
-    us.data(2:end,:) = ts.data(2:end,:)-ts.data(1:end-1,:);
-    us.data(1,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['qdiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta ' us.tex{i}]};
-    end
-  case 12
-    us.data(4:end,:) = ts.data(4:end,:)-ts.data(1:end-3,:);
-    us.data(1:3,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['qdiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta_3 ' us.tex{i}]};
-    end
-  case 52
-    error('dseries::qgrowth: I do not know yet how to compute quaterly differences from weekly data!')
-  otherwise
-    error(['dseries::ygrowth: object ' inputname(1) ' has unknown frequency']);
-end
-
-%@test:1
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     ts = ts.qdiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = NaN(1,ts.vobs);
-%$     DATA = [DATA; ones(ts.nobs-1,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = transpose(0:1:80);
-%$     ts = dseries(data,'1950M1');
-%$     ts = ts.qdiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = NaN(3,ts.vobs);
-%$     DATA = [DATA; 3*ones(ts.nobs-3,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/qgrowth.m b/matlab/@dseries/qgrowth.m
deleted file mode 100644
index 30e8d7b69f1954fa0a19ac885dc0f3d0234d0fd5..0000000000000000000000000000000000000000
--- a/matlab/@dseries/qgrowth.m
+++ /dev/null
@@ -1,107 +0,0 @@
-function us = qgrowth(ts) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} qgrowth (@var{ts})
-%! @anchor{qgrowth}
-%! @sp 1
-%! Computes quaterly growth rates.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 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/>.
-
-us = ts;
-
-switch frequency(ts)
-  case 1
-    error('dseries::qgrowth: I cannot compute quaterly growth rates from yearly data!')
-  case 4
-    us.data(2:end,:) = ts.data(2:end,:)./ts.data(1:end-1,:) - 1;
-    us.data(1,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['qgrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta ' us.tex{i}]};
-    end
-  case 12
-    us.data(4:end,:) = ts.data(4:end,:)./ts.data(1:end-3,:) - 1;
-    us.data(1:3,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['qgrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta_3 ' us.tex{i}]};
-    end
-  case 52
-    error('dseries::qgrowth: I do not know yet how to compute quaterly growth rates from weekly data!')
-  otherwise
-    error(['dseries::ygrowth: object ' inputname(1) ' has unknown frequency']);
-end
-
-%@test:1
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = (1+.01).^transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     ts = ts.qgrowth;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = NaN(1,ts.vobs);
-%$     DATA = [DATA; .01*ones(ts.nobs-1,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = (1+.01).^transpose(0:1:80);
-%$     ts = dseries(data,'1950M1');
-%$     ts = ts.qgrowth;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     DATA = NaN(3,ts.vobs);
-%$     DATA = [DATA; (1.01^3-1)*ones(ts.nobs-3,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA,1e-15);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/remove.m b/matlab/@dseries/remove.m
deleted file mode 100644
index db9690cfd6c2ef800d1698ea983d3f7f6c108d66..0000000000000000000000000000000000000000
--- a/matlab/@dseries/remove.m
+++ /dev/null
@@ -1,98 +0,0 @@
-function ts = remove(ts,a) % --*-- Unitary tests --*--
-
-% Removes a variable from a dseries object (alias for the pop method).
-
-%@info:
-%! @deftypefn {Function File} {@var{ts} =} pop (@var{ts}, @var{a})
-%! @anchor{dseries/pop}
-%! @sp 1
-%! Remove method for the dseries class. Removes a variable from a dseries object.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}.
-%! @item a
-%! String, name of the variable to be removed.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Object instantiated by @ref{dseries}, without variable (@var{a}).
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% 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/>.
-
-ts = pop(ts, a);
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = remove(ts1,'A2');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,[A(:,1), A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'A3'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts2 = ts1.remove('A2');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,[A(:,1), A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/@dseries/rename.m b/matlab/@dseries/rename.m
deleted file mode 100644
index de67e2b908f0b5fe04e505e3fcaab68d6b6b725c..0000000000000000000000000000000000000000
--- a/matlab/@dseries/rename.m
+++ /dev/null
@@ -1,76 +0,0 @@
-function ts = rename(ts,old,new) % --*-- Unitary tests --*--
-
-% 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 ~ischar(old) || ~ischar(new)
-    error(['dseries::rename: Input arguments ''' inputname(2) ''' and ''' inputname(3) '''  have to be strings!'])
-end
-    
-idname = find(strcmp(old,ts.name));
-
-if isempty(idname)
-    error(['dseries::rename: Variable ' old ' is unknown in dseries object ' inputname(1)  '!'])
-end
-
-ts.name(idname) = {new};
-
-%@test:1
-%$ t = zeros(8,1);
-%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
-%$ try
-%$     ts = rename(ts,'Output','Production');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Production'; 'Consumption'});
-%$     t(8) = dyn_assert(ts.tex,{'Y_t'; 'C_t'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(8,1);
-%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
-%$ try
-%$     ts = ts.rename('Output','Production');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Production'; 'Consumption'});
-%$     t(8) = dyn_assert(ts.tex,{'Y_t'; 'C_t'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/save.m b/matlab/@dseries/save.m
deleted file mode 100644
index 3e8b478fc8ebad46cb55453135ef8a71d8da7385..0000000000000000000000000000000000000000
--- a/matlab/@dseries/save.m
+++ /dev/null
@@ -1,171 +0,0 @@
-function save(A,basename,format) % --*-- Unitary tests --*--
-
-% Saves a dseries object on disk.
-
-% 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 nargin<3 || isempty(format)
-    format = 'csv';
-end
-
-if nargin<2 || isempty(basename)
-    basename = inputname(1);
-end
-
-switch format
-  case 'm'
-    if exist([basename, '.m'],'file')
-        copyfile([basename, '.m'],[basename, '.old.m']);
-    end
-    fid = fopen([basename, '.m'],'w');
-    fprintf(fid,'%% File created on %s.\n',datestr(now));
-    fprintf(fid,'\n');
-    fprintf(fid,'FREQ__ = %s;\n',num2str(frequency(A)));
-    fprintf(fid,'INIT__ = ''%s'';\n',date2string(firstdate(A)));
-    fprintf(fid,'\n');
-    fprintf(fid,'NAMES__ = {');
-    for i=1:vobs(A)
-        fprintf(fid,[ '''' A.name{i}  '''']);
-        if i<vobs(A)
-            fprintf(fid,'; ');
-        end
-    end
-    fprintf(fid,'};\n');
-    str = 'TEX__ = {';
-    for i=1:vobs(A)-1
-        str = [str, '''%s''; '];
-    end
-    str = [str, '''%s''};'];
-    str = sprintf(str, A.tex{:});
-    pattern = '(\w*)(\\\_)';
-    str = regexprep(str, pattern, '$1\\\\_');
-    fprintf(fid,str);
-    fprintf(fid,'\n\n');
-    for v=1:vobs(A)
-        fprintf(fid,'%s = [\n', A.name{v});
-        fprintf(fid,'%15.8g\n',A.data(1:end-1,v));
-        fprintf(fid,'%15.8g];\n\n',A.data(end,v));
-    end
-    fclose(fid);
-  case 'mat'
-    FREQ__ = frequency(A);
-    INIT__ = date2string(firstdate(A));
-    NAMES__ = A.name;
-    TEX__ = A.tex;
-    str = [];
-    for v=1:vobs(A)
-        str = [str, A.name{v} ' = A.data(:,' num2str(v) ');' ];
-    end
-    eval(str);
-    if exist([basename, '.mat'],'file')
-        copyfile([basename, '.mat'],[basename, '.old.mat']);
-    end
-    save([basename '.mat'],'INIT__','FREQ__','NAMES__','TEX__',A.name{:});
-  case 'csv'
-    if exist([basename, '.csv'],'file')
-        copyfile([basename, '.csv'],[basename, '.old.csv']);
-    end
-    fid = fopen([basename, '.csv'],'w');
-    fprintf(fid,',%s', A.name{:});
-    fprintf(fid,'\n');
-    for t=1:nobs(A)
-        str = sprintf(', %15.8g',A.data(t,:));
-        fprintf(fid, '%s%s\n',date2string(A.dates(t)),str);
-    end
-    fclose(fid);
-end
-
-%@test:1
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    save(ts1,[],'csv');
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    save(ts1,[],'m');
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    save(ts1,[],'mat');
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    if isoctave
-%$        ts1.save('A');
-%$    else
-%$        ts1.save;
-%$    end
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:4
diff --git a/matlab/@dseries/set_names.m b/matlab/@dseries/set_names.m
deleted file mode 100644
index 0751872ab43bcf1089100bb54bd9e66ea92b007b..0000000000000000000000000000000000000000
--- a/matlab/@dseries/set_names.m
+++ /dev/null
@@ -1,113 +0,0 @@
-function A = set_names(B,varargin) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} times (@var{B},@code{varargin})
-%! @anchor{@nSeries/set_names}
-%! @sp 1
-%! Specify names of the variables in a @ref{dseries} object.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2012 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/>.
-
-% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
-
-n = nargin-1;
-
-if ~isdseries(B)
-    error(['dseries::rename: ' inputname(1) ' must be a dseries object!'])
-end
-
-if ~isequal(vobs(B),n)
-    error(['dseries::rename: The number of variables in ' inputname(1) ' does not match the number of declared names!'])
-end
-
-A = B;
-
-for i=1:vobs(A)
-    if ~isempty(varargin{i})
-        A.name(i) = { varargin{i} };
-    end
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'Variable_2';'A3'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],[],[]);
-%$    ts2 = set_names(ts1,'A1',[],'A3');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$ 
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,3);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.name,A_name);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Define names
-%$ A_name = {'A1';'Variable_2';'A3'};
-%$
-%$ t = zeros(4,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],[],[]);
-%$    ts1 = ts1.set_names('A1',[],'A3');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name,A_name);
-%$ end
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/size.m b/matlab/@dseries/size.m
deleted file mode 100644
index c83090b51258e2c8afd4e370848b383bc4be82be..0000000000000000000000000000000000000000
--- a/matlab/@dseries/size.m
+++ /dev/null
@@ -1,34 +0,0 @@
-function varargout = size(o, varargin)
-
-% Copyright (C) 2013-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/>.
-
-switch nargout
-  case 0
-    size(o.data, varargin{:})
-  case 1
-    varargout{1} = size(o.data, varargin{:});
-  case 2
-    if isequal(nargin, 1)
-        varargout{1} = size(o.data, 1);
-        varargout{2} = size(o.data, 2);
-    else
-        error('dseries::size: Wrong calling sequence!')
-    end
-  otherwise
-    error('dseries::size: Wrong calling sequence! Cannot return more than two arguments.')
-end
\ No newline at end of file
diff --git a/matlab/@dseries/subsasgn.m b/matlab/@dseries/subsasgn.m
deleted file mode 100644
index b8abbbbde8869ef5fba4d784d4fe4fb883bc2991..0000000000000000000000000000000000000000
--- a/matlab/@dseries/subsasgn.m
+++ /dev/null
@@ -1,886 +0,0 @@
-function A = subsasgn(A,S,B) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} subsasgn (@var{A}, @var{S}, @var{B})
-%! @anchor{@dseries/subsasgn}
-%! @sp 1
-%! Overloads the subsasgn method for the Dynare time series class (@ref{dseries}).
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2012-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/>.
-
-merge_dseries_objects = 1;
-
-switch length(S)
-    case 1
-      switch S(1).type
-        case '{}' % Multiple variable selection.
-          if ~isequal(numel(S(1).subs),numel(unique(S(1).subs)))
-              error('dseries::subsasgn: Wrong syntax!')
-          end
-          for i=1:numel(S(1).subs)
-              element = S(1).subs{i};
-              idArobase = strfind(element,'@');
-              if ~isempty(idArobase)
-                  switch length(idArobase)
-                    case 2
-                      idComma = strfind(element(idArobase(1)+1:idArobase(2)-1),',');
-                      if ~isempty(idComma)
-                          elements = cell(1,numel(idComma)+1); j = 1;
-                          expression = element(idArobase(1)+1:idArobase(2)-1);
-                          while ~isempty(expression)
-                              [token, expression] = strtok(expression,',');
-                              elements(j) = {[element(1:idArobase(1)-1), token, element(idArobase(2)+1:end)]};
-                              j = j + 1;
-                          end
-                          S(1).subs = replace_object_in_a_one_dimensional_cell_array(S(1).subs, elements(:), i);
-                      else
-                          error('dseries::subsasgn: Wrong syntax, matlab''s regular expressions cannot be used here!')
-                      end
-                    case 4
-                      idComma_1 = strfind(element(idArobase(1)+1:idArobase(2)-1),',');
-                      idComma_2 = strfind(element(idArobase(3)+1:idArobase(4)-1),',');
-                      if ~isempty(idComma_1)
-                          elements = cell(1,(numel(idComma_1)+1)*(numel(idComma_2)+1)); j = 1;
-                          expression_1 = element(idArobase(1)+1:idArobase(2)-1);
-                          while ~isempty(expression_1)
-                              [token_1, expression_1] = strtok(expression_1,',');
-                              expression_2 = element(idArobase(3)+1:idArobase(4)-1);
-                              while ~isempty(expression_2)
-                                  [token_2, expression_2] = strtok(expression_2,',');
-                                  elements(j) = {[element(1:idArobase(1)-1), token_1, element(idArobase(2)+1:idArobase(3)-1), token_2, element(idArobase(4)+1:end)]};
-                                  j = j+1;
-                              end
-                          end
-                          S(1).subs = replace_object_in_a_one_dimensional_cell_array(S(1).subs, elements(:), i);
-                      else
-                          error('dseries::subsasgn: Wrong syntax, matlab''s regular expressions cannot be used here!')
-                      end
-                    otherwise
-                      error('dseries::subsasgn: Wrong syntax!')
-                  end
-              end
-          end
-          if isempty(B)
-              for i=1:length(S(1).subs)
-                  A = remove(A,S(1).subs{i});
-              end
-              return
-          end
-          if ~isequal(length(S(1).subs),vobs(B))
-              error('dseries::subsasgn: Wrong syntax!')
-          end
-          if ~isequal(S(1).subs(:),B.name)
-              for i = 1:vobs(B)
-                  if ~isequal(S(1).subs{i},B.name{i})
-                      % Rename a variable.
-                      id = find(strcmp(S(1).subs{i},A.name));
-                      if isempty(id)
-                          % Add a new variable a change its name.
-                          B.name(i) = {S(1).subs{i}};
-                          B.tex(i) = {name2tex(S(1).subs{i})};
-                      else
-                          % Rename variable and change its content.
-                          B.name(i) = A.name(id);
-                          B.tex(i) = A.tex(id);
-                      end
-                  end
-              end
-          end
-        case '.'
-          if isequal(S(1).subs,'init') && isdates(B) && isequal(length(B),1)
-              % Change the initial date (update dates member)
-              A.dates = B:B+(nobs(A)-1);
-              return
-          elseif isequal(S(1).subs,'dates') && isdates(B)
-              % Overwrite the dates member
-              A.dates = B;
-              return
-          elseif ismember(S(1).subs,{'data','name','tex'})
-              error(['dseries::subsasgn: You cannot overwrite ' S(1).subs ' member!'])
-          elseif ~isequal(S(1).subs,B.name)
-              % Single variable selection.
-              if ~isequal(S(1).subs,B.name{1})
-                  % Rename a variable.
-                  id = find(strcmp(S(1).subs,A.name));
-                  if isempty(id)
-                      % Add a new variable a change its name.
-                      B.name(1) = {S(1).subs};
-                      B.tex(1) = {name2tex(S(1).subs)};
-                  else
-                      % Rename variable and change its content.
-                      B.name(1) = A.name(id);
-                      B.tex(1) = A.tex(id);
-                  end
-              end
-          end
-        case '()' % Date(s) selection
-          if isdates(S(1).subs{1}) || isdate(S(1).subs{1})
-                if isdate(S(1).subs{1})
-                    Dates = dates(S(1).subs{1});
-                else
-                    Dates = S(1).subs{1};
-                end
-              [junk, tdx] = intersect(A.dates.time,Dates.time,'rows');
-              if isdseries(B)
-                  [junk, tdy] = intersect(B.dates.time,Dates.time,'rows');
-                  if isempty(tdy)
-                      error('dseries::subsasgn: Periods of the dseries objects on the left and right hand sides must intersect!')
-                  end
-                  if ~isequal(vobs(A), vobs(B))
-                      error('dseries::subsasgn: Dimension error! The number of variables on the left and right hand side must match.')
-                  end
-                  A.data(tdx,:) = B.data(tdy,:);
-                  merge_dseries_objects = 0;
-              elseif isnumeric(B)
-                  merge_dseries_objects = 0;
-                  if isequal(length(tdx),rows(B))
-                      if isequal(columns(A.data),columns(B))
-                          A.data(tdx,:) = B;
-                      else
-                          error('dseries::subsasgn: Dimension error! The number of variables on the left and right hand side must match.')
-                      end
-                  else
-                      error('dseries::subsassgn: Dimension error! The number of periods on the left and right hand side must match.')
-                  end
-              else
-                  error('dseries::subsasgn: The object on the right hand side must be a dseries object or a numeric array!')
-              end
-          elseif ischar(S(1).subs{1}) && isequal(S(1).subs{1},':') && isempty(A)
-              if isnumeric(B)
-                  if isequal(rows(B),1)
-                      A.data = repmat(B,A.dates.ndat,1);
-                  elseif isequal(rows(B),A.dates.ndat)
-                      A.data = B;
-                  else
-                      error('dseries::subsasgn: Wrong syntax!')
-                  end
-                  if isempty(A.name)
-                      A.name = default_name(vobs(A));
-                      A.tex = name2tex(A.name);
-                  end
-              elseif isdseries(B)
-                  if isequal(nobs(B), 1)
-                      A.data = repmat(B.data,A.dates.ndat,1);
-                  elseif isequal(nobs(B), A.dates.ndat)
-                      A.data = B;
-                  else
-                      error('dseries::subsasgn: Wrong syntax!')
-                  end
-                  if isempty(A.name)
-                      A.name = B.name;
-                      A.tex = B.tex;
-                  end
-              end
-              return
-          else
-              error('dseries::subsasgn: Wrong syntax!')
-          end
-        otherwise
-          error('dseries::subsasgn: Wrong syntax!')
-      end
-  case 2
-    merge_dseries_objects = 0;
-    if ((isequal(S(1).type,'{}') || isequal(S(1).type,'.')) && isequal(S(2).type,'()'))
-        if isequal(S(1).type,'{}')
-            sA = extract(A,S(1).subs{:});
-        else
-            sA = extract(A,S(1).subs);
-        end
-        if (isdseries(B) && isequal(vobs(sA), vobs(B))) || (isnumeric(B) && isequal(vobs(sA),columns(B))) || (isnumeric(B) && isequal(columns(B),1))
-            if isdates(S(2).subs{1})
-                [junk, tdx] = intersect(sA.dates.time,S(2).subs{1}.time,'rows');
-                if isdseries(B)
-                    [junk, tdy] = intersect(B.dates.time,S(2).subs{1}.time,'rows');
-                    if isempty(tdy)
-                        error('dseries::subsasgn: Periods of the dseries objects on the left and right hand sides must intersect!')
-                    end
-                    sA.data(tdx,:) = B.data(tdy,:);
-                elseif isnumeric(B)
-                    merge_dseries_objects = 0;
-                    if isequal(length(tdx),rows(B))
-                        if isequal(columns(sA.data),columns(B))
-                            sA.data(tdx,:) = B;
-                        elseif isequal(size(B,2),1)
-                            sA.data(tdx,:) = repmat(B,1,columns(sA.data));
-                        else
-                            error('dseries::subsasgn: Dimension error! The number of variables on the left and right hand side must match.')
-                        end
-                    else
-                        if isequal(columns(sA.data),columns(B)) && isequal(rows(B),1)
-                            sA.data(tdx,:) = repmat(B,length(tdx),1);
-                        elseif isequal(rows(B),1)
-                            sA.data(tdx,:) = B;
-                        else
-                            error('dseries::subsassgn: Dimension error! The number of periods on the left and right hand side must match.')
-                        end
-                    end
-                else
-                    error('dseries::subsasgn: The object on the right hand side must be a dseries object or a numeric array!')
-                end
-            else
-                error('dseries::subsasgn: Wrong syntax!')
-            end
-            A = merge(A,sA);
-        else
-            error('dseries::subsasgn: Dimension error! The number of variables on the left and right hand side must match.')
-        end
-    end
-  otherwise
-    error('dseries::subsasgn: Wrong syntax!')
-end
-
-if isempty(A)
-    % Assign variables to an empty dseries object.
-    A = B;
-    return
-end
-
-if merge_dseries_objects
-    A = merge(A,B);
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     ts1{'A2'} = ts2;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[A(:,1), B, A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$
-%$ % Apply the exponential function to the second variable.
-%$ ts1{'A2'} = ts1{'A2'}.exp;
-%$
-%$ % Instantiate a time series object.
-%$
-%$    t(1) = dyn_assert(ts1.vobs,3);
-%$    t(2) = dyn_assert(ts1.nobs,10);
-%$    t(3) = dyn_assert(ts1.name{2},'A2');
-%$    t(4) = dyn_assert(ts1.name{1},'A1');
-%$    t(5) = dyn_assert(ts1.name{3},'A3');
-%$    t(6) = dyn_assert(ts1.data,[A(:,1), exp(A(:,2)), A(:,3)],1e-15);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$
-%$ % Apply the logarithm function to the first and third variables.
-%$ ts1{'A1'} = ts1{'A1'}.log;
-%$ ts1{'A3'} = ts1{'A3'}.log;
-%$
-%$ % Instantiate a time series object.
-%$
-%$    t(1) = dyn_assert(ts1.vobs,3);
-%$    t(2) = dyn_assert(ts1.nobs,10);
-%$    t(3) = dyn_assert(ts1.name{2},'A2');
-%$    t(4) = dyn_assert(ts1.name{1},'A1');
-%$    t(5) = dyn_assert(ts1.name{3},'A3');
-%$    t(6) = dyn_assert(ts1.data,[log(A(:,1)), A(:,2), log(A(:,3))],1e-15);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Define a datasets.
-%$ A = rand(10,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$
-%$ % Apply the logarithm function to the first and third variables of ts1.
-%$ ts1{'A1','A3'} = ts1{'A1','A3'}.log;
-%$
-%$ t(1) = dyn_assert(ts1.vobs,3);
-%$ t(2) = dyn_assert(ts1.nobs,10);
-%$ t(3) = dyn_assert(ts1.name{1},'A1') && dyn_assert(ts1.name{2},'A2') && dyn_assert(ts1.name{3},'A3');
-%$ t(4) = dyn_assert(ts1.data,[log(A(:,1)), A(:,2), log(A(:,3))],1e-15);
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'A1';'B2';'B3'},[]);
-%$
-%$ % Apply the logarithm function to the first and third variables.
-%$ ts1.A1 = ts2.A1;
-%$
-%$ % Instantiate a time series object.
-%$
-%$ t(1) = dyn_assert(ts1.vobs,3);
-%$ t(2) = dyn_assert(ts1.nobs,10);
-%$ t(3) = dyn_assert(ts1.name{1},'A1');
-%$ t(4) = dyn_assert(ts1.data(:,1),B(:,1), 1e-15);
-%$ t(5) = dyn_assert(ts1.data(:,2:3),A(:,2:3), 1e-15);
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,2);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'B1';'B2'},[]);
-%$
-%$ % Call tested routine.
-%$ try
-%$     ts1.B2 = ts2.B2.log;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,4);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{1},'A1');
-%$    t(5) = dyn_assert(ts1.name{2},'A2');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.name{4},'B2');
-%$    t(8) = dyn_assert(ts1.data,[A(:,1), A(:,2), A(:,3), log(B(:,2))],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,2);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'B1';'B2'},[]);
-%$
-%$ % Append B2 to the first object.
-%$ ts1{'B2'} = ts2{'B2'};
-%$ t(1) = 1;
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,4);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{1},'A1');
-%$    t(5) = dyn_assert(ts1.name{2},'A2');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(6) = dyn_assert(ts1.name{4},'B2');
-%$    t(7) = dyn_assert(ts1.data,[A(:,1), A(:,2), A(:,3), B(:,2)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:7
-
-%@test:8
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     ts1{'A4'} = ts2;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,4);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.name{4},'A4');
-%$    t(8) = dyn_assert(ts1.data,[A, B],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:8
-
-%@test:9
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,2);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'A1';'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     ts1{'A1','A4'} = ts2;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,4);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.name{4},'A4');
-%$    t(8) = dyn_assert(ts1.data,[B(:,1), A(:,2:3), B(:,2)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:9
-
-
-%@test:10
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,[],{'A1';'B1';'B2'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     ts1{'A@1,2@','A4'} = ts2;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,4);
-%$    t(3) = dyn_assert(ts1.nobs,10);
-%$    t(4) = dyn_assert(ts1.name{1},'A1');
-%$    t(5) = dyn_assert(ts1.name{2},'A2');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.name{4},'A4');
-%$    t(8) = dyn_assert(ts1.data,[B(:,1:2), A(:,3), B(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:10
-
-%@test:11
-%$ % Define a datasets.
-%$ A = rand(10,3); B = rand(10,5);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,[],{'A_1';'A_2';'A_3'},[]);
-%$ ts2 = dseries(B,[],{'A_1';'A_2';'B_1';'B_2';'B_3'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     ts1{'@A,B@_@1,2@'} = ts2{'@A,B@_@1,2@'};
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    %t(2) = dyn_assert(ts1.vobs,4);
-%$    %t(3) = dyn_assert(ts1.nobs,10);
-%$    %t(4) = dyn_assert(ts1.name,{'A1','A2';'A3';'B1';'B2'});
-%$    %t(5) = dyn_assert(ts1.data,[B(:,1:2), A(:,3), B(:,3:4)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:11
-
-%@test:12
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1{'A1'}(rg) = ts2{'B1'}(rg);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:12
-
-%@test:13
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1{'A1'}(rg) = B(3:7);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:13
-
-%@test:14
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1.A1(rg) = B(3:7);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); B(3:7); A(8:end,1)], A(:,2:3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:14
-
-%@test:15
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1.A1(rg) = sqrt(pi);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); repmat(sqrt(pi),5,1); A(8:end,1)], A(:,2:3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:15
-
-%@test:16
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1{'A1','A2'}(rg) = sqrt(pi);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); repmat(sqrt(pi),5,1); A(8:end,1)], [A(1:2,2); repmat(sqrt(pi),5,1); A(8:end,2)], A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:16
-
-%@test:17
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1{'A1','A2'}(rg) = [sqrt(pi), pi];
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); repmat(sqrt(pi),5,1); A(8:end,1)], [A(1:2,2); repmat(pi,5,1); A(8:end,2)], A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:17
-
-%@test:18
-%$ % Define a datasets.
-%$ A = rand(40,3); B = rand(40,1);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$ ts2 = dseries(B,'1950Q1',{'B1'},[]);
-%$
-%$ % modify first object.
-%$ try
-%$     d1 = dates('1950Q3');
-%$     d2 = dates('1951Q3');
-%$     rg = d1:d2;
-%$     ts1{'A1','A2'}(rg) = ones(5,1);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,[[A(1:2,1); ones(5,1); A(8:end,1)], [A(1:2,2); ones(5,1); A(8:end,2)], A(:,3)],1e-15);
-%$ end
-%$ T = all(t);
-%@eof:18
-
-%@test:19
-%$ % Define a datasets.
-%$ A = rand(40,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$
-%$ % Instantiate a dates object.
-%$ dd = dates('1952Q1');
-%$
-%$ % modify first object.
-%$ try
-%$     ts1.init = dd;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,A,1e-15);
-%$    t(8) = dyn_assert(isequal(ts1.init,dd),1);
-%$    t(9) = dyn_assert(isequal(ts1.dates(1),dd),1);
-%$ end
-%$ T = all(t);
-%@eof:19
-
-%@test:20
-%$ % Define a datasets.
-%$ A = rand(40,3);
-%$
-%$ % Instantiate two dseries object.
-%$ ts1 = dseries(A,'1950Q1',{'A1';'A2';'A3'},[]);
-%$
-%$ % Instantiate a dates object.
-%$ dd = dates('1952Q1');
-%$
-%$ % modify first object.
-%$ try
-%$     ts1.dates = dd:(dd+(ts1.nobs-1));
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts1.vobs,3);
-%$    t(3) = dyn_assert(ts1.nobs,40);
-%$    t(4) = dyn_assert(ts1.name{2},'A2');
-%$    t(5) = dyn_assert(ts1.name{1},'A1');
-%$    t(6) = dyn_assert(ts1.name{3},'A3');
-%$    t(7) = dyn_assert(ts1.data,A,1e-15);
-%$    t(8) = dyn_assert(isequal(ts1.init,dd),1);
-%$    t(9) = dyn_assert(isequal(ts1.dates(1),dd),1);
-%$ end
-%$ T = all(t);
-%@eof:20
-
-%@test:21
-%$ % Define a datasets.
-%$ A = rand(4,3);
-%$
-%$ % Instantiate an empty dseries object.
-%$ ts = dseries(dates('1950Q1'):dates('1950Q4'));
-%$
-%$ % Populate ts
-%$ try
-%$     ts(:) = A;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts.vobs,3);
-%$    t(3) = dyn_assert(ts.nobs,4);
-%$    t(4) = dyn_assert(ts.data,A,1e-15);
-%$ end
-%$ T = all(t);
-%@eof:21
-
-%@test:22
-%$ % Define a datasets.
-%$ A = rand(1,3);
-%$
-%$ % Instantiate an empty dseries object.
-%$ ts = dseries(dates('1950Q1'):dates('1950Q4'));
-%$
-%$ % Populate ts
-%$ try
-%$     ts(:) = A;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ % Instantiate a time series object.
-%$ if t(1)
-%$    t(2) = dyn_assert(ts.vobs,3);
-%$    t(3) = dyn_assert(ts.nobs,4);
-%$    t(4) = dyn_assert(ts.data,repmat(A,4,1),1e-15);
-%$ end
-%$ T = all(t);
-%@eof:22
-
-%@test:23
-%$ % Instantiate a dseries object.
-%$ ts0 = dseries(randn(10,6), '1999y');
-%$
-%$ % Try to remove Variable_2 and Variable_3
-%$ try
-%$     ts0{'Variable_@2,3@'} = [];
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)
-%$    % Try to display Variable_2 and Variable_3 again (should fail because already removed)
-%$    try
-%$       ts0{'Variable_@2,3@'};
-%$       t(2) = 0;
-%$    catch
-%$       t(2) = 1;
-%$    end
-%$ end
-%$ T = all(t);
-%@eof:23
\ No newline at end of file
diff --git a/matlab/@dseries/subsref.m b/matlab/@dseries/subsref.m
deleted file mode 100644
index 3f6bf582de566a6ac785e9b41d024835cda98271..0000000000000000000000000000000000000000
--- a/matlab/@dseries/subsref.m
+++ /dev/null
@@ -1,689 +0,0 @@
-function B = subsref(A, S) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} subsref (@var{ts},S)
-%! @anchor{@dseries/subsref}
-%! @sp 1
-%! Overloads the subsref method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item ts
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item S
-%! Matlab's structure array S with two fields, type and subs. The type field is string containing '()', '@{@}', or '.', where '()' specifies
-%! integer subscripts, '@{@}' specifies cell array subscripts, and '.' specifies subscripted structure fields. The subs field is a cell array
-%! or a string containing the actual subscripts (see matlab's documentation).
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item us
-%! Dynare time series object. Depending on the calling sequence @var{us} is a transformation of @var{ts} obtained by applying a public method on @var{ts},
-%! or a dseries object built by extracting a variable from @var{ts}, or a dseries object containing a subsample of the all the variable in @var{ts}.
-%! @end table
-%! @sp 2
-%! @strong{Example 1.} Let @var{ts} be a dseries object containing three variables named 'A1', 'A2' and 'A3'. Then the following syntax:
-%! @example
-%!   us = ts.A1;
-%! @end example
-%!will create a new dseries object @var{us} containing the variable 'A1'.
-%! @sp 1
-%! @strong{Example 2.} Let @var{ts} be a dseries object. Then the following syntax:
-%! @example
-%!   us = ts.log;
-%! @end example
-%!will create a new dseries object @var{us} containing all the variables of @var{ts} transformed by the neperian logarithm.
-%! @sp 1
-%! @strong{Example 3.} Let @var{ts} be a dseries object. The following syntax:
-%! @example
-%!   us = ts(3:50);
-%! @end example
-%!will create a new dseries object @var{us} by selecting a subsample out of @var{ts}.
-%! @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/>.
-
-switch S(1).type
-  case '.'
-    switch S(1).subs
-      case {'data','name','tex','dates'}        % Public members.
-        if length(S)>1 && isequal(S(2).type,'()') && isempty(S(2).subs)
-            error(['dseries::subsref: ' S(1).subs ' is not a method but a member!'])
-        end
-        B = builtin('subsref', A, S(1));
-      case {'log','exp','ygrowth','qgrowth','ydiff','qdiff','abs'}         % Give "dot access" to public methods without args.
-        B = feval(S(1).subs,A);
-        if length(S)>1 && isequal(S(2).type,'()') && isempty(S(2).subs)
-            S = shiftS(S,1);
-        end
-      case 'nobs'
-        % Returns the number of observations.
-        B = rows(A.data);
-      case 'vobs'
-        % Returns the number of variables.
-        B = columns(A.data);
-      case 'init'
-        % Returns a dates object (first date).
-        B = A.dates(1);
-      case 'last'
-        % Returns a dates object (last date).
-        B = A.dates(end);
-      case 'freq'
-        % Returns an integer characterizing the data frequency (1, 4, 12 or 52)
-        B = A.dates.freq;
-      case {'lag','lead','hptrend','hpcycle','chain','detrend'} % Methods with less than two arguments.
-        if length(S)>1 && isequal(S(2).type,'()')
-            if isempty(S(2).subs)
-                B = feval(S(1).subs,A);
-                S = shiftS(S,1);
-            else
-                if length(S(2).subs{1})>1
-                    error(['dseries::subsref: ' S(1).subs{1} ' method admits no more than one argument!'])
-                end
-                B = feval(S(1).subs,A,S(2).subs{1});
-                S = shiftS(S,1);
-            end
-        else
-            B = feval(S(1).subs,A);
-        end
-      case {'cumsum','insert','pop','cumprod','remove'} % Methods with less than three argument.
-        if length(S)>1 && isequal(S(2).type,'()')
-            if isempty(S(2).subs)
-                B = feval(S(1).subs,A);
-                S = shiftS(S,1);
-            else
-                if length(S(2).subs)>2
-                    error(['dseries::subsref: ' S(1).subs{1} ' method admits no more than two arguments!'])
-                end
-                B = feval(S(1).subs,A,S(2).subs{:});
-                S = shiftS(S,1);
-            end
-        else
-            B = feval(S(1).subs,A);
-        end
-      case 'baxter_king_filter'
-        if length(S)>1 && isequal(S(2).type,'()')
-            if isempty(S(2).subs)
-                B = feval(S(1).subs,A);
-                S = shiftS(S,1);
-            else
-                B = feval(S(1).subs,A,S(2).subs{1})
-                S = shiftS(S,1);
-            end
-        else
-            B = feval(S(1).subs,A);
-        end
-      case 'save'                                                        % Save dseries object on disk (default is a csv file).
-        B = NaN;
-        if isequal(length(S),2)
-            if strcmp(S(2).type,'()')
-                if isempty(S(2).subs)
-                    save(A,inputname(1));
-                else
-                    if isempty(S(2).subs{1})
-                        save(A,inputname(1),S(2).subs{2});
-                    else
-                        save(A,S(2).subs{:});
-                    end
-                end
-                S = shiftS(S,1);
-            else
-                error('dseries::subsref: Wrong syntax.')
-            end
-        elseif isequal(length(S),1)
-            save(A,inputname(1));
-        else
-            error('dseries::subsref: Call to save method must come in last position!')
-        end
-      case 'size'
-        if isequal(length(S),2) && strcmp(S(2).type,'()')
-            if isempty(S(2).subs)
-                [x,y] = size(A);
-                B = [x, y];
-            else
-                B = size(A,S(2).subs{1});
-            end
-            S = shiftS(S,1);
-        elseif isequal(length(S),1)
-            [x,y] = size(A);
-            B = [x, y];
-        else
-            error('dseries::subsref: Call to size method must come in last position!')
-        end
-      case {'set_names','rename','tex_rename'}
-        B = feval(S(1).subs,A,S(2).subs{:});
-        S = shiftS(S,1);
-      case {'disp'}
-        feval(S(1).subs,A);
-        return
-      otherwise                                                            % Extract a sub-object by selecting one variable.
-        ndx = find(strcmp(S(1).subs,A.name));
-        if ~isempty(ndx)
-            B = dseries();
-            B.data = A.data(:,ndx);
-            B.name = A.name(ndx);
-            B.tex = A.tex(ndx);
-            B.tex  = deblank(A.tex(ndx,:));
-            B.dates = A.dates;
-        else
-            error('dseries::subsref: Unknown public method, public member or variable!')
-        end
-    end
-  case '()'
-    if ischar(S(1).subs{1}) && ~isdate(S(1).subs{1})
-        % If ts is an empty dseries object, populate this object by reading data in a file.
-        if isempty(A)
-            B = dseries(S(1).subs{1});
-        else
-            error(['dseries::subsref: dseries object ''' inputname(1) '''  is not empty!'])
-        end
-    elseif isa(S(1).subs{1},'dynTimeIndex')
-        % shift backward/forward (lag/lead) dseries object
-        shift = S(1).subs{1}.index;
-        if shift>0
-            B = feval('lead',A,shift);
-        elseif shift<0
-            B = feval('lag',A,-shift);
-        else
-            % Do nothing.
-            B = A;
-        end
-    elseif isscalar(S(1).subs{1}) && isnumeric(S(1).subs{1}) && isint(S(1).subs{1})
-        % Input is also interpreted as a backward/forward operator
-        if S(1).subs{1}>0
-            B = feval('lead', A, S(1).subs{1});
-        elseif S(1).subs{1}<0
-            B = feval('lag', A, -S(1).subs{1});
-        else
-            % Do nothing.
-            B = A;
-        end
-    elseif isdates(S(1).subs{1}) || isdate(S(1).subs{1})
-        if isdate(S(1).subs{1})
-            Dates = dates(S(1).subs{1});
-        else
-            Dates = S(1).subs{1};
-        end
-        % Test if Dates is out of bounds
-        if min(Dates)<min(A.dates)
-            error(['dseries::subsref: Indices are out of bounds! Subsample cannot start before ' date2string(A.dates(1)) '.'])
-        end
-        if  max(Dates)>max(A.dates)
-            error(['dseries::subsref: Indices are out of bounds! Subsample cannot end after ' date2string(A.dates(end)) '.'])
-        end
-        % Extract a subsample using a dates object
-        [junk,tdx] = intersect(A.dates.time,Dates.time,'rows');
-        B = dseries();
-        B.data = A.data(tdx,:);
-        B.name = A.name;
-        B.tex  = A.tex;
-        B.dates = A.dates(tdx);
-    elseif isvector(S(1).subs{1}) && all(isint(S(1).subs{1}))
-        error('dseries::subsref: It is not possible to select observations with a vector of integers. You have to index with a dates object instead!');
-    else
-        error('dseries::subsref: I have no idea of what you are trying to do!')
-    end
-  case '{}'
-    if iscellofchar(S(1).subs)
-        B = extract(A,S(1).subs{:});
-    elseif isequal(length(S(1).subs),1) && all(isint(S(1).subs{1}))
-        idx = S(1).subs{1};
-        if max(idx)>size(A.data,2) || min(idx)<1
-            error('dseries::subsref: Indices are out of bounds!')
-        end
-        B = dseries();
-        B.data = A.data(:,idx);
-        B.name = A.name(idx);
-        B.tex  = A.tex(idx);
-        B.dates = A.dates;
-    else
-        error('dseries::subsref: What the Hell are you tryin'' to do?!')
-    end
-  otherwise
-    error('dseries::subsref: What the Hell are you doin'' here?!')
-end
-
-S = shiftS(S,1);
-if ~isempty(S)
-    B = subsref(B, S);
-end
-
-%@test:1
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1(ts1.dates(2:9));
-%$
-%$ % Expected results.
-%$ e.data = [transpose(2:9),2*transpose(2:9)];
-%$ e.nobs = 8;
-%$ e.vobs = 2;
-%$ e.name = {'A1';'A2'};
-%$ e.freq = 1;
-%$ e.init = dates(1,2);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(a.data,e.data);
-%$ t(2) = dyn_assert(a.nobs,e.nobs);
-%$ t(3) = dyn_assert(a.vobs,e.vobs);
-%$ t(4) = dyn_assert(a.freq,e.freq);
-%$ t(5) = dyn_assert(isequal(a.init,e.init),1);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1.A1;
-%$
-%$ % Expected results.
-%$ e.data = transpose(1:10);
-%$ e.nobs = 10;
-%$ e.vobs = 1;
-%$ e.name = {'A1'};
-%$ e.freq = 1;
-%$ e.init = dates(1,1);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(a.data,e.data);
-%$ t(2) = dyn_assert(isequal(a.init,e.init),1);
-%$ t(3) = dyn_assert(a.nobs,e.nobs);
-%$ t(4) = dyn_assert(a.vobs,e.vobs);
-%$ t(5) = dyn_assert(a.freq,e.freq);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1.log;
-%$
-%$ % Expected results.
-%$ e.data = log(A);
-%$ e.nobs = 10;
-%$ e.vobs = 2;
-%$ e.name = {'A1';'A2'};
-%$ e.freq = 1;
-%$ e.init = dates(1,1);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(a.data,e.data);
-%$ t(2) = dyn_assert(a.nobs,e.nobs);
-%$ t(3) = dyn_assert(a.vobs,e.vobs);
-%$ t(4) = dyn_assert(a.freq,e.freq);
-%$ t(5) = dyn_assert(isequal(a.init,e.init),1);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ % Create an empty dseries object.
-%$ dataset = dseries();
-%$
-%$ t = zeros(5,1);
-%$
-%$ try
-%$    A = dataset('dynseries_test_data.csv');
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ % Check the results.
-%$ if length(t)>1
-%$     t(2) = dyn_assert(A.nobs,4);
-%$     t(3) = dyn_assert(A.vobs,4);
-%$     t(4) = dyn_assert(A.freq,4);
-%$     t(5) = dyn_assert(isequal(A.init,dates('1990Q1')),1);
-%$ end
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10),3*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'B1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1{'A1','B1'};
-%$
-%$ % Expected results.
-%$ e.data = A(:,[1,3]);
-%$ e.nobs = 10;
-%$ e.vobs = 2;
-%$ e.name = {'A1';'B1'};
-%$ e.freq = 1;
-%$ e.init = dates(1,1);
-%$
-%$ t(1) = dyn_assert(e.data,a.data);
-%$ t(2) = dyn_assert(e.nobs,a.nobs);
-%$ t(3) = dyn_assert(e.vobs,a.vobs);
-%$ t(4) = dyn_assert(e.name,a.name);
-%$ t(5) = dyn_assert(isequal(e.init,a.init),1);
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ % Define a data set.
-%$ A = rand(10,24);
-%$
-%$ % Define names
-%$ A_name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; 'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'; 'HICP_1';'HICP_2';'HICP_3'; 'HICP_4'; 'HICP_5'; 'HICP_6'; 'HICP_7'; 'HICP_8'; 'HICP_9'; 'HICP_10'; 'HICP_11'; 'HICP_12';};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$
-%$ % Call the tested method.
-%$ a = ts1{'GDP_[0-9]'};
-%$ b = ts1{'[A-Z]_1$'};
-%$
-%$ % Expected results.
-%$ e1.data = A(:,1:12);
-%$ e1.nobs = 10;
-%$ e1.vobs = 12;
-%$ e1.name = {'GDP_1';'GDP_2';'GDP_3'; 'GDP_4'; 'GDP_5'; 'GDP_6'; 'GDP_7'; 'GDP_8'; 'GDP_9'; 'GDP_10'; 'GDP_11'; 'GDP_12'};
-%$ e1.freq = 1;
-%$ e1.init = dates(1,1);
-%$ e2.data = A(:,[1 13]);
-%$ e2.nobs = 10;
-%$ e2.vobs = 2;
-%$ e2.name = {'GDP_1';'HICP_1'};
-%$ e2.freq = 1;
-%$ e2.init = dates(1,1);
-%$
-%$ % Check results.
-%$ t(1) = dyn_assert(e1.data,a.data);
-%$ t(2) = dyn_assert(e1.nobs,a.nobs);
-%$ t(3) = dyn_assert(e1.vobs,a.vobs);
-%$ t(4) = dyn_assert(e1.name,a.name);
-%$ t(5) = dyn_assert(isequal(e1.init,a.init),1);
-%$ t(6) = dyn_assert(e2.data,b.data);
-%$ t(7) = dyn_assert(e2.nobs,b.nobs);
-%$ t(8) = dyn_assert(e2.vobs,b.vobs);
-%$ t(9) = dyn_assert(e2.name,b.name);
-%$ t(10) = dyn_assert(isequal(e2.init,b.init),1);
-%$ T = all(t);
-%@eof:6
-
-%@test:7
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts1.save('ts1');
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:7
-
-%@test:8
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    ts1.save('test_generated_data_file','m');
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:8
-
-%@test:9
-%$ % Define a data set.
-%$ A = [transpose(1:60),2*transpose(1:60),3*transpose(1:60)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'B1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,'1971Q1',A_name,[]);
-%$
-%$ % Define the range of a subsample.
-%$ range = dates('1971Q2'):dates('1971Q4');
-%$ % Call the tested method.
-%$ a = ts1(range);
-%$
-%$ % Expected results.
-%$ e.data = A(2:4,:);
-%$ e.nobs = 3;
-%$ e.vobs = 3;
-%$ e.name = {'A1';'A2';'B1'};
-%$ e.freq = 4;
-%$ e.init = dates('1971Q2');
-%$
-%$ t(1) = dyn_assert(e.data,a.data);
-%$ t(2) = dyn_assert(e.nobs,a.nobs);
-%$ t(3) = dyn_assert(e.vobs,a.vobs);
-%$ t(4) = dyn_assert(e.name,a.name);
-%$ t(5) = dyn_assert(isequal(e.init,a.init),1);
-%$ T = all(t);
-%@eof:9
-
-%@test:10
-%$ % Define a data set.
-%$ A = [transpose(1:60),2*transpose(1:60),3*transpose(1:60)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'B1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,'1971Q1',A_name,[]);
-%$
-%$ % Test the size method.
-%$ B = ts1.size();
-%$ C = ts1.size(1);
-%$ D = ts1.size(2);
-%$ E = ts1.size;
-%$
-%$ t(1) = dyn_assert(B,[60, 3]);
-%$ t(2) = dyn_assert(E,[60, 3]);
-%$ t(3) = dyn_assert(C,60);
-%$ t(4) = dyn_assert(D,3);
-%$ T = all(t);
-%@eof:10
-
-%@test:11
-%$ % Define a data set.
-%$ A = [transpose(1:60),2*transpose(1:60),3*transpose(1:60)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2';'B1'};
-%$
-%$ % Instantiate a time series object.
-%$ ts1 = dseries(A,'1971Q1',A_name,[]);
-%$
-%$ % Test the size method.
-%$ B = ts1{1};
-%$ C = ts1{[1,3]};
-%$ D = ts1{'A1'};
-%$
-%$ t(1) = dyn_assert(B.name{1},'A1');
-%$ t(2) = dyn_assert(B.data,A(:,1));
-%$ t(3) = dyn_assert(C.name{1},'A1');
-%$ t(4) = dyn_assert(C.data(:,1),A(:,1));
-%$ t(5) = dyn_assert(C.name{2},'B1');
-%$ t(6) = dyn_assert(C.data(:,2),A(:,3));
-%$ t(7) = dyn_assert(D.name{1},'A1');
-%$ t(8) = dyn_assert(D.data,A(:,1));
-%$ T = all(t);
-%@eof:11
-
-%@test:12
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,[]);
-%$    if isoctave
-%$        ts1.save('ts1');
-%$    else
-%$        ts1.save();
-%$    end
-%$    t = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:12
-
-%@test:13
-%$ try
-%$     data = transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     a = ts.lag;
-%$     b = ts.lead;
-%$     tt = dynTimeIndex();
-%$     c = ts(tt-1);
-%$     d = ts(tt+1);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)>1
-%$     t(2) = (a==c);
-%$     t(3) = (b==d);
-%$ end
-%$
-%$ T = all(t);
-%@eof:13
-
-%@test:14
-%$ try
-%$     data = transpose(0:1:50);
-%$     ts = dseries(data,'1950Q1');
-%$     a = ts.lag;
-%$     b = ts.lead;
-%$     c = ts(-1);
-%$     d = ts(1);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)>1
-%$     t(2) = (a==c);
-%$     t(3) = (b==d);
-%$ end
-%$
-%$ T = all(t);
-%@eof:14
-
-%@test:15
-%$ try
-%$     ds = dseries(transpose(1:5));
-%$     ts = ds(ds.dates(2:3));
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ if t(1)>1
-%$     t(2) = isdseries(ts);
-%$     t(3) = isequal(ts.data,ds.data(2:3));
-%$ end
-%$
-%$ T = all(t);
-%@eof:15
-
-%@test:16
-%$ try
-%$     ds = dseries(transpose(1:5));
-%$     ts = ds(ds.dates(2:6));
-%$     t(1) = 0;
-%$ catch
-%$     t(1) = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:16
-
-%@test:17
-%$ try
-%$     ds = dseries(transpose(1:5));
-%$     ts = ds(dates('1Y'):dates('6Y'));
-%$     t(1) = 0;
-%$ catch
-%$     t(1) = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:17
-
-%@test:18
-%$ try
-%$     ds = dseries(transpose(1:5));
-%$     ts = ds(dates('-2Y'):dates('4Y'));
-%$     t(1) = 0;
-%$ catch
-%$     t(1) = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:18
\ No newline at end of file
diff --git a/matlab/@dseries/tex_rename.m b/matlab/@dseries/tex_rename.m
deleted file mode 100644
index 86e3bf974fd852f607b878e361229bc1ff759477..0000000000000000000000000000000000000000
--- a/matlab/@dseries/tex_rename.m
+++ /dev/null
@@ -1,88 +0,0 @@
-function ts = tex_rename(ts, varargin) % --*-- Unitary tests --*--
-
-% 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/>.
-
-assert(nargin <= 3, 'dseries::tex_rename: accepts at most three args');
-
-if nargin == 2
-    newtexname = varargin{1};
-    assert(vobs(ts) == 1, ['dseries::tex_rename: with one argument, the dseries contain only one variable.']);
-else
-    newtexname = varargin{2};
-    name = varargin{1};
-    assert(ischar(name), 'dseries::tex_rename: second input argument (name) must be a string');
-end
-
-assert(ischar(newtexname), 'dseries::tex_rename: third input argument (newtexname) name must be a string');
-
-if nargin == 2
-    idname = 1;
-else
-    idname = find(strcmp(name, ts.name));
-    if isempty(idname)
-        error(['dseries::tex_rename: Variable ' name ' is unknown in dseries object ' inputname(1)  '!'])
-    end
-end
-
-ts.tex(idname) = {newtexname};
-
-%@test:1
-%$ t = zeros(8,1);
-%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
-%$ try
-%$     ts = tex_rename(ts,'Output','\\Delta Y_t');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Output'; 'Consumption'});
-%$     t(8) = dyn_assert(ts.tex,{'\\Delta Y_t'; 'C_t'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(8,1);
-%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
-%$ try
-%$     ts = ts.tex_rename('Output','\\Delta Y_t');
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$     t(2) = dyn_assert(ts.freq,4);
-%$     t(3) = dyn_assert(ts.init.freq,4);
-%$     t(4) = dyn_assert(ts.init.time,[1950, 1]);
-%$     t(5) = dyn_assert(ts.vobs,2);
-%$     t(6) = dyn_assert(ts.nobs,5);
-%$     t(7) = dyn_assert(ts.name,{'Output'; 'Consumption'});
-%$     t(8) = dyn_assert(ts.tex,{'\\Delta Y_t'; 'C_t'});
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/uminus.m b/matlab/@dseries/uminus.m
deleted file mode 100644
index 000fbda74873b75eacecf9bfc569b2a76665144e..0000000000000000000000000000000000000000
--- a/matlab/@dseries/uminus.m
+++ /dev/null
@@ -1,81 +0,0 @@
-function A = uminus(B) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C})
-%! @anchor{@dseries/uminus}
-%! @sp 1
-%! Overloads the uminus method for the Dynare time series class (@ref{dseries}).
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item B
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @item C
-%! Dynare time series object instantiated by @ref{dseries}.
-%! @end table
-%! @sp 1
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item A
-%! Dynare time series object.
-%! @end deftypefn
-%@eod:
-
-% 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/>.
-
-A = dseries();
-
-A.data = -(B.data);
-A.dates = B.dates;
-
-A.name = cell(vobs(A),1);
-A.tex = cell(vobs(A),1);
-for i = 1:vobs(A)
-    A.name(i) = {[ '-' B.name{i}]};
-    A.tex(i) = {[ '-' B.tex{i}]};
-end
-
-%@test:1
-%$ % Define a datasets.
-%$ A = rand(10,2);
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ A_tex = {'A_1';'A_2'};
-%$ t = zeros(6,1);
-%$
-%$ % Instantiate a time series object.
-%$ try
-%$    ts1 = dseries(A,[],A_name,A_tex);
-%$    ts2 = -ts1;
-%$    t(1) = 1;
-%$ catch
-%$    t = 0;
-%$ end
-%$
-%$ if length(t)>1
-%$    t(2) = dyn_assert(ts2.vobs,2);
-%$    t(3) = dyn_assert(ts2.nobs,10);
-%$    t(4) = dyn_assert(ts2.data,-A,1e-15);
-%$    t(5) = dyn_assert(ts2.name,{'-A1';'-A2'});
-%$    t(6) = dyn_assert(ts2.tex,{'-A_1';'-A_2'});
-%$ end
-%$ T = all(t);
-%@eof:1
diff --git a/matlab/@dseries/vertcat.m b/matlab/@dseries/vertcat.m
deleted file mode 100644
index ad2af8b073611d2705937980553815a422ea6027..0000000000000000000000000000000000000000
--- a/matlab/@dseries/vertcat.m
+++ /dev/null
@@ -1,142 +0,0 @@
-function a = vertcat(varargin) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function file} {@var{a} =} vertcat (@var{b},@var{c}, ...)
-%! @anchor{horzcat}
-%! @sp 1
-%! Method of the dseries class.
-%! @sp 1
-%! This method overloads the vertical concatenation operator, so that
-%! two (or more) time series objects containing the same variables 
-%! can be merged using the following syntax:
-%!
-%!     a = [b; c; d];
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item b
-%! Dynare time series object, instantiated by @ref{dseries}.
-%! @item c
-%! Dynare time series object, instantiated by @ref{dseries}.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item a
-%! Dynare time series object.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-
-if nargin==0
-    a = DynSeries();
-elseif nargin == 1
-    a = varargin{1};
-elseif nargin>1
-    a = varargin{1};
-    for i=2:nargin
-        a = vertcat_(a,varargin{i});
-    end
-end
-
-function d = vertcat_(b, c)
-    d = NaN;
-    if ~isequal(frequency(b), frequency(c))
-        error('dseries::vertcat: Frequencies must be common!')
-    end
-    if ~isequal(vobs(b), vobs(c))
-        error('dseries::vertcat: Number of variables must be common!')
-    end
-    if ~isequal(b.name, c.name)
-        error('dseries::vertcat: Variables must be common!')
-    end
-    d = b;
-    d.data = [b.data; c.data];
-    d.dates = [b.dates; c.dates];
-
-%@test:1
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(1:10),2*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'A1';'A2'};
-%$
-%$ % Define expected results.
-%$ e.init = dates(1,1);
-%$ e.freq = 1;
-%$ e.name = {'A1';'A2'};
-%$ e.data = [A;B];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(B,[],B_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts3 = [ts1;ts2];
-%$
-%$ % Check the results.
-%$
-%$ t(1) = dyn_assert(isequal(ts3.init,e.init),1);
-%$ t(2) = dyn_assert(ts3.freq,e.freq);
-%$ t(3) = dyn_assert(ts3.data,e.data);
-%$ t(4) = dyn_assert(ts3.name,e.name);
-%$ t(5) = dyn_assert(ts3.nobs,20);
-%$ T = all(t);
-%@eof:1
-
-
-%@test:2
-%$ % Define a data set.
-%$ A = [transpose(1:10),2*transpose(1:10)];
-%$ B = [transpose(1:10),2*transpose(1:10)];
-%$ C = [transpose(1:10),3*transpose(1:10)];
-%$
-%$ % Define names
-%$ A_name = {'A1';'A2'};
-%$ B_name = {'A1';'A2'};
-%$ C_name = {'A1';'A2'};
-%$
-%$ % Define expected results.
-%$ e.init = dates(1,1);
-%$ e.freq = 1;
-%$ e.name = {'A1';'A2'};
-%$ e.data = [A;B;C];
-%$
-%$ % Instantiate two time series objects.
-%$ ts1 = dseries(A,[],A_name,[]);
-%$ ts2 = dseries(B,[],B_name,[]);
-%$ ts3 = dseries(C,[],C_name,[]);
-%$
-%$ % Call the tested method.
-%$ ts4 = [ts1; ts2; ts3];
-%$
-%$ % Check the results.
-%$
-%$ t(1) = dyn_assert(isequal(ts4.init,e.init),1);
-%$ t(2) = dyn_assert(ts4.freq,e.freq);
-%$ t(3) = dyn_assert(ts4.data,e.data);
-%$ t(4) = dyn_assert(ts4.name,e.name);
-%$ t(5) = dyn_assert(ts4.nobs,30);
-%$ T = all(t);
-%@eof:2
diff --git a/matlab/@dseries/vobs.m b/matlab/@dseries/vobs.m
deleted file mode 100644
index 37c1c80dd31eb48cfdbeda31a70e8ef5988fc33e..0000000000000000000000000000000000000000
--- a/matlab/@dseries/vobs.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function s = vobs(ts)
-
-% Returns the number of variables in a @dseries object.
-
-% 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/>.
-
-s = columns(ts.data);
\ No newline at end of file
diff --git a/matlab/@dseries/ydiff.m b/matlab/@dseries/ydiff.m
deleted file mode 100644
index d50200b57f5841940c859a5f5822da32cde21f5b..0000000000000000000000000000000000000000
--- a/matlab/@dseries/ydiff.m
+++ /dev/null
@@ -1,171 +0,0 @@
-function us = ydiff(ts) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} ydiff (@var{ts})
-%! @anchor{ydiff}
-%! @sp 1
-%! Computes annual differences.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 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/>.
-
-us = ts;
-
-switch frequency(ts)
-  case 1
-    us.data(2:end,:) = ts.data(2:end,:)-ts.data(1:end-1,:);
-    us.data(1,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ydiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta ' us.tex{i}]};
-    end
-  case 4
-    us.data(5:end,:) = ts.data(5:end,:)-ts.data(1:end-4,:);
-    us.data(1:4,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ydiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta_4 ' us.tex{i}]};
-    end
-  case 12
-    us.data(13:end,:) = ts.data(13:end,:)-ts.data(1:end-12,:);
-    us.data(1:12,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ydiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta_{12} ' us.tex{i}]};
-    end
-  case 52
-    us.data(53:end,:) = ts.data(53:end,:)-ts.data(1:end-52,:);
-    us.data(1:52,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ydiff(' us.name{i} ')']};
-        us.tex(i) = {['\Delta_{52} ' us.tex{i}]};
-    end
-  otherwise
-    error(['dseries::ygrowth: object ' inputname(1) ' has unknown frequency']);
-end
-
-%@test:1
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     data = transpose(1:100);
-%$     ts = dseries(data,'1950Q1',{'A1'},{'A_1'});
-%$     ts = ts.ydiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(4,ts.vobs);
-%$     DATA = [DATA; 4*ones(ts.nobs-4,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$     t(3) = dyn_assert(ts.name{1},['ydiff(A1)']);
-%$     t(4) = dyn_assert(ts.tex{1},['\\Delta_4 A_1']);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     data = transpose(1:100);
-%$     ts = dseries(data,'1950M1',{'A1'},{'A_1'});
-%$     ts = ts.ydiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(12,ts.vobs);
-%$     DATA = [DATA; 12*ones(ts.nobs-12,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$     t(3) = dyn_assert(ts.name{1},['ydiff(A1)']);
-%$     t(4) = dyn_assert(ts.tex{1},['\\Delta_{12} A_1']);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = transpose(1:100);
-%$     ts = dseries(data,'1950W1',{'A1'},{'A_1'});
-%$     ts = ts.ydiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(52,ts.vobs);
-%$     DATA = [DATA; 52*ones(ts.nobs-52,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$     t(3) = dyn_assert(ts.name{1},['ydiff(A1)']);
-%$     t(4) = dyn_assert(ts.tex{1},['\\Delta_{52} A_1']);
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ t = zeros(4,1);
-%$
-%$ try
-%$     data = transpose(1:100);
-%$     ts = dseries(data,'1950Y',{'A1'},{'A_1'});
-%$     ts = ts.ydiff;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(1,ts.vobs);
-%$     DATA = [DATA; ones(ts.nobs-1,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$     t(3) = dyn_assert(ts.name{1},['ydiff(A1)']);
-%$     t(4) = dyn_assert(ts.tex{1},['\\Delta A_1']);
-%$ end
-%$
-%$ T = all(t);
-%@eof:4
diff --git a/matlab/@dseries/ygrowth.m b/matlab/@dseries/ygrowth.m
deleted file mode 100644
index 9b50c38c93b97d4bc73fc1c31d05a6e9030036ad..0000000000000000000000000000000000000000
--- a/matlab/@dseries/ygrowth.m
+++ /dev/null
@@ -1,141 +0,0 @@
-function us = ygrowth(ts) % --*-- Unitary tests --*--
-
-%@info:
-%! @deftypefn {Function File} {@var{us} =} ygrowth (@var{ts})
-%! @anchor{ygrowth}
-%! @sp 1
-%! Computes annual growth rates.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @var
-%! @item ts
-%! Dynare time series object, instantiated by @ref{dseries}
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @var
-%! @item us
-%! Dynare time series object with transformed data field.
-%! @end table
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 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/>.
-
-us = ts;
-
-switch frequency(ts)
-  case 1
-    us.data(2:end,:) = ts.data(2:end,:)./ts.data(1:end-1,:) - 1;
-    us.data(1,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ygrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta ' us.tex{i}]};
-    end
-  case 4
-    us.data(5:end,:) = ts.data(5:end,:)./ts.data(1:end-4,:) - 1;
-    us.data(1:4,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ygrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta_4 ' us.tex{i}]};
-    end
-  case 12
-    us.data(13:end,:) = ts.data(13:end,:)./ts.data(1:end-12,:) - 1;
-    us.data(1:12,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ygrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta_{12} ' us.tex{i}]};
-    end
-  case 52
-    us.data(53:end,:) = ts.data(53:end,:)./ts.data(1:end-52,:) - 1;
-    us.data(1:52,:) = NaN;
-    for i = 1:vobs(ts)
-        us.name(i) = {['ygrowth(' us.name{i} ')']};
-        us.tex(i) = {['\delta_{52} ' us.tex{i}]};
-    end
-  otherwise
-    error(['dseries::ygrowth: object ' inputname(1) ' has unknown frequency']);
-end
-
-%@test:1
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = repmat(transpose(1:4),100,1);
-%$     ts = dseries(data,'1950Q1');
-%$     ts = ts.ygrowth;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(4,ts.vobs);
-%$     DATA = [DATA; zeros(ts.nobs-4,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = repmat(transpose(1:12),100,1);
-%$     ts = dseries(data,'1950M1');
-%$     ts = ts.ygrowth;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(12,ts.vobs);
-%$     DATA = [DATA; zeros(ts.nobs-12,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ t = zeros(2,1);
-%$
-%$ try
-%$     data = repmat(transpose(1:52),100,1);
-%$     ts = dseries(data,'1950W1');
-%$     ts = ts.ygrowth;
-%$     t(1) = 1;
-%$ catch
-%$     t = 0;
-%$ end
-%$
-%$
-%$ if length(t)>1
-%$     DATA = NaN(52,ts.vobs);
-%$     DATA = [DATA; zeros(ts.nobs-52,ts.vobs)];
-%$     t(2) = dyn_assert(ts.data,DATA);
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
diff --git a/matlab/common_strings_in_cell_arrays.m b/matlab/common_strings_in_cell_arrays.m
index fdea23aa35222b977dea6ec7a92a863068abacfc..06277f95fdd30a097242f7a05aef86506ba78b23 100644
--- a/matlab/common_strings_in_cell_arrays.m
+++ b/matlab/common_strings_in_cell_arrays.m
@@ -77,9 +77,9 @@ end
 %$ end
 %$
 %$ if length(t)>1
-%$    t(2) = dyn_assert(n,m);
-%$    t(3) = dyn_assert(n,0);
-%$    t(4) = dyn_assert(isempty(message),1);
+%$    t(2) = dassert(n,m);
+%$    t(3) = dassert(n,0);
+%$    t(4) = dassert(isempty(message),1);
 %$ end
 %$ T = all(t);
 %@eof:1
@@ -98,9 +98,9 @@ end
 %$ end
 %$
 %$ if length(t)>1
-%$    t(2) = dyn_assert(n,m);
-%$    t(3) = dyn_assert(n,2);
-%$    t(4) = dyn_assert(message,'A2 and A4');
+%$    t(2) = dassert(n,m);
+%$    t(3) = dassert(n,2);
+%$    t(4) = dassert(message,'A2 and A4');
 %$ end
 %$ T = all(t);
 %@eof:2
@@ -119,9 +119,9 @@ end
 %$ end
 %$
 %$ if length(t)>1
-%$    t(2) = dyn_assert(n,m);
-%$    t(3) = dyn_assert(n,3);
-%$    t(4) = dyn_assert(message,'A2, A4 and A1');
+%$    t(2) = dassert(n,m);
+%$    t(3) = dassert(n,3);
+%$    t(4) = dassert(message,'A2, A4 and A1');
 %$ end
 %$ T = all(t);
 %@eof:3
diff --git a/matlab/compute_model_moments.m b/matlab/compute_model_moments.m
index 7b8e514571a02e020718f0b6596d03f9e766f065..1c89a5e07dfee184832b99247aff6ce7f5d892af 100644
--- a/matlab/compute_model_moments.m
+++ b/matlab/compute_model_moments.m
@@ -28,4 +28,5 @@ function moments=compute_model_moments(dr,M_,options_)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
-moments = th_autocovariances(dr,options_.varlist,M_,options_);
+[ivar,vartan,options_] = get_variables_list(options_,M_);
+moments = th_autocovariances(dr,ivar,M_,options_,options_.nodecomposition);
diff --git a/matlab/compute_moments_varendo.m b/matlab/compute_moments_varendo.m
index 6482afb746b403f7480344aabdc80ab1fa17618d..8a294606f9d15ec9fe24f40f70bca8c53b831cac 100644
--- a/matlab/compute_moments_varendo.m
+++ b/matlab/compute_moments_varendo.m
@@ -55,6 +55,7 @@ NumberOfEndogenousVariables = rows(var_list_);
 NumberOfExogenousVariables = M_.exo_nbr;
 list_of_exogenous_variables = M_.exo_names;
 NumberOfLags = options_.ar;
+NoDecomposition = options_.nodecomposition;
 if isfield(options_,'conditional_variance_decomposition')
     Steps = options_.conditional_variance_decomposition;
 else
@@ -95,18 +96,20 @@ else
 end
 % VARIANCE DECOMPOSITION.
 if M_.exo_nbr > 1
-    if posterior
-        for i=1:NumberOfEndogenousVariables
-            for j=1:NumberOfExogenousVariables
-                oo_ = posterior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
+    if ~NoDecomposition
+        if posterior
+            for i=1:NumberOfEndogenousVariables
+                for j=1:NumberOfExogenousVariables
+                    oo_ = posterior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
+                end
             end
-        end
-    else
-        for i=1:NumberOfEndogenousVariables
-            for j=1:NumberOfExogenousVariables
-                oo_ = prior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
+        else
+            for i=1:NumberOfEndogenousVariables
+                for j=1:NumberOfExogenousVariables
+                    oo_ = prior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
+                end
             end
-        end        
+        end
     end
     % CONDITIONAL VARIANCE DECOMPOSITION.
     if Steps
diff --git a/matlab/convert_dyn_45_to_44.m b/matlab/convert_dyn_45_to_44.m
new file mode 100644
index 0000000000000000000000000000000000000000..ed1e704af76bf1c13d008fc47af4c988101a1021
--- /dev/null
+++ b/matlab/convert_dyn_45_to_44.m
@@ -0,0 +1,89 @@
+function []=convert_dyn_45_to_44
+% function []=convert_dyn_45_to_44
+% This function converts the oo_-structure fields that have been changed in Dynare 4.5. 
+% following https://github.com/DynareTeam/dynare/pull/771 to the old format
+% of Dynare 4.4
+
+global M_ oo_ options_
+
+%% add initial conditions to Bayesian forecasts
+if isfield(oo_,'PointForecast')
+    var_names=fieldnames(oo_.PointForecast.HPDinf);
+    moment_names=fieldnames(oo_.PointForecast);
+    for moment_iter=1:length(moment_names)
+        for var_iter=1:length(var_names)
+            if strcmp(moment_names{moment_iter},'deciles')
+                oo_.MeanForecast.(moment_names{moment_iter}).(var_names{var_iter})=...
+                    [oo_.SmoothedVariables.(moment_names{moment_iter}).(var_names{var_iter})(:,end)*ones(M_.maximum_endo_lag,1)  oo_.MeanForecast.(moment_names{moment_iter}).(var_names{var_iter})];
+                oo_.PointForecast.(moment_names{moment_iter}).(var_names{var_iter})=...
+                    [oo_.SmoothedVariables.(moment_names{moment_iter}).(var_names{var_iter})(:,end)*ones(M_.maximum_endo_lag,1) oo_.PointForecast.(moment_names{moment_iter}).(var_names{var_iter})];                
+            else
+                oo_.MeanForecast.(moment_names{moment_iter}).(var_names{var_iter})=...
+                    [oo_.SmoothedVariables.(moment_names{moment_iter}).(var_names{var_iter})(end)*ones(M_.maximum_endo_lag,1); oo_.MeanForecast.(moment_names{moment_iter}).(var_names{var_iter})];
+                oo_.PointForecast.(moment_names{moment_iter}).(var_names{var_iter})=...
+                    [oo_.SmoothedVariables.(moment_names{moment_iter}).(var_names{var_iter})(end)*ones(M_.maximum_endo_lag,1); oo_.PointForecast.(moment_names{moment_iter}).(var_names{var_iter})];
+            end
+        end
+    end
+end
+
+%% change HPD-fields back to row vectors
+if isfield(oo_.PointForecast,'HPDinf')
+    names=fieldnames(oo_.PointForecast.HPDinf);
+    for ii=1:length(names)
+        oo_.PointForecast.HPDinf.(names{ii})=oo_.PointForecast.HPDinf.(names{ii})';
+        oo_.PointForecast.HPDsup.(names{ii})=oo_.PointForecast.HPDsup.(names{ii})';
+    end
+end
+
+if isfield(oo_.MeanForecast,'HPDinf')
+    names=fieldnames(oo_.MeanForecast.HPDinf);
+    for ii=1:length(names)
+        oo_.MeanForecast.HPDinf.(names{ii})=oo_.MeanForecast.HPDinf.(names{ii})';
+        oo_.MeanForecast.HPDsup.(names{ii})=oo_.MeanForecast.HPDsup.(names{ii})';
+    end
+end
+
+if isfield(oo_.UpdatedVariables,'HPDinf')
+    names=fieldnames(oo_.UpdatedVariables.HPDinf);
+    for ii=1:length(names)
+        oo_.UpdatedVariables.HPDinf.(names{ii})=oo_.UpdatedVariables.HPDinf.(names{ii})';
+        oo_.UpdatedVariables.HPDsup.(names{ii})=oo_.UpdatedVariables.HPDsup.(names{ii})';
+    end
+end
+
+if isfield(oo_.SmoothedVariables,'HPDinf')
+    names=fieldnames(oo_.SmoothedVariables.HPDinf);
+    for ii=1:length(names)
+        oo_.SmoothedVariables.HPDinf.(names{ii})=oo_.SmoothedVariables.HPDinf.(names{ii})';
+        oo_.SmoothedVariables.HPDsup.(names{ii})=oo_.SmoothedVariables.HPDsup.(names{ii})';
+    end
+end
+
+if isfield(oo_.FilteredVariables,'HPDinf')
+    names=fieldnames(oo_.FilteredVariables.HPDinf);
+    for ii=1:length(names)
+        oo_.FilteredVariables.HPDinf.(names{ii})=oo_.FilteredVariables.HPDinf.(names{ii})';
+        oo_.FilteredVariables.HPDsup.(names{ii})=oo_.FilteredVariables.HPDsup.(names{ii})';
+    end
+end
+
+if isfield(oo_.SmoothedShocks,'HPDinf')
+    names=fieldnames(oo_.SmoothedShocks.HPDinf);
+    for ii=1:length(names)
+        oo_.SmoothedShocks.HPDinf.(names{ii})=oo_.SmoothedShocks.HPDinf.(names{ii})';
+        oo_.SmoothedShocks.HPDsup.(names{ii})=oo_.SmoothedShocks.HPDsup.(names{ii})';
+    end
+end
+
+%% padd classical filtered variables with redundant zeros
+if isfield(oo_,'FilteredVariables')
+    names=fieldnames(oo_.FilteredVariables);
+    for ii=1:length(names)
+        %make sure Bayesian fields are not affect
+        if ~strcmp(names{ii},'Mean') && ~strcmp(names{ii},'Median') && ~strcmp(names{ii},'deciles') ...
+                && ~strcmp(names{ii},'Var') && ~strcmp(names{ii},'HPDinf') && ~strcmp(names{ii},'HPDsup') 
+            oo_.FilteredVariables.(names{ii})=[0; oo_.FilteredVariables.(names{ii}); zeros(options_.nk-1,1)];
+        end
+    end
+end
diff --git a/matlab/cubature_with_gaussian_weight.m b/matlab/cubature_with_gaussian_weight.m
index 1e011790813372668b212fb7b2b29636069dfcb0..ecc69230dd75847af8841ef993767f254b52f8bf 100644
--- a/matlab/cubature_with_gaussian_weight.m
+++ b/matlab/cubature_with_gaussian_weight.m
@@ -159,10 +159,10 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) fourth order moments.
 %$ m4 = nodes.^4*weights;
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(m2,ones(d,1),1e-12);
-%$ t(4) = dyn_assert(m3,zeros(d,1),1e-12);
-%$ t(5) = dyn_assert(m4,d*ones(d,1),1e-10);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(m2,ones(d,1),1e-12);
+%$ t(4) = dassert(m3,zeros(d,1),1e-12);
+%$ t(5) = dassert(m4,d*ones(d,1),1e-10);
 %$ T = all(t);
 %@eof:1
 
@@ -201,10 +201,10 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) fourth order moments.
 %$ m4 = nodes.^4*weights;
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(m2,transpose(1:d),1e-12);
-%$ t(4) = dyn_assert(m3,zeros(d,1),1e-12);
-%$ t(5) = dyn_assert(m4,d*transpose(1:d).^2,1e-10);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(m2,transpose(1:d),1e-12);
+%$ t(4) = dassert(m3,zeros(d,1),1e-12);
+%$ t(5) = dassert(m4,d*transpose(1:d).^2,1e-10);
 %$ T = all(t);
 %@eof:2
 
@@ -237,9 +237,9 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) second order moments.
 %$ m2 = bsxfun(@times,nodes,transpose(weights))*transpose(nodes);
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(diag(m2),transpose(1:d),1e-12);
-%$ t(4) = dyn_assert(m2(:),vec(diag(diag(m2))),1e-12);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(diag(m2),transpose(1:d),1e-12);
+%$ t(4) = dassert(m2(:),vec(diag(diag(m2))),1e-12);
 %$ T = all(t);
 %@eof:3
 
@@ -280,9 +280,9 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) third order moments.
 %$ m3 = nodes.^3*weights;
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(m2(:),vec(Sigma),1e-12);
-%$ t(4) = dyn_assert(m3,zeros(d,1),1e-12);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(m2(:),vec(Sigma),1e-12);
+%$ t(4) = dassert(m3,zeros(d,1),1e-12);
 %$ T = all(t);
 %@eof:4
 
@@ -322,11 +322,11 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) fifth order moments.
 %$ m5 = nodes.^5*weights;
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(m2,ones(d,1),1e-12);
-%$ t(4) = dyn_assert(m3,zeros(d,1),1e-12);
-%$ t(5) = dyn_assert(m4,3*ones(d,1),1e-12);
-%$ t(6) = dyn_assert(m5,zeros(d,1),1e-12);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(m2,ones(d,1),1e-12);
+%$ t(4) = dassert(m3,zeros(d,1),1e-12);
+%$ t(5) = dassert(m4,3*ones(d,1),1e-12);
+%$ t(6) = dassert(m5,zeros(d,1),1e-12);
 %$ T = all(t);
 %@eof:5
 
@@ -361,8 +361,8 @@ function m = ee(n,i,j)
 %$ % Compute (approximated) third order moments.
 %$ m3 = nodes.^3*weights;
 %$
-%$ t(2) = dyn_assert(m1,zeros(d,1),1e-12);
-%$ t(3) = dyn_assert(m2,ones(d,1),1e-12);
-%$ t(4) = dyn_assert(m3,zeros(d,1),1e-12);
+%$ t(2) = dassert(m1,zeros(d,1),1e-12);
+%$ t(3) = dassert(m2,ones(d,1),1e-12);
+%$ t(4) = dassert(m3,zeros(d,1),1e-12);
 %$ T = all(t);
 %@eof:6
diff --git a/matlab/cycle_reduction.m b/matlab/cycle_reduction.m
index f9cb2c9b5dd43647d832895b718499cbf1ed2b70..019c39a190dc6e25d8455e4f678441881fb92b84 100644
--- a/matlab/cycle_reduction.m
+++ b/matlab/cycle_reduction.m
@@ -143,7 +143,7 @@ end
 %$
 %$ % Check the results.
 %$ if t(1) && t(2)
-%$     t(3) = dyn_assert(X1,X2,1e-12);
+%$     t(3) = dassert(X1,X2,1e-12);
 %$ end
 %$
 %$ T = all(t);
diff --git a/matlab/disp_th_moments.m b/matlab/disp_th_moments.m
index 3ea10eaf1b95726f7133152d99f150f543d5479b..3db312cdcb897e43593243c72b1da8034d479df2 100644
--- a/matlab/disp_th_moments.m
+++ b/matlab/disp_th_moments.m
@@ -20,6 +20,8 @@ function disp_th_moments(dr,var_list)
 
 global M_ oo_ options_
 
+nodecomposition = options_.nodecomposition;
+
 if size(var_list,1) == 0
     var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
 end
@@ -34,7 +36,7 @@ for i=1:nvar
     end
 end
 
-[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_);
+[oo_.gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_, nodecomposition);
 m = dr.ys(ivar);
 non_stationary_vars = setdiff(1:length(ivar),stationary_vars);
 m(non_stationary_vars) = NaN;
@@ -51,7 +53,9 @@ oo_.mean = m;
 oo_.var = oo_.gamma_y{1};
 
 if size(stationary_vars, 1) > 0
-    oo_.variance_decomposition=100*oo_.gamma_y{options_.ar+2};
+    if ~nodecomposition
+        oo_.variance_decomposition=100*oo_.gamma_y{options_.ar+2};
+    end
     if ~options_.noprint %options_.nomoments == 0
         if options_.order == 2
             title='APROXIMATED THEORETICAL MOMENTS';
@@ -66,7 +70,7 @@ if size(stationary_vars, 1) > 0
         lh = size(labels,2)+2;
         dyntable(title,headers,labels,z,lh,11,4);
 
-        if M_.exo_nbr > 1
+        if M_.exo_nbr > 1 && ~nodecomposition
             skipline()
             if options_.order == 2
                 title='APPROXIMATED VARIANCE DECOMPOSITION (in percent)';            
diff --git a/matlab/distributions/inverse_gamma_specification.m b/matlab/distributions/inverse_gamma_specification.m
index 1a073775c4cf31776373fd1f588baadd55a034de..20b1b9b35d9fe9e0f19d7ee2b3237c9eaccd6f9e 100644
--- a/matlab/distributions/inverse_gamma_specification.m
+++ b/matlab/distributions/inverse_gamma_specification.m
@@ -139,11 +139,11 @@ end
 %$ [s3,nu3] = inverse_gamma_specification(.75,.1,1,0);
 %$ [s4,nu4] = inverse_gamma_specification(.75,.1,1,1);
 %$ % Check the results.
-%$ t(1) = dyn_assert(s0,s1,1e-6);
-%$ t(2) = dyn_assert(nu0,nu1,1e-6);
+%$ t(1) = dassert(s0,s1,1e-6);
+%$ t(2) = dassert(nu0,nu1,1e-6);
 %$ t(3) = isnan(s4);
 %$ t(4) = isnan(nu4);
-%$ t(5) = dyn_assert(s3,16.240907971002265,1e-6);;
-%$ t(6) = dyn_assert(nu3,30.368398202624046,1e-6);;
+%$ t(5) = dassert(s3,16.240907971002265,1e-6);;
+%$ t(6) = dassert(nu3,30.368398202624046,1e-6);;
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m
index 564f2747b4f2630fd71d1ef52b59810177fa4d68..99d5e09397024f7c3256fa807bbcb1bbd14d5c19 100644
--- a/matlab/dyn_ramsey_static.m
+++ b/matlab/dyn_ramsey_static.m
@@ -94,7 +94,7 @@ if options_.steadystate_flag
     end
     ys_init=zeros(size(oo.steady_state)); %create starting vector for steady state computation as only instrument value is handed over
     ys_init(k_inst) = x; %set instrument, the only value required for steady state computation, to current value
-    [x,params,check] = evaluate_steady_state_file(ys_init,... returned x now has size endo_nbr as opposed to input size of n_instruments
+    [x,params,check] = evaluate_steady_state_file(ys_init,... %returned x now has size endo_nbr as opposed to input size of n_instruments
                                                   [oo.exo_steady_state; ...
                                                   oo.exo_det_steady_state], ...
                                                   M,options_);
diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index 6340710a533650a291adaab38a6cda4475179fea..d2083c70c8ff065ff71ad1df9e23dcf3e555706b 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -59,12 +59,12 @@ addpath([dynareroot '/particle/'])
 addpath([dynareroot '/gsa/'])
 addpath([dynareroot '/ep/'])
 addpath([dynareroot '/lmmcp/'])
+addpath([dynareroot '/modules/dates/src/'])
+addpath([dynareroot '/modules/dseries/src/'])
 addpath([dynareroot '/utilities/doc/'])
-addpath([dynareroot '/utilities/tests/'])
-addpath([dynareroot '/utilities/dates/'])
+addpath([dynareroot '/utilities/tests/src/'])
 addpath([dynareroot '/utilities/dataset/'])
 addpath([dynareroot '/utilities/general/'])
-addpath([dynareroot '/utilities/dseries/'])
 addpath([dynareroot '/reports/'])
 
 % For functions that exist only under some Octave versions
@@ -92,6 +92,11 @@ if isoctave
     addpath([dynareroot '/missing/ilu'])
 end
 
+% corrcoef with two outputs is missing in Octave (ticket #796)
+if isoctave && ~user_has_octave_forge_package('nan')
+    addpath([dynareroot '/missing/corrcoef'])
+end
+
 % strjoin is missing in older versions of MATLAB and in Octave < 3.8
 if (isoctave && octave_ver_less_than('3.8')) || ...
         (~isoctave && matlab_ver_less_than('8.1'))
@@ -262,7 +267,7 @@ if verbose
 end
 
 % Save empty dates and dseries objects (necessary if a mod file is not preprocessed).
-dates('initialize');
+initialize_dates_toolbox;
 dseries('initialize');
 
 cd(origin);
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index ed2e3d84a4b2b81fc36eb0ce579d0c0ef2a56258..07b8c50a65e0413823e1349a97f68e34f57db9e3 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -155,49 +155,39 @@ if nnobs > 1 && horizon > 0
             offsetx = 0;
         end
         vname = deblank(var_list(i,:));
-        maxlag = M_.maximum_lag;
         for j=1:nnobs
             if mh_replic > 0
-                eval(['oo_.RecursiveForecast.Mean.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.MeanForecast.Mean.' ...
-                      vname '(maxlag+1:end);']);
-                eval(['oo_.RecursiveForecast.HPDinf.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.MeanForecast.HPDinf.' ...
-                      vname '(maxlag+1:end);']);
-                eval(['oo_.RecursiveForecast.HPDsup.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.MeanForecast.HPDsup.' ...
-                      vname '(maxlag+1:end);']);
-                eval(['oo_.RecursiveForecast.HPDTotalinf.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.PointForecast.HPDinf.' ...
-                      vname '(maxlag+1:end);']);
-                eval(['oo_.RecursiveForecast.HPDTotalsup.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.PointForecast.HPDsup.' ...
-                      vname '(maxlag+1:end);']);
+                oo_.RecursiveForecast.Mean.(vname)(j,:) = ...
+                      oo_recursive_{nobs(j)}.MeanForecast.Mean.(vname);
+                oo_.RecursiveForecast.HPDinf.(vname)(j,:) = ...
+                      oo_recursive_{nobs(j)}.MeanForecast.HPDinf.(vname);
+                oo_.RecursiveForecast.HPDsup.(vname)(j,:) = ...
+                      oo_recursive_{nobs(j)}.MeanForecast.HPDsup.(vname);
+                oo_.RecursiveForecast.HPDTotalinf.(vname)(j,:) = ...
+                      oo_recursive_{nobs(j)}.PointForecast.HPDinf.(vname);
+                oo_.RecursiveForecast.HPDTotalsup.(vname)(j,:) = ...
+                      oo_recursive_{nobs(j)}.PointForecast.HPDsup.(vname);
             else
-                eval(['oo_.RecursiveForecast.Mean.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.forecast.Mean.' ...
-                      vname ';']);
-                eval(['oo_.RecursiveForecast.HPDinf.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.forecast.HPDinf.' ...
-                      vname ';']);
-                eval(['oo_.RecursiveForecast.HPDsup.' vname '(j,:) =' ...
-                      'oo_recursive_{' int2str(nobs(j))  '}.forecast.HPDsup.' ...
-                      vname ';']);
-            end
+                oo_.RecursiveForecast.Mean.(vname)(j,:) =...
+                      oo_recursive_{nobs(j)}.forecast.Mean.(vname);
+                oo_.RecursiveForecast.HPDinf.(vname)(j,:) =...
+                      oo_recursive_{nobs(j)}.forecast.HPDinf.(vname);
+                oo_.RecursiveForecast.HPDsup.(vname)(j,:) =...
+                      oo_recursive_{nobs(j)}.forecast.HPDsup.(vname);
+              end
             x = nobs(1)+nobs(j)-nobs(1)+(1:horizon);
 
-            y = eval(['oo_.RecursiveForecast.Mean.' vname '(j,:)']);
-            y1 = eval(['oo_.RecursiveForecast.HPDinf.' vname '(j,:)']);
-            y2 = eval(['oo_.RecursiveForecast.HPDsup.' vname '(j,:)']);
+            y = oo_.RecursiveForecast.Mean.(vname)(j,:);
+            y1 = oo_.RecursiveForecast.HPDinf.(vname)(j,:);
+            y2 = oo_.RecursiveForecast.HPDsup.(vname)(j,:);
             plot(x,y,'-b','linewidth',2)
             plot(x,y1,'--g', ...
                  'linewidth',1.5)
             plot(x,y2,'--g', ...
                  'linewidth',1.5)
             if mh_replic
-                y3 = eval(['oo_.RecursiveForecast.HPDTotalinf.' vname '(j,:)']);
-                y4 = eval(['oo_.RecursiveForecast.HPDTotalsup.' vname ...
-                           '(j,:)']);
+                y3 = oo_.RecursiveForecast.HPDTotalinf.(vname)(j,:);
+                y4 = oo_.RecursiveForecast.HPDTotalsup.(vname)(j,:);
                 plot(x,y3,'--r', ...
                      'linewidth',1.5)
                 plot(x,y4,'--r','linewidth',1.5)
diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index 59ef2090d2e95199a926a43a5b49fec22934a244..111a1181431a8764da2dbcdf45d14e8fdf908be6 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -226,7 +226,7 @@ if isequal(options_.mode_compute,0) && isempty(options_.mode_file) && options_.m
                   ' = atT(i,:)'';']);
             if options_.nk > 0
                 eval(['oo_.FilteredVariables.' deblank(M_.endo_names(i1,:)) ...
-                      ' = squeeze(aK(1,i,:));']);
+                      ' = squeeze(aK(1,i,2:end-(options_.nk-1)));']);
             end
             eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(i1,:)) ' = updated_variables(i,:)'';']);
         end
@@ -256,6 +256,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         end
         [xparam1,fval,exitflag,output,lamdba,grad,hessian_fmincon] = ...
             fmincon(objective_function,xparam1,[],[],[],[],bounds.lb,bounds.ub,[],optim_options,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 2
         error('ESTIMATION: mode_compute=2 option (Lester Ingber''s Adaptive Simulated Annealing) is no longer available')
       case 3
@@ -279,6 +280,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
             func = @(x) objective_function(x, dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
             [xparam1,fval,exitflag] = fminunc(func,xparam1,optim_options);
         end
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 4
         % Set default options.
         H0 = 1e-4*eye(nx);
@@ -316,7 +318,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         [fval,xparam1,grad,hessian_csminwel,itct,fcount,retcodehat] = ...
             csminwel1(objective_function, xparam1, H0, analytic_grad, crit, nit, numgrad, epsilon, dataset_, dataset_info, options_, M_, estim_params_, bayestopt_,bounds, oo_);
         % Disp value at the mode.
-        disp(sprintf('Objective function at mode: %f',fval))
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 5
         if isfield(options_,'hess')
             flag = options_.hess;
@@ -361,6 +363,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         end
         parameter_names = bayestopt_.name;
         save([M_.fname '_mode.mat'],'xparam1','hh','parameter_names');
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 6
         % Set default options
         gmhmaxlikOptions = options_.gmhmaxlik;
@@ -479,7 +482,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         skipline()
         disp(['Optimal value of the scale parameter = ' num2str(Scale)])
         skipline()
-        disp(['Final value of the log posterior (or likelihood): ' num2str(fval)])
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
         skipline()
         parameter_names = bayestopt_.name;
         save([M_.fname '_mode.mat'],'xparam1','hh','parameter_names');
@@ -495,6 +498,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
             eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']);
         end
         [xparam1,fval,exitflag] = fminsearch(objective_function,xparam1,optim_options,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 8
         % Dynare implementation of the simplex algorithm.
         simplexOptions = options_.simplex;
@@ -519,7 +523,8 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
                 end
             end
         end
-        [xparam1,fval,exitflag] = simplex_optimization_routine(objective_function,xparam1,simplexOptions,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        [xparam1,fval,exitflag] = simplex_optimization_routine(objective_function,xparam1,simplexOptions,bayestopt_.name,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 9
         % Set defaults
         H0 = 1e-4*ones(nx,1);
@@ -546,7 +551,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         warning('off','CMAES:InitialSigma');
         [x, fval, COUNTEVAL, STOPFLAG, OUT, BESTEVER] = cmaes(func2str(objective_function),xparam1,H0,cmaesOptions,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
         xparam1=BESTEVER.x;
-        disp(sprintf('\n Objective function at mode: %f',fval))
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', BESTEVER.f);
       case 10
         simpsaOptions = options_.simpsa;
         if isfield(options_,'optim_opt')
@@ -576,6 +581,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         simpsaOptionsList = options2cell(simpsaOptions);
         simpsaOptions = simpsaset(simpsaOptionsList{:});
         [xparam1, fval, exitflag] = simpsa(func2str(objective_function),xparam1,bounds.lb,bounds.ub,simpsaOptions,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 11
          options_.cova_compute = 0 ;
          [xparam1,stdh,lb_95,ub_95,med_param] = online_auxiliary_filter(xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_) ;
@@ -585,6 +591,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
         myoptions(3)=1e-6; %accuracy of function (see Solvopt p.29)
         myoptions(5)= 1.0;
         [xparam1,fval]=solvopt(xparam1,objective_function,[],myoptions,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       case 102
         %simulating annealing
         %        LB=zeros(size(xparam1))-20;
@@ -622,9 +629,11 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
 
         [xparam1, fval, nacc, nfcnev, nobds, ier, t, vm] = sa(objective_function,xparam1,maxy,rt_,epsilon,ns,nt ...
                                                               ,neps,maxevl,LB,UB,c,idisp ,t,vm,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
       otherwise
         if ischar(options_.mode_compute)
             [xparam1, fval, retcode ] = feval(options_.mode_compute,objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+            fprintf('\nFinal value of minus the log posterior (or likelihood):%f \n', fval);
         else
             error(['dynare_estimation:: mode_compute = ' int2str(options_.mode_compute) ' option is unknown!'])
         end
@@ -848,8 +857,8 @@ if (any(bayestopt_.pshape  >0 ) && options_.mh_replic) || ...
             end
             prior_posterior_statistics('posterior',dataset_,dataset_info);
         end
-        xparam = get_posterior_parameters('mean');
-        M_ = set_all_parameters(xparam,estim_params_,M_);
+        xparam1 = get_posterior_parameters('mean');
+        M_ = set_all_parameters(xparam1,estim_params_,M_);
     end
 end
 
@@ -886,7 +895,7 @@ if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.psha
                             'atT(i,:)'';']);
         if options_.nk > 0
             eval(['oo_.FilteredVariables.' deblank(M_.endo_names(i1,:)) ...
-                  ' = squeeze(aK(1,i,:));']);
+                  ' = squeeze(aK(1,i,2:end-(options_.nk-1)));']);
         end
         eval(['oo_.UpdatedVariables.' deblank(M_.endo_names(i1,:)) ...
               ' = updated_variables(i,:)'';']);
diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index 99534d9f9d32e561c4bf4bc18dbc3d5ef429751e..454375def536e073143fbde73b86569eca04b52d 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -384,9 +384,15 @@ oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
 k3 = [];
 k3p = [];
 if options_.selected_variables_only
-    for i=1:size(var_list_,1)
-        k3 = [k3; strmatch(var_list_(i,:),M_.endo_names(dr.order_var,:), 'exact')];
-        k3p = [k3; strmatch(var_list_(i,:),M_.endo_names, 'exact')];
+    if options_.forecast > 0 && options_.mh_replic == 0 && ~options_.load_mh_file
+        fprintf('\nEstimation: The selected_variables_only option is incompatible with classical forecasts. It will be ignored.\n')
+        k3 = (1:M_.endo_nbr)';
+        k3p = (1:M_.endo_nbr)';    
+    else
+        for i=1:size(var_list_,1)
+            k3 = [k3; strmatch(var_list_(i,:),M_.endo_names(dr.order_var,:), 'exact')];
+            k3p = [k3; strmatch(var_list_(i,:),M_.endo_names, 'exact')];
+        end
     end
 else
     k3 = (1:M_.endo_nbr)';
@@ -451,8 +457,15 @@ if options_.analytic_derivation,
         [tmp1, params] = evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);
         change_flag=any(find(params-M.params));
         if change_flag,
-            disp('The steadystate file changed the values for the following parameters: '),
-            disp(M.param_names(find(params-M.params),:))
+            skipline();
+            if any(isnan(params))
+                disp('After computing the steadystate, the following parameters are still NaN: '),
+                disp(M.param_names(isnan(params),:))
+            end
+            if any(find(params(~isnan(params))-M.params(~isnan(params))))
+                disp('The steadystate file changed the values for the following parameters: '),
+                disp(M.param_names(find(params(~isnan(params))-M.params(~isnan(params))),:))
+            end
             disp('The derivatives of jacobian and steady-state will be computed numerically'),
             disp('(re-set options_.analytic_derivation_mode= -2)'),
             options_.analytic_derivation_mode= -2;
diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m
index 9a883e9d23fd6aef6255318f6d75a9f653d7aae0..33f2c151e7901c05cb76793853f90ced902a7f08 100644
--- a/matlab/dynare_identification.m
+++ b/matlab/dynare_identification.m
@@ -130,22 +130,6 @@ options_.plot_priors = 0;
 options_.smoother=1;
 [dataset_,dataset_info,xparam1,hh, M_, options_, oo_, estim_params_,bayestopt_]=dynare_estimation_init(M_.endo_names,fname_,1, M_, options_, oo_, estim_params_, bayestopt_);
 options_ident.analytic_derivation_mode = options_.analytic_derivation_mode;
-if isempty(dataset_),
-    dataset_.info.ntobs = periods;
-    dataset_.info.nvobs = length(options_.varobs);
-    dataset_.info.varobs = options_.varobs;
-    dataset_.rawdata = [];
-    dataset_.missing.state = 0;
-    for jdata=1:periods,
-        temp1{jdata}=[1:dataset_.info.nvobs]';
-    end
-    dataset_.missing.aindex = temp1;
-    dataset_.missing.vindex = [];
-    dataset_.missing.number_of_observations = [];
-    dataset_.missing.no_more_missing_observations = 1;
-    dataset_.descriptive.mean = [];
-    dataset_.data = [];
-end
 
 if prior_exist
     if any(bayestopt_.pshape > 0)
diff --git a/matlab/dynare_sensitivity.m b/matlab/dynare_sensitivity.m
index d85ca1f22bff00ac3d04c77f88535c43101d1063..9d4a5085d398682c04c567681738e3a173f89762 100644
--- a/matlab/dynare_sensitivity.m
+++ b/matlab/dynare_sensitivity.m
@@ -145,13 +145,13 @@ options_gsa = set_default_option(options_gsa,'load_stab',0);
 options_gsa = set_default_option(options_gsa,'alpha2_stab',0);
 options_gsa = set_default_option(options_gsa,'ksstat',0.1);
 options_gsa = set_default_option(options_gsa,'pvalue_ks',0.001);
-options_gsa = set_default_option(options_gsa,'pvalue_corr',0.001);
+options_gsa = set_default_option(options_gsa,'pvalue_corr',1.e-5);
 %options_gsa = set_default_option(options_gsa,'load_mh',0);
 % REDFORM mapping
 options_gsa = set_default_option(options_gsa,'logtrans_redform',0);
 options_gsa = set_default_option(options_gsa,'threshold_redform',[]);
 options_gsa = set_default_option(options_gsa,'ksstat_redform',0.001);
-options_gsa = set_default_option(options_gsa,'alpha2_redform',0);
+options_gsa = set_default_option(options_gsa,'alpha2_redform',1.e-5);
 options_gsa = set_default_option(options_gsa,'namendo',[]);
 options_gsa = set_default_option(options_gsa,'namlagendo',[]);
 options_gsa = set_default_option(options_gsa,'namexo',[]);
@@ -161,7 +161,7 @@ options_gsa = set_default_option(options_gsa,'var_rmse',char(options_.varobs));
 options_gsa = set_default_option(options_gsa,'pfilt_rmse',0.1);
 options_gsa = set_default_option(options_gsa,'istart_rmse',options_.presample+1);
 options_gsa = set_default_option(options_gsa,'alpha_rmse',0.001);
-options_gsa = set_default_option(options_gsa,'alpha2_rmse',0);
+options_gsa = set_default_option(options_gsa,'alpha2_rmse',1.e-5);
 
 if options_gsa.redform && options_gsa.neighborhood_width==0 && isempty(options_gsa.threshold_redform),
     options_gsa.pprior=1;
@@ -243,7 +243,7 @@ end
 
 options_.opt_gsa = options_gsa;
 if ~isempty(options_gsa.moment_calibration) || ~isempty(options_gsa.irf_calibration),
-    map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_);
+    map_calibration(OutputDirectoryName, M_, options_, oo_, estim_params_,bayestopt_);
 end
 
 if options_gsa.identification,
diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m
index 855887a64be5f0e2e66aa31a7dfa782edb4f67bd..a4b9db9ab8697642f9d759be04770aad7b75a651 100644
--- a/matlab/dynare_solve.m
+++ b/matlab/dynare_solve.m
@@ -173,5 +173,5 @@ elseif options_.solve_algo == 10
         info = 1;
     end
 else
-    error('DYNARE_SOLVE: option solve_algo must be one of [0,1,2,3,4,9]')
+    error('DYNARE_SOLVE: option solve_algo must be one of [0,1,2,3,4,9,10]')
 end
diff --git a/matlab/forcst.m b/matlab/forcst.m
index c125e1fc533c84adb2aaa6f00e7b04b5f5635966..dc269e5117b4ecee0afb61ef1c12fb73154dcc69 100644
--- a/matlab/forcst.m
+++ b/matlab/forcst.m
@@ -67,6 +67,7 @@ sigma_u = B*M_.Sigma_e*B';
 sigma_u1 = ghu1*M_.Sigma_e*ghu1';
 sigma_y = 0;
 
+var_yf=NaN(horizon,nvar); %initialize
 for i=1:horizon
     sigma_y1 = ghx1*sigma_y*ghx1'+sigma_u1;
     var_yf(i,:) = diag(sigma_y1)';
diff --git a/matlab/gauss_hermite_weights_and_nodes.m b/matlab/gauss_hermite_weights_and_nodes.m
index 70d5abae441e1ecebcf7a44e146ac9555530551c..a9a75b4e1bc3c151cccee441c11c2e8e3160ccd2 100644
--- a/matlab/gauss_hermite_weights_and_nodes.m
+++ b/matlab/gauss_hermite_weights_and_nodes.m
@@ -69,8 +69,8 @@ nodes = sqrt(2)*nodes;
 %$ enodes = [-2.020182870; -0.9585724646; 0; 0.9585724646;   2.020182870]; 
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
-%$ t(2) = dyn_assert(enodes,nodes/sqrt(2),1e-8);
+%$ t(1) = dassert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dassert(enodes,nodes/sqrt(2),1e-8);
 %$ T = all(t);
 %@eof:1
 
@@ -83,9 +83,9 @@ nodes = sqrt(2)*nodes;
 %$ variance = sum(weights.*(nodes.^2));
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
-%$ t(2) = dyn_assert(1.0,variance,1e-12);
-%$ t(3) = dyn_assert(0.0,expectation,1e-12);
+%$ t(1) = dassert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dassert(1.0,variance,1e-12);
+%$ t(3) = dassert(0.0,expectation,1e-12);
 %$ T = all(t);
 %@eof:2
 
@@ -102,9 +102,9 @@ nodes = sqrt(2)*nodes;
 %$ variance = transpose(WEIGHTS)*NODES.^2;
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
-%$ t(2) = dyn_assert(ones(1,2),variance,1e-12);
-%$ t(3) = dyn_assert(zeros(1,2),expectation,1e-12);
+%$ t(1) = dassert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dassert(ones(1,2),variance,1e-12);
+%$ t(3) = dassert(zeros(1,2),expectation,1e-12);
 %$ T = all(t);
 %@eof:3
 
@@ -117,8 +117,8 @@ nodes = sqrt(2)*nodes;
 %$ variance = sum(weights.*((nodes*.1).^2));
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(1.0,sum_of_weights,1e-12);
-%$ t(2) = dyn_assert(.01,variance,1e-12);
-%$ t(3) = dyn_assert(0.0,expectation,1e-12);
+%$ t(1) = dassert(1.0,sum_of_weights,1e-12);
+%$ t(2) = dassert(.01,variance,1e-12);
+%$ t(3) = dassert(0.0,expectation,1e-12);
 %$ T = all(t);
 %@eof:4
diff --git a/matlab/gauss_legendre_weights_and_nodes.m b/matlab/gauss_legendre_weights_and_nodes.m
index 63aae899900c912144c4489501f1c052ee480d7f..a1b6fc2903421f21c55fb6e71a19508880146f49 100644
--- a/matlab/gauss_legendre_weights_and_nodes.m
+++ b/matlab/gauss_legendre_weights_and_nodes.m
@@ -96,16 +96,16 @@ end
 %$ f7 = [.1294849661; .2797053914; .3818300505]; f7 = [f7; .4179591836; flipud(f7)];
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(e2,n2,1e-9);
-%$ t(2) = dyn_assert(e3,n3,1e-9);
-%$ t(3) = dyn_assert(e4,n4,1e-9);
-%$ t(4) = dyn_assert(e5,n5,1e-9);
-%$ t(5) = dyn_assert(e7,n7,1e-9);
-%$ t(6) = dyn_assert(w2,f2,1e-9);
-%$ t(7) = dyn_assert(w3,f3,1e-9);
-%$ t(8) = dyn_assert(w4,f4,1e-9);
-%$ t(9) = dyn_assert(w5,f5,1e-9);
-%$ t(10) = dyn_assert(w7,f7,1e-9);
+%$ t(1) = dassert(e2,n2,1e-9);
+%$ t(2) = dassert(e3,n3,1e-9);
+%$ t(3) = dassert(e4,n4,1e-9);
+%$ t(4) = dassert(e5,n5,1e-9);
+%$ t(5) = dassert(e7,n7,1e-9);
+%$ t(6) = dassert(w2,f2,1e-9);
+%$ t(7) = dassert(w3,f3,1e-9);
+%$ t(8) = dassert(w4,f4,1e-9);
+%$ t(9) = dassert(w5,f5,1e-9);
+%$ t(10) = dassert(w7,f7,1e-9);
 %$ T = all(t);
 %@eof:1
 
@@ -116,7 +116,7 @@ end
 %$
 %$ for i=1:nmax
 %$     [n,w] = gauss_legendre_weights_and_nodes(i);
-%$     t(i) = dyn_assert(sum(w),2,1e-12);
+%$     t(i) = dassert(sum(w),2,1e-12);
 %$ end
 %$
 %$ T = all(t);
@@ -127,6 +127,6 @@ end
 %$ % Check that the 
 %$ t(1) = all(n>pi);
 %$ t(2) = all(n<2*pi);
-%$ t(3) = dyn_assert(sum(w),pi,1e-12);
+%$ t(3) = dassert(sum(w),pi,1e-12);
 %$ T = all(t);
 %@eof:3
\ No newline at end of file
diff --git a/matlab/getJJ.m b/matlab/getJJ.m
index b81de6a239805cab3aaf05392360b821c4640675..e27ed22b8d08355dcdc005725223766a6bbc9141 100644
--- a/matlab/getJJ.m
+++ b/matlab/getJJ.m
@@ -128,7 +128,8 @@ end
 if nargout >2,
     %     sy=sy(mf,mf);
     options_.ar=nlags;
-    [GAM,stationary_vars] = th_autocovariances(oo_.dr,oo_.dr.order_var(mf),M_,options_);
+    nodecomposition = 1;
+    [GAM,stationary_vars] = th_autocovariances(oo_.dr,oo_.dr.order_var(mf),M_,options_,nodecomposition);
     sy=sqrt(diag(GAM{1}));
     sy=sy*sy';
     if useautocorr,
diff --git a/matlab/get_variance_of_endogenous_variables.m b/matlab/get_variance_of_endogenous_variables.m
index 8cbbb41b150559708a4a55aea6d5b613be07e741..df03a1a489536bc1ba4d72404f5f4b4931e07dea 100644
--- a/matlab/get_variance_of_endogenous_variables.m
+++ b/matlab/get_variance_of_endogenous_variables.m
@@ -48,16 +48,13 @@ n = length(i_var);
 [vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold, [], [], options_.debug);
 
 if size(u,2) > 0
-    i_stat_0 = find(any(abs(A*u) < options_.Schur_vec_tol,2));
-    i_stat = find(any(abs(ghx*u) < options_.Schur_vec_tol,2));
-    
+    i_stat = find(any(abs(ghx*u) < options_.Schur_vec_tol,2)); %only set those variances of objective function for which variance is finite     
     ghx = ghx(i_stat,:);
     ghu = ghu(i_stat,:);
 else
-    i_stat_0 = 1:size(ghx,2);
     i_stat = (1:n)';
 end
 
 vx1 = Inf*ones(n,n);
-vx1(i_stat,i_stat) = ghx(:,i_stat_0)*vx(i_stat_0,i_stat_0)*ghx(:,i_stat_0)'+ghu*Sigma_e*ghu';
+vx1(i_stat,i_stat) = ghx*vx*ghx'+ghu*Sigma_e*ghu';
 
diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m
index b75148515e1fc5545948303e216efb2097d04659..0fb91497410b9252ee1490197aeea710fde9454d 100644
--- a/matlab/global_initialization.m
+++ b/matlab/global_initialization.m
@@ -144,6 +144,7 @@ options_.relative_irf = 0;
 options_.ar = 5;
 options_.hp_filter = 0;
 options_.hp_ngrid = 512;
+options_.nodecomposition = 0;
 options_.nomoments = 0;
 options_.nocorr = 0;
 options_.periods = 0;
@@ -484,6 +485,8 @@ simplex.tolerance.f = 1e-4;
 simplex.maxiter = 5000;
 simplex.maxfcallfactor = 500;
 simplex.maxfcall = [];
+simplex.verbosity = 2;
+simplex.delta_factor=0.05;
 options_.simplex = simplex;
 
 % CMAES optimization routine.
diff --git a/matlab/gsa/map_calibration.m b/matlab/gsa/map_calibration.m
index 5f9df099daefef5f2058665800b54f9b2e47df46..da933023daef9cbfe4db9616d8936d52ec410451 100644
--- a/matlab/gsa/map_calibration.m
+++ b/matlab/gsa/map_calibration.m
@@ -1,4 +1,4 @@
-function map_calibration(OutputDirectoryName, Model, DynareOptions, DynareResults, EstimatedParameters)
+function map_calibration(OutputDirectoryName, Model, DynareOptions, DynareResults, EstimatedParameters, BayesInfo)
 
 % Copyright (C) 2014 Dynare Team
 %
@@ -22,6 +22,15 @@ pnames = Model.param_names(EstimatedParameters.param_vals(:,1),:);
 pvalue_ks = DynareOptions.opt_gsa.pvalue_ks;
 indx_irf = [];
 indx_moment = [];
+DynareOptions.nodisplay = 1;
+init = ~DynareOptions.opt_gsa.load_stab;
+
+options_mcf.pvalue_ks = DynareOptions.opt_gsa.pvalue_ks;
+options_mcf.pvalue_corr = DynareOptions.opt_gsa.pvalue_corr;
+options_mcf.alpha2 = DynareOptions.opt_gsa.alpha2_stab;
+options_mcf.param_names = pnames;
+options_mcf.fname_ = fname_;
+options_mcf.OutputDirectoryName = OutputDirectoryName;
 
 skipline()
 disp('Sensitivity analysis for calibration criteria')
@@ -49,20 +58,25 @@ else
     end        
 end
 [Nsam, np] = size(lpmat);
+npar = size(pnames,1);
+nshock = np - npar;
 
 nbr_irf_restrictions = size(DynareOptions.endogenous_prior_restrictions.irf,1);
+nbr_moment_restrictions = size(DynareOptions.endogenous_prior_restrictions.moment,1);
+
+if init
 mat_irf=cell(nbr_irf_restrictions,1);
 for ij=1:nbr_irf_restrictions,
     mat_irf{ij}=NaN(Nsam,length(DynareOptions.endogenous_prior_restrictions.irf{ij,3}));
 end
 
-nbr_moment_restrictions = size(DynareOptions.endogenous_prior_restrictions.moment,1);
 mat_moment=cell(nbr_moment_restrictions,1);
 for ij=1:nbr_moment_restrictions,
     mat_moment{ij}=NaN(Nsam,length(DynareOptions.endogenous_prior_restrictions.moment{ij,3}));
 end
 
 irestrictions = [1:Nsam];
+h = dyn_waitbar(0,'Please wait...');
 for j=1:Nsam,
     Model = set_all_parameters(lpmat(j,:)',EstimatedParameters,Model);
     [Tt,Rr,SteadyState,info] = dynare_resolve(Model,DynareOptions,DynareResults,'restrict');
@@ -83,96 +97,270 @@ for j=1:Nsam,
     else
         irestrictions(j)=0;
     end
+    dyn_waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
 end
+dyn_waitbar_close(h);
+
 irestrictions=irestrictions(find(irestrictions));
 xmat=lpmat(irestrictions,:);
 skipline()
-save([OutputDirectoryName,filesep,fname_,'_',type,'_restrictions'],'xmat','mat_irf','mat_moment','irestrictions','indx_irf','indx_moment');
-
+endo_prior_restrictions=DynareOptions.endogenous_prior_restrictions;
+save([OutputDirectoryName,filesep,fname_,'_',type,'_restrictions'],'xmat','mat_irf','mat_moment','irestrictions','indx_irf','indx_moment','endo_prior_restrictions');
+else
+load([OutputDirectoryName,filesep,fname_,'_',type,'_restrictions'],'xmat','mat_irf','mat_moment','irestrictions','indx_irf','indx_moment','endo_prior_restrictions');
+end    
 if ~isempty(indx_irf),
+    
+    % For single legend search which has maximum nbr of restrictions 
+    all_irf_couples = cellstr([char(endo_prior_restrictions.irf(:,1)) char(endo_prior_restrictions.irf(:,2))]);
+    irf_couples = unique(all_irf_couples);
+    nbr_irf_couples = size(irf_couples,1);
+    plot_indx = NaN(nbr_irf_couples,1);
+    time_matrix=cell(nbr_irf_couples,1);
+    irf_matrix=cell(nbr_irf_couples,1);
+    irf_mean=cell(nbr_irf_couples,1);
+    irf_median=cell(nbr_irf_couples,1);
+    irf_var=cell(nbr_irf_couples,1);
+    irf_HPD=cell(nbr_irf_couples,1);
+    irf_distrib=cell(nbr_irf_couples,1);
+    maxijv=0;
+    for ij=1:nbr_irf_restrictions
+        if length(endo_prior_restrictions.irf{ij,3})>maxijv
+            maxij=ij;maxijv=length(endo_prior_restrictions.irf{ij,3});
+        end
+        plot_indx(ij) = find(strcmp(irf_couples,all_irf_couples(ij,:)));
+        time_matrix{plot_indx(ij)} = [time_matrix{plot_indx(ij)} endo_prior_restrictions.irf{ij,3}];
+    end
+    
     indx_irf = indx_irf(irestrictions,:);
     h1=dyn_figure(DynareOptions,'name',[type ' evaluation of irf restrictions']);
-    nrow=ceil(sqrt(nbr_irf_restrictions));
+    nrow=ceil(sqrt(nbr_irf_couples));
     ncol=nrow;
-    if nrow*(nrow-1)>nbr_irf_restrictions,
+    if nrow*(nrow-1)>nbr_irf_couples,
         ncol=nrow-1;
     end
     for ij=1:nbr_irf_restrictions,
-        figure(h1),
         mat_irf{ij}=mat_irf{ij}(irestrictions,:);
-        subplot(nrow,ncol,ij),
+        irf_matrix{plot_indx(ij)} = [irf_matrix{plot_indx(ij)} mat_irf{ij}];
         for ik=1:size(mat_irf{ij},2),
-            cumplot(mat_irf{ij}(:,ik)),
-            hold all,
+            [Mean,Median,Var,HPD,Distrib] = ...
+                posterior_moments(mat_irf{ij}(:,ik),0,DynareOptions.mh_conf_sig);
+            irf_mean{plot_indx(ij)} = [irf_mean{plot_indx(ij)}; Mean];
+            irf_median{plot_indx(ij)} = [irf_median{plot_indx(ij)}; Median];
+            irf_var{plot_indx(ij)} = [irf_var{plot_indx(ij)}; Var];
+            irf_HPD{plot_indx(ij)} = [irf_HPD{plot_indx(ij)}; HPD];
+            irf_distrib{plot_indx(ij)} = [irf_distrib{plot_indx(ij)}; Distrib'];
         end
-        %     hist(mat_irf{ij}),
-        a=axis;
-        x1val=max(DynareOptions.endogenous_prior_restrictions.irf{ij,4}(1),a(1));
-        x2val=min(DynareOptions.endogenous_prior_restrictions.irf{ij,4}(2),a(2));
-        hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'k');
-        set(hp,'FaceAlpha',[0.5])
-        hold off,
-        leg = num2str(DynareOptions.endogenous_prior_restrictions.irf{ij,3}(1));
+        leg = num2str(endo_prior_restrictions.irf{ij,3}(1));
+        aleg = num2str(endo_prior_restrictions.irf{ij,3}(1));
         if size(mat_irf{ij},2)>1,
-            leg = [leg,':' ,num2str(DynareOptions.endogenous_prior_restrictions.irf{ij,3}(end))];
+            leg = [leg,':' ,num2str(endo_prior_restrictions.irf{ij,3}(end))];
+            aleg = [aleg,'-' ,num2str(endo_prior_restrictions.irf{ij,3}(end))];
+        end        
+        if length(time_matrix{plot_indx(ij)})==1,
+            figure(h1),
+            subplot(nrow,ncol, plot_indx(ij)),
+            hc = cumplot(mat_irf{ij}(:,ik));
+            set(hc,'color','k','linewidth',2)
+            hold all,
+            a=axis;
+            x1val=max(endo_prior_restrictions.irf{ij,4}(1),a(1));
+            x2val=min(endo_prior_restrictions.irf{ij,4}(2),a(2));
+            hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'b');
+            set(hp,'FaceAlpha', 0.5)
+            hold off,
+            %         hold off,
+            title([endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'],'interpreter','none'),
+            %set(legend_h,'Xlim',[0 1]);
+            %         if ij==maxij
+            %             leg1 = num2str(endo_prior_restrictions.irf{ij,3}(:));
+            %             [legend_h,object_h,plot_h,text_strings]=legend(leg1);
+            %             Position=get(legend_h,'Position');Position(1:2)=[-0.055 0.95-Position(4)];
+            %             set(legend_h,'Position',Position);
+            %         end
         end
-        title([DynareOptions.endogenous_prior_restrictions.irf{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.irf{ij,2}, '(', leg,')'],'interpreter','none'),
-        
+        % hc = get(h,'Children');
+        %for i=2:2:length(hc)
+        %end
         indx1 = find(indx_irf(:,ij)==0);
         indx2 = find(indx_irf(:,ij)~=0);
-        atitle=[DynareOptions.endogenous_prior_restrictions.irf{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.irf{ij,2}, '(', leg,')'];
-        fprintf(['%4.1f%% of the prior support matches IRF ',atitle,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,DynareOptions.endogenous_prior_restrictions.irf{ij,4})
-        aname=[type '_irf_calib_',int2str(ij)];
-        atitle=[type ' IRF Calib: Parameter(s) driving ',DynareOptions.endogenous_prior_restrictions.irf{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.irf{ij,2}, '(', leg,')'];
-        [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
-        indplot=find(proba<pvalue_ks);
-        if ~isempty(indplot)
-            stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
+        atitle0=[endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'];
+        fprintf(['%4.1f%% of the prior support matches IRF ',atitle0,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,endo_prior_restrictions.irf{ij,4})
+        % aname=[type '_irf_calib_',int2str(ij)];
+        aname=[type '_irf_calib_',endo_prior_restrictions.irf{ij,1},'_vs_',endo_prior_restrictions.irf{ij,2},'_',aleg];
+        atitle=[type ' IRF Calib: Parameter(s) driving ',endo_prior_restrictions.irf{ij,1},' vs ',endo_prior_restrictions.irf{ij,2}, '(', leg,')'];
+        options_mcf.amcf_name = aname;
+        options_mcf.amcf_title = atitle;
+        options_mcf.beha_title = 'IRF prior restriction';
+        options_mcf.nobeha_title = 'NO IRF prior restriction';
+        options_mcf.title = atitle0;
+        if ~isempty(indx1) && ~isempty(indx2)
+            mcf_analysis(xmat(:,nshock+1:end), indx1, indx2, options_mcf, DynareOptions);
+        end
+
+%         [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
+%         indplot=find(proba<pvalue_ks);
+%         if ~isempty(indplot)
+%             stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
+%         end
+    end
+    figure(h1);
+    for ij=1:nbr_irf_couples,
+        if length(time_matrix{ij})>1,
+            subplot(nrow,ncol, ij)
+            itmp = (find(plot_indx==ij));
+            plot(time_matrix{ij},[max(irf_matrix{ij})' min(irf_matrix{ij})'],'k--','linewidth',2)
+            hold on,
+            plot(time_matrix{ij},irf_median{ij},'k','linewidth',2)
+            plot(time_matrix{ij},[irf_distrib{ij}],'k-')
+            a=axis;
+            tmp=[];
+            for ir=1:length(itmp),
+                for it=1:length(endo_prior_restrictions.irf{itmp(ir),3})
+                temp_index = find(time_matrix{ij}==endo_prior_restrictions.irf{itmp(ir),3}(it));
+                tmp(temp_index,:) = endo_prior_restrictions.irf{itmp(ir),4};
+                end
+            end
+%             tmp = cell2mat(endo_prior_restrictions.irf(itmp,4));
+            tmp(isinf(tmp(:,1)),1)=a(3);
+            tmp(isinf(tmp(:,2)),2)=a(4);
+            hp = patch([time_matrix{ij} time_matrix{ij}(end:-1:1)],tmp(:),'b');
+            set(hp,'FaceAlpha',[0.5])
+            plot(a(1:2),[0 0],'r')
+            hold off,
+            axis([max(1,a(1)) a(2:4)])
+            box on,
+            set(gca,'xtick',sort(time_matrix{ij}))
+            itmp = min(itmp);
+            title([endo_prior_restrictions.irf{itmp,1},' vs ',endo_prior_restrictions.irf{itmp,2}],'interpreter','none'),
         end
     end
     dyn_saveas(h1,[OutputDirectoryName,filesep,fname_,'_',type,'_irf_restrictions'],DynareOptions);
+
     skipline()
 end
 
 if ~isempty(indx_moment)
+    options_mcf.param_names = char(BayesInfo.name);
+    all_moment_couples = cellstr([char(endo_prior_restrictions.moment(:,1)) char(endo_prior_restrictions.moment(:,2))]);
+    moment_couples = unique(all_moment_couples);
+    nbr_moment_couples = size(moment_couples,1);
+    plot_indx = NaN(nbr_moment_couples,1);
+    time_matrix=cell(nbr_moment_couples,1);
+    moment_matrix=cell(nbr_moment_couples,1);
+    moment_mean=cell(nbr_moment_couples,1);
+    moment_median=cell(nbr_moment_couples,1);
+    moment_var=cell(nbr_moment_couples,1);
+    moment_HPD=cell(nbr_moment_couples,1);
+    moment_distrib=cell(nbr_moment_couples,1);
+    % For single legend search which has maximum nbr of restrictions 
+    maxijv=0;
+    for ij=1:nbr_moment_restrictions
+        if length(endo_prior_restrictions.moment{ij,3})>maxijv
+            maxij=ij;maxijv=length(endo_prior_restrictions.moment{ij,3});
+        end
+        plot_indx(ij) = find(strcmp(moment_couples,all_moment_couples(ij,:)));
+        time_matrix{plot_indx(ij)} = [time_matrix{plot_indx(ij)} endo_prior_restrictions.moment{ij,3}];
+    end
+    
     indx_moment = indx_moment(irestrictions,:);
     h2=dyn_figure(DynareOptions,'name',[type ' evaluation of moment restrictions']);
-    nrow=ceil(sqrt(nbr_moment_restrictions));
+    nrow=ceil(sqrt(nbr_moment_couples));
     ncol=nrow;
-    if nrow*(nrow-1)>nbr_moment_restrictions,
+    if nrow*(nrow-1)>nbr_moment_couples,
         ncol=nrow-1;
     end
+    
     for ij=1:nbr_moment_restrictions,
-        figure(h2),
         mat_moment{ij}=mat_moment{ij}(irestrictions,:);
-        subplot(nrow,ncol,ij),
+        moment_matrix{plot_indx(ij)} = [moment_matrix{plot_indx(ij)} mat_moment{ij}];
         for ik=1:size(mat_moment{ij},2),
-            cumplot(mat_moment{ij}(:,ik)),
-            hold all,
+            [Mean,Median,Var,HPD,Distrib] = ...
+                posterior_moments(mat_moment{ij}(:,ik),0,DynareOptions.mh_conf_sig);
+            moment_mean{plot_indx(ij)} = [moment_mean{plot_indx(ij)}; Mean];
+            moment_median{plot_indx(ij)} = [moment_median{plot_indx(ij)}; Median];
+            moment_var{plot_indx(ij)} = [moment_var{plot_indx(ij)}; Var];
+            moment_HPD{plot_indx(ij)} = [moment_HPD{plot_indx(ij)}; HPD];
+            moment_distrib{plot_indx(ij)} = [moment_distrib{plot_indx(ij)}; Distrib'];
         end
-        %     hist(mat_moment{ij}),
-        a=axis;
-        x1val=max(DynareOptions.endogenous_prior_restrictions.moment{ij,4}(1),a(1));
-        x2val=min(DynareOptions.endogenous_prior_restrictions.moment{ij,4}(2),a(2));
-        hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'k');
-        set(hp,'FaceAlpha',[0.5])
-        hold off,
-        leg = num2str(DynareOptions.endogenous_prior_restrictions.moment{ij,3}(1));
+        leg = num2str(endo_prior_restrictions.moment{ij,3}(1));
+        aleg = num2str(endo_prior_restrictions.moment{ij,3}(1));
         if size(mat_moment{ij},2)>1,
-            leg = [leg,':' ,num2str(DynareOptions.endogenous_prior_restrictions.moment{ij,3}(end))];
+            leg = [leg,':' ,num2str(endo_prior_restrictions.moment{ij,3}(end))];
+            aleg = [aleg,'_' ,num2str(endo_prior_restrictions.moment{ij,3}(end))];
+        end
+        if length(time_matrix{plot_indx(ij)})==1,
+            figure(h2),
+            subplot(nrow,ncol,plot_indx(ij)),
+            hc = cumplot(mat_moment{ij}(:,ik));
+            set(hc,'color','k','linewidth',2)
+            hold all,
+            %     hist(mat_moment{ij}),
+            a=axis;
+            x1val=max(endo_prior_restrictions.moment{ij,4}(1),a(1));
+            x2val=min(endo_prior_restrictions.moment{ij,4}(2),a(2));
+            hp = patch([x1val x2val x2val x1val],a([3 3 4 4]),'b');
+            set(hp,'FaceAlpha', 0.5)
+            hold off,
+            title([endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2},'(',leg,')'],'interpreter','none'),
+%         if ij==maxij
+%             leg1 = num2str(endo_prior_restrictions.moment{ij,3}(:));
+%             [legend_h,object_h,plot_h,text_strings]=legend(leg1);
+%             Position=get(legend_h,'Position');Position(1:2)=[-0.055 0.95-Position(4)];
+%             set(legend_h,'Position',Position);
+%         end
         end
-        title([DynareOptions.endogenous_prior_restrictions.moment{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.moment{ij,2},'(',leg,')'],'interpreter','none'),
-        
         indx1 = find(indx_moment(:,ij)==0);
         indx2 = find(indx_moment(:,ij)~=0);
-        atitle=[DynareOptions.endogenous_prior_restrictions.moment{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.moment{ij,2}, '(', leg,')'];
-        fprintf(['%4.1f%% of the prior support matches MOMENT ',atitle,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,DynareOptions.endogenous_prior_restrictions.moment{ij,4})
-        aname=[type '_moment_calib_',int2str(ij)];
-        atitle=[type ' MOMENT Calib: Parameter(s) driving ',DynareOptions.endogenous_prior_restrictions.moment{ij,1},' vs ',DynareOptions.endogenous_prior_restrictions.moment{ij,2}, '(', leg,')'];
-        [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
-        indplot=find(proba<pvalue_ks);
-        if ~isempty(indplot)
-            stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
+        atitle0=[endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2}, '(', leg,')'];
+        fprintf(['%4.1f%% of the prior support matches MOMENT ',atitle0,' inside [%4.1f, %4.1f]\n'],length(indx1)/length(irestrictions)*100,endo_prior_restrictions.moment{ij,4})
+        % aname=[type '_moment_calib_',int2str(ij)];
+        aname=[type '_moment_calib_',endo_prior_restrictions.moment{ij,1},'_vs_',endo_prior_restrictions.moment{ij,2},'_',aleg];
+        atitle=[type ' MOMENT Calib: Parameter(s) driving ',endo_prior_restrictions.moment{ij,1},' vs ',endo_prior_restrictions.moment{ij,2}, '(', leg,')'];
+        options_mcf.amcf_name = aname;
+        options_mcf.amcf_title = atitle;
+        options_mcf.beha_title = 'moment prior restriction';
+        options_mcf.nobeha_title = 'NO moment prior restriction';
+        options_mcf.title = atitle0;
+        if ~isempty(indx1) && ~isempty(indx2)
+            mcf_analysis(xmat, indx1, indx2, options_mcf, DynareOptions);
+        end
+        
+%         [proba, dproba] = stab_map_1(xmat, indx1, indx2, aname, 0);
+%         indplot=find(proba<pvalue_ks);
+%         if ~isempty(indplot)
+%             stab_map_1(xmat, indx1, indx2, aname, 1, indplot, OutputDirectoryName,[],atitle);
+%         end
+    end
+    figure(h2);
+    for ij=1:nbr_moment_couples,
+        if length(time_matrix{ij})>1,
+            subplot(nrow,ncol, ij)
+            itmp = (find(plot_indx==ij));
+            plot(time_matrix{ij},[max(moment_matrix{ij})' min(moment_matrix{ij})'],'k--','linewidth',2)
+            hold on,
+            plot(time_matrix{ij},moment_median{ij},'k','linewidth',2)
+            plot(time_matrix{ij},[moment_distrib{ij}],'k-')
+            a=axis;
+            tmp=[];
+            for ir=1:length(itmp),
+                for it=1:length(endo_prior_restrictions.moment{itmp(ir),3})
+                temp_index = find(time_matrix{ij}==endo_prior_restrictions.moment{itmp(ir),3}(it));
+                tmp(temp_index,:) = endo_prior_restrictions.moment{itmp(ir),4};
+                end
+            end
+%             tmp = cell2mat(endo_prior_restrictions.moment(itmp,4));
+            tmp(isinf(tmp(:,1)),1)=a(3);
+            tmp(isinf(tmp(:,2)),2)=a(4);
+            hp = patch([time_matrix{ij} time_matrix{ij}(end:-1:1)],tmp(:),'b');
+            set(hp,'FaceAlpha',[0.5])
+            plot(a(1:2),[0 0],'r')
+            hold off,
+            axis(a)
+            box on,
+            set(gca,'xtick',sort(time_matrix{ij}))
+            itmp = min(itmp);
+            title([endo_prior_restrictions.moment{itmp,1},' vs ',endo_prior_restrictions.moment{itmp,2}],'interpreter','none'),
         end
     end
     dyn_saveas(h2,[OutputDirectoryName,filesep,fname_,'_',type,'_moment_restrictions'],DynareOptions);
diff --git a/matlab/gsa/mcf_analysis.m b/matlab/gsa/mcf_analysis.m
new file mode 100644
index 0000000000000000000000000000000000000000..fb46c51bcd4b7c18bd58575d9facaeb489ac39a8
--- /dev/null
+++ b/matlab/gsa/mcf_analysis.m
@@ -0,0 +1,61 @@
+function mcf_analysis(lpmat, ibeha, inobeha, options_mcf, DynareOptions)
+%
+% Written by Marco Ratto
+% Joint Research Centre, The European Commission,
+% marco.ratto@jrc.ec.europa.eu
+%
+
+% Copyright (C) 2014 European Commission
+%
+% 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/>.
+
+pvalue_ks = options_mcf.pvalue_ks;
+pvalue_corr = options_mcf.pvalue_corr;
+alpha2 = options_mcf.alpha2;
+param_names = options_mcf.param_names;
+amcf_name = options_mcf.amcf_name;
+amcf_title = options_mcf.amcf_title;
+beha_title = options_mcf.beha_title;
+nobeha_title = options_mcf.nobeha_title;
+title = options_mcf.title;
+fname_ = options_mcf.fname_;
+OutputDirectoryName = options_mcf.OutputDirectoryName;
+
+[proba, dproba] = stab_map_1(lpmat, ibeha, inobeha, [],0);
+%         indindet=find(dproba>ksstat);
+indmcf=find(proba<pvalue_ks);
+[tmp,jtmp] = sort(proba(indmcf),2,'ascend');
+indmcf = indmcf(jtmp);
+if ~isempty(indmcf)
+    disp(['Smirnov statistics in driving ', title])
+    for j=1:length(indmcf),
+        disp([param_names(indmcf(j),:),'   d-stat = ', num2str(dproba(indmcf(j)),'%1.3f'),'   p-value = ', num2str(proba(indmcf(j)),'%1.3f')])
+    end
+    skipline()
+end
+if length(ibeha)>10 && length(inobeha)>10,
+    indcorr1 = stab_map_2(lpmat(ibeha,:),alpha2, pvalue_corr, beha_title);
+    indcorr2 = stab_map_2(lpmat(inobeha,:),alpha2, pvalue_corr, nobeha_title);
+    indcorr = union(indcorr1(:), indcorr2(:));
+    indcorr = indcorr(~ismember(indcorr(:),indmcf));
+    indmcf = [indmcf(:); indcorr(:)];
+end
+if ~isempty(indmcf)
+    skipline()
+    scatter_mcf(lpmat(ibeha,indmcf),lpmat(inobeha,indmcf), param_names(indmcf,:), ...
+        '.', [fname_,'_',amcf_name], OutputDirectoryName, amcf_title,[], DynareOptions, ...
+        beha_title, nobeha_title)
+end
diff --git a/matlab/gsa/scatter_mcf.m b/matlab/gsa/scatter_mcf.m
new file mode 100644
index 0000000000000000000000000000000000000000..90d363cb3c7e4c11567026cdfa433988946f83d4
--- /dev/null
+++ b/matlab/gsa/scatter_mcf.m
@@ -0,0 +1,167 @@
+function  scatter_mcf(X,Y,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, DynareOptions, beha_name, non_beha_name)
+% Frontend to the Sensitivity Analysis Toolbox for DYNARE
+%
+% Reference:
+% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
+
+% 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/>.
+
+% PURPOSE: Pairwise scatter plots of the columns of x and y after
+% Monte Carlo filtering
+%---------------------------------------------------
+% USAGE:    scatter_mcf(x,y,vnames,pltsym,diagon)
+%        or scatter_mcf(x,y) which relies on defaults
+% where:
+%        x = an nxk matrix with columns containing behavioural sample
+%        y = an mxk matrix with columns containing non-behavioural sample
+%   vnames = a vector of variable names
+%            (default = numeric labels 1,2,3 etc.)
+%   pltsym = a plt symbol
+%            (default = '.' for npts > 100, 'o' for npts < 100
+
+
+Z=[X;Y];
+[n,p] = size(X);
+% X = X - ones(n,1)*min(Z);
+% X = X ./ (ones(n,1)*max(Z));
+[n,p] = size(Y);
+% Y = Y - ones(n,1)*min(Z);
+% Y = Y ./ (ones(n,1)*max(Z));
+[n,p] = size(Z);
+clear Z;
+
+nflag = 0;
+if nargin >=3
+    nflag = 1;
+end;
+
+if nargin<4 || isempty(plotsymbol)
+    if n*p<100, plotsymbol = 'o';
+    else plotsymbol = '.';
+    end
+end
+
+if nargin<5
+    fnam='';
+end
+if nargin<6,
+  dirname='';
+  nograph=1;
+else
+  nograph=0;    
+end
+if nargin<7,
+  figtitle=fnam;
+end
+if nargin<8,
+  xparam1=[];
+end
+if nargin<10,
+  beha_name = 'BEHAVIOUR';
+  non_beha_name = 'NON-BEHAVIOUR';
+end
+if nargin==10,
+  non_beha_name = ['NON-' beha_name];
+end
+
+fig_nam_=[fnam];
+if ~nograph,
+    hh=dyn_figure(DynareOptions,'name',figtitle);
+end
+
+bf = 0.1;
+ffs = 0.05/(p-1);
+ffl = (1-2*bf-0.05)/p;
+if p>1,
+    fL = linspace(bf,1-bf+ffs,p+1);
+else
+    fL = bf;
+end
+for i = 1:p
+    for j = 1:p
+        h = axes('position',[fL(i),fL(p+1-j),ffl,ffl]);
+        if i==j
+            h1=cumplot(X(:,j));
+            %             set(h1,'color',[0 0 1], 'linestyle','--','LineWidth',1.5)
+            set(h1,'color',[0 0 1],'LineWidth',1.5)
+            hold on,
+            h2=cumplot(Y(:,j));
+            set(h2,'color',[1 0 0],'LineWidth',1.5)
+            if ~isempty(xparam1)
+                hold on, plot(xparam1([j j]),[0 1],'k--')
+            end
+            if j<p
+                set(gca,'XTickLabel',[],'XTick',[]);
+            else
+                grid off
+            end
+            set(gca,'YTickLabel',[],'YTick',[]);
+        else
+            if j>i
+                plot(X(:,i),X(:,j),[plotsymbol,'b'])
+                hold on,
+                plot(Y(:,i),Y(:,j),[plotsymbol,'r'])
+            else
+                plot(Y(:,i),Y(:,j),[plotsymbol,'r'])
+                hold on,
+                plot(X(:,i),X(:,j),[plotsymbol,'b'])
+            end
+            if ~isempty(xparam1)
+                hold on, plot(xparam1(i),xparam1(j),'k*')
+            end
+            hold off;
+            %             axis([-0.1 1.1 -0.1 1.1])
+            if i<p,
+                set(gca,'YTickLabel',[],'YTick',[]);
+            else
+                set(gca,'yaxislocation','right');
+            end
+            if j<p
+                set(gca,'XTickLabel',[],'XTick',[]);
+            end
+        end
+        if nflag == 1
+            set(gca,'fontsize',9);
+        end;
+        if i==1
+            if nflag == 1
+                ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
+                    'HorizontalAlignment','right','VerticalAlignment','middle');
+            else
+                ylabel([num2str(j),' '],'Rotation',90)
+            end;
+        end
+        if j==1
+            if nflag == 1
+                title(vnames(i,:),'interpreter','none','Rotation',45, ...
+                    'HorizontalAlignment','left','VerticalAlignment','bottom')
+            else
+                title(num2str(i))
+            end;
+        end
+        drawnow
+    end
+end
+if ~isoctave
+    annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name,'Color','Blue','horizontalalignment','center');
+    annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center');
+end
+
+if ~nograph,
+    dyn_saveas(hh,[dirname,filesep,fig_nam_],DynareOptions);
+end
\ No newline at end of file
diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m
index 92016f031d9a0a9de7b188605cd12f1282b7fb79..f7db079df6f0fdf104f14ffb9667a5b368d9517d 100644
--- a/matlab/gsa/stab_map_.m
+++ b/matlab/gsa/stab_map_.m
@@ -102,6 +102,13 @@ if nargin==0,
     OutputDirectoryName='';
 end
 
+options_mcf.pvalue_ks = pvalue_ks;
+options_mcf.pvalue_corr = pvalue_corr;
+options_mcf.alpha2 = alpha2;
+options_mcf.param_names = char(bayestopt_.name(nshock+1:end));
+options_mcf.fname_ = fname_;
+options_mcf.OutputDirectoryName = OutputDirectoryName;
+
 opt=options_;
 options_.periods=0;
 options_.nomoments=1;
@@ -254,14 +261,13 @@ if fload==0,
     iunstable=[1:Nsam];
     iindeterm=zeros(1,Nsam);
     iwrong=zeros(1,Nsam);
+    inorestriction=zeros(1,Nsam);
+    irestriction=zeros(1,Nsam);
     for j=1:Nsam,
         M_ = set_all_parameters([lpmat0(j,:) lpmat(j,:)]',estim_params_,M_);
         %try stoch_simul([]);
         try
             [Tt,Rr,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_,'restrict');
-            if info(1)==0,
-                info=endogenous_prior_restrictions(Tt,Rr,M_,options_,oo_);
-            end
             infox(j,1)=info(1);
             if infox(j,1)==0 && ~exist('T'),
                 dr_=oo_.dr;
@@ -303,7 +309,6 @@ if fload==0,
         dr_ = oo_.dr;
         if isfield(dr_,'ghx'),
             egg(:,j) = sort(dr_.eigval);
-            iunstable(j)=0;
             if prepSA
                 jstab=jstab+1;
                 T(:,:,jstab) = [dr_.ghx dr_.ghu];
@@ -317,6 +322,15 @@ if fload==0,
                 nboth = dr_.nboth;
                 nfwrd = dr_.nfwrd;
             end
+            info=endogenous_prior_restrictions(Tt,Rr,M_,options_,oo_);
+            infox(j,1)=info(1);
+            if info(1),
+                iwrong(j)=j;
+                inorestriction(j)=j;
+            else
+                iunstable(j)=0;
+                irestriction(j)=j;
+            end
         else
             istable(j)=0;
             if isfield(dr_,'eigval')
@@ -348,10 +362,13 @@ if fload==0,
     else
         T=[];
     end
-    istable=istable(find(istable));  % stable params
-    iunstable=iunstable(find(iunstable));   % unstable params
+    istable=istable(find(istable));  % stable params ignoring restrictions
+    irestriction=irestriction(find(irestriction));  % stable params & restrictions OK
+    inorestriction=inorestriction(find(inorestriction));  % stable params violating restrictions
+    iunstable=iunstable(find(iunstable));   % violation of BK & restrictions & solution could not be found (whatever goes wrong)
     iindeterm=iindeterm(find(iindeterm));  % indeterminacy
     iwrong=iwrong(find(iwrong));  % dynare could not find solution
+    ixun=iunstable(find(~ismember(iunstable,[iindeterm,iwrong]))); % explosive roots
 
     %     % map stable samples
     %     istable=[1:Nsam];
@@ -395,22 +412,22 @@ if fload==0,
     if pprior,
         if ~prepSA
             save([OutputDirectoryName filesep fname_ '_prior.mat'], ...
-                'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
+                'bkpprior','lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
                 'egg','yys','nspred','nboth','nfwrd','infox')
         else
             save([OutputDirectoryName filesep fname_ '_prior.mat'], ...
-                'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
+                'bkpprior','lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
                 'egg','yys','T','nspred','nboth','nfwrd','infox')
         end
 
     else
         if ~prepSA
             save([OutputDirectoryName filesep fname_ '_mc.mat'], ...
-                'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
+                'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
                 'egg','yys','nspred','nboth','nfwrd','infox')
         else
             save([OutputDirectoryName filesep fname_ '_mc.mat'], ...
-                'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
+                'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun', ...
                 'egg','yys','T','nspred','nboth','nfwrd','infox')
         end
     end
@@ -420,7 +437,7 @@ else
     else
         filetoload=[OutputDirectoryName filesep fname_ '_mc.mat'];
     end
-    load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd','infox')
+    load(filetoload,'lpmat','lpmat0','irestriction','iunstable','istable','iindeterm','iwrong','ixun','egg','yys','nspred','nboth','nfwrd','infox')
     Nsam = size(lpmat,1);
     if pprior==0,
         eval(['load ' options_.mode_file '.mat;']);
@@ -467,38 +484,25 @@ else
 end
 
 if pprior
-    % univariate
-    aname='prior_stab'; atitle='Prior StabMap: Parameter driving non-existence of unique stable solution (Unacceptable)';
-    aindetname=[aname, '_indet']; aindettitle='Prior StabMap: Parameter driving indeterminacy';
-    aunstablename=[aname, '_unst'];  aunstabletitle='Prior StabMap: Parameter driving explosiveness of solution';
-    awronguniname=[aname, '_wrong']; awrongunititle='Prior StabMap: Parameter driving inability to find solution';
-    % bivariate
-    auname='prior_unacceptable'; autitle='Prior StabMap: non-existence of unique stable solution (Unacceptable)';
     aunstname='prior_unstable'; aunsttitle='Prior StabMap: explosiveness of solution';
     aindname='prior_indeterm'; aindtitle='Prior StabMap: Indeterminacy';
     awrongname='prior_wrong'; awrongtitle='Prior StabMap: inability to find solution';
-    asname='prior_stable'; astitle='Prior StabMap: unique Stable Saddle-Path';
+    acalibname='prior_calib'; acalibtitle='Prior StabMap: IRF/moment restrictions';
+    asname='prior_stable'; atitle='Prior StabMap: Parameter driving non-existence of unique stable solution (Unacceptable)';
 else
-    % univariate
-    aname='mc_stab'; atitle='MC (around posterior mode) StabMap: Parameter driving non-existence of unique stable solution (Unacceptable)';
-    aindetname=[aname, '_indet']; aindettitle='MC (around posterior mode) StabMap: Parameter driving indeterminacy';
-    aunstablename=[aname, '_unst'];  aunstabletitle='MC (around posterior mode) StabMap: Parameter driving explosiveness of solution';
-    awronguniname=[aname, '_wrong']; awrongunititle='MC (around posterior mode) StabMap: Parameter driving inability to find solution';
-    % bivariate
-    auname='mc_unacceptable'; autitle='MC (around posterior mode) StabMap: non-existence of unique stable solution (Unacceptable)';
     aunstname='mc_unstable'; aunsttitle='MC (around posterior mode) StabMap: explosiveness of solution';
     aindname='mc_indeterm';  aindtitle='MC (around posterior mode) StabMap: Indeterminacy';
     awrongname='mc_wrong'; awrongtitle='MC (around posterior mode) StabMap: inability to find solution';
-    asname='mc_stable'; astitle='MC (around posterior mode) StabMap: Unique Stable Saddle-Path';
+    acalibname='mc_calib'; acalibtitle='MC (around posterior mode) StabMap: IRF/moment restrictions';
+    asname='mc_stable'; atitle='MC (around posterior mode) StabMap: Parameter driving non-existence of unique stable solution (Unacceptable)';
 end
-delete([OutputDirectoryName,filesep,fname_,'_',aname,'_*.*']);
-%delete([OutputDirectoryName,filesep,fname_,'_',aname,'_SA_*.*']);
-delete([OutputDirectoryName,filesep,fname_,'_',asname,'_corr_*.*']);
-delete([OutputDirectoryName,filesep,fname_,'_',auname,'_corr_*.*']);
-delete([OutputDirectoryName,filesep,fname_,'_',aunstname,'_corr_*.*']);
-delete([OutputDirectoryName,filesep,fname_,'_',aindname,'_corr_*.*']);
+delete([OutputDirectoryName,filesep,fname_,'_',asname,'.*']);
+delete([OutputDirectoryName,filesep,fname_,'_',acalibname,'.*']);
+delete([OutputDirectoryName,filesep,fname_,'_',aindname,'.*']);
+delete([OutputDirectoryName,filesep,fname_,'_',aunstname,'.*']);
+delete([OutputDirectoryName,filesep,fname_,'_',awrongname,'.*']);
 
-if length(iunstable)>0 ,
+if length(iunstable)>0 || length(iwrong)>0,
     fprintf(['%4.1f%% of the prior support gives unique saddle-path solution.\n'],length(istable)/Nsam*100)
     fprintf(['%4.1f%% of the prior support gives explosive dynamics.\n'],(length(iunstable)-length(iwrong)-length(iindeterm) )/Nsam*100)
     if ~isempty(iindeterm),
@@ -544,99 +548,77 @@ if length(iunstable)>0 ,
 
     end
     skipline()
-    if length(iunstable)<Nsam
+    if length(iunstable)<Nsam || length(istable)>1
+        itot = [1:Nsam];
         % Blanchard Kahn
-        [proba, dproba] = stab_map_1(lpmat, istable, iunstable, aname,0);
-        %     indstab=find(dproba>ksstat);
-        indstab=find(proba<pvalue_ks);
-        disp('Smirnov statistics in driving acceptable behaviour')
-        for j=1:length(indstab),
-            disp([M_.param_names(estim_params_.param_vals(indstab(j),1),:),'   d-stat = ', num2str(dproba(indstab(j)),'%1.3f'),'   p-value = ', num2str(proba(indstab(j)),'%1.3f')])
-        end
-        skipline()
-        if ~isempty(indstab)
-            stab_map_1(lpmat, istable, iunstable, aname, 1, indstab, OutputDirectoryName,[],atitle);
-        end
-        ixun=iunstable(find(~ismember(iunstable,[iindeterm,iwrong])));
+        itmp = itot(find(~ismember(itot,istable)));
+        options_mcf.amcf_name = asname;
+        options_mcf.amcf_title = atitle;
+        options_mcf.beha_title = 'unique Stable Saddle-Path';
+        options_mcf.nobeha_title = 'NO unique Stable Saddle-Path';
+        options_mcf.title = 'unique solution';
+        mcf_analysis(lpmat, istable, itmp, options_mcf, options_)
+
         if ~isempty(iindeterm),
-            [proba, dproba] = stab_map_1(lpmat, [1:Nsam], iindeterm, aindetname ,0);
-            %         indindet=find(dproba>ksstat);
-            indindet=find(proba<pvalue_ks);
-            disp('Smirnov statistics in driving indeterminacy')
-            for j=1:length(indindet),
-                disp([M_.param_names(estim_params_.param_vals(indindet(j),1),:),'   d-stat = ', num2str(dproba(indindet(j)),'%1.3f'),'   p-value = ', num2str(proba(indindet(j)),'%1.3f')])
-            end
-            skipline()
-            if ~isempty(indindet)
-                stab_map_1(lpmat, [1:Nsam], iindeterm, aindetname, 1, indindet, OutputDirectoryName,[],aindettitle);
-            end
+            itmp = itot(find(~ismember(itot,iindeterm)));
+            options_mcf.amcf_name = aindname;
+            options_mcf.amcf_title = aindtitle;
+            options_mcf.beha_title = 'NO indeterminacy';
+            options_mcf.nobeha_title = 'indeterminacy';
+            options_mcf.title = 'indeterminacy';
+            mcf_analysis(lpmat, itmp, iindeterm, options_mcf, options_)
         end
         
         if ~isempty(ixun),
-            [proba, dproba] = stab_map_1(lpmat, [1:Nsam], ixun, aunstablename,0);
-            %         indunst=find(dproba>ksstat);
-            indunst=find(proba<pvalue_ks);
-            disp('Smirnov statistics in driving instability')
-            for j=1:length(indunst),
-                disp([M_.param_names(estim_params_.param_vals(indunst(j),1),:),'   d-stat = ', num2str(dproba(indunst(j)),'%1.3f'),'   p-value = ', num2str(proba(indunst(j)),'%1.3f')])
-            end
-            skipline()
-            if ~isempty(indunst)
-                stab_map_1(lpmat, [1:Nsam], ixun, aunstablename, 1, indunst, OutputDirectoryName,[],aunstabletitle);
-            end
+            itmp = itot(find(~ismember(itot,ixun)));
+            options_mcf.amcf_name = aunstname;
+            options_mcf.amcf_title = aunsttitle;
+            options_mcf.beha_title = 'NO explosive solution';
+            options_mcf.nobeha_title = 'explosive solution';
+            options_mcf.title = 'instability';
+            mcf_analysis(lpmat, itmp, ixun, options_mcf, options_)
         end
         
+        inorestriction = istable(find(~ismember(istable,irestriction))); % what went wrong beyong prior restrictions
+        iwrong = iwrong(find(~ismember(iwrong,inorestriction))); % what went wrong beyong prior restrictions
         if ~isempty(iwrong),
-            [proba, dproba] = stab_map_1(lpmat, [1:Nsam], iwrong, awronguniname,0);
-            %         indwrong=find(dproba>ksstat);
-            indwrong=find(proba<pvalue_ks);
-            disp('Smirnov statistics in driving no solution')
-            for j=1:length(indwrong),
-                disp([M_.param_names(estim_params_.param_vals(indwrong(j),1),:),'   d-stat = ', num2str(dproba(indwrong(j)),'%1.3f'),'   p-value = ', num2str(proba(indwrong(j)),'%1.3f')])
-            end
-            skipline()
-            if ~isempty(indwrong)
-                stab_map_1(lpmat, [1:Nsam], iwrong, awronguniname, 1, indwrong, OutputDirectoryName,[],awrongunititle);
-            end
+            itmp = itot(find(~ismember(itot,iwrong)));
+            options_mcf.amcf_name = awrongname;
+            options_mcf.amcf_title = awrongtitle;
+            options_mcf.beha_title = 'NO inability to find a solution';
+            options_mcf.nobeha_title = 'inability to find a solution';
+            options_mcf.title = 'inability to find a solution';
+            mcf_analysis(lpmat, itmp, iwrong, options_mcf, options_)
         end
         
-        skipline()
-        disp('Starting bivariate analysis:')
-        
-        c0=corrcoef(lpmat(istable,:));
-        c00=tril(c0,-1);
-        
-        if length(istable)>10,
-            stab_map_2(lpmat(istable,:),alpha2, pvalue_corr, asname, OutputDirectoryName,xparam1,astitle);
-        end
-        if length(iunstable)>10,
-            stab_map_2(lpmat(iunstable,:),alpha2, pvalue_corr, auname, OutputDirectoryName,xparam1,autitle);
-        end
-        if length(iindeterm)>10,
-            stab_map_2(lpmat(iindeterm,:),alpha2, pvalue_corr, aindname, OutputDirectoryName,xparam1,aindtitle);
-        end
-        if length(ixun)>10,
-            stab_map_2(lpmat(ixun,:),alpha2, pvalue_corr, aunstname, OutputDirectoryName,xparam1,aunsttitle);
-        end
-        if length(iwrong)>10,
-            stab_map_2(lpmat(iwrong,:),alpha2, pvalue_corr, awrongname, OutputDirectoryName,xparam1,awrongtitle);
+        if ~isempty(irestriction),
+            options_mcf.param_names = char(bayestopt_.name);
+            options_mcf.amcf_name = acalibname;
+            options_mcf.amcf_title = acalibtitle;
+            options_mcf.beha_title = 'prior IRF/moment calibration';
+            options_mcf.nobeha_title = 'NO prior IRF/moment calibration';
+            options_mcf.title = 'prior restrictions';
+            mcf_analysis([lpmat0 lpmat], irestriction, inorestriction, options_mcf, options_)
+            iok = irestriction(1);
+            x0 = [lpmat0(iok,:)'; lpmat(iok,:)'];
+        else
+            iok = istable(1);
+            x0=0.5.*(bounds.ub(1:nshock)-bounds.lb(1:nshock))+bounds.lb(1:nshock);
+            x0 = [x0; lpmat(iok,:)'];
         end
         
-        x0=0.5.*(bounds.ub(1:nshock)-bounds.lb(1:nshock))+bounds.lb(1:nshock);
-        x0 = [x0; lpmat(istable(1),:)'];
-        if istable(end)~=Nsam
-            M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(1),:)';
-            [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
-            %     stoch_simul([]);
-        end
+        M_ = set_all_parameters(x0,estim_params_,M_);
+        [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
+        %     stoch_simul([]);
     else
         disp('All parameter values in the specified ranges are not acceptable!')
         x0=[];
     end
 else
-    disp('All parameter values in the specified ranges give unique saddle-path solution!')
-        x0=0.5.*(bounds.ub(1:nshock)-bounds.lb(1:nshock))+bounds.lb(1:nshock);
-        x0 = [x0; lpmat(istable(1),:)'];
+    disp('All parameter values in the specified ranges give unique saddle-path solution,')
+    disp('and match prior IRF/moment restriction(s) if any!')
+    x0=0.5.*(bounds.ub(1:nshock)-bounds.lb(1:nshock))+bounds.lb(1:nshock);
+    x0 = [x0; lpmat(istable(1),:)'];
 
 end
 
diff --git a/matlab/gsa/stab_map_1.m b/matlab/gsa/stab_map_1.m
index b6d847c15351e8b4d8867ca00367a6bf5a037a3d..681db4724d992d687cfc581ba6549ff3e891834d 100644
--- a/matlab/gsa/stab_map_1.m
+++ b/matlab/gsa/stab_map_1.m
@@ -100,6 +100,10 @@ if iplot && ~options_.nograph
             %     title([ftit{j},'. D-stat ', num2str(dproba(ipar(j)),2)],'interpreter','none')
             title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
         end
-        dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_);
+        if nparplot>12,
+            dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA_',int2str(i)],options_);
+        else
+            dyn_saveas(hh,[dirname,filesep,fname_,'_',aname,'_SA'],options_);
+        end
     end
 end
diff --git a/matlab/gsa/stab_map_2.m b/matlab/gsa/stab_map_2.m
index d4e94f02e82221e4a5d4338f1dfb213e0af31a31..7848de1c6e235bb3559aa82342693ba1a10aa174 100644
--- a/matlab/gsa/stab_map_2.m
+++ b/matlab/gsa/stab_map_2.m
@@ -1,4 +1,4 @@
-function stab_map_2(x,alpha2, pvalue, fnam, dirname,xparam1,figtitle)
+function indcorr = stab_map_2(x,alpha2, pvalue_crit, fnam, dirname,xparam1,figtitle)
 % function stab_map_2(x, alpha2, pvalue, fnam, dirname,xparam1)
 %
 % Written by Marco Ratto
@@ -32,11 +32,13 @@ global bayestopt_ estim_params_ options_ oo_ M_
 npar=size(x,2);
 nsam=size(x,1);
 ishock= npar>estim_params_.np;
+nograph = options_.nograph;
 if nargin<4,
   fnam='';
 end
 if nargin<5,
   dirname='';
+  nograph=1;
 end
 if nargin<6,
   xparam1=[];
@@ -53,7 +55,7 @@ nshock = nshock + estim_params_.nvn;
 nshock = nshock + estim_params_.ncx;
 nshock = nshock + estim_params_.ncn;
 
-c0=corrcoef(x);
+[c0, pvalue] = corrcoef(x);
 c00=tril(c0,-1);
 fig_nam_=[fname_,'_',fnam,'_corr_'];
 
@@ -70,13 +72,13 @@ end
 disp([' '])
 disp(['Correlation analysis for ',fnam])
 
+indcorr = [];
 for j=1:npar,
     i2=find(abs(c00(:,j))>alpha2);
     if length(i2)>0,
         for jx=1:length(i2),
-            tval  = abs(c00(i2(jx),j)*sqrt( (nsam-2)/(1-c00(i2(jx),j)^2) ));
-            tcr = tcrit(nsam-2,pvalue);
-            if tval>tcr,
+            if pvalue(j,i2(jx))<pvalue_crit,
+                indcorr = [indcorr; [j i2(jx)]];
                 j2=j2+1;
                 if ishock,
                     tmp_name = (['[',bayestopt_.name{j},',',bayestopt_.name{i2(jx)},']']);
@@ -85,7 +87,7 @@ for j=1:npar,
                 end
                 fprintf(1,'%20s: corrcoef = %7.3f\n',tmp_name,c0(i2(jx),j));
                     
-                if ~options_.nograph,
+                if ~nograph,
                 if mod(j2,12)==1,
                     ifig=ifig+1;
                     hh=dyn_figure(options_,'name',[figtitle,' sample bivariate projection ', num2str(ifig)]);
@@ -118,12 +120,12 @@ for j=1:npar,
             
         end
     end
-    if ~options_.nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0),
+    if ~nograph && (j==(npar)) && j2>0 && (mod(j2,12)~=0),
         dyn_saveas(hh,[dirname,filesep,fig_nam_,int2str(ifig)],options_);
     end
     
 end
 if j2==0,
-    disp(['No correlation term with pvalue <', num2str(pvalue),' found for ',fnam])
+    disp(['No correlation term with pvalue <', num2str(pvalue_crit),' and |corr. coef.| >',num2str(alpha2),' found for ',fnam])
 end
 %close all
diff --git a/matlab/hessian.m b/matlab/hessian.m
index d536c27a3b0ec17b75f718a2e5cb47d89e31e7c3..13ddc2f44bcdadf8ca52fce23c7df149ac50ebca 100644
--- a/matlab/hessian.m
+++ b/matlab/hessian.m
@@ -1,5 +1,5 @@
-function hessian_mat = hessian(func,x,gstep,varargin)
-% function hessian_mat = hessian(func,x,gstep,varargin)
+function hessian_mat = hessian(func,x,gstep,varargin) % --*-- Unitary tests --*--
+
 % Computes second order partial derivatives
 %
 % INPUTS
@@ -12,13 +12,21 @@ function hessian_mat = hessian(func,x,gstep,varargin)
 %    hessian_mat [double]   Hessian matrix
 %
 % ALGORITHM
-%    Uses Abramowitz and Stegun (1965) formulas 25.3.24 and 25.3.27 p. 884
+%    Uses Abramowitz and Stegun (1965) formulas 25.3.23 
+% \[
+%     \frac{\partial^2 f_{0,0}}{\partial {x^2}} = \frac{1}{h^2}\left( f_{1,0} - 2f_{0,0} + f_{ - 1,0} \right)
+% \]
+% and 25.3.27 p. 884
+% 
+% \[
+%     \frac{\partial ^2f_{0,0}}{\partial x\partial y} = \frac{-1}{2h^2}\left(f_{1,0} + f_{-1,0} + f_{0,1} + f_{0,-1} - 2f_{0,0} - f_{1,1} - f_{-1,-1} \right)
+% \]
 %
 % SPECIAL REQUIREMENTS
 %    none
 %  
 
-% Copyright (C) 2001-2012 Dynare Team
+% Copyright (C) 2001-2014 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -49,34 +57,87 @@ xh1=x;
 f0=feval(func,x,varargin{:});
 f1=zeros(size(f0,1),n);
 f_1=f1;
-for i=1:n    
+for i=1:n
+    %do step up
     xh1(i)=x(i)+h1(i);
     f1(:,i)=feval(func,xh1,varargin{:});
+    %do step up
     xh1(i)=x(i)-h_1(i);
     f_1(:,i)=feval(func,xh1,varargin{:});
-    xh1(i)=x(i);
-    i=i+1;
+    xh1(i)=x(i);%reset parameter
 end
 xh_1=xh1;
 hessian_mat = zeros(size(f0,1),n*n);
+temp=f1+f_1-f0*ones(1,n); %term f_(1,0)+f_(-1,0)-f_(0,0) used later
 for i=1:n    
-    if i > 1        
+    if i > 1  %fill symmetric part of Hessian based on previously computed results      
         k=[i:n:n*(i-1)];
         hessian_mat(:,(i-1)*n+1:(i-1)*n+i-1)=hessian_mat(:,k);
     end     
-    hessian_mat(:,(i-1)*n+i)=(f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i));
-    temp=f1+f_1-f0*ones(1,n);
+    hessian_mat(:,(i-1)*n+i)=(f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i)); %formula 25.3.23
     for j=i+1:n        
+        %step in up direction
         xh1(i)=x(i)+h1(i);
         xh1(j)=x(j)+h_1(j);
+        %step in down direction
         xh_1(i)=x(i)-h1(i);
         xh_1(j)=x(j)-h_1(j);
-        hessian_mat(:,(i-1)*n+j)=-(-feval(func,xh1,varargin{:})-feval(func,xh_1,varargin{:})+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j));
+        hessian_mat(:,(i-1)*n+j)=-(-feval(func,xh1,varargin{:})-feval(func,xh_1,varargin{:})+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j)); %formula 25.3.27
+        %reset grid points
         xh1(i)=x(i);
         xh1(j)=x(j);
         xh_1(i)=x(i);
         xh_1(j)=x(j);
-        j=j+1;
     end    
-    i=i+1;
-end
\ No newline at end of file
+end
+
+
+%@test:1
+%$ % Create a function.
+%$ fid = fopen('exfun.m','w+');
+%$ fprintf(fid,'function [f,g,H] = exfun(xvar)\\n');
+%$ fprintf(fid,'x = xvar(1);\\n');
+%$ fprintf(fid,'y = xvar(2);\\n');
+%$ fprintf(fid,'f = x^2* log(y);\\n');
+%$ fprintf(fid,'if nargout>1\\n');
+%$ fprintf(fid,'    g = zeros(2,1);\\n');
+%$ fprintf(fid,'    g(1) = 2*x*log(y);\\n');
+%$ fprintf(fid,'    g(2) = x*x/y;\\n');
+%$ fprintf(fid,'end\\n');
+%$ fprintf(fid,'if nargout>2\\n');
+%$ fprintf(fid,'    H = zeros(2,2);\\n');
+%$ fprintf(fid,'    H(1,1) = 2*log(y);\\n');
+%$ fprintf(fid,'    H(1,2) = 2*x/y;\\n');
+%$ fprintf(fid,'    H(2,1) = H(1,2);\\n');
+%$ fprintf(fid,'    H(2,2) = -x*x/(y*y);\\n');
+%$ fprintf(fid,'    H = H(:);\\n');
+%$ fprintf(fid,'end\\n');
+%$ fclose(fid);
+%$
+%$ rehash;
+%$
+%$ t = zeros(5,1);
+%$
+%$ % Evaluate the Hessian at (1,e)
+%$ try
+%$    H = hessian('exfun',[1; exp(1)],[1e-2; 1]);
+%$    t(1) = 1;
+%$ catch
+%$    t(1) = 0;
+%$ end
+%$
+%$ % Compute the true Hessian matrix
+%$ [f, g, Htrue] = exfun([1 exp(1)]);
+%$
+%$ % Delete exfun routine from disk.
+%$ delete('exfun.m');
+%$
+%$ % Compare the values in H and Htrue
+%$ if t(1)
+%$    t(2) = dassert(abs(H(1)-Htrue(1))<1e-6,true);
+%$    t(3) = dassert(abs(H(2)-Htrue(2))<1e-6,true);
+%$    t(4) = dassert(abs(H(3)-Htrue(3))<1e-6,true);
+%$    t(5) = dassert(abs(H(4)-Htrue(4))<1e-6,true);
+%$ end
+%$ T = all(t);
+%@eof:1
diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m
index ce39b30cc8b0ffec5c347031792f409ed51dfb1e..0706988386f8529b991e4641904a4bfa3824d641 100644
--- a/matlab/identification_analysis.m
+++ b/matlab/identification_analysis.m
@@ -134,18 +134,17 @@ if info(1)==0,
             options_.noprint = 1;
             options_.order = 1;
             options_.SpectralDensity.trigger = 0;
-            options_.periods = dataset_.nobs+100;
+            options_.periods = periods+100;
             if options_.kalman_algo > 2,
                 options_.kalman_algo = 1;
             end
             analytic_derivation = options_.analytic_derivation;
             options_.analytic_derivation = -2;
             info = stoch_simul(char(options_.varobs));
-            dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end),dataset_.dates(1),dataset_.names,dataset_.tex);
-            %data_info.data=oo_.endo_simul(options_.varobs_id,100+1:end);
-            %                         datax=data;
+            dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs);            
             derivatives_info.no_DLIK=1;
-            [fval,DLIK,AHess,cost_flag,ys,trend_coeff,info,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_,derivatives_info);
+            bounds = prior_bounds(bayestopt_,options_);
+            [fval,DLIK,AHess,cost_flag,ys,trend_coeff,info,M_,options_,bayestopt_,oo_] = dsge_likelihood(params',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,derivatives_info);
 %                 fval = DsgeLikelihood(xparam1,data_info,options_,M_,estim_params_,bayestopt_,oo_);
             options_.analytic_derivation = analytic_derivation;
             AHess=-AHess;
diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m
index 45189b0b18aac5da90e219d662bcd1fb4fc965f4..73637948c9ddb68e9e3019ccfce31317b2842cdf 100644
--- a/matlab/initial_estimation_checks.m
+++ b/matlab/initial_estimation_checks.m
@@ -75,7 +75,12 @@ test_for_deep_parameters_calibration(Model);
 % Evaluate the likelihood.
 ana_deriv = DynareOptions.analytic_derivation;
 DynareOptions.analytic_derivation=0;
-[fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
+if ~isequal(DynareOptions.mode_compute,11)
+  [fval,junk1,junk2,a,b,c,d] = feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
+else 
+    b=0;
+    fval = 0;
+end
 DynareOptions.analytic_derivation=ana_deriv;
 
 if DynareOptions.dsge_var || strcmp(func2str(objective_function),'non_linear_dsge_likelihood')
@@ -106,4 +111,6 @@ if any(abs(DynareResults.steady_state(BayesInfo.mfys))>1e-9) && (DynareOptions.p
     error('You should change something in your mod file...')
 end
 
-disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
+if ~isequal(DynareOptions.mode_compute,11)
+    disp(['Initial value of the log posterior (or likelihood): ' num2str(-fval)]);
+end
diff --git a/matlab/insert_column_vector_in_a_matrix.m b/matlab/insert_column_vector_in_a_matrix.m
index 6ab517e3f81fd4389607dc1f482ceff595ae4d38..387a0d5406cbb61bd4217c94e396137b96d53490 100644
--- a/matlab/insert_column_vector_in_a_matrix.m
+++ b/matlab/insert_column_vector_in_a_matrix.m
@@ -58,9 +58,9 @@ end
 %$ end
 %$ 
 %$ if t(1)
-%$   t(2) = dyn_assert(A4,[A,b],1e-15);
-%$   t(3) = dyn_assert(A1,[b,A],1e-15);
-%$   t(4) = dyn_assert(A2,[A(:,1), b, A(:,2:end)],1e-15);
+%$   t(2) = dassert(A4,[A,b],1e-15);
+%$   t(3) = dassert(A1,[b,A],1e-15);
+%$   t(4) = dassert(A2,[A(:,1), b, A(:,2:end)],1e-15);
 %$ end
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/insert_object_in_a_one_dimensional_cell_array.m b/matlab/insert_object_in_a_one_dimensional_cell_array.m
index 3eb82e0ba0caed883b9537f2a8565e5b91ec5cce..6532afbb77b496f88d1f46e4bfe53e9fd1ef4f1c 100644
--- a/matlab/insert_object_in_a_one_dimensional_cell_array.m
+++ b/matlab/insert_object_in_a_one_dimensional_cell_array.m
@@ -65,9 +65,9 @@ end
 %$ end
 %$
 %$ if t(1)
-%$   t(2) = dyn_assert(C4,[A;b]);
-%$   t(3) = dyn_assert(C1,[b;A],1e-15);
-%$   t(4) = dyn_assert(C2,[A(1); b; A(2:3)]);
+%$   t(2) = dassert(C4,[A;b]);
+%$   t(3) = dassert(C1,[b;A],1e-15);
+%$   t(4) = dassert(C2,[A(1); b; A(2:3)]);
 %$ end
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/internals.m b/matlab/internals.m
index 462f936aa6eb83ca1d5eb710a2da0b2949fe307a..4fc079ec28fd4f2064cfe3245f055a6ba48eb2bc 100644
--- a/matlab/internals.m
+++ b/matlab/internals.m
@@ -82,7 +82,7 @@ if strcmpi(flag,'--test')
         dynare_path = dynare_config([],0);
         number_of_matlab_routines = length(varargin);
         for i=1:number_of_matlab_routines
-            dynTest(varargin{i},dynare_path);
+            dtest(varargin{i},[dynare_path '..' filesep 'tests']);
         end
     else
         disp('You have to specify at least one Matlab routine after --test flag!')
diff --git a/matlab/load_csv_file_data.m b/matlab/load_csv_file_data.m
index 72e5857c66b065d3ebe20ae240ea9025a11c123e..639ed5b30a82115e72408089a4460d01f6b8d2f3 100644
--- a/matlab/load_csv_file_data.m
+++ b/matlab/load_csv_file_data.m
@@ -42,7 +42,13 @@ assert(exist(file, 'file') == 2, ['load_csv_file_data: I can''t find file ' file
 
 if isoctave
     if ~user_has_octave_forge_package('io')
-        error('The io package is required to read CSV files from Octave')
+        try
+            pkg load io
+        catch
+            error(['The io package is required to read CSV files from Octave. ' ...
+                'It can be installed by running the following from the Octave ' ...
+                ' command line: pkg install -forge io']);
+        end
     end
     A = csv2cell(file);
     [data, T, L] = parsecell(A);
diff --git a/matlab/load_m_file_data.m b/matlab/load_m_file_data.m
index 05aa753c0c23654fc8a0ea99cf64e8fdf2ed6632..5c2e47881fd817154139fc5db5b85cb9dedc6b5f 100644
--- a/matlab/load_m_file_data.m
+++ b/matlab/load_m_file_data.m
@@ -146,13 +146,13 @@ end
 %$ end
 %$
 %$ % Check the results.
-%$ t(2) = dyn_assert(freq,4);
-%$ t(3) = dyn_assert(isa(init,'dates'),1);
-%$ t(4) = dyn_assert(init.freq,4);
-%$ t(5) = dyn_assert(init.time,[1938 4]);
-%$ t(6) = dyn_assert(varlist,{'azert';'yuiop'});
-%$ t(7) = dyn_assert(tex,{'azert';'yuiop'});
-%$ t(8) = dyn_assert(data(:,1),[1;2;3;4;5]);
-%$ t(9) = dyn_assert(data(:,2),[2;3;4;5;6]);
+%$ t(2) = dassert(freq,4);
+%$ t(3) = dassert(isa(init,'dates'),1);
+%$ t(4) = dassert(init.freq,4);
+%$ t(5) = dassert(init.time,[1938 4]);
+%$ t(6) = dassert(varlist,{'azert';'yuiop'});
+%$ t(7) = dassert(tex,{'azert';'yuiop'});
+%$ t(8) = dassert(data(:,1),[1;2;3;4;5]);
+%$ t(9) = dassert(data(:,2),[2;3;4;5;6]);
 %$ T = all(t);
 %@eof:1
diff --git a/matlab/load_mat_file_data.m b/matlab/load_mat_file_data.m
index 955d996851c452e55858d3945cc57473ee269024..98825a49a3113f4648a3aa619b27f067b7a0bd90 100644
--- a/matlab/load_mat_file_data.m
+++ b/matlab/load_mat_file_data.m
@@ -108,14 +108,14 @@ end
 %$ end
 %$
 %$ % Check the results.
-%$ t(2) = dyn_assert(freq,12);
-%$ t(3) = dyn_assert(isa(init,'dates'),1);
-%$ t(4) = dyn_assert(init.freq,12);
-%$ t(5) = dyn_assert(init.time,[1938 11]);
-%$ t(6) = dyn_assert(varlist,{'hagop';'bedros'});
-%$ t(7) = dyn_assert(varlist,{'hagop';'bedros'});
-%$ t(8) = dyn_assert(data(:,1),[1;2;3;4;5]);
-%$ t(9) = dyn_assert(data(:,2),[2;3;4;5;6]);
+%$ t(2) = dassert(freq,12);
+%$ t(3) = dassert(isa(init,'dates'),true);
+%$ t(4) = dassert(init.freq,12);
+%$ t(5) = dassert(init.time,[1938 11]);
+%$ t(6) = dassert(varlist,{'hagop';'bedros'});
+%$ t(7) = dassert(varlist,{'hagop';'bedros'});
+%$ t(8) = dassert(data(:,1),[1;2;3;4;5]);
+%$ t(9) = dassert(data(:,2),[2;3;4;5;6]);
 %$ T = all(t);
 %@eof:1
 
@@ -142,13 +142,13 @@ end
 %$ end
 %$
 %$ % Check the results.
-%$ t(2) = dyn_assert(freq,12);
-%$ t(3) = dyn_assert(isa(init,'dates'),1);
-%$ t(4) = dyn_assert(init.freq,12);
-%$ t(5) = dyn_assert(init.time,[1938 11]);
-%$ t(6) = dyn_assert(varlist,{'hagop';'bedros'});
-%$ t(7) = dyn_assert(varlist,{'hagop';'bedros'});
-%$ t(8) = dyn_assert(data(:,1),[1;2;3;4;5]);
-%$ t(9) = dyn_assert(data(:,2),[2;3;4;5;6]);
+%$ t(2) = dassert(freq,12);
+%$ t(3) = dassert(isa(init,'dates'),true);
+%$ t(4) = dassert(init.freq,12);
+%$ t(5) = dassert(init.time,[1938 11]);
+%$ t(6) = dassert(varlist,{'hagop';'bedros'});
+%$ t(7) = dassert(varlist,{'hagop';'bedros'});
+%$ t(8) = dassert(data(:,1),[1;2;3;4;5]);
+%$ t(9) = dassert(data(:,2),[2;3;4;5;6]);
 %$ T = all(t);
 %@eof:2
diff --git a/matlab/missing/corrcoef/corrcoef.m b/matlab/missing/corrcoef/corrcoef.m
new file mode 100644
index 0000000000000000000000000000000000000000..c918c61043ddf89d11f1556f2ec315b651389859
--- /dev/null
+++ b/matlab/missing/corrcoef/corrcoef.m
@@ -0,0 +1,387 @@
+function [R,sig,ci1,ci2,nan_sig] = corrcoef(X,Y,varargin)
+% CORRCOEF calculates the correlation matrix from pairwise correlations.
+%   The input data can contain missing values encoded with NaN.
+%   Missing data (NaN's) are handled by pairwise deletion [15].
+%   In order to avoid possible pitfalls, use case-wise deletion or
+%   or check the correlation of NaN's with your data (see below).
+%   A significance test for testing the Hypothesis
+%   'correlation coefficient R is significantly different to zero'
+%   is included.
+%
+% [...] = CORRCOEF(X);
+%      calculates the (auto-)correlation matrix of X
+% [...] = CORRCOEF(X,Y);
+%      calculates the crosscorrelation between X and Y
+%
+% [...] = CORRCOEF(..., Mode);
+%       Mode='Pearson' or 'parametric' [default]
+%               gives the correlation coefficient
+%               also known as the 'product-moment coefficient of correlation'
+%               or 'Pearson''s correlation' [1]
+%       Mode='Spearman'     gives 'Spearman''s Rank Correlation Coefficient'
+%               This replaces SPEARMAN.M
+%       Mode='Rank'         gives a nonparametric Rank Correlation Coefficient
+%               This is the "Spearman rank correlation with proper handling of ties"
+%               This replaces RANKCORR.M
+%
+% [...] = CORRCOEF(..., param1, value1, param2, value2, ... );
+%	param       value
+%	'Mode'		type of correlation
+%		'Pearson','parametric'
+%		'Spearman'
+%		'rank'
+%	'rows'		how do deal with missing values encoded as NaN's.
+%		'complete': remove all rows with at least one NaN
+%		'pairwise': [default]
+%	'alpha'		0.01	: significance level to compute confidence interval
+%
+% [R,p,ci1,ci2,nansig] = CORRCOEF(...);
+%   R is the correlation matrix
+%	R(i,j) is the correlation coefficient r between X(:,i) and Y(:,j)
+%  p    gives the significance of R
+%	It tests the null hypothesis that the product moment correlation coefficient is zero
+%       using Student's t-test on the statistic t = r*sqrt(N-2)/sqrt(1-r^2)
+%       where N is the number of samples (Statistics, M. Spiegel, Schaum series).
+%  p > alpha: do not reject the Null hypothesis: 'R is zero'.
+%  p < alpha: The alternative hypothesis 'R is larger than zero' is true with probability (1-alpha).
+%  ci1	lower (1-alpha) confidence interval
+%  ci2	upper (1-alpha) confidence interval
+%	If no alpha is provided, the default alpha is 0.01. This can be changed with function flag_implicit_significance.
+%  nan_sig  p-value whether H0: 'NaN''s are not correlated' could be correct
+%       if nan_sig < alpha, H1 ('NaNs are correlated') is very likely.
+%
+% The result is only valid if the occurence of NaN's is uncorrelated. In
+% order to avoid this pitfall, the correlation of NaN's should be checked
+% or case-wise deletion should be applied.
+%   Case-Wise deletion can be implemented
+%    ix = ~any(isnan([X,Y]),2);
+%    [...] = CORRCOEF(X(ix,:),Y(ix,:),...);
+%
+%  Correlation (non-random distribution) of NaN's can be checked with
+%       [nan_R,nan_sig]=corrcoef(X,isnan(X))
+%   or  [nan_R,nan_sig]=corrcoef([X,Y],isnan([X,Y]))
+%   or  [R,p,ci1,ci2] = CORRCOEF(...);
+%
+% Further recommandation related to the correlation coefficient:
+% + LOOK AT THE SCATTERPLOTS to make sure that the relationship is linear
+% + Correlation is not causation because
+%	it is not clear which parameter is 'cause' and which is 'effect' and
+%       the observed correlation between two variables might be due to the action of other, unobserved variables.
+%
+% see also: SUMSKIPNAN, COVM, COV, COR, SPEARMAN, RANKCORR, RANKS,
+%       PARTCORRCOEF, flag_implicit_significance
+%
+% REFERENCES:
+% on the correlation coefficient
+% [ 1] http://mathworld.wolfram.com/CorrelationCoefficient.html
+% [ 2] http://www.geography.btinternet.co.uk/spearman.htm
+% [ 3] Hogg, R. V. and Craig, A. T. Introduction to Mathematical Statistics, 5th ed.  New York: Macmillan, pp. 338 and 400, 1995.
+% [ 4] Lehmann, E. L. and D'Abrera, H. J. M. Nonparametrics: Statistical Methods Based on Ranks, rev. ed. Englewood Cliffs, NJ: Prentice-Hall, pp. 292, 300, and 323, 1998.
+% [ 5] Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, pp. 634-637, 1992
+% [ 6] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
+% on the significance test of the correlation coefficient
+% [11] http://www.met.rdg.ac.uk/cag/STATS/corr.html
+% [12] http://www.janda.org/c10/Lectures/topic06/L24-significanceR.htm
+% [13] http://faculty.vassar.edu/lowry/ch4apx.html
+% [14] http://davidmlane.com/hyperstat/B134689.html
+% [15] http://www.statsoft.com/textbook/stbasic.html%Correlations
+% others
+% [20] http://www.tufts.edu/~gdallal/corr.htm
+% [21] Fisher transformation http://en.wikipedia.org/wiki/Fisher_transformation
+
+%       $Id: corrcoef.m 9387 2011-12-15 10:42:14Z schloegl $
+%       Copyright (C) 2000-2004,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
+%       Copyright (C) 2014 Dynare Team
+%       This function is part of the NaN-toolbox
+%       http://pub.ist.ac.at/~schloegl/matlab/NaN/
+
+%    This program 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.
+%
+%    This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+% Features:
+% + handles missing values (encoded as NaN's)
+%       + pairwise deletion of missing data
+%       + checks independence of missing values (NaNs)
+% + parametric and non-parametric (rank) correlation
+%       + Pearson's correlation
+%       + Spearman's rank correlation
+%       + Rank correlation (non-parametric, Spearman rank correlation with proper handling of ties)
+% + is fast, using an efficient algorithm O(n.log(n)) for calculating the ranks
+% + significance test for null-hypthesis: r=0
+% + confidence interval included
+% - rank correlation works for cell arrays, too (no check for missing values).
+% + compatible with Octave and Matlab
+
+global FLAG_NANS_OCCURED;
+
+NARG = nargout;	% needed because nargout is not reentrant in Octave, and corrcoef is recursive
+mode = [];
+
+if nargin==1
+        Y = [];
+        Mode='Pearson';
+elseif nargin==0
+        fprintf(2,'Error CORRCOEF: Missing argument(s)\n');
+elseif nargin>1
+        if ischar(Y)
+                varg = [Y,varargin];
+                Y=[];
+        else
+                varg = varargin;
+        end;
+
+        if length(varg)<1,
+                Mode = 'Pearson';
+        elseif length(varg)==1,
+                Mode = varg{1};
+        else
+                for k = 2:2:length(varg),
+                        mode = setfield(mode,lower(varg{k-1}),varg{k});
+                end;
+                if isfield(mode,'mode')
+                        Mode = mode.mode;
+                end;
+        end;
+end;
+if isempty(Mode) Mode='pearson'; end;
+Mode=[Mode,'        '];
+
+
+
+FLAG_WARNING = warning;		% save warning status
+warning('off');
+
+[r1,c1]=size(X);
+if ~isempty(Y)
+        [r2,c2]=size(Y);
+        if r1~=r2,
+                fprintf(2,'Error CORRCOEF: X and Y must have the same number of observations (rows).\n');
+                return;
+        end;
+        NN = real(~isnan(X)')*real(~isnan(Y));
+else
+        [r2,c2]=size(X);
+        NN = real(~isnan(X)')*real(~isnan(X));
+end;
+
+%%%%% generate combinations using indices for pairwise calculation of the correlation
+YESNAN = any(isnan(X(:))) | any(isnan(Y(:)));
+if YESNAN,
+    FLAG_NANS_OCCURED=(1==1);
+    if isfield(mode,'rows')
+        if strcmp(mode.rows,'complete')
+            ix = ~any([X,Y],2);
+            X = X(ix,:);
+            if ~isempty(Y)
+                Y = Y(ix,:);
+            end;
+            YESNAN = 0;
+            NN = size(X,1);
+        elseif strcmp(mode.rows,'all')
+            fprintf(1,'Warning: data contains NaNs, rows=pairwise is used.');
+            %%NN(NN < size(X,1)) = NaN;
+        elseif strcmp(mode.rows,'pairwise')
+            %%% default
+        end;
+    end;
+end;
+if isempty(Y),
+        IX = ones(c1)-diag(ones(c1,1));
+        [jx, jy ] = find(IX);
+        [jxo,jyo] = find(IX);
+    R = eye(c1);
+else
+        IX = sparse([],[],[],c1+c2,c1+c2,c1*c2);
+        IX(1:c1,c1+(1:c2)) = 1;
+        [jx,jy] = find(IX);
+
+        IX = ones(c1,c2);
+        [jxo,jyo] = find(IX);
+    R = zeros(c1,c2);
+end;
+
+if strcmp(lower(Mode(1:7)),'pearson');
+        % see http://mathworld.wolfram.com/CorrelationCoefficient.html
+    if ~YESNAN,
+                [S,N,SSQ] = sumskipnan(X,1);
+                if ~isempty(Y),
+                    [S2,N2,SSQ2] = sumskipnan(Y,1);
+                        CC = X'*Y;
+                        M1 = S./N;
+                        M2 = S2./N2;
+                        cc = CC./NN - M1'*M2;
+                        R  = cc./sqrt((SSQ./N-M1.*M1)'*(SSQ2./N2-M2.*M2));
+                else
+                        CC = X'*X;
+                        M  = S./N;
+                        cc = CC./NN - M'*M;
+                        v  = SSQ./N - M.*M; %max(N-1,0);
+                        R  = cc./sqrt(v'*v);
+                end;
+        else
+                if ~isempty(Y),
+                        X  = [X,Y];
+                end;
+                for k = 1:length(jx),
+                        %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
+                        ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
+                        [s,n,s2] = sumskipnan(X(ik,[jx(k),jy(k)]),1);
+                        v  = (s2-s.*s./n)./n;
+                        cc = X(ik,jx(k))'*X(ik,jy(k));
+                        cc = cc/n(1) - prod(s./n);
+                        %r(k) = cc./sqrt(prod(v));
+                        R(jxo(k),jyo(k)) = cc./sqrt(prod(v));
+                end;
+    end
+
+elseif strcmp(lower(Mode(1:4)),'rank');
+        % see [ 6] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
+    if ~YESNAN,
+                if isempty(Y)
+                    R = corrcoef(ranks(X));
+                else
+                        R = corrcoef(ranks(X),ranks(Y));
+                end;
+        else
+                if ~isempty(Y),
+                        X = [X,Y];
+                end;
+                for k = 1:length(jx),
+                        %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
+                        ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
+                        il = ranks(X(ik,[jx(k),jy(k)]));
+                        R(jxo(k),jyo(k)) = corrcoef(il(:,1),il(:,2));
+                end;
+        X = ranks(X);
+    end;
+
+elseif strcmp(lower(Mode(1:8)),'spearman');
+        % see [ 6] http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
+        if ~isempty(Y),
+                X = [X,Y];
+        end;
+
+        n = repmat(nan,c1,c2);
+
+        if ~YESNAN,
+                iy = ranks(X);	%  calculates ranks;
+
+                for k = 1:length(jx),
+                        [R(jxo(k),jyo(k)),n(jxo(k),jyo(k))] = sumskipnan((iy(:,jx(k)) - iy(:,jy(k))).^2);	% NN is the number of non-missing values
+                end;
+        else
+                for k = 1:length(jx),
+                        %ik = ~any(isnan(X(:,[jx(k),jy(k)])),2);
+                        ik = ~isnan(X(:,jx(k))) & ~isnan(X(:,jy(k)));
+                        il = ranks(X(ik,[jx(k),jy(k)]));
+                        % NN is the number of non-missing values
+                        [R(jxo(k),jyo(k)),n(jxo(k),jyo(k))] = sumskipnan((il(:,1) - il(:,2)).^2);
+                end;
+        X = ranks(X);
+        end;
+        R = 1 - 6 * R ./ (n.*(n.*n-1));
+
+elseif strcmp(lower(Mode(1:7)),'partial');
+        fprintf(2,'Error CORRCOEF: use PARTCORRCOEF \n',Mode);
+
+        return;
+
+elseif strcmp(lower(Mode(1:7)),'kendall');
+        fprintf(2,'Error CORRCOEF: mode ''%s'' not implemented yet.\n',Mode);
+
+        return;
+else
+        fprintf(2,'Error CORRCOEF: unknown mode ''%s''\n',Mode);
+end;
+
+if (NARG<2),
+        warning(FLAG_WARNING);  % restore warning status
+        return;
+end;
+
+
+% CONFIDENCE INTERVAL
+if isfield(mode,'alpha')
+    alpha = mode.alpha;
+elseif exist('flag_implicit_significance','file'),
+        alpha = flag_implicit_significance;
+else
+    alpha = 0.01;
+end;
+% fprintf(1,'CORRCOEF: confidence interval is based on alpha=%f\n',alpha);
+
+
+% SIGNIFICANCE TEST
+R(isnan(R))=0;
+tmp = 1 - R.*R;
+tmp(tmp<0) = 0;		% prevent tmp<0 i.e. imag(t)~=0
+t   = R.*sqrt(max(NN-2,0)./tmp);
+
+if exist('t_cdf','file');
+        sig = t_cdf(t,NN-2);
+elseif exist('tcdf','file')>1;
+        sig = tcdf(t,NN-2);
+else
+        fprintf('CORRCOEF: significance test not completed because of missing TCDF-function\n')
+        sig = repmat(nan,size(R));
+end;
+sig  = 2 * min(sig,1 - sig);
+
+
+if NARG<3,
+    warning(FLAG_WARNING);  % restore warning status
+        return;
+end;
+
+
+tmp = R;
+%tmp(ix1 | ix2) = nan;		% avoid division-by-zero warning
+z   = log((1+tmp)./(1-tmp))/2;  % Fisher transformation [21]
+%sz = 1./sqrt(NN-3);		% standard error of z
+sz  = sqrt(2)*erfinv(1-alpha)./sqrt(NN-3);	% confidence interval for alpha of z
+
+ci1 = tanh(z-sz);
+ci2 = tanh(z+sz);
+
+%ci1(isnan(ci1))=R(isnan(ci1));	% in case of isnan(ci), the interval limits are exactly the R value
+%ci2(isnan(ci2))=R(isnan(ci2));
+
+if (NARG<5) || ~YESNAN,
+    nan_sig = repmat(NaN,size(R));
+    warning(FLAG_WARNING);  % restore warning status
+    return;
+end;
+
+%%%%% ----- check independence of NaNs (missing values) -----
+[nan_R, nan_sig] = corrcoef(X,double(isnan(X)));
+
+% remove diagonal elements, because these have not any meaning %
+nan_sig(isnan(nan_R)) = nan;
+% remove diagonal elements, because these have not any meaning %
+nan_R(isnan(nan_R)) = 0;
+
+if 0, any(nan_sig(:) < alpha),
+        tmp = nan_sig(:);			% Hack to skip NaN's in MIN(X)
+        min_sig = min(tmp(~isnan(tmp)));    % Necessary, because Octave returns NaN rather than min(X) for min(NaN,X)
+        fprintf(1,'CORRCOFF Warning: Missing Values (i.e. NaNs) are not independent of data (p-value=%f)\n', min_sig);
+        fprintf(1,'   Its recommended to remove all samples (i.e. rows) with any missing value (NaN).\n');
+        fprintf(1,'   The null-hypotheses (NaNs are uncorrelated) is rejected for the following parameter pair(s).\n');
+        [ix,iy] = find(nan_sig < alpha);
+        disp([ix,iy])
+end;
+
+%%%%% ----- end of independence check ------
+
+warning(FLAG_WARNING);  % restore warning status
+return;
+
diff --git a/matlab/missing/corrcoef/flag_implicit_skip_nan.m b/matlab/missing/corrcoef/flag_implicit_skip_nan.m
new file mode 100644
index 0000000000000000000000000000000000000000..409b9f69648ea224f956bdcbb1b968b8f3bcc652
--- /dev/null
+++ b/matlab/missing/corrcoef/flag_implicit_skip_nan.m
@@ -0,0 +1,66 @@
+function FLAG = flag_implicit_skip_nan(i)
+% FLAG_IMPLICIT_SKIP_NAN sets and gets default mode for handling NaNs
+%	1 skips NaN's (the default mode if no mode is set)
+%   0 NaNs are propagated; input NaN's give NaN's at the output
+%
+% FLAG = flag_implicit_skip_nan()
+%   gets current mode
+%
+% flag_implicit_skip_nan(FLAG)    % sets mode
+%
+% prevFLAG = flag_implicit_skip_nan(nextFLAG)
+%	gets previous set FLAG and sets FLAG for the future
+% flag_implicit_skip_nan(prevFLAG)
+%	resets FLAG to previous mode
+%
+% It is used in:
+%	SUMSKIPNAN, MEDIAN, QUANTILES, TRIMEAN
+% and affects many other functions like:
+%	CENTER, KURTOSIS, MAD, MEAN, MOMENT, RMS, SEM, SKEWNESS,
+%	STATISTIC, STD, VAR, ZSCORE etc.
+%
+% The mode is stored in the global variable FLAG_implicit_skip_nan
+% It is recommended to use flag_implicit_skip_nan(1) as default and
+% flag_implicit_skip_nan(0) should be used for exceptional cases only.
+% This feature might disappear without further notice, so you should really not
+% rely on it.
+
+
+%    This program 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.
+%
+%    This program 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 this program; if not, write to the Free Software
+%    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+%	$Id: flag_implicit_skip_nan.m 8351 2011-06-24 17:35:07Z carandraug $
+%   Copyright (C) 2001-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>
+%   Copyright (C) 2014 Dynare Team
+%       This function is part of the NaN-toolbox
+%       http://pub.ist.ac.at/~schloegl/matlab/NaN/
+
+
+persistent FLAG_implicit_skip_nan;
+
+%% if strcmp(version,'3.6'), FLAG_implicit_skip_nan=(1==1); end;	%% hack for the use with Freemat3.6
+
+%%% set DEFAULT value of FLAG
+if isempty(FLAG_implicit_skip_nan),
+    FLAG_implicit_skip_nan = (1==1); %logical(1); % logical.m not available on 2.0.16
+end;
+
+FLAG = FLAG_implicit_skip_nan;
+if nargin>0,
+    FLAG_implicit_skip_nan = (i~=0); %logical(i); %logical.m not available in 2.0.16
+    if (~i)
+        warning('flag_implicit_skipnan(0): You are warned!!! You have turned off skipping NaN in sumskipnan. This is not recommended. Make sure you really know what you do.')
+    end;
+end;
+
diff --git a/matlab/missing/corrcoef/sumskipnan.m b/matlab/missing/corrcoef/sumskipnan.m
new file mode 100644
index 0000000000000000000000000000000000000000..78f8ecbc1e40854d7c96083f11d7315b5947b6c1
--- /dev/null
+++ b/matlab/missing/corrcoef/sumskipnan.m
@@ -0,0 +1,194 @@
+function [o,count,SSQ] = sumskipnan(x, DIM, W)
+% SUMSKIPNAN adds all non-NaN values.
+%
+% All NaN's are skipped; NaN's are considered as missing values.
+% SUMSKIPNAN of NaN's only  gives O; and the number of valid elements is return.
+% SUMSKIPNAN is also the elementary function for calculating
+% various statistics (e.g. MEAN, STD, VAR, RMS, MEANSQ, SKEWNESS,
+% KURTOSIS, MOMENT, STATISTIC etc.) from data with missing values.
+% SUMSKIPNAN implements the DIMENSION-argument for data with missing values.
+% Also the second output argument return the number of valid elements (not NaNs)
+%
+% Y = sumskipnan(x [,DIM])
+% [Y,N,SSQ] = sumskipnan(x [,DIM])
+% [...] = sumskipnan(x, DIM, W)
+%
+% x	input data
+% DIM	dimension (default: [])
+%	empty DIM sets DIM to first non singleton dimension
+% W	weight vector for weighted sum, numel(W) must fit size(x,DIM)
+% Y	resulting sum
+% N	number of valid (not missing) elements
+% SSQ	sum of squares
+%
+% the function FLAG_NANS_OCCURED() returns whether any value in x
+%  is a not-a-number (NaN)
+%
+% features:
+% - can deal with NaN's (missing values)
+% - implements dimension argument.
+% - computes weighted sum
+% - compatible with Matlab and Octave
+%
+% see also: FLAG_NANS_OCCURED, SUM, NANSUM, MEAN, STD, VAR, RMS, MEANSQ,
+%      SSQ, MOMENT, SKEWNESS, KURTOSIS, SEM
+
+
+%    This program 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.
+%
+%    This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
+
+%	$Id: sumskipnan.m 9033 2011-11-08 20:58:07Z schloegl $
+%       Copyright (C) 2000-2005,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
+%       Copyright (C) 2014 Dynare Team
+%       This function is part of the NaN-toolbox
+%       http://pub.ist.ac.at/~schloegl/matlab/NaN/
+
+
+global FLAG_NANS_OCCURED;
+
+if nargin<2,
+        DIM = [];
+end;
+if nargin<3,
+        W = [];
+end;
+
+% an efficient implementation in C of the following lines
+% could significantly increase performance
+% only one loop and only one check for isnan is needed
+% An MEX-Implementation is available in sumskipnan.cpp
+%
+% Outline of the algorithm:
+% for { k=1,o=0,count=0; k++; k<N}
+%   if ~isnan(i(k))
+%   {   o     += x(k);
+%               count += 1;
+%		tmp    = x(k)*x(k)
+%		o2    += tmp;
+%		o3    += tmp.*tmp;
+%       };
+
+if isempty(DIM),
+        DIM = find(size(x)>1,1);
+        if isempty(DIM), DIM = 1; end;
+end
+if (DIM<1), DIM = 1; end; %% Hack, because min([])=0 for FreeMat v3.5
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% non-float data
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if  (isempty(W) && (~(isa(x,'float') || isa(x,'double')))) || ~flag_implicit_skip_nan(), %%% skip always NaN's
+    if ~isempty(W)
+        error('SUMSKIPNAN: weighted sum of integers not supported, yet');
+    end;
+    x = double(x);
+    o = sum(x,DIM);
+    if nargout>1
+        sz = size(x);
+        N  = sz(DIM);
+        sz(DIM) = 1;
+        count = repmat(N,sz);
+        if nargout>2
+            x = x.*x;
+            SSQ = sum(x,DIM);
+        end;
+    end;
+    return;
+end;
+
+if (length(size(x))<DIM)
+    error('SUMSKIPNAN: DIM argument larger than number of dimensions of x');
+elseif ~isempty(W) && (size(x,DIM)~=numel(W))
+    error('SUMSKIPNAN: size of weight vector does not match size(x,DIM)');
+end;
+
+%% mex and oct files expect double
+x = double(x);
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% use Matlab-MEX function when available
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%if 1,
+try
+
+    %% using sumskipnan_mex.mex
+
+    %% !!! hack: FLAG_NANS_OCCURED is an output argument, reserve memory !!!
+    if isempty(FLAG_NANS_OCCURED),
+        FLAG_NANS_OCCURED = logical(0);  % default value
+    end;
+
+    if (nargout<2),
+        o = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
+        if (~isreal(x))
+            io = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
+            o  = o + i*io;
+        end;
+        return;
+    elseif (nargout==2),
+        [o,count] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
+        if (~isreal(x))
+            [io,icount] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
+            if any(count(:)-icount(:))
+                error('Number of NaNs differ for REAL and IMAG part');
+            else
+                o  = o+i*io;
+            end;
+        end;
+        return;
+    elseif (nargout>=3),
+        [o,count,SSQ] = sumskipnan_mex(real(x),DIM,FLAG_NANS_OCCURED,W);
+        if (~isreal(x))
+            [io,icount,iSSQ] = sumskipnan_mex(imag(x),DIM,FLAG_NANS_OCCURED,W);
+            if any(count(:)-icount(:))
+                error('Number of NaNs differ for REAL and IMAG part');
+            else
+                o  = o+i*io;
+                SSQ = SSQ+iSSQ;
+            end;
+        end;
+        return;
+    end;
+end;
+
+if ~isempty(W)
+    error('weighted sumskipnan requires sumskipnan_mex');
+end;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% count non-NaN's
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+if nargout>1,
+        count = sum(x==x,DIM);
+    FLAG_NANS_OCCURED = any(count(:)<size(x,DIM));
+end;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% replace NaN's with zero
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+x(x~=x) = 0;
+o = sum(x,DIM);
+
+if nargout>2,
+        x = real(x).^2 + imag(x).^2;
+        SSQ = sum(x,DIM);
+end;
+
+%!assert(sumskipnan([1,2],1),[1,2])
+%!assert(sumskipnan([1,NaN],2),1)
+%!assert(sumskipnan([1,NaN],2),1)
+%!assert(sumskipnan([nan,1,4,5]),10)
+%!assert(sumskipnan([nan,1,4,5]',1,[3;2;1;0]),6)
+
+
+
diff --git a/matlab/missing/corrcoef/tcdf.m b/matlab/missing/corrcoef/tcdf.m
new file mode 100644
index 0000000000000000000000000000000000000000..c282e0a1745c80b660f4a56425d08898f55ecbfb
--- /dev/null
+++ b/matlab/missing/corrcoef/tcdf.m
@@ -0,0 +1,62 @@
+function p = tcdf(x,n)
+% TCDF returns student cumulative distribtion function
+%
+% cdf = tcdf(x,DF);
+%
+% Computes the CDF of the students distribution
+%    with DF degrees of freedom
+% x,DF must be matrices of same size, or any one can be a scalar.
+%
+% see also: NORMCDF, TPDF, TINV
+
+% Reference(s):
+
+%	$Id: tcdf.m 9033 2011-11-08 20:58:07Z schloegl $
+%	Copyright (C) 2000-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>
+%   Copyright (C) 2014 Dynare Team
+%       This is part of the NaN-toolbox. For more details see
+%       http://pub.ist.ac.at/~schloegl/matlab/NaN/
+
+%    This program 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.
+%
+%    This program 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 this program; If not, see <http://www.gnu.org/licenses/>.
+
+
+% check size of arguments
+if all(size(x)==1)
+    x = repmat(x,size(n));
+elseif all(size(n)==1)
+    n = repmat(n,size(x));
+elseif all(size(x)==size(n))
+    ;	%% OK, do nothing
+else
+    error('size of input arguments must be equal or scalar')
+end;
+
+% allocate memory
+p = zeros(size(x));
+p((x==Inf) & (n>0)) = 1;
+
+% workaround for invalid arguments in BETAINC
+ix   = isnan(x) | ~(n>0);
+p(ix)= NaN;
+
+ix    = (x > -Inf) & (x < Inf) & (n > 0);
+p(ix) = betainc (n(ix) ./ (n(ix) + x(ix).^2), n(ix)/2, 1/2) / 2;
+
+ix    = find(x>0);
+p(ix) = 1 - p(ix);
+
+% shape output
+p = reshape(p,size(x));
+
+%!assert(tcdf(NaN,4),NaN)
diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m
index 29b56b318f8f83f31ec7e8c524b28efdf29b67e0..62ec92054e666ab69cd9b41ce1837de78e408647 100644
--- a/matlab/model_diagnostics.m
+++ b/matlab/model_diagnostics.m
@@ -169,6 +169,18 @@ for b=1:nb
 end
     
 if singularity_problem 
+    try
+        options_check=options;
+        options_check.noprint=1;
+        [eigenvalues_] = check(M, options_check, oo);
+        if any((abs(eigenvalues_)-1)<1e-6)
+            fprintf('MODEL_DIAGNOSTICS:  The singularity seems to be (partly) caused by the presence of a unit root\n')
+            fprintf('MODEL_DIAGNOSTICS:  as the absolute value of one eigenvalue is in the range of +-1e-6 to 1.\n')
+            fprintf('MODEL_DIAGNOSTICS:  If the model is actually supposed to feature unit root behavior, such a warning is expected,\n')
+            fprintf('MODEL_DIAGNOSTICS:  but you should nevertheless check whether there is an additional singularity problem.\n')
+        end
+    catch
+    end
     fprintf('MODEL_DIAGNOSTICS:  The presence of a singularity problem typically indicates that there is one\n')
     fprintf('MODEL_DIAGNOSTICS:  redundant equation entered in the model block, while another non-redundant equation\n')
     fprintf('MODEL_DIAGNOSTICS:  is missing. The problem often derives from Walras Law.\n')
@@ -192,7 +204,7 @@ if options.order == 1
         [junk,jacobia_] = feval([M.fname '_dynamic'],z(iyr0),exo_simul, ...
                             M.params, dr.ys, it_);
     end;
-elseif options.order == 2
+elseif options.order >= 2
     if (options.bytecode)
         [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
                             M.params, dr.ys, 1);
diff --git a/matlab/modules/dates b/matlab/modules/dates
new file mode 160000
index 0000000000000000000000000000000000000000..79e67d31857ee344b5d4c3906fe66dbce4fded6b
--- /dev/null
+++ b/matlab/modules/dates
@@ -0,0 +1 @@
+Subproject commit 79e67d31857ee344b5d4c3906fe66dbce4fded6b
diff --git a/matlab/modules/dseries b/matlab/modules/dseries
new file mode 160000
index 0000000000000000000000000000000000000000..5d76092a0ebca10c4c458b1d5fd5448ab2c9cff3
--- /dev/null
+++ b/matlab/modules/dseries
@@ -0,0 +1 @@
+Subproject commit 5d76092a0ebca10c4c458b1d5fd5448ab2c9cff3
diff --git a/matlab/osr1.m b/matlab/osr1.m
index 6f2b08dafee2c786ba605fd5119fd8fec4538f7b..eb23312ffe499556b3bcd583a7014db3e1a6a8a2 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -77,6 +77,8 @@ H0 = 1e-4*eye(np);
 crit=options_.osr.tolf;
 nit=options_.osr.maxit;
 
+%extract unique entries of covariance
+i_var=unique(i_var);
 %% do initial checks
 [loss,vx,info,exit_flag]=osr_obj(t0,i_params,inv_order_var(i_var),weights(i_var,i_var));
 if info~=0
@@ -95,6 +97,7 @@ end
 [f,p]=csminwel1('osr_obj',t0,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,i_params,...
                 inv_order_var(i_var),weights(i_var,i_var));
 osr_res.objective_function = f;
+M_.params(i_params)=p; %make sure optimal parameters are set (and not the last draw used in csminwel)
 for i=1:length(i_params)
     osr_res.optim_params.(deblank(M_.param_names(i_params(i),:))) = p(i);
 end
diff --git a/matlab/osr_obj.m b/matlab/osr_obj.m
index 431a941f7fb9030b9acb6b90bd8c2d328139bf2c..378d2b06ed0b50362aa14018eb3d07c3c86f741e 100644
--- a/matlab/osr_obj.m
+++ b/matlab/osr_obj.m
@@ -86,4 +86,4 @@ switch info(1)
 end
 
 vx = get_variance_of_endogenous_variables(dr,i_var);
-loss = weights(:)'*vx(:);
+loss = full(weights(:)'*vx(:));
diff --git a/matlab/particle/local_state_space_iteration/local_state_space_iteration_2.m b/matlab/particle/local_state_space_iteration/local_state_space_iteration_2.m
index bc205d1803497df5910a92423c8e8450a03edabb..0c6a52d071a74c84dfcd2c69cd16cce9233084b5 100644
--- a/matlab/particle/local_state_space_iteration/local_state_space_iteration_2.m
+++ b/matlab/particle/local_state_space_iteration/local_state_space_iteration_2.m
@@ -135,9 +135,9 @@ end
 %$ end
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(y1,ones(n,1));
-%$ t(2) = dyn_assert(y2,ones(n,1));
-%$ t(3) = dyn_assert(y2_,ones(n,1));
+%$ t(1) = dassert(y1,ones(n,1));
+%$ t(2) = dassert(y2,ones(n,1));
+%$ t(3) = dassert(y2_,ones(n,1));
 %$ T = all(t);
 %@eof:1
 
@@ -218,9 +218,9 @@ end
 %$     cd(where_am_i_coming_from);
 %$     dynare_config([],0);
 %$     % Check the results.
-%$     t(1) = dyn_assert(y1a,y1b);
-%$     t(2) = dyn_assert(y2a,y2b);
-%$     t(3) = dyn_assert(y2a_,y2b_);
+%$     t(1) = dassert(y1a,y1b);
+%$     t(2) = dassert(y2a,y2b);
+%$     t(3) = dassert(y2a_,y2b_);
 %$     T = all(t);
 %$ else
 %$     t(1) = 1;
@@ -258,13 +258,13 @@ end
 %$ t1 = toc;
 %$ tic, for i=1:10, y2 = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,2); end
 %$ t2 = toc;
-%$ t(1) = dyn_assert(y1,y2,1e-15); clear('y1');
+%$ t(1) = dassert(y1,y2,1e-15); clear('y1');
 %$ tic, for i=1:10, y3 = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,3); end
 %$ t3 = toc;
-%$ t(2) = dyn_assert(y2,y3,1e-15); clear('y2');
+%$ t(2) = dassert(y2,y3,1e-15); clear('y2');
 %$ tic, for i=1:10, y4 = local_state_space_iteration_2(yhat,epsilon,ghx,ghu,constant,ghxx,ghuu,ghxu,4); end
 %$ t4 = toc;
-%$ t(3) = dyn_assert(y4,y3,1e-15); clear('y3','y4');
+%$ t(3) = dassert(y4,y3,1e-15); clear('y3','y4');
 %$ t(4) = (t1>t2) && (t2>t3) && (t3>t4);
 %$ if ~t(4)
 %$     disp('Timmings:')
diff --git a/matlab/particle/online_auxiliary_filter.m b/matlab/particle/online_auxiliary_filter.m
index 4a8243a2df7391658b5f8630c6ca22369c194df1..1edcb66b9f7750a1745a2bba40493d95cce6e2ab 100644
--- a/matlab/particle/online_auxiliary_filter.m
+++ b/matlab/particle/online_auxiliary_filter.m
@@ -85,8 +85,8 @@ small_a = sqrt(1-h_square) ;
 
 % Initialization of parameter particles 
 xparam = zeros(number_of_parameters,number_of_particles) ;
-stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/100 ;
-stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/50 ;
+%stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/100 ;
+stderr = sqrt(bsxfun(@power,bounds(:,2)+bounds(:,1),2)/12)/10 ;
 i = 1 ;
 while i<=number_of_particles
     %candidate = start_param + .001*liu_west_chol_sigma_bar*randn(number_of_parameters,1) ;
@@ -110,7 +110,10 @@ std_xparam = zeros(number_of_parameters,sample_size) ;
 lb95_xparam = zeros(number_of_parameters,sample_size) ;
 ub95_xparam = zeros(number_of_parameters,sample_size) ;
 
-%% The Online filter 
+disp(0) 
+disp(start_param)
+    
+    %% The Online filter 
 for t=1:sample_size
     disp(t)
     % Moments of parameters particles distribution 
diff --git a/matlab/particle/solve_model_for_online_filter.m b/matlab/particle/solve_model_for_online_filter.m
index a9cefe4074195ebd81372bae489b1ab6d31ee9fa..31fb7f7e69960c27c4a2cb5173a0290385ac9349 100644
--- a/matlab/particle/solve_model_for_online_filter.m
+++ b/matlab/particle/solve_model_for_online_filter.m
@@ -307,11 +307,18 @@ end
 
 ReducedForm.ghx  = dr.ghx(restrict_variables_idx,:);
 ReducedForm.ghu  = dr.ghu(restrict_variables_idx,:);
-ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
-ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:);
-ReducedForm.ghxu = dr.ghxu(restrict_variables_idx,:);
 ReducedForm.steadystate = dr.ys(dr.order_var(restrict_variables_idx));
-ReducedForm.constant = ReducedForm.steadystate + .5*dr.ghs2(restrict_variables_idx);
+if DynareOptions.order>1
+    ReducedForm.ghxx = dr.ghxx(restrict_variables_idx,:);
+    ReducedForm.ghuu = dr.ghuu(restrict_variables_idx,:);
+    ReducedForm.ghxu = dr.ghxu(restrict_variables_idx,:);
+    ReducedForm.constant = ReducedForm.steadystate + .5*dr.ghs2(restrict_variables_idx);
+else 
+    ReducedForm.ghxx = zeros(size(restrict_variables_idx,1),size(dr.kstate,2));
+    ReducedForm.ghuu = zeros(size(restrict_variables_idx,1),size(dr.ghu,2));
+    ReducedForm.ghxu = zeros(size(restrict_variables_idx,1),size(dr.ghx,2));
+    ReducedForm.constant = ReducedForm.steadystate ;
+end
 ReducedForm.state_variables_steady_state = dr.ys(dr.order_var(state_variables_idx));
 ReducedForm.Q = Q;
 ReducedForm.H = H;
diff --git a/matlab/particle/traditional_resampling.m b/matlab/particle/traditional_resampling.m
index 6c7b70ed0b8087cbee52cff03e1942ebb6013e1c..a9d86eb36e1705d95b50adfa21279a74ccabf937 100644
--- a/matlab/particle/traditional_resampling.m
+++ b/matlab/particle/traditional_resampling.m
@@ -231,7 +231,7 @@ end
 %$ end
 %$
 %$ % Check results.
-%$ t(1) = dyn_assert(indx1,indx1_);
-%$ t(2) = dyn_assert(indx2,indx2_);
+%$ t(1) = dassert(indx1,indx1_);
+%$ t(2) = dassert(indx2,indx2_);
 %$ T = all(t);
 %@eof:3
\ No newline at end of file
diff --git a/matlab/perfect_foresight_solver.m b/matlab/perfect_foresight_solver.m
index ec88ab319312cf0df65070763c90273e7403baad..bfeb16e4f309ef2e33dcb4953923df7d03a12f53 100644
--- a/matlab/perfect_foresight_solver.m
+++ b/matlab/perfect_foresight_solver.m
@@ -141,7 +141,7 @@ end
 if oo_.deterministic_simulation.status == 1
     disp('Perfect foresight solution found.')
 else
-    disp('Failed to solve perfect foresight model')
+    warning('Failed to solve perfect foresight model')
 end
 
 dyn2vec;
diff --git a/matlab/pm3.m b/matlab/pm3.m
index 9e34bf1c045538a3f2d2839ad4918d22c768455b..583cd6ff04ebee6b038ac0b168a260870639c966 100644
--- a/matlab/pm3.m
+++ b/matlab/pm3.m
@@ -1,10 +1,31 @@
 function pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryName,var_type)
+% pm3(n1,n2,ifil,B,tit1,tit2,tit3,tit_tex,names1,names2,name3,DirectoryName,var_type)
+% Computes, stores and plots the posterior moment statistics.
+%
+% Inputs:
+%  n1           [scalar] size of first dimension of moment matrix
+%  n2           [scalar] size of second dimension of moment matrix
+%  ifil         [scalar] number of moment files to load
+%  B         [scalar] number of subdraws
+%  tit1         [string] Figure title 
+%  tit2         [string] not used
+%  tit3         [string] Save name for figure
+%  tit_tex      [cell array] TeX-Names for Variables
+%  name1        [cell array] Names of variables subset selected for moments
+%  name2            [cell array] Names of all variables in the moment matrix from
+%                       which names1 is selected
+%  name3        [string] Name of the field in oo_ structure to be set
+%  name3        [string] Name of the field in oo_ structure to be set
+%  DirectoryName [string] Name of the directory in which to save and from
+%                       where to read
+%  var_type     [string] suffix of the filename from which to load moment
+%                   matrix
 
 % PARALLEL CONTEXT
 % See also the comment in random_walk_metropolis_hastings.m funtion.
 
 
-% Copyright (C) 2007-2013 Dynare Team
+% Copyright (C) 2007-2014 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -40,9 +61,8 @@ else
     end
 end
 if options_.TeX
-    % needs to be fixed
     if isempty(tit_tex),
-        tit_tex=M_.endo_names_tex;
+        tit_tex=names1;
     end
         
     varlist_TeX = [];
@@ -126,8 +146,8 @@ for i = 1:nvar
     eval(['oo_.' name3 '.Median.' name ' = Median(:,i);']);
     eval(['oo_.' name3 '.Var.' name ' = Var(:,i);']);
     eval(['oo_.' name3 '.deciles.' name ' = Distrib(:,:,i);']);
-    eval(['oo_.' name3 '.HPDinf.' name ' = HPD(1,:,i);']);
-    eval(['oo_.' name3 '.HPDsup.' name ' = HPD(2,:,i);']);
+    eval(['oo_.' name3 '.HPDinf.' name ' = HPD(1,:,i)'';']);
+    eval(['oo_.' name3 '.HPDsup.' name ' = HPD(2,:,i)'';']);
     if filter_step_ahead_indicator
         for K_step = 1:length(options_.filter_step_ahead)
             name4=['Filtered_Variables_',num2str(K_step),'_step_ahead'];
diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m
index f06e0d433ea024755cd1d0069a03c935d2269685..35a0b481f682cc8841b2d7bf7ea665d3f472f0ea 100644
--- a/matlab/prior_posterior_statistics.m
+++ b/matlab/prior_posterior_statistics.m
@@ -58,6 +58,7 @@ naK = length(options_.filter_step_ahead);
 MaxNumberOfBytes=options_.MaxNumberOfBytes;
 endo_nbr=M_.endo_nbr;
 exo_nbr=M_.exo_nbr;
+meas_err_nbr=length(M_.Correlation_matrix_ME);
 nvobs     = length(options_.varobs);
 iendo = 1:endo_nbr;
 horizon = options_.forecast;
@@ -102,8 +103,8 @@ if naK
 end
 
 if horizon
-    MAX_nforc1 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*(horizon+maxlag))/8));
-    MAX_nforc2 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*(horizon+maxlag))/ ...
+    MAX_nforc1 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*horizon)/8));
+    MAX_nforc2 = min(B,ceil(MaxNumberOfBytes/((endo_nbr)*horizon)/ ...
                             8));
     IdObs    = bayestopt_.mfys;
 
@@ -144,8 +145,8 @@ if options_.filter_step_ahead
     run_smoother = 1;
 end
 if options_.forecast
-    stock_forcst_mean = zeros(endo_nbr,horizon+maxlag,MAX_nforc1);
-    stock_forcst_point = zeros(endo_nbr,horizon+maxlag,MAX_nforc2);
+    stock_forcst_mean = zeros(endo_nbr,horizon,MAX_nforc1);
+    stock_forcst_point = zeros(endo_nbr,horizon,MAX_nforc2);
     run_smoother = 1;
 end
 
@@ -268,10 +269,15 @@ if options_.smoother
         '',M_.exo_names,M_.exo_names_tex,M_.exo_names,...
         M_.exo_names,'SmoothedShocks',DirectoryName,'_inno');
     if nvn
-        % needs to  be fixed
-        %        pm3(endo_nbr,gend,ifil(3),B,'Smoothed measurement errors',...
-        %            M_.endo_names(SelecVariables),M_.endo_names,'tit_tex',M_.endo_names,...
-        %            'names2','smooth_errors',[M_.fname '/metropolis'],'_error')
+        for obs_iter=1:length(options_.varobs)        
+            meas_error_names{obs_iter,1}=['SE_EOBS_' M_.endo_names(strmatch(options_.varobs{obs_iter},M_.endo_names,'exact'),:)];
+            texnames{obs_iter,1}=['SE_EOBS_' M_.endo_names_tex(strmatch(options_.varobs{obs_iter},M_.endo_names,'exact'),:)];
+        end
+        meas_error_names=char(meas_error_names);
+        texnames=char(texnames);
+        pm3(meas_err_nbr,gend,ifil(3),B,'Smoothed measurement errors',...
+           '',meas_error_names,texnames,meas_error_names,...
+           meas_error_names,'SmoothedMeasurementErrors',DirectoryName,'_error')
     end
 end
 
@@ -286,10 +292,10 @@ if options_.filtered_vars
 end
 
 if options_.forecast
-    pm3(endo_nbr,horizon+maxlag,ifil(6),B,'Forecasted variables (mean)',...
+    pm3(endo_nbr,horizon,ifil(6),B,'Forecasted variables (mean)',...
         '',varlist,M_.endo_names_tex,M_.endo_names,...
         varlist,'MeanForecast',DirectoryName,'_forc_mean');
-    pm3(endo_nbr,horizon+maxlag,ifil(6),B,'Forecasted variables (point)',...
+    pm3(endo_nbr,horizon,ifil(6),B,'Forecasted variables (point)',...
         '',varlist,M_.endo_names_tex,M_.endo_names,...
         varlist,'PointForecast',DirectoryName,'_forc_point');
 end
diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m
index 63443a6ae12bb054cd793df6e51bc64a110ac97e..ef8328c3577d132692e078cff232214cf21e1271 100644
--- a/matlab/prior_posterior_statistics_core.m
+++ b/matlab/prior_posterior_statistics_core.m
@@ -135,8 +135,8 @@ if run_smoother
   stock_update=NaN(endo_nbr,gend,MAX_nsmoo);
   stock_innov=NaN(M_.exo_nbr,gend,MAX_ninno);
   if horizon
-      stock_forcst_mean= NaN(endo_nbr,horizon+maxlag,MAX_nforc1);
-      stock_forcst_point = NaN(endo_nbr,horizon+maxlag,MAX_nforc2);
+      stock_forcst_mean= NaN(endo_nbr,horizon,MAX_nforc1);
+      stock_forcst_point = NaN(endo_nbr,horizon,MAX_nforc2);
   end
 end
 if nvn
@@ -214,8 +214,8 @@ for b=fpar:B
                 yf1 = yf1 + repmat(SteadyState',[horizon+maxlag,1,1]);
             end
 
-            stock_forcst_mean(:,:,irun(6)) = yf';
-            stock_forcst_point(:,:,irun(7)) = yf1';
+            stock_forcst_mean(:,:,irun(6)) = yf(maxlag+1:end,:)';
+            stock_forcst_point(:,:,irun(7)) = yf1(maxlag+1:end,:)';
         end
     else
         [T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
diff --git a/matlab/qmc_sequence.m b/matlab/qmc_sequence.m
index bfbb15dff4dcb2a5c1867769674b25ae2bdd8508..aa26ae2d3cc962b05f59e46ceeaf47c72ceb9b29 100644
--- a/matlab/qmc_sequence.m
+++ b/matlab/qmc_sequence.m
@@ -111,9 +111,9 @@
 %$ [draws2, Q] = qmc_sequence(d,S,0,n);
 %$ [draws3, P] = qmc_sequence(d,s,0,2*n);
 %$
-%$ t(1) = dyn_assert(s,int64(0));
-%$ t(2) = dyn_assert(P,Q);
-%$ t(3) = dyn_assert([draws1,draws2],draws3);
+%$ t(1) = dassert(s,int64(0));
+%$ t(2) = dassert(P,Q);
+%$ t(3) = dassert([draws1,draws2],draws3);
 %$ T = all(t);
 %@eof:2
 
@@ -129,8 +129,8 @@
 %$ draws3 = draws2;
 %$ draws3(1,:) = 2*draws2(1,:);
 %$ draws3(2,:) = 3*draws2(2,:)-1;
-%$ t(1) = dyn_assert(S,Q);
-%$ t(2) = dyn_assert(draws1,draws3);
+%$ t(1) = dassert(S,Q);
+%$ t(2) = dassert(draws1,draws3);
 %$ T = all(t);
 %@eof:3
 
@@ -143,15 +143,15 @@
 %$
 %$ [draws, S] = qmc_sequence(d,s,2,n,radius);
 %$
-%$ t(1) = dyn_assert(sqrt(draws(:,3)'*draws(:,3)),radius,1e-14);
-%$ t(2) = dyn_assert(sqrt(draws(:,5)'*draws(:,5)),radius,1e-14);
-%$ t(3) = dyn_assert(sqrt(draws(:,7)'*draws(:,7)),radius,1e-14);
-%$ t(4) = dyn_assert(sqrt(draws(:,11)'*draws(:,11)),radius,1e-14);
-%$ t(5) = dyn_assert(sqrt(draws(:,13)'*draws(:,13)),radius,1e-14);
-%$ t(6) = dyn_assert(sqrt(draws(:,17)'*draws(:,17)),radius,1e-14);
-%$ t(7) = dyn_assert(sqrt(draws(:,19)'*draws(:,19)),radius,1e-14);
-%$ t(8) = dyn_assert(sqrt(draws(:,23)'*draws(:,23)),radius,1e-14);
-%$ t(9) = dyn_assert(sqrt(draws(:,29)'*draws(:,29)),radius,1e-14);
+%$ t(1) = dassert(sqrt(draws(:,3)'*draws(:,3)),radius,1e-14);
+%$ t(2) = dassert(sqrt(draws(:,5)'*draws(:,5)),radius,1e-14);
+%$ t(3) = dassert(sqrt(draws(:,7)'*draws(:,7)),radius,1e-14);
+%$ t(4) = dassert(sqrt(draws(:,11)'*draws(:,11)),radius,1e-14);
+%$ t(5) = dassert(sqrt(draws(:,13)'*draws(:,13)),radius,1e-14);
+%$ t(6) = dassert(sqrt(draws(:,17)'*draws(:,17)),radius,1e-14);
+%$ t(7) = dassert(sqrt(draws(:,19)'*draws(:,19)),radius,1e-14);
+%$ t(8) = dassert(sqrt(draws(:,23)'*draws(:,23)),radius,1e-14);
+%$ t(9) = dassert(sqrt(draws(:,29)'*draws(:,29)),radius,1e-14);
 %$ T = all(t);
 %@eof:4
 
@@ -174,6 +174,6 @@
 %$
 %$ COVARIANCE = draws*draws'/(b*n);
 %$
-%$ t(1) = dyn_assert(covariance,COVARIANCE,1e-6);
+%$ t(1) = dassert(covariance,COVARIANCE,1e-6);
 %$ T = all(t);
 %@eof:5
\ No newline at end of file
diff --git a/matlab/quadratic_matrix_equation_solver.m b/matlab/quadratic_matrix_equation_solver.m
index 146dc9aee91a36661773ce04e3a4ce9f64ebe28e..f222df843f9aa5cf76bf61ef401d269f23a9ec31 100644
--- a/matlab/quadratic_matrix_equation_solver.m
+++ b/matlab/quadratic_matrix_equation_solver.m
@@ -152,7 +152,7 @@ function t = line_search(A,H,F)
 %$ tic, X2 = quadratic_matrix_equation_solver(A,B,C,1e-16,100,1,zeros(n)); toc
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(X1,X2,1e-12);
+%$ t(1) = dassert(X1,X2,1e-12);
 %$
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/reduced_rank_cholesky.m b/matlab/reduced_rank_cholesky.m
index af16453b396710593b2da656746fa8764e1dd6fc..1af9ec6090e2838d9f9131275d22b90975885032 100644
--- a/matlab/reduced_rank_cholesky.m
+++ b/matlab/reduced_rank_cholesky.m
@@ -92,6 +92,6 @@ end
 %$
 %$
 %$ % Check the results.
-%$ t(2) = dyn_assert(T,chol(X),1e-16);
+%$ t(2) = dassert(T,chol(X),1e-16);
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/replace_object_in_a_one_dimensional_cell_array.m b/matlab/replace_object_in_a_one_dimensional_cell_array.m
index dd717454fb244d520be40765450d73523c096045..9f3c03a25146aeaa85e7ce5e777256d5f5705c39 100644
--- a/matlab/replace_object_in_a_one_dimensional_cell_array.m
+++ b/matlab/replace_object_in_a_one_dimensional_cell_array.m
@@ -74,7 +74,7 @@ end
 %$ end
 %$
 %$ if t(1)
-%$   t(2) = dyn_assert(C,[B; A(2:3)]);
+%$   t(2) = dassert(C,[B; A(2:3)]);
 %$ end
 %$ T = all(t);
 %@eof:1
@@ -91,7 +91,7 @@ end
 %$ 
 %$ D = {'A1';'B1';'A4'};
 %$ if t(1)
-%$   t(2) = dyn_assert(C,D);
+%$   t(2) = dassert(C,D);
 %$ end
 %$ T = all(t);
 %@eof:2
\ No newline at end of file
diff --git a/matlab/resol.m b/matlab/resol.m
index cae7a1a49cbdad4ef95548f4f05d301bb94725ac..92c775806782913052368174b1042aa847fc1eca 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -116,18 +116,18 @@ if options.loglinear
         fprintf('You are attempting to simulate/estimate a loglinear approximation of a model, but\n')
         fprintf('the steady state level of the following variables is not strictly positive:\n')
         for var_iter=1:length(idx)
-            fprintf(' - %s (%s)\n',deblank(variables_with_non_positive_steady_state(var_iter,:)), num2str(dr.ys(idx)))
+            fprintf(' - %s (%s)\n',deblank(variables_with_non_positive_steady_state(var_iter,:)), num2str(dr.ys(idx(var_iter))))
         end
         if isestimation()
-            fprintf('You should check that the priors and/or bounds over the deep parameters are such')
-            fprintf('the steady state levels of all the variables are strictly positive, or consider')
-            fprintf('a linearization of the model instead of a log linearization.')
+            fprintf('You should check that the priors and/or bounds over the deep parameters are such\n')
+            fprintf('that the steady state levels of all the variables are strictly positive, or consider\n')
+            fprintf('a linearization of the model instead of a log linearization.\n')
         else
-            fprintf('You should check that the calibration of the deep parameters is such that the')
-            fprintf('steady state levels of all the variables are strictly positive, or consider')
-            fprintf('a linearization of the model instead of a log linearization.')
+            fprintf('You should check that the calibration of the deep parameters is such that the\n')
+            fprintf('steady state levels of all the variables are strictly positive, or consider\n')
+            fprintf('a linearization of the model instead of a log linearization.\n')
         end
-        error('stoch_simul::resol: The loglinearization of the model cannot be performed because the steady state is not strictly positive!')
+        error('stoch_simul::resol: The loglinearization of the model cannot be performed, because the steady state is not strictly positive!')
     end
 end
 
diff --git a/matlab/sim1.m b/matlab/sim1.m
index 87517461af3fd04107b89d7732e87c36d85ad2b3..bbf41d1936cae674da9d6569200dff1a9a519b5b 100644
--- a/matlab/sim1.m
+++ b/matlab/sim1.m
@@ -136,6 +136,9 @@ for iter = 1:options_.simul.maxit
         if any(isnan(res)) || any(isinf(res)) || any(isnan(Y)) || any(isinf(Y))
             fprintf('\nWARNING: NaN or Inf detected in the residuals or endogenous variables.\n');    
         end
+        if ~isreal(res) || ~isreal(Y)
+            fprintf('\nWARNING: Imaginary parts detected in the residuals or endogenous variables.\n');    
+        end        
         skipline()
     end
     
@@ -162,7 +165,7 @@ end
 
 
 if stop
-    if any(isnan(res)) || any(isinf(res)) || any(isnan(Y)) || any(isinf(Y))
+    if any(isnan(res)) || any(isinf(res)) || any(isnan(Y)) || any(isinf(Y)) || ~isreal(res) || ~isreal(Y)
         oo_.deterministic_simulation.status = 0;% NaN or Inf occurred
         oo_.deterministic_simulation.error = err;
         oo_.deterministic_simulation.iterations = iter;
@@ -171,7 +174,12 @@ if stop
         skipline();
         fprintf('\nSimulation terminated after %d iterations.\n',iter);
         fprintf('Total time of simulation: %16.13f\n',etime(clock,h1));
-        fprintf('WARNING: Simulation terminated with NaN or Inf in the residuals or endogenous variables. There is most likely something wrong with your model.\n');
+        if ~isreal(res) || ~isreal(Y)
+            fprintf('WARNING: Simulation terminated with imaginary parts in the residuals or endogenous variables.\n');
+        else
+            fprintf('WARNING: Simulation terminated with NaN or Inf in the residuals or endogenous variables.\n');
+        end
+        fprintf('WARNING: There is most likely something wrong with your model. Try model_diagnostics.\n');
     else
         skipline();
         fprintf('\nSimulation concluded successfully after %d iterations.\n',iter);
diff --git a/matlab/simplex_optimization_routine.m b/matlab/simplex_optimization_routine.m
index 9d60b5774ead3d38ad97b9b3576f2271a37aa517..33843cf0d589caef3391eef246f5a3fc39cbdc9c 100644
--- a/matlab/simplex_optimization_routine.m
+++ b/matlab/simplex_optimization_routine.m
@@ -1,4 +1,4 @@
-function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
+function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,var_names,varargin)
 
 % Nelder-Mead like optimization routine (see http://en.wikipedia.org/wiki/Nelder-Mead_method)
 %
@@ -11,6 +11,8 @@ function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,o
 %  o objective_function     [string]                  Name of the objective function to be minimized.
 %  o x                      [double]                  n*1 vector, starting guess of the optimization routine.
 %  o options                [structure]               Options of this implementation of the simplex algorithm.
+%  o var_names              [cell]                    Names of parameters
+%                                                       for verbose output
 %  o varargin               [cell of structures]      Structures to be passed to the objective function.
 %
 %     varargin{1} --> DynareDataset
@@ -45,14 +47,16 @@ function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,o
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 % Set verbose mode
-verbose = 2;
+verbose = options.verbosity;
 
 % Set number of control variables.
 number_of_variables = length(x);
 
 % get options.
 if isempty(options.maxfcall)
-    max_func_calls = options.maxfcallfactor*number_of_variables
+    max_func_calls = options.maxfcallfactor*number_of_variables;
+else
+    max_func_calls=options.maxfcall;
 end
 
 % Set tolerance parameter.
@@ -153,8 +157,8 @@ else
 end
 
 % Set delta parameter.
-if isfield(options,'delta_parameter')% Size of the simplex
-    delta = options.delta_parameter;
+if isfield(options,'delta_factor')% Size of the simplex
+    delta = options.delta_factor;
 else
     delta = 0.05;
 end
@@ -194,7 +198,7 @@ else
         disp(['Current parameter values: '])
         fprintf(1,'%s: \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \n','Names','Best point', 'Worst point', 'Mean values', 'Min values', 'Max values');
         for i=1:number_of_variables
-            fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',varargin{6}.name{i},v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
+            fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',var_names{i},v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
         end
         skipline()
     end
@@ -406,7 +410,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
         disp(['Current parameter values: '])
         fprintf(1,'%s: \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \n','Names','Best point', 'Worst point', 'Mean values', 'Min values', 'Max values');
         for i=1:number_of_variables
-            fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',varargin{6}.name{i}, v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
+            fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',var_names{i}, v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
         end
         skipline()
     end
@@ -432,7 +436,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
                 disp(['values for the control variables. '])
                 disp(['New value of delta (size of the new simplex) is: '])
                 for i=1:number_of_variables
-                    fprintf(1,'%s: \t\t\t %+8.6f \n',varargin{6}.name{i}, delta(i));
+                    fprintf(1,'%s: \t\t\t %+8.6f \n',var_names{i}, delta(i));
                 end
             end
             % Reset counters
@@ -479,7 +483,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
                 disp(['values for the control variables. '])
                 disp(['New value of delta (size of the new simplex) is: '])
                 for i=1:number_of_variables
-                    fprintf(1,'%s: \t\t\t %+8.6f \n',varargin{6}.name{i}, delta(i));
+                    fprintf(1,'%s: \t\t\t %+8.6f \n',var_names{i}, delta(i));
                 end
             end
             % Reset counters
@@ -499,7 +503,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
 end% while loop.
 
 x(:) = v(:,1);
-fval = fv(:,1);
+fval = fv(1);
 exitflag = 1;
 
 if func_count>= max_func_calls
diff --git a/matlab/skipline.m b/matlab/skipline.m
index feb5bd83fde2b7c98177d764cdb7d863fa1e3766..6eadae93a57b1305430e7a9b810b79a7b65f0be3 100644
--- a/matlab/skipline.m
+++ b/matlab/skipline.m
@@ -1,6 +1,17 @@
-function skipline(n,fid)
-    
-% Copyright (C) 2013 Dynare Team
+function skipline(n, fid)
+% function skipline(n, fid)
+% This function prints n newlines to fid
+%
+% INPUTS 
+%
+%   n        [integer]    Number of newlines to print
+%   fid      [integer]    file id returned by fopen
+%    
+% OUTPUTS 
+%   None
+%
+
+% Copyright (C) 2013-2014 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -17,18 +28,14 @@ function skipline(n,fid)
 % You should have received a copy of the GNU General Public License
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.    
 
-if nargin<2
-    fid = 1;
+if nargin < 2
+	fid = 1;
+	if nargin < 1
+		n = 1;
+	end
 end
 
-if nargin<1
-    fid = 1;
+for i=1:n
+	fprintf(fid,'\n');
 end
-    
-if ~nargin || isequal(n,1)
-    fprintf(fid,'\n');
-else
-    for i=1:n
-        fprintf(fid,'\n');
-    end
 end
\ No newline at end of file
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index 8f22a025ce62717203399927590206bba79dfc41..64b9b2c810933f2239c54e60f163334703f582c9 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -241,9 +241,19 @@ else
         dr = dyn_second_order_solver(jacobia_,hessian1,dr,M_,...
                                      options_.threads.kronecker.A_times_B_kronecker_C,...
                                      options_.threads.kronecker.sparse_hessian_times_B_kronecker_C);
+                                 
+        % reordering second order derivatives, used for deterministic
+        % variables below
+        k1 = nonzeros(M_.lead_lag_incidence(:,order_var)');
+        kk = [k1; length(k1)+(1:M_.exo_nbr+M_.exo_det_nbr)'];
+        nk = size(kk,1);
+        kk1 = reshape([1:nk^2],nk,nk);
+        kk1 = kk1(kk,kk);
+        hessian1 = hessian1(:,kk1(:));
     end
 end
 
+
 %exogenous deterministic variables
 if M_.exo_det_nbr > 0
     gx = dr.gx;
diff --git a/matlab/test_for_deep_parameters_calibration.m b/matlab/test_for_deep_parameters_calibration.m
index c5b88b40fb1790852aba625f8ef772a5ffe908b7..b45ad399bdd5b3b41f98b7f567a78ebfb0e00cb3 100644
--- a/matlab/test_for_deep_parameters_calibration.m
+++ b/matlab/test_for_deep_parameters_calibration.m
@@ -42,7 +42,7 @@ if ~isempty(plist)
     end
     tmp = dbstack;
     message = [message, ' when using ' tmp(2).name '. '];
-    message = [message, 'If these parameters are not initialized in a steadystate file, Dynare may not be able to solve the model...'];
+    message = [message, 'If these parameters are not initialized in a steadystate file or a steady_state_model-block, Dynare may not be able to solve the model...'];
     message_id  = 'Dynare:ParameterCalibration:NaNValues';
     warning(message_id,message);
     if strmatch('optimal_policy_discount_factor',plist,'exact')
diff --git a/matlab/utilities/dataset/describe_missing_data.m b/matlab/utilities/dataset/describe_missing_data.m
index 69589933ee0cdadd7e57b93344f11d04edb36445..f13bb6c7aaeb6621bdbf945faff6c96e0e37a2e2 100644
--- a/matlab/utilities/dataset/describe_missing_data.m
+++ b/matlab/utilities/dataset/describe_missing_data.m
@@ -121,9 +121,9 @@ end
 %$ [B,C,D,E] = describe_missing_data(transpose(A));
 %$
 %$ % Check the results.
-%$ t(1) = dyn_assert(B,eB);
-%$ t(2) = dyn_assert(C,eC);
-%$ t(3) = dyn_assert(D,eD);
-%$ t(4) = dyn_assert(E,eE);
+%$ t(1) = dassert(B,eB);
+%$ t(2) = dassert(C,eC);
+%$ t(3) = dassert(D,eD);
+%$ t(4) = dassert(E,eE);
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dataset/makedataset.m b/matlab/utilities/dataset/makedataset.m
index f1ca78fde6541fea4ecbc705855fa53dee3d100d..86f40df100f51748e6fd02721cfbb59757b94a41 100644
--- a/matlab/utilities/dataset/makedataset.m
+++ b/matlab/utilities/dataset/makedataset.m
@@ -36,7 +36,8 @@ end
 if isempty(DynareOptions.datafile) && isempty(DynareOptions.dataset.file) && isempty(DynareOptions.dataset.series)
     if gsa_flag
         DynareDataset = dseries();
-        DatasetInfo = [];
+        DatasetInfo = struct('missing', struct('state', 0, 'aindex', [], 'vindex', [], 'number_of_observations', NaN, 'no_more_missing_observations', NaN), ...
+                     'descriptive', struct('mean', [], 'covariance', [], 'correlation', [], 'autocovariance', []));
         newdatainterface=0;
         return
     else
diff --git a/matlab/utilities/dates/add_periods_to_array_of_dates.m b/matlab/utilities/dates/add_periods_to_array_of_dates.m
deleted file mode 100644
index 48a371739a22767f65bd1e2215c1ae71a704a7e6..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/add_periods_to_array_of_dates.m
+++ /dev/null
@@ -1,83 +0,0 @@
-function time = add_periods_to_array_of_dates(time, freq, p)  % --*-- Unitary tests --*--
-
-% Adds a p periods (p can be negative) to a date (or a set of dates) characterized by array time and frequency freq.
-    
-% 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(rows(time),1) && length(p)>1
-    time = repmat(time,length(p),1);
-end
-
-time(:,1) = time(:,1) + fix(p/freq);
-time(:,2) = time(:,2) + rem(p,freq);
-
-id1 = find(time(:,2)>freq);
-if ~isempty(id1)
-    time(id1,1) = time(id1,1) + 1;
-    time(id1,2) = time(id1,2) - freq;
-end
-
-id2 = find(time(:,2)<1);
-if ~isempty(id2)
-    time(id2,1) = time(id2,1) - 1;
-    time(id2,2) = time(id2,2) + freq;
-end
-
-%@test:1
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 1),[1950 2]);
-%$ t(2) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 2),[1950 3]);
-%$ t(3) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 3),[1950 4]);
-%$ t(4) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 4),[1951 1]);
-%$ t(5) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 5),[1951 2]);
-%$ t(6) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 6),[1951 3]);
-%$ t(7) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 7),[1951 4]);
-%$ t(8) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, 8),[1952 1]);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates(repmat([1950 1],8,1), 4, transpose(1:8)),[1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4; 1952 1]);
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates([1950 1], 1, 1),[1951 1]);
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates([1950 1; 1950 2; 1950 3; 1950 4], 4, 1),[1950 2; 1950 3; 1950 4; 1951 1]);
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, transpose(1:8)),[1950 2; 1950 3; 1950 4; 1951 1; 1951 2; 1951 3; 1951 4; 1952 1]);
-%$ T = all(t);
-%@eof:5
-
-%@test:6
-%$ t(1) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -1),[1949 4]);
-%$ t(2) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -2),[1949 3]);
-%$ t(3) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -3),[1949 2]);
-%$ t(4) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -4),[1949 1]);
-%$ t(5) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -5),[1948 4]);
-%$ t(6) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -6),[1948 3]);
-%$ t(7) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -7),[1948 2]);
-%$ t(8) = dyn_assert(add_periods_to_array_of_dates([1950 1], 4, -8),[1948 1]);
-%$ T = all(t);
-%@eof:6
\ No newline at end of file
diff --git a/matlab/utilities/dates/add_periods_to_date.m b/matlab/utilities/dates/add_periods_to_date.m
deleted file mode 100644
index 22ff62c5d109c7b65cb4b5e7a157c4ce3e16e7ef..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/add_periods_to_date.m
+++ /dev/null
@@ -1,57 +0,0 @@
-function time = add_periods_to_date(time, freq, p)  % --*-- Unitary tests --*--
-
-% Adds a p periods (p can be negative) to a date (or a set of dates) characterized by array time and frequency freq.
-    
-% 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/>.
-
-time(1) = time(1) + fix(p/freq);
-time(2) = time(2) + rem(p,freq);
-
-if time(2)>freq
-    time(1) = time(1) + 1;
-    time(2) = time(2) - freq;
-end
-
-if time(2)<1
-    time(1) = time(1) - 1;
-    time(2) = time(2) + freq;
-end
-
-%@test:1
-%$ t(1) = dyn_assert(add_periods_to_date([1950 1], 4, 1),[1950 2]);
-%$ t(2) = dyn_assert(add_periods_to_date([1950 1], 4, 2),[1950 3]);
-%$ t(3) = dyn_assert(add_periods_to_date([1950 1], 4, 3),[1950 4]);
-%$ t(4) = dyn_assert(add_periods_to_date([1950 1], 4, 4),[1951 1]);
-%$ t(5) = dyn_assert(add_periods_to_date([1950 1], 4, 5),[1951 2]);
-%$ t(6) = dyn_assert(add_periods_to_date([1950 1], 4, 6),[1951 3]);
-%$ t(7) = dyn_assert(add_periods_to_date([1950 1], 4, 7),[1951 4]);
-%$ t(8) = dyn_assert(add_periods_to_date([1950 1], 4, 8),[1952 1]);
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ t(1) = dyn_assert(add_periods_to_date([1950 1], 4, -1),[1949 4]);
-%$ t(2) = dyn_assert(add_periods_to_date([1950 1], 4, -2),[1949 3]);
-%$ t(3) = dyn_assert(add_periods_to_date([1950 1], 4, -3),[1949 2]);
-%$ t(4) = dyn_assert(add_periods_to_date([1950 1], 4, -4),[1949 1]);
-%$ t(5) = dyn_assert(add_periods_to_date([1950 1], 4, -5),[1948 4]);
-%$ t(6) = dyn_assert(add_periods_to_date([1950 1], 4, -6),[1948 3]);
-%$ t(7) = dyn_assert(add_periods_to_date([1950 1], 4, -7),[1948 2]);
-%$ t(8) = dyn_assert(add_periods_to_date([1950 1], 4, -8),[1948 1]);
-%$ T = all(t);
-%@eof:2
\ No newline at end of file
diff --git a/matlab/utilities/dates/date2string.m b/matlab/utilities/dates/date2string.m
deleted file mode 100644
index 26358ee23fc2060372421b542bb2bd846232df6a..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/date2string.m
+++ /dev/null
@@ -1,51 +0,0 @@
-function s = date2string(varargin)
- 
-% Returns date as a string.
-%
-% INPUTS 
-%  o varargin{1}     + dates object with one element, if nargin==1.
-%                    + 1*2 vector of integers (first element is the year, second element is the subperiod), if nargin==2.
-%  o varargin{2}     integer scalar equal to 1, 4, 12 or 52 (frequency).
-%
-% OUTPUTS 
-%  o s               string.
-    
-% 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,1) 
-    if ~(isa(varargin{1},'dates') && isequal(length(varargin{1}),1))
-        error(['dates::format: Input argument ' inputname(1) ' has to be a dates object with one element!'])
-    else
-        time = varargin{1}.time;
-        freq = varargin{1}.freq;
-    end
-end
-
-if isequal(nargin,2)
-    if ~(isvector(varargin{1}) && isequal(length(varargin{1}),2) && all(isint(varargin{1})) && isscalar(varargin{2} && ismember(varargin{2},[1 4 12 52])))
-        error(['dates::format: First input must be a 1*2 vector of integers and second input must be a scalar integer (1, 4, 12 or 52)!'])
-    else
-        time = varargin{1};
-        freq = varargin{2};
-    end
-end
-
-s = [num2str(time(1)) freq2string(freq)];
-if freq>1
-    s = strcat(s, num2str(time(2)));
-end
\ No newline at end of file
diff --git a/matlab/utilities/dates/freq2string.m b/matlab/utilities/dates/freq2string.m
deleted file mode 100644
index 2d12f8def073acc9e2d260b25a32a5c82eb346a3..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/freq2string.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function s = freq2string(freq)
-
-% INPUTS 
-%  o freq     scalar integer,  equal to 1, 4, 12 or 52 (resp. annual, quaterly, monthly or weekly)
-%
-% OUTPUTS 
-%  o s        character, equal to Y, Q, M or W (resp. annual, quaterly, monthly or weekly)
-    
-% 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/>.
-
-switch freq
-  case 1
-    s = 'Y';
-  case 4
-    s = 'Q';
-  case 12
-    s = 'M';
-  case 52
-    s = 'W';
-  otherwise
-    error('dates::freq2string: Unknown frequency!')
-end
\ No newline at end of file
diff --git a/matlab/utilities/dates/isdate.m b/matlab/utilities/dates/isdate.m
deleted file mode 100644
index 726e5e47980429e27458391a5f2c1aedb5fa2e19..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isdate.m
+++ /dev/null
@@ -1,55 +0,0 @@
-function b = isdate(str)  % --*-- Unitary tests --*--
-
-% Tests if the input string can be interpreted as a date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a date or 0 otherwise.
-
-% 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 isnumeric(str) && isscalar(str)
-    b = 1;
-    return
-end
-
-b = isstringdate(str);
-
-%@test:1
-%$
-%$ date_1 = 1950;
-%$ date_2 = '1950m2';
-%$ date_3 = '-1950m2';
-%$ date_4 = '1950m52';
-%$ date_5 = ' 1950';
-%$ date_6 = '1950Y';
-%$ date_7 = '-1950a';
-%$ date_8 = '1950m ';
-%$
-%$ t(1) = dyn_assert(isdate(date_1),1);
-%$ t(2) = dyn_assert(isdate(date_2),1);
-%$ t(3) = dyn_assert(isdate(date_3),1);
-%$ t(4) = dyn_assert(isdate(date_4),0);
-%$ t(5) = dyn_assert(isdate(date_5),0);
-%$ t(6) = dyn_assert(isdate(date_6),1);
-%$ t(7) = dyn_assert(isdate(date_7),1);
-%$ t(8) = dyn_assert(isdate(date_8),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/isdates.m b/matlab/utilities/dates/isdates.m
deleted file mode 100644
index 33b679020bb4b539593495456d17f504fc3c57b2..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isdates.m
+++ /dev/null
@@ -1,22 +0,0 @@
-function B = isdates(A)
-
-% Tests if the input A is a dates object.
-
-% 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/>.
-
-B = isa(A,'dates');
\ No newline at end of file
diff --git a/matlab/utilities/dates/isfreq.m b/matlab/utilities/dates/isfreq.m
deleted file mode 100644
index 79ba42c5395ab9484bff5e18f10a69ffb37b79d0..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isfreq.m
+++ /dev/null
@@ -1,39 +0,0 @@
-function B = isfreq(A)
-
-% Tests if A can be interpreted as a frequency.
-%
-% INPUTS 
-%  o A     scalar integer or character.
-%
-% OUTPUTS 
-%  o B     scalar integer equal to one if A can be interpreted as a frequency, zero otherwise.
-
-% 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/>.
-
-B = 0;
-
-if ischar(A)
-    if isequal(length(A),1) && ismember(upper(A),{'Y','A','Q','M','W'})
-        B = 1;
-        return
-    end
-end
-
-if isnumeric(A) && isequal(length(A),1) && ismember(A,[1 4 12 52])
-    B = 1;
-end
\ No newline at end of file
diff --git a/matlab/utilities/dates/ismonthly.m b/matlab/utilities/dates/ismonthly.m
deleted file mode 100644
index a66d06e695f1f411ad09127f14a767d20caaa178..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/ismonthly.m
+++ /dev/null
@@ -1,58 +0,0 @@
-function b = ismonthly(str)  % --*-- Unitary tests --*--
-
-% Tests if the input can be interpreted as a monthly date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a monthly date or 0 otherwise.
-
-% 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 ischar(str)
-    if isempty(regexp(str,'^-?[0-9]*[Mm]([1-9]|1[0-2])$','once'))
-        b = 0;
-    else
-        b = 1;
-    end
-else
-    b = 0;
-end
-
-%@test:1
-%$
-%$ date_1 = '1950M2';
-%$ date_2 = '1950m2';
-%$ date_3 = '-1950m2';
-%$ date_4 = '1950m12';
-%$ date_5 = '1950 azd ';
-%$ date_6 = '1950Y';
-%$ date_7 = '1950Q3';
-%$ date_8 = '1950m24';
-%$
-%$ t(1) = dyn_assert(ismonthly(date_1),1);
-%$ t(2) = dyn_assert(ismonthly(date_2),1);
-%$ t(3) = dyn_assert(ismonthly(date_3),1);
-%$ t(4) = dyn_assert(ismonthly(date_4),1);
-%$ t(5) = dyn_assert(ismonthly(date_5),0);
-%$ t(6) = dyn_assert(ismonthly(date_6),0);
-%$ t(7) = dyn_assert(ismonthly(date_7),0);
-%$ t(8) = dyn_assert(ismonthly(date_8),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/isquaterly.m b/matlab/utilities/dates/isquaterly.m
deleted file mode 100644
index 2b154ef3c5f403a296b5c95c00ef79b8202862f1..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isquaterly.m
+++ /dev/null
@@ -1,56 +0,0 @@
-function b = isquaterly(str)  % --*-- Unitary tests --*--
-
-% Tests if the input can be interpreted as a quaterly date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a quaterly date or 0 otherwise.
-
-% 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 ischar(str)
-    if isempty(regexp(str,'^-?[0-9]*[Qq][1-4]$','once'))
-        b = 0;
-    else
-        b = 1;
-    end
-else
-    b = 0;
-end
-
-%@test:1
-%$
-%$ date_1 = '1950Q2';
-%$ date_2 = '1950q2';
-%$ date_3 = '-1950q2';
-%$ date_4 = '1950q12';
-%$ date_5 = '1950 azd ';
-%$ date_6 = '1950Y';
-%$ date_7 = '1950m24';
-%$
-%$ t(1) = dyn_assert(isquaterly(date_1),1);
-%$ t(2) = dyn_assert(isquaterly(date_2),1);
-%$ t(3) = dyn_assert(isquaterly(date_3),1);
-%$ t(4) = dyn_assert(isquaterly(date_4),0);
-%$ t(5) = dyn_assert(isquaterly(date_5),0);
-%$ t(6) = dyn_assert(isquaterly(date_6),0);
-%$ t(7) = dyn_assert(isquaterly(date_7),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/isstringdate.m b/matlab/utilities/dates/isstringdate.m
deleted file mode 100644
index fbac8b0072e54c596fc5549445664f689f8c9ee2..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isstringdate.m
+++ /dev/null
@@ -1,54 +0,0 @@
-function b = isstringdate(str)  % --*-- Unitary tests --*--
-
-% Tests if the input string can be interpreted as a date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a date or 0 otherwise.
-
-% 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 ischar(str)
-    b = isquaterly(str) || isyearly(str) || ismonthly(str) || isweekly(str);
-else
-    b = 0;
-end
-
-%@test:1
-%$
-%$ date_1 = '1950M2';
-%$ date_2 = '1950m2';
-%$ date_3 = '-1950m2';
-%$ date_4 = '1950m52';
-%$ date_5 = ' 1950';
-%$ date_6 = '1950Y';
-%$ date_7 = '-1950a';
-%$ date_8 = '1950m ';
-%$
-%$ t(1) = dyn_assert(isstringdate(date_1),1);
-%$ t(2) = dyn_assert(isstringdate(date_2),1);
-%$ t(3) = dyn_assert(isstringdate(date_3),1);
-%$ t(4) = dyn_assert(isstringdate(date_4),0);
-%$ t(5) = dyn_assert(isstringdate(date_5),0);
-%$ t(6) = dyn_assert(isstringdate(date_6),1);
-%$ t(7) = dyn_assert(isstringdate(date_7),1);
-%$ t(8) = dyn_assert(isstringdate(date_8),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/issubperiod.m b/matlab/utilities/dates/issubperiod.m
deleted file mode 100644
index 5f7a7560bcc7202a0712152a4c8f362334507e83..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/issubperiod.m
+++ /dev/null
@@ -1,24 +0,0 @@
-function C = issubperiod(A,B)
-
-% 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 isfreq(B)
-    C = all(isint(A)) && all(A>=1) && all(A<=B);
-else
-    error('issubperiod:: Second input argument must be equal to 1, 4, 12 or 52 (frequency)!')
-end
\ No newline at end of file
diff --git a/matlab/utilities/dates/isweekly.m b/matlab/utilities/dates/isweekly.m
deleted file mode 100644
index d9988f5253bd865d83d04e8cb18e59a441fd836a..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isweekly.m
+++ /dev/null
@@ -1,58 +0,0 @@
-function b = isweekly(str)  % --*-- Unitary tests --*--
-
-% Tests if the input can be interpreted as a weekly date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a weekly date or 0 otherwise.
-
-% 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 ischar(str)
-    if isempty(regexp(str,'^-?[0-9]*[Ww]([1-9]|[1-4][0-9]|5[0-2])$','once'))
-        b = 0;
-    else
-        b = 1;
-    end
-else
-    b = 0;
-end
-
-%@test:1
-%$
-%$ date_1 = '1950W2';
-%$ date_2 = '1950w2';
-%$ date_3 = '-1950w2';
-%$ date_4 = '1950w22';
-%$ date_5 = '1950 azd ';
-%$ date_6 = '1950Y';
-%$ date_7 = '1950Q3';
-%$ date_8 = '1950m54';
-%$
-%$ t(1) = dyn_assert(isweekly(date_1),1);
-%$ t(2) = dyn_assert(isweekly(date_2),1);
-%$ t(3) = dyn_assert(isweekly(date_3),1);
-%$ t(4) = dyn_assert(isweekly(date_4),1);
-%$ t(5) = dyn_assert(isweekly(date_5),0);
-%$ t(6) = dyn_assert(isweekly(date_6),0);
-%$ t(7) = dyn_assert(isweekly(date_7),0);
-%$ t(8) = dyn_assert(isweekly(date_8),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/isyearly.m b/matlab/utilities/dates/isyearly.m
deleted file mode 100644
index d1345a0a185eed4ea79ccfe69d7ca9d1239a5231..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/isyearly.m
+++ /dev/null
@@ -1,58 +0,0 @@
-function b = isyearly(str)  % --*-- Unitary tests --*--
-
-% Tests if the input can be interpreted as a yearly date.
-%
-% INPUTS 
-%  o str     string.
-%
-% OUTPUTS 
-%  o b       integer scalar, equal to 1 if str can be interpreted as a yearly date or 0 otherwise.
-
-% 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 ischar(str)
-    if isempty(regexp(str,'^-?[0-9]*[YyAa]$','once'))
-        b = 0;
-    else
-        b = 1;
-    end
-else
-    b = 0;
-end
-
-%@test:1
-%$
-%$ date_1 = '1950M2';
-%$ date_2 = '1950m2';
-%$ date_3 = '-1950m2';
-%$ date_4 = '1950m12';
-%$ date_5 = '1950 azd ';
-%$ date_6 = '1950Y';
-%$ date_7 = '-1950a';
-%$ date_8 = '1950m24';
-%$
-%$ t(1) = dyn_assert(isyearly(date_1),0);
-%$ t(2) = dyn_assert(isyearly(date_2),0);
-%$ t(3) = dyn_assert(isyearly(date_3),0);
-%$ t(4) = dyn_assert(isyearly(date_4),0);
-%$ t(5) = dyn_assert(isyearly(date_5),0);
-%$ t(6) = dyn_assert(isyearly(date_6),1);
-%$ t(7) = dyn_assert(isyearly(date_7),1);
-%$ t(8) = dyn_assert(isyearly(date_8),0);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/string2date.m b/matlab/utilities/dates/string2date.m
deleted file mode 100644
index bb91a05fb3b693c196576f842e8a16b6d698129d..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/string2date.m
+++ /dev/null
@@ -1,109 +0,0 @@
-function date = string2date(a) % --*-- Unitary tests --*--
-    
-% 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/>.
-
-date = struct('freq', NaN, 'time', NaN(1,2));
-
-if ~ischar(a) || ~isdate(a)
-    error('dates::string2date: Input must be a string that can be interpreted as a date!');
-end
-
-if isyearly(a)
-    year = 1:(regexp(a,'[AaYy]')-1);
-    date.freq = 1;
-    date.time = write_time_field_y(a, year);
-    return
-end
-
-if isquaterly(a)
-    year = 1:(regexp(a,'[Qq]')-1);
-    date.freq = 4;
-    date.time = write_time_field(a, year);
-    return
-end
-
-if ismonthly(a)
-    year = 1:(regexp(a,'[Mm]')-1);
-    date.freq = 12;
-    date.time = write_time_field(a, year);
-    return
-end
-
-if isweekly(a)
-    year = 1:(regexp(a,'[Ww]')-1);
-    date.freq = 52;
-    date.time = write_time_field(a, year);
-    return
-end
-
-
-function b = write_time_field(c, d)
-    b(1) = str2double(c(d));
-    b(2) = str2double(c(d(end)+2:end));
-
-function b = write_time_field_y(c, d)
-    b(1) = str2double(c(d));
-    b(2) = 1;
-
-%@test:1
-%$
-%$ % Define some dates
-%$ date_1 = '1950Q2';
-%$ date_2 = '1950m10';
-%$ date_3 = '1950w50';
-%$ date_4 = '1950a';
-%$ date_5 = '1967y';
-%$ date_6 = '2009A';
-%$
-%$ % Define expected results.
-%$ e_date_1 = [1950 2];
-%$ e_freq_1 = 4;
-%$ e_date_2 = [1950 10];
-%$ e_freq_2 = 12;
-%$ e_date_3 = [1950 50];
-%$ e_freq_3 = 52;
-%$ e_date_4 = [1950 1];
-%$ e_freq_4 = 1;
-%$ e_date_5 = [1967 1];
-%$ e_freq_5 = 1;
-%$ e_date_6 = [2009 1];
-%$ e_freq_6 = 1;
-%$
-%$ % Call the tested routine.
-%$ d1 = string2date(date_1);
-%$ d2 = string2date(date_2);
-%$ d3 = string2date(date_3);
-%$ d4 = string2date(date_4);
-%$ d5 = string2date(date_5);
-%$ d6 = string2date(date_6);
-%$
-%$ % Check the results.
-%$ t(1) = dyn_assert(d1.time,e_date_1);
-%$ t(2) = dyn_assert(d2.time,e_date_2);
-%$ t(3) = dyn_assert(d3.time,e_date_3);
-%$ t(4) = dyn_assert(d4.time,e_date_4);
-%$ t(5) = dyn_assert(d5.time,e_date_5);
-%$ t(6) = dyn_assert(d6.time,e_date_6);
-%$ t(7) = dyn_assert(d1.freq,e_freq_1);
-%$ t(8) = dyn_assert(d2.freq,e_freq_2);
-%$ t(9) = dyn_assert(d3.freq,e_freq_3);
-%$ t(10) = dyn_assert(d4.freq,e_freq_4);
-%$ t(11)= dyn_assert(d5.freq,e_freq_5);
-%$ t(12)= dyn_assert(d6.freq,e_freq_6);
-%$ T = all(t);
-%@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/dates/string2freq.m b/matlab/utilities/dates/string2freq.m
deleted file mode 100644
index ea04c39649e27a0f3555163d6e44ad612cc2009f..0000000000000000000000000000000000000000
--- a/matlab/utilities/dates/string2freq.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function freq = string2freq(s)
-
-% INPUTS 
-%  o s        character, equal to Y, Q, M or W (resp. annual, quaterly, monthly or weekly)
-%
-% OUTPUTS 
-%  o freq     scalar integer,  equal to 1, 4, 12 or 52 (resp. annual, quaterly, monthly or weekly)
-    
-% 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/>.
-
-switch upper(s)
-  case {'Y','A'}
-    freq = 1;
-  case 'Q'
-    freq = 4;
-  case 'M'
-    freq = 12;
-  case 'W'
-    freq = 52;
-  otherwise
-    error('dates::freq2string: Unknown frequency!')
-end
\ No newline at end of file
diff --git a/matlab/utilities/dseries/from.m b/matlab/utilities/dseries/from.m
deleted file mode 100644
index 81fd5bc1621a1af14cd6d239b3f6123c6f70c4d7..0000000000000000000000000000000000000000
--- a/matlab/utilities/dseries/from.m
+++ /dev/null
@@ -1,494 +0,0 @@
-function from(varargin)   % --*-- Unitary tests --*--
-
-% 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/>.
-
-lvarargin = lower(varargin);
-
-to_id = strmatch('to',lvarargin);
-do_id = strmatch('do',lvarargin);
-
-if isempty(to_id) || isempty(do_id)
-    error(get_error_message_0())
-end
-
-if do_id<to_id
-    msg = sprinf('dseries::from: Wrong syntax! The TO keyword must preceed the DO keyword.\n');
-    error(get_error_message_0(msg))
-end
-
-if ~isdate(varargin{1})
-    % The first argument is not a string formatted date. Test if this argument refers to a dates object
-    % in the caller workspace.
-    try
-        d1 = evalin('caller', varargin{1});
-        if ~isdates(d1)
-            error(['dseries::from: Variable ' varargin{1} ' is not a dates object!'])
-        end
-    catch
-        error(['dseries::from: Variable ' varargin{1} ' is unknown!'])
-    end
-    if ~exist('d1')
-        msg = sprintf('dseries::from: Wrong syntax! The FROM statement must be followed by a string formatted date.\n');
-        error(get_error_message_0(msg))
-    end
-else
-    d1 = dates(varargin{1}); % First date
-end
-
-if ~isequal(to_id,2)
-    msg = sprintf('dseries::from: Wrong syntax! The first dates object must be immediately followed by the TO keyword.\n');
-    error(get_error_message_0(msg))
-end
-
-if ~isdate(varargin{3})
-    % The third argument is not a string formatted date. Test if this argument refers to a dates object
-    % in the caller workspace.
-    try
-        d2 = evalin('caller', varargin{3});
-        if ~isdates(d2)
-            error(['dseries::from: Variable ' varargin{3} ' is not a dates object!'])
-        end
-    catch
-        error(['dseries::from: Variable ' varargin{3} ' is unknown!'])
-    end
-    if ~exist('d2')
-        msg = sprintf('dseries::from: Wrong syntax! The TO keyword must be followed by a second dates object.\n');
-        error(get_error_message_0(msg))
-    end
-else
-    d2 = dates(varargin{3}); % Last date
-end
-
-if d1>d2
-    error('dseries::from: The first date must preceed the second one!')
-end
-
-if ~isequal(do_id,4)
-    msg = sprintf('dseries::from: Wrong syntax! The second dates object must be immediately followed by the DO keyword.\n');
-    error(get_error_message_0(msg))
-end
-
-% Build the recursive expression.
-EXPRESSION = char([varargin{5:end}]);
-
-% Check that the expression is an assignment
-equal_id = strfind(EXPRESSION,'=');
-if isempty(equal_id)
-    error('dseries::from: Wrong syntax! The expression following the DO keyword must be an assignment (missing equal symbol).')
-end
-
-% Issue ann error message if the user attempts to do more than one assignment.
-if ~isequal(length(equal_id),1)
-    error('dseries::from: Not yet implemented! Only one assignment is allowed in the FROM-TO-DO statement.')
-end
-
-% Get all the variables involved in the recursive expression.
-variables = unique(regexpi(EXPRESSION, '\w*\(t\)|\w*\(t\-\d\)|\w*\(t\+\d\)|\w*\.\w*\(t\)|\w*\.\w*\(t\-\d\)|\w*\.\w*\(t\+\d\)','match'));
-
-% Copy EXPRESSION in expression. In the next loop we will remove all indexed variables from expression.
-expression = EXPRESSION;
-
-% Build an incidence table (max lag/lead for each variable)
-%
-% Column 1: Name of the variable.
-% Column 2: Maximum lag order.
-% Column 3: Equal to 1 if the variable appears at the current period, 0 otherwise.
-% Column 4: Maximum lead order.
-% Column 5: Vector of effective lag orders.
-% Column 6: Vector of effective lead orders.
-%
-% Initialization.
-leadlagtable = cell(0,6);
-% Loop over the variables (dseries objects).
-for i=1:length(variables)
-    expression = strrep(expression,variables{i},'');
-    current = ~isempty(regexpi(variables{i},'\(t\)'));
-    lag = ~isempty(regexpi(variables{i},'\(t\-\d\)'));
-    lead = ~isempty(regexpi(variables{i},'\(t\+\d\)'));
-    start = regexpi(variables{i},'\(t\)|\(t\-\d\)|\(t\+\d\)');
-    index = variables{i}(start:end);
-    variables(i) = {variables{i}(1:start-1)};
-    if isempty(leadlagtable)
-        leadlagtable(1,1) = {variables{i}};
-        if current
-            leadlagtable(1,3) = {1};
-        else
-            leadlagtable(1,3) = {0};
-        end
-        if lag
-            tmp = regexpi(index,'\d','match');
-            leadlagtable(1,2) = {str2double(tmp{1})};
-            leadlagtable(1,5) = {str2double(tmp{1})};
-        else
-            leadlagtable(1,2) = {0};
-            leadlagtable(1,5) = {[]};
-        end
-        if lead
-            tmp = regexpi(index,'\d','match');
-            leadlagtable(1,4) = {str2double(tmp{1})};
-            leadlagtable(1,6) = {str2double(tmp{1})};
-        else
-            leadlagtable(1,4) = {0};
-            leadlagtable(1,6) = {[]};
-        end
-    else
-        linea = strmatch(variables{i},leadlagtable(:,1));
-        if isempty(linea)
-            % This is a new variable!
-            linea = size(leadlagtable,1)+1;
-            leadlagtable(linea,1) = {variables{i}};
-            leadlagtable(linea,2) = {0};
-            leadlagtable(linea,3) = {0};
-            leadlagtable(linea,4) = {0};
-            leadlagtable(linea,5) = {[]};
-            leadlagtable(linea,6) = {[]};
-        end
-        if current
-            leadlagtable(linea,3) = {1};
-        end
-        if lag
-            tmp = regexpi(index,'\d','match');
-            leadlagtable(linea,2) = {max(str2double(tmp{1}),leadlagtable{linea,2})};
-            leadlagtable(linea,5) = {sortrows([leadlagtable{linea,5}; str2double(tmp{1})])};
-        end
-        if lead
-            tmp = regexpi(index,'\d','match');
-            leadlagtable(linea,4) = {max(str2double(tmp{1}),leadlagtable{linea,4})};
-            leadlagtable(linea,6) = {sortrows([leadlagtable{linea,6}; str2double(tmp{1})])};
-        end
-    end
-end
-
-% Set the number of variables
-number_of_variables = size(leadlagtable,1);
-
-% Initialize a cell array containing the names of the variables.
-variable_names = cell(1);
-
-% Test that all the involved variables are available dseries objects. Also check that
-% these time series are defined over the time range given by d1 and d2 (taking care of
-% the lags and leads) and check that each object is a singleton
-for i=1:number_of_variables
-    current_variable = leadlagtable{i,1};
-    idvar = strfind(current_variable,'.');
-    if isempty(idvar)
-        idvar = 0;
-    end
-    if idvar
-        current_variable_0 = current_variable(1:idvar-1);
-    else
-        current_variable_0 = current_variable;
-    end
-    try
-        var = evalin('caller',current_variable_0);
-    catch
-        error(['dseries::from: Variable ' current_variable_0 ' is unknown!'])
-    end
-    if idvar
-        try
-            eval(sprintf('var = var.%s;',current_variable(idvar+1:end)))
-        catch
-            error(sprintf('dseries::from: Variable %s is not a member of dseries oject %s!', current_variable(idvar+1:end), current_variable_0))
-        end
-    end
-    if ~isdseries(var)
-        error(['dseries::from: Variable ' current_variable ' is not a dseries object!'])
-    else
-        if ~var.vobs
-            msg = sprintf('dseries::from: Object %s must not be empty!\n',current_variable);
-            error(msg)
-        end
-        if var.vobs>1
-            msg = sprintf('dseries::from: Object %s must contain only one variable!\n',current_variable);
-            error(msg)
-        end
-        if i>1
-            if ismember(var.name,variable_names)
-                % Locally change variable name.
-                var = var.rename(var.name{1},get_random_string(20));
-            end
-            variable_names(i) = {var.name{1}};
-        else
-            variable_names(i) = {var.name{1}};
-        end
-        if d1<var.dates(1)+leadlagtable{i,2}
-            msg = sprintf('dseries::from: Initial date of the loop (%s) is inconsistent with %s''s range!\n',char(d1),current_variable);
-            msg = [msg, sprintf('               Initial date should be greater than or equal to %s.',char(var.dates(1)+leadlagtable{i,2}))];
-            error(msg)
-        end
-        if d2>var.dates(end)-leadlagtable{i,4}
-            % The first variable should be the assigned variable (will be tested later)
-            if ~isassignedvariable(leadlagtable{i,1},EXPRESSION)
-                msg = sprintf('dseries::from: Last date of the loop (%s) is inconsistent with %s''s range!\n',char(d2),current_variable);
-                msg = [msg, sprintf('               Last date should be less than or equal to %s.',char(var.dates(end)-leadlagtable{i,4}))];
-                error(msg)
-            else
-                var = [var; dseries(NaN((d2-var.dates(end)),1),var.dates(end)+1:d2,var.name)];
-            end
-        end
-        eval(sprintf('%s = var;',current_variable));
-    end
-end
-
-% Get the name of the assigned variable (with time index)
-assignedvariablename = regexpi(EXPRESSION(1:equal_id-1), '\w*\(t\)|\w*\(t\-\d\)|\w*\(t\+\d\)|\w*\.\w*\(t\)|\w*\.\w*\(t\-\d\)|\w*\.\w*\(t\+\d\)','match');
-if isempty(assignedvariablename)
-    error('dseries::from: Wrong syntax! The expression following the DO keyword must be an assignment (missing variable before the equal symbol).')
-end
-if length(assignedvariablename)>1
-    error('dseries::from: No more than one variable can be assigned!')
-end
-% Check if the model is static
-start = regexpi(assignedvariablename{1},'\(t\)|\(t\-\d\)|\(t\+\d\)');
-index = assignedvariablename{1}(start:end);
-assignedvariablename = assignedvariablename{1}(1:start-1);
-indva = strmatch(assignedvariablename, leadlagtable(:,1));
-dynamicmodel = ~isempty(regexpi(EXPRESSION(equal_id:end), ...
-                                sprintf('%s\\(t\\)|%s\\(t\\-\\d\\)|%s\\(t\\+\\d\\)',assignedvariablename,assignedvariablename,assignedvariablename),'match'));
-% Check that the dynamic model for the endogenous variable is not forward looking.
-if dynamicmodel
-    indum = index2num(index);
-    if indum<leadlagtable{indva,4}
-        error('dseries::from: It is not possible to simulate a forward looking model!')
-    end
-end
-% Check that the assigned variable does not depend on itself (the assigned variable can depend on its past level but not on the current level).
-if dynamicmodel
-    tmp = regexpi(EXPRESSION(equal_id+1:end), ...
-                  sprintf('%s\\(t\\)|%s\\(t\\-\\d\\)|%s\\(t\\+\\d\\)',assignedvariablename,assignedvariablename,assignedvariablename),'match');
-    tmp = cellfun(@extractindex, tmp);
-    tmp = cellfun(@index2num, tmp);
-    if ~all(tmp(:)<indum)
-        error(sprintf('dseries::from: On the righthand side, the endogenous variable, %s, must be indexed by %s at most.',assignedvariablename,num2index(indum-1)))
-    end
-end
-
-% Put all the variables in a unique dseries object.
-list_of_variables = leadlagtable{1,1};
-for i=2:number_of_variables
-   list_of_variables = [list_of_variables, ',' leadlagtable{i,1}];
-end
-eval(sprintf('tmp = [%s];', list_of_variables));
-
-% Get base time index
-t1 = find(d1==tmp.dates);
-t2 = find(d2==tmp.dates);
-
-% Get data
-data = tmp.data;
-
-% Isolate the (potential) parameters in the expression to be evaluated
-TMP314 = regexp(expression, '([0-9]*\.[0-9]*|\w*)', 'match');
-% Here I remove the numbers (TMP314 -> TMP314159).
-TMP3141 = regexp(TMP314,'(([0-9]*\.[0-9]*)|([0-9]*))','match');
-TMP31415 = find(cellfun(@isempty,TMP3141));
-TMP314159 = TMP314(TMP31415);
-
-if dynamicmodel
-    % Transform EXPRESSION by replacing calls to the dseries objects by references to data.
-    for i=1:number_of_variables
-        EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t\\)',leadlagtable{i,1}),sprintf('data(t,%s)',num2str(i)));
-        for j=1:length(leadlagtable{i,5})
-            lag = leadlagtable{i,5}(j);
-            EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t-%s\\)',leadlagtable{i,1},num2str(lag)), ...
-                                   sprintf('data(t-%s,%s)',num2str(lag),num2str(i)));
-        end
-        for j=1:length(leadlagtable{i,6})
-            lead = leadlagtable{i,6}(j);
-            EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t+%s\\)',leadlagtable{i,1},num2str(lead)), ...
-                                   sprintf('data(t+%s,%s)',num2str(lead),num2str(i)));
-        end
-    end
-    % Get values for the parameters (if any)
-    if ~isempty(TMP314159)
-        for i=1:length(TMP314159)
-            wordcandidate = TMP314159{i};
-            try % If succesful, word is a reference to a variable in the caller function/script.
-                thiswordisaparameter = evalin('caller', wordcandidate);
-                eval(sprintf('%s = thiswordisaparameter;',wordcandidate));
-            catch
-                % I assume that word is a reference to a function.
-            end
-        end
-    end
-    % Do the job. Evaluate the recursion.
-    eval(sprintf('for t=%s:%s, %s; end',num2str(t1),num2str(t2),EXPRESSION));
-else
-    % Transform EXPRESSION by replacing calls to the dseries objects by references to data.
-    for i=1:number_of_variables
-        EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t\\)',leadlagtable{i,1}), ...
-                               sprintf('data(%s:%s,%s)',num2str(t1),num2str(t2),num2str(i)));
-        for j=1:length(leadlagtable{i,5})
-            lag = leadlagtable{i,5}(j);
-            EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t-%s\\)',leadlagtable{i,1},num2str(lag)), ...
-                                   sprintf('data(%s:%s,%s)',num2str(t1-lag),num2str(t2-lag),num2str(i)));
-        end
-        for j=1:length(leadlagtable{i,6})
-            lead = leadlagtable{i,6}(j);
-            EXPRESSION = regexprep(EXPRESSION,sprintf('%s\\(t+%s\\)',leadlagtable{i,1},num2str(lead)), ...
-                                   sprintf('data(%s:%s,%s)',num2str(t1-lead),num2str(t2-lead),num2str(i)));
-        end
-    end
-    % Transform some operators (^ -> .^, / -> ./ and * -> .*)
-    EXPRESSION = strrep(EXPRESSION,'^','.^');
-    EXPRESSION = strrep(EXPRESSION,'*','.*');
-    EXPRESSION = strrep(EXPRESSION,'/','./');
-    % Get values for the parameters (if any)
-    if ~isempty(TMP314159)
-        for i=1:length(TMP314159)
-            wordcandidate = TMP314159{i};
-            try % If succesful, word is a reference to a variable in the caller function/script.
-                thiswordisaparameter = evalin('caller', wordcandidate);
-                eval(sprintf('%s = thiswordisaparameter;',wordcandidate));
-            catch
-                % I assume that word is a reference to a function.
-            end
-        end
-    end
-    % Do the job. Evaluate the static expression.
-    eval(sprintf('%s;',EXPRESSION));
-end
-
-% Put assigned variable back in the caller workspace...
-if isempty(strfind(assignedvariablename,'.'))
-    eval(sprintf('assignin(''caller'', ''%s'', dseries(data(:,indva),%s.init,%s.name,%s.tex));', ...
-                 assignedvariablename,assignedvariablename,assignedvariablename,assignedvariablename))
-else
-    DATA = num2cell(data(:,indva));
-    strdata = sprintf('%f ', DATA{:});
-    evalin('caller',sprintf('%s = dseries(transpose([%s]),%s.init,%s.name,%s.tex);', ...
-                            assignedvariablename,strdata,assignedvariablename,assignedvariablename,assignedvariablename))
-end
-
-function msg = get_error_message_0(msg)
-    if ~nargin
-        msg = sprintf('Wrong syntax! The correct syntax is:\n\n');
-    else
-        msg = [msg, sprintf('The correct syntax is:\n\n')];
-    end
-    msg = [msg, sprintf('    from d1 to d2 do SOMETHING\n\n')];
-    msg = [msg, sprintf('where d1<d2 are dates objects, and SOMETHING is a recursive expression involving dseries objects.')];
-
-
-function index = extractindex(str)
-    index = regexpi(str,'\(t\)|\(t\-\d\)|\(t\+\d\)','match');
-
-
-function i = index2num(id)
-    if isequal('(t)',id)
-        i = 0;
-        return
-    end
-    if isequal('-',id(3))
-        i = - str2num(id(4:end-1));
-    else
-        i = str2num(id(4:end-1));
-    end
-
-
-function id = num2index(i)
-    if isequal(i,0)
-        id = '(t)';
-        return
-    end
-    if i<0
-        id = ['(t-' int2str(abs(i)) ')'];
-    else
-        id = ['(t+' int2str(i) ')'];
-    end
-
-function i = isassignedvariable(var,expr)
-    idv = strfind(expr,var);
-    idq = strfind(expr,'=');
-    if ~isempty(idv)
-        if idv(1)<idq
-            i = 1;
-            return
-        end
-    end
-    i = 0;
-
-%@test:1
-%$ try
-%$     y = dseries(zeros(400,1),dates('1950Q1')) ;
-%$     v = dseries(randn(400,1),dates('1950Q1')) ;
-%$     u = dseries(randn(400,1),dates('1950Q1')) ;
-%$     from 1950Q2 to 2049Q4 do y(t) = (1+.01*u(t))*y(t-1) + v(t)
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:1
-
-%@test:2
-%$ try
-%$     y = dseries(zeros(400,1),dates('1950Q1')) ;
-%$     v = dseries(randn(400,1),dates('1950Q1')) ;
-%$     u = dseries(randn(400,1),dates('1950Q1')) ;
-%$     from 1950Q2 to 2049Q3 do y(t) = (1+.01*u(t))*y(t+1) + v(t)
-%$     t(1) = 0;
-%$ catch
-%$     t(1) = 1;
-%$ end
-%$
-%$ T = all(t);
-%@eof:2
-
-%@test:3
-%$ try
-%$     y = dseries(zeros(400,1),dates('1950Q1')) ;
-%$     v = dseries(randn(400,1),dates('1950Q1')) ;
-%$     u = dseries(randn(400,1),dates('1950Q1')) ;
-%$     from 1950Q2 to 2049Q4 do y(t) = v(t) -.5*v(t-1);
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:3
-
-%@test:4
-%$ try
-%$     y = dseries(zeros(400,1),dates('1950Q1')) ;
-%$     v = dseries(randn(400,1),dates('1950Q1')) ;
-%$     u = dseries(randn(400,1),dates('1950Q1')) ;
-%$     from 1950Q2 to 2049Q4 do y(t) = 2*((v(t) -.5*v(t-1))>0)-1;
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:4
-
-%@test:5
-%$ try
-%$     y = dseries(zeros(4000,1),dates('1950Q1')) ;
-%$     v = dseries(randn(4000,1),dates('1950Q1')) ;
-%$     u = dseries(randn(4000,1),dates('1950Q1')) ;
-%$     from 1950Q2 to 2949Q4 do y(t) = y(t-1)*(2*((v(t) -.5*v(t-1))>u(t))-1)+u(t); %plot(y)
-%$     t(1) = 1;
-%$ catch
-%$     t(1) = 0;
-%$ end
-%$
-%$ T = all(t);
-%@eof:5
diff --git a/matlab/utilities/dseries/isdseries.m b/matlab/utilities/dseries/isdseries.m
deleted file mode 100644
index 9d2c7d2497887f75a8b336f097fedc07a2791ce3..0000000000000000000000000000000000000000
--- a/matlab/utilities/dseries/isdseries.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function B = isdseries(A)
-
-% Copyright (C) 2011-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/>.
-
-B = isa(A,'dseries');
\ No newline at end of file
diff --git a/matlab/utilities/general/compare_vectors.m b/matlab/utilities/general/compare_vectors.m
index 07dca457279aead5d487e3f0c51594737c8f38f2..97e916c7573cee000345a042880d70d8d4acc71e 100644
--- a/matlab/utilities/general/compare_vectors.m
+++ b/matlab/utilities/general/compare_vectors.m
@@ -77,18 +77,18 @@ else
 end
 
 %@test:1
-%$ t(1) = dyn_assert(compare_vectors(@lt, [1990 3], [1991 3]), 1);
-%$ t(2) = dyn_assert(compare_vectors(@lt, [1990 3], [1990 3]), 0);
-%$ t(3) = dyn_assert(compare_vectors(@le, [1990 3], [1990 3]), 1);
-%$ t(4) = dyn_assert(compare_vectors(@lt, [1990 3], [1990 4]), 1);
-%$ t(5) = dyn_assert(compare_vectors(@le, [1990 3], [1990 4]), 1);
-%$ t(6) = dyn_assert(compare_vectors(@gt, [1990 3], [1991 3]), 0);
-%$ t(7) = dyn_assert(compare_vectors(@gt, [1990 3], [1990 3]), 0);
-%$ t(8) = dyn_assert(compare_vectors(@ge, [1990 3], [1990 3]), 1);
-%$ t(9) = dyn_assert(compare_vectors(@gt, [1990 3], [1990 4]), 0);
-%$ t(10) = dyn_assert(compare_vectors(@ge, [1990 3], [1990 4]), 0);
-%$ t(11) = dyn_assert(compare_vectors(@le, [1991 3], [1990 4]), 0);
-%$ t(12) = dyn_assert(compare_vectors(@le, [1991 3], [1990 2]), 0);
-%$ t(13) = dyn_assert(compare_vectors(@le, [1945 2], [1950, 1]),1);
+%$ t(1) = dassert(compare_vectors(@lt, [1990 3], [1991 3]), 1);
+%$ t(2) = dassert(compare_vectors(@lt, [1990 3], [1990 3]), 0);
+%$ t(3) = dassert(compare_vectors(@le, [1990 3], [1990 3]), 1);
+%$ t(4) = dassert(compare_vectors(@lt, [1990 3], [1990 4]), 1);
+%$ t(5) = dassert(compare_vectors(@le, [1990 3], [1990 4]), 1);
+%$ t(6) = dassert(compare_vectors(@gt, [1990 3], [1991 3]), 0);
+%$ t(7) = dassert(compare_vectors(@gt, [1990 3], [1990 3]), 0);
+%$ t(8) = dassert(compare_vectors(@ge, [1990 3], [1990 3]), 1);
+%$ t(9) = dassert(compare_vectors(@gt, [1990 3], [1990 4]), 0);
+%$ t(10) = dassert(compare_vectors(@ge, [1990 3], [1990 4]), 0);
+%$ t(11) = dassert(compare_vectors(@le, [1991 3], [1990 4]), 0);
+%$ t(12) = dassert(compare_vectors(@le, [1991 3], [1990 2]), 0);
+%$ t(13) = dassert(compare_vectors(@le, [1945 2], [1950, 1]),1);
 %$ T = all(t);
 %@eof:1
\ No newline at end of file
diff --git a/matlab/utilities/general/name2tex.m b/matlab/utilities/general/name2tex.m
index 0bf02a2cb91f8eb08c2a25886a8e4b504d075875..33c0513b41f2071963603282251a1d43b54fcbd6 100644
--- a/matlab/utilities/general/name2tex.m
+++ b/matlab/utilities/general/name2tex.m
@@ -96,22 +96,22 @@ end
 %$ t17 = name2tex('_azert_uiop_qsdfg',1);
 %$ t18 = name2tex('_azert_uiop_qsdfg_',1);
 %$
-%$ t(1) = dyn_assert(strcmp(t1,'\\_azert'),1);
-%$ t(2) = dyn_assert(strcmp(t2,'azert\\_'),1);
-%$ t(3) = dyn_assert(strcmp(t3,'\\_azert\\_'),1);
-%$ t(4) = dyn_assert(strcmp(t4,'azert\\_uiop'),1);
-%$ t(5) = dyn_assert(strcmp(t5,'azert\\_uiop\\_qsdfg'),1);
-%$ t(6) = dyn_assert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),1);
-%$ t(7) = dyn_assert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),1);
-%$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1);
-%$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1);
-%$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1);
-%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1);
-%$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1);
-%$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1);
-%$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1);
-%$ t(15) = dyn_assert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),1);
-%$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1);
+%$ t(1) = dassert(strcmp(t1,'\\_azert'),true);
+%$ t(2) = dassert(strcmp(t2,'azert\\_'),true);
+%$ t(3) = dassert(strcmp(t3,'\\_azert\\_'),true);
+%$ t(4) = dassert(strcmp(t4,'azert\\_uiop'),true);
+%$ t(5) = dassert(strcmp(t5,'azert\\_uiop\\_qsdfg'),true);
+%$ t(6) = dassert(strcmp(t6,'azert\\_uiop\\_qsdfg\\_'),true);
+%$ t(7) = dassert(strcmp(t7,'\\_azert\\_uiop\\_qsdfg'),true);
+%$ t(8) = dassert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),true);
+%$ t(9) = dassert(strcmp(t11,'\\_azert'),true);
+%$ t(10) = dassert(strcmp(t12,'azert\\_'),true);
+%$ t(11) = dassert(strcmp(t13,'\\_azert\\_'),true);
+%$ t(12) = dassert(strcmp(t14,'azert_{uiop}'),true);
+%$ t(13) = dassert(strcmp(t15,'azert\\_uiop_{qsdfg}'),true);
+%$ t(14) = dassert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),true);
+%$ t(15) = dassert(strcmp(t17,'\\_azert\\_uiop_{qsdfg}'),true);
+%$ t(16) = dassert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),true);
 %$
 %$ T = all(t);
 %@eof:1
@@ -135,22 +135,22 @@ end
 %$ t17 = name2tex({'_azert_uiop_qsdfg'},1);
 %$ t18 = name2tex({'_azert_uiop_qsdfg_'},1);
 %$
-%$ t(1) = dyn_assert(t1,{'\\_azert'});
-%$ t(2) = dyn_assert(t2,{'azert\\_'});
-%$ t(3) = dyn_assert(t3,{'\\_azert\\_'});
-%$ t(4) = dyn_assert(t4,{'azert\\_uiop'});
-%$ t(5) = dyn_assert(t5,{'azert\\_uiop\\_qsdfg'});
-%$ t(6) = dyn_assert(t6,{'azert\\_uiop\\_qsdfg\\_'});
-%$ t(7) = dyn_assert(t7,{'\\_azert\\_uiop\\_qsdfg'});
-%$ t(8) = dyn_assert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'});
-%$ t(9) = dyn_assert(t11,{'\\_azert'});
-%$ t(10) = dyn_assert(t12,{'azert\\_'});
-%$ t(11) = dyn_assert(t13,{'\\_azert\\_'});
-%$ t(12) = dyn_assert(t14,{'azert_{uiop}'});
-%$ t(13) = dyn_assert(t15,{'azert\\_uiop_{qsdfg}'});
-%$ t(14) = dyn_assert(t16,{'azert\\_uiop_{qsdfg\\_}'});
-%$ t(15) = dyn_assert(t17,{'\\_azert\\_uiop_{qsdfg}'});
-%$ t(16) = dyn_assert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'});
+%$ t(1) = dassert(t1,{'\\_azert'});
+%$ t(2) = dassert(t2,{'azert\\_'});
+%$ t(3) = dassert(t3,{'\\_azert\\_'});
+%$ t(4) = dassert(t4,{'azert\\_uiop'});
+%$ t(5) = dassert(t5,{'azert\\_uiop\\_qsdfg'});
+%$ t(6) = dassert(t6,{'azert\\_uiop\\_qsdfg\\_'});
+%$ t(7) = dassert(t7,{'\\_azert\\_uiop\\_qsdfg'});
+%$ t(8) = dassert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'});
+%$ t(9) = dassert(t11,{'\\_azert'});
+%$ t(10) = dassert(t12,{'azert\\_'});
+%$ t(11) = dassert(t13,{'\\_azert\\_'});
+%$ t(12) = dassert(t14,{'azert_{uiop}'});
+%$ t(13) = dassert(t15,{'azert\\_uiop_{qsdfg}'});
+%$ t(14) = dassert(t16,{'azert\\_uiop_{qsdfg\\_}'});
+%$ t(15) = dassert(t17,{'\\_azert\\_uiop_{qsdfg}'});
+%$ t(16) = dassert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'});
 %$
 %$ T = all(t);
 %@eof:2
@@ -174,11 +174,11 @@ end
 %$ end
 %$
 %$ if t(1)
-%$     t(3) = dyn_assert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'});
+%$     t(3) = dassert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'});
 %$ end
 %$
 %$ if t(2)
-%$     t(4) = dyn_assert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'});
+%$     t(4) = dassert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'});
 %$ end
 %$
 %$ T = all(t);
diff --git a/matlab/utilities/tests b/matlab/utilities/tests
new file mode 160000
index 0000000000000000000000000000000000000000..be3cc662f26b949936aa88d39f658480b09322f0
--- /dev/null
+++ b/matlab/utilities/tests
@@ -0,0 +1 @@
+Subproject commit be3cc662f26b949936aa88d39f658480b09322f0
diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m
deleted file mode 100644
index b4a1dcd20ba344b455fc44f1e886cd9ac2bf3c83..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/build_report_summary.m
+++ /dev/null
@@ -1,101 +0,0 @@
-function str = build_report_summary(reportfile, printonscreen, mailreport)
-
-% 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,1)
-    printonscreen = 1;
-    mailreport = 0;
-end
-
-if nargin<3
-    mailreport = 0;
-else
-    if ischar(mailreport)
-        mailto = mailreport;
-        mailreport = 1;
-        fid = fopen('~/.matlab-send-report');
-        server = fgetl(fid);
-        fclose(fid);
-        fprintf('\n\n');
-        disp('Send report...')
-        system(['scp ' reportfile ' ' server]);
-        system(['scp ' reportfile(1:end-3) 'log ' server]);
-    else
-        if ~isequal(mailreport,0)
-            error('build_report_summary:: Third argument must be an adress email!')
-        end
-    end
-end
-
-reportfilecontent = load(reportfile);
-reportcell = reportfilecontent.report;
-gitinfo = reportfilecontent.gitinfo;
-gitlastcommithash = reportfilecontent.gitlastcommithash;
-
-str = 'Hi,';
-str = char(str,'');
-str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at:');
-str = char(str,'');
-str = char(str,'');
-str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]);
-str = char(str,'');
-str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile(1:end-3) 'log']);
-str = char(str,'');
-str = char(str,gitinfo(1,:));
-str = char(str,gitinfo(2,:));
-str = char(str,'');
-str = char(str,'');
-str = char(str,['===========================']);
-str = char(str,'DYNARE/MATLAB UNITARY TESTS');
-str = char(str,'===========================');
-str = char(str,['| TOTAL: ' int2str(size(reportcell,1))]);
-str = char(str,['|  PASS: ' int2str(length(find(cell2mat(reportcell(:,3)))))]);
-str = char(str,['|  FAIL: ' int2str(length(find(~cell2mat(reportcell(:,3)))))]);
-str = char(str,'|');
-str = char(str,'| LIST OF FAILED TESTS:');
-for i=1:size(reportcell,1)
-    if ~reportcell{i,3}
-        str = char(str,['|    * ' reportcell{i,1} ' (test #'  int2str(reportcell{i,2}) '{' strrep(int2str(transpose(find(~reportcell{i,4}))),' ',',') '})']);
-    end
-end
-
-if printonscreen
-    skipline(2);
-    disp(str)
-    skipline(2);
-end
-
-if mailreport
-    if exist('~/.matlab-send-mail-info','file')
-        fid = fopen('~/.matlab-send-mail-info','r');
-    else
-       disp(['build_report_summary:: I Cannot send the report to ' mailto ' because the sender and the smtp server are not defined!'])
-       disp(['                       You probably need to add a ''.matlab-send-mail-info'' in your root directory...'])
-       return
-    end
-    setpref('Internet','SMTP_Server',fgetl(fid));
-    setpref('Internet','SMTP_Username',fgetl(fid));
-    setpref('Internet','E_mail',fgetl(fid));
-    setpref('Internet','SMTP_Passeword',fgetl(fid));
-    fclose(fid);
-    STR = [deblank(str(1,:))];
-    for i=2:size(str,1)
-        STR = [STR 10 deblank(str(i,:)) ];
-    end
-    sendmail(mailto,'Dynare/Matlab unitary tests',STR); 
-end
\ No newline at end of file
diff --git a/matlab/utilities/tests/dynTest.m b/matlab/utilities/tests/dynTest.m
deleted file mode 100644
index 8dd2fc01702e49e273092db3c782a11ea988f198..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/dynTest.m
+++ /dev/null
@@ -1,84 +0,0 @@
-function dynTest(fun,dynare_path)
-
-%@info:
-%! @deftypefn {Function File} dynTest (@var{fun})
-%! @anchor{dynTest}
-%! @sp 1
-%! Tests matlab/octave routine @var{fun}.m.
-%! @sp 2
-%!
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item fun
-%! string, name of the matlab/octave routine to be tested.
-%! @end table
-%! @sp 2
-%!
-%! @strong{Outputs}
-%! @sp 1
-%! None
-%! @sp 2
-%!
-%! @strong{This function is called by:}
-%! @sp 1
-%! @ref{internals}, @ref{mroutines}
-%! @sp 2
-%!
-%! @strong{This function calls:}
-%! @sp 1
-%! @ref{mtest}
-%!
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2011-2012 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/>.
-
-% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
-
-original_directory = pwd();
-
-[pathstr1, name1, ext1] = fileparts(fun);
-
-pathstr1 = [original_directory filesep pathstr1];
-
-cd([dynare_path filesep '..' filesep 'tests']);
-
-mex_flag = 0;
-if exist(name1)==3
-    mex_flag = 1;
-end
-
-class_flag = 0;
-if ~isempty(strfind(fun,'@')) || ~isempty(strfind(which(name1),'@'))
-    class_flag = 1;
-end
-
-check = mtest(name1,pathstr1);
-
-if check
-    if mex_flag
-        disp(['Succesfull test(s) for ' name1 ' mex file!'])
-    elseif class_flag
-        disp(['Succesfull test(s) for ' name1 ' method!'])
-    else
-        disp(['Succesfull test(s) for ' name1 ' routine!'])
-    end
-end
-
-cd(original_directory);
\ No newline at end of file
diff --git a/matlab/utilities/tests/dyn_assert.m b/matlab/utilities/tests/dyn_assert.m
deleted file mode 100644
index 5311631396f3bc054fd0945fa68000e4cbb7f734..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/dyn_assert.m
+++ /dev/null
@@ -1,63 +0,0 @@
-function t = dyn_assert(A,B,tol)
-% This function tests the equality of two objects.
-
-% Copyright (C) 2011-2012 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/>.
-
-% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
-
-if ( (nargin<3) || isempty(tol) )
-    use_isequal_matlab_builtin = 1;
-else
-    use_isequal_matlab_builtin = 0;
-end
-
-[nA,mA] = size(A);
-[nB,mB] = size(B);
-
-if nA-nB
-    error('assert:: Dimensions of compared objects A and B don''t match!')
-end
-
-if mA-mB
-    error('assert:: Dimensions of compared objects A and B don''t match!')
-end
-
-if isstruct(B) && ~isstruct(A)
-    error('assert:: Compared objects are not of the same type!')
-end
-
-if iscell(B) && ~iscell(A)
-    error('assert:: Compared objects are not of the same type!')
-end
-
-if use_isequal_matlab_builtin
-    t = isequal(A,B);
-    if ~t
-        t = isequalwithequalnans(A,B);
-    end
-else
-    t = 1;
-    if ~(isstruct(B) || iscell(B))
-        if max(abs(A(:)-B(:)))>tol
-            t = 0;
-        end
-    else
-        % not yet implemented
-        t = NaN;
-    end
-end
\ No newline at end of file
diff --git a/matlab/utilities/tests/get_directory_description.m b/matlab/utilities/tests/get_directory_description.m
deleted file mode 100644
index 3be45da11da0847da76fa9406d97c1b4d1027111..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/get_directory_description.m
+++ /dev/null
@@ -1,34 +0,0 @@
-function flist = get_directory_description(basedir)
-
-% 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/>.
-
-dd = dir(basedir);
-flist = {};
-file = 1;
-
-for f=1:length(dd)
-    if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..'))
-        if dd(f).isdir
-            r = get_directory_description([ basedir filesep dd(f).name]);
-            flist = { flist{:} r{:} };
-        else
-            flist{length(flist)+1} = [basedir filesep dd(f).name];
-        end
-        file = file + 1; 
-    end
-end
diff --git a/matlab/utilities/tests/is_unitary_test_available.m b/matlab/utilities/tests/is_unitary_test_available.m
deleted file mode 100644
index 80a3bc240c6df90ab2116a296698c90fdbd0273b..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/is_unitary_test_available.m
+++ /dev/null
@@ -1,51 +0,0 @@
-function info = is_unitary_test_available(fun)
-
-%@info:
-%! @deftypefn {Function File} {@var{info} =} is_unitary_test_available (@var{fun})
-%! @anchor{is_unitary_test_available}
-%! @sp 1
-%! Tests if matlab/octave routine @var{fun} has unitary tests.
-%! @sp 2
-%! @strong{Inputs}
-%! @sp 1
-%! @table @ @var
-%! @item fun
-%! string, name of the matlab/octave routine to be tested.
-%! @end table
-%! @sp 2
-%! @strong{Outputs}
-%! @sp 1
-%! @table @ @var
-%! @item info
-%! Integer scalar equal to one if unitary tests are available, zero otherwise.
-%! @end table
-%! @sp 2
-%! @end deftypefn
-%@eod:
-
-% Copyright (C) 2013 Dynare Team
-%
-% This file is part of Dynare.
-%
-% Dynare is free software: you can redistribute it and/or modify
-% it under the terms of the GNU General Public License as published by
-% the Free Software Foundation, either version 3 of the License, or
-% (at your option) any later version.
-%
-% Dynare is distributed in the hope that it will be useful,
-% but WITHOUT ANY WARRANTY; without even the implied warranty of
-% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-% GNU General Public License for more details.
-%
-% You should have received a copy of the GNU General Public License
-% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
-    
-info = 0;
-
-fid = fopen(fun,'r');
-first_line = fgetl(fid);
-fclose(fid);
-
-if strfind(first_line,'% --*-- Unitary tests --*--')
-    info = 1;
-end
\ No newline at end of file
diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m
deleted file mode 100644
index 29f771613b48c54517f08868e8338309aca8f37f..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/mtest.m
+++ /dev/null
@@ -1,137 +0,0 @@
-function [check, info] = mtest(fname, fpath)
-% Extract test sections from matlab's routine executes the test and report errors.
-
-% Copyright (C) 2011-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/>.
-
-% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
-
-% Default answer (no problem).
-check = 1;
-
-% Open the matlab file.
-if nargin<2 || isempty(fpath)
-    if nargout<2
-        error('mtest:: Wrong calling sequence!')
-    end
-    % The full path to the matlab routine (with extension) is given.
-    fid = fopen(fname,'r');
-    [junk, FNAME, vessel] = fileparts(fname);
-else
-    fid = fopen([fpath '/' fname '.m'],'r');
-    FNAME = fname;
-end
-
-% Read the matlab file.
-file = textscan(fid,'%s','delimiter','\n');
-file = file{1};
-
-% Close the matlab file.
-fclose(fid);
-
-% Locate the test blocks.
-b1 = find(strncmp(file,'%@test:',7))+1;
-b2 = find(strncmp(file,'%@eof:',6))-1;
-nn = length(b2);
-
-if length(b1)-length(b2)
-    error('test:: There is a problem with the test blocks definition!')
-end
-
-% Initialize the second output if necessary.
-if nargout>1
-    % First column   name of the tested routine.
-    % Second column  number of the unitary test.
-    % Third column   status of the unitary test (0 if the test fails, 1 otherwise)
-    % Fourth column  details about the failure (vector of integers)
-    % Fifth column   elapsed time in seconds (cpu time).
-    info = cell(nn,5);
-end
-
-% Perform the tests.
-for i=1:nn
-    if nargout>1
-        info(i,1) = {fname};
-        info(i,2) = {i};
-    end
-    % Write the temporary test routine.
-    tid = fopen([FNAME '_test_' int2str(i) '.m'],'w');
-    fprintf(tid,['function [T,t,LOG] = ' FNAME '_test_' int2str(i) '()\n']);
-    fprintf(tid,['try\n']);
-    for j=b1(i):b2(i)
-        str = sprintf('%s \n',file{j}(4:end));
-        str = regexprep(str, '%', '%%');
-        fprintf(tid,str);
-    end
-    fprintf(tid,['LOG = NaN;\n']);
-    if isoctave
-        fprintf(tid,'catch\n');
-        fprintf(tid,'exception = lasterror;\n');
-        fprintf(tid, 'LOG = ''%s'';\n','The Log output is not available with Octave!');
-    else
-        fprintf(tid,'catch exception\n');
-        fprintf(tid,['LOG = getReport(exception,''extended'');\n']);
-    end
-    fprintf(tid,['T = NaN;\n']);
-    fprintf(tid,['t = NaN;\n']);
-    fprintf(tid,['end\n']);
-    fclose(tid);
-    % Call the temporary test routine.
-    init = cputime;
-    [TestFlag,TestDetails,LOG] = feval([FNAME '_test_' int2str(i)]);
-    time = cputime-init;
-    if isnan(TestFlag)
-        fprintf(['\n'])
-        fprintf(['Call to ' FNAME ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n'])
-        fprintf(['\n'])
-        if ~isoctave
-            disp(LOG)
-        end
-        check = 0;
-        if nargout>1
-            info(i,3) = {0};
-        end
-        continue
-    end
-    if ~TestFlag
-        if nargout>1
-            info(i,3) = {0};
-            tmp = ones(length(TestDetails),1);
-        end
-        fprintf(['Test n°' int2str(i) ' for routine ' FNAME ' failed (' datestr(now) ')!\n']);
-        for j=1:length(TestDetails)
-            if ~TestDetails(j)
-                if nargout>1
-                    tmp(j) = 0;
-                end
-                fprintf(['Output argument n°' int2str(j) ' didn''t give the expected result.\n']);
-            end
-        end
-        if nargout>1
-            info(i,4) = {tmp};
-            info(i,5) = {NaN};
-        end
-        check = 0;
-    else
-        if nargout>1
-            info(i,3) = {1};
-            info(i,4) = {ones(length(TestDetails),1)};
-            info(i,5) = {time};
-        end
-        delete([FNAME '_test_' int2str(i) '.m'])
-    end
-end
\ No newline at end of file
diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m
deleted file mode 100644
index b20d6c959b4a89c0631de4d2c5c89b33a50c49d3..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/run_unitary_tests.m
+++ /dev/null
@@ -1,36 +0,0 @@
-function [report, time] = run_unitary_tests(listoffiles)
-    
-% 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/>.
-
-report = {};
-    
-for f=1:length(listoffiles)
-    if isequal(listoffiles{f}(end-1:end),'.m') && isempty(strfind(listoffiles{f},'.#'))
-        if is_unitary_test_available(listoffiles{f})
-            disp(['***** Process unitary tests in      ' listoffiles{f}])
-            [check, info] = mtest(listoffiles{f});
-            report = [report; info];
-        else
-            disp(['Booh! No unitary tests available in ' listoffiles{f}])
-        end
-    end
-end
-
-if nargout>1
-    time = clock;
-end
diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m
deleted file mode 100644
index ef2499eb54277b75414861517b7d4b5a8c4beb62..0000000000000000000000000000000000000000
--- a/matlab/utilities/tests/run_unitary_tests_in_directory.m
+++ /dev/null
@@ -1,47 +0,0 @@
-function report = run_unitary_tests_in_directory(dirname,savereport,printreport,sendreport)
-
-% 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/>.
-
-system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info');
-system('git rev-parse HEAD > git.last-commit-hash');
-
-fid = fopen('git.info');
-gitinfo = fgetl(fid);
-gitinfo = char(gitinfo,fgetl(fid));
-fclose(fid);
-
-fid = fopen('git.last-commit-hash');
-gitlastcommithash = fgetl(fid);
-fclose(fid);
-
-matlabverion = version;
-platform = computer;
-
-listoffiles = get_directory_description(dirname);
-
-diary(['report-' gitlastcommithash '.log'] )
-[report, time] = run_unitary_tests(listoffiles)
-diary off
-
-if nargin>1 && savereport>0
-    save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash','matlabverion','platform');
-end
-
-if nargin>2
-    build_report_summary(['report-' gitlastcommithash '.mat'], printreport, sendreport);
-end
\ No newline at end of file
diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy
index 1a0399c26df915469a61636919428848d290ae68..1773f3ea26c76c9df06d837acdba397c63a19b9b 100644
--- a/preprocessor/DynareBison.yy
+++ b/preprocessor/DynareBison.yy
@@ -84,7 +84,7 @@ class ParsingDriver;
 
 %token AIM_SOLVER ANALYTIC_DERIVATION AR AUTOCORR
 %token BAYESIAN_IRF BETA_PDF BLOCK USE_CALIBRATION
-%token BVAR_DENSITY BVAR_FORECAST PARAMS
+%token BVAR_DENSITY BVAR_FORECAST PARAMS NODECOMPOSITION
 %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
@@ -94,7 +94,7 @@ class ParsingDriver;
 %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR
 %token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME PROCESS PROBABILITY MULTINOMIAL
 %token <string_val> FLOAT_NUMBER DATES NUM_NONSTATIONARY MAX_ORDER_OF_INTEGRATION
-%token DEFAULT FIXED_POINT
+%token DEFAULT FIXED_POINT OPT_ALGO
 %token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
 %token GAMMA_PDF GRAPH GRAPH_FORMAT CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
 %token HISTVAL HISTVAL_FILE HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID
@@ -1120,6 +1120,7 @@ stoch_simul_primary_options : o_dr_algo
 
 stoch_simul_options : stoch_simul_primary_options
                     | o_loglinear
+                    | o_nodecomposition
                     ;
 
 prob_symbol_list : prob_symbol_list symbol
@@ -1696,7 +1697,8 @@ estimation_options : o_datafile
                    | o_mh_nblocks
                    | o_load_mh_file
                    | o_loglinear
-		   | o_logdata
+                   | o_logdata
+                   | o_nodecomposition
                    | o_nodiagnostic
                    | o_bayesian_irf
                    | o_dsge_var
@@ -1810,6 +1812,8 @@ osr_options_list : osr_options_list COMMA osr_options
 osr_options : stoch_simul_primary_options
             | o_osr_maxit
             | o_osr_tolf
+            | o_opt_algo
+            | o_optim
             ;
 
 osr : OSR ';'
@@ -1868,6 +1872,8 @@ identification_option : o_ar
                       | o_nograph
                       | o_nodisplay
                       | o_graph_format
+                      | o_diffuse_filter
+                      | o_prior_trunc
                       ;
 
 model_comparison : MODEL_COMPARISON mc_filename_list ';'
@@ -2431,6 +2437,9 @@ calib_smoother_options_list : calib_smoother_option COMMA calib_smoother_options
 calib_smoother_option : o_filtered_vars
                       | o_filter_step_ahead
                       | o_datafile
+                      | o_prefilter
+                      | o_loglinear
+                      | o_first_obs
                       ;
 
 extended_path : EXTENDED_PATH ';'
@@ -2564,6 +2573,9 @@ o_simul_maxit : MAXIT EQUAL INT_NUMBER { driver.option_num("simul.maxit", $3); }
 o_dp_maxit : MAXIT EQUAL INT_NUMBER { driver.option_num("dp.maxit", $3); };
 o_osr_maxit : MAXIT EQUAL INT_NUMBER { driver.option_num("osr.maxit", $3); };
 o_osr_tolf : TOLF EQUAL non_negative_number { driver.option_num("osr.tolf", $3); };
+o_opt_algo : OPT_ALGO EQUAL INT_NUMBER { driver.option_num("osr.opt_algo", $3); }
+           | OPT_ALGO EQUAL filename { driver.option_str("osr.opt_algo", $3); }
+           ;
 o_cutoff : CUTOFF EQUAL non_negative_number { driver.cutoff($3); };
 o_markowitz : MARKOWITZ EQUAL non_negative_number { driver.option_num("markowitz", $3); };
 o_minimal_solving_periods : MINIMAL_SOLVING_PERIODS EQUAL non_negative_number { driver.option_num("minimal_solving_periods", $3); };
@@ -2805,6 +2817,7 @@ o_parameter_set : PARAMETER_SET EQUAL PRIOR_MODE
                 | PARAMETER_SET EQUAL CALIBRATION
                   { driver.option_str("parameter_set", "calibration"); }
                 ;
+o_nodecomposition : NODECOMPOSITION { driver.option_num("nodecomposition", "1"); };
 o_ms_drop : DROP EQUAL INT_NUMBER { driver.option_num("ms.drop", $3); };
 o_ms_mh_replic : MH_REPLIC EQUAL INT_NUMBER { driver.option_num("ms.mh_replic", $3); };
 o_freq : FREQ EQUAL INT_NUMBER
diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll
index 2d3c305e88a2d6aca2bf5d1fb88bbd15caac9271..d3a003d8aa261160ec7a20b5ba7ec34e9f5a47fd 100644
--- a/preprocessor/DynareFlex.ll
+++ b/preprocessor/DynareFlex.ll
@@ -457,6 +457,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::CNUM;
 }
+<DYNARE_STATEMENT>nodecomposition {return token::NODECOMPOSITION;};
 <DYNARE_STATEMENT>banact {return token::BANACT;}
 <DYNARE_BLOCK>use_calibration {return token::USE_CALIBRATION;}
 <DYNARE_STATEMENT>output_file_tag {return token::OUTPUT_FILE_TAG;}
@@ -501,6 +502,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>random_function_convergence_criterion {return token::RANDOM_FUNCTION_CONVERGENCE_CRITERION;}
 <DYNARE_STATEMENT>random_parameter_convergence_criterion {return token::RANDOM_PARAMETER_CONVERGENCE_CRITERION;}
 <DYNARE_STATEMENT>tolf {return token::TOLF;}
+<DYNARE_STATEMENT>opt_algo {return token::OPT_ALGO;}
 <DYNARE_STATEMENT>instruments {return token::INSTRUMENTS;}
 <DYNARE_STATEMENT>hessian  {
   yylval->string_val = new string(yytext);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3b295fb88982bbf8853fe84752fcea3254996208..b133708533968acc5b62c914a8fb57adb70cac27 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,8 @@ MODFILES = \
 	example1_macroif.mod \
 	t_sgu_ex1.mod \
 	optimal_policy/osr_example.mod \
+	optimal_policy/osr_example_objective_correctness.mod \
+	optimal_policy/osr_example_obj_corr_non_stat_vars.mod \
 	optimal_policy/ramsey.mod \
 	optimal_policy/nk_ramsey.mod \
 	optimal_policy/nk_ramsey_model.mod \
@@ -120,6 +122,9 @@ MODFILES = \
 	identification/kim/kim2.mod \
 	identification/as2007/as2007.mod \
 	simul/example1.mod \
+	simul/Solow_no_varexo.mod \
+	simul/simul_ZLB_purely_forward.mod \
+	simul/simul_ZLB_purely_forward_no_solution.mod \
 	conditional_forecasts/fs2000_cal.mod \
 	conditional_forecasts/fs2000_est.mod \
 	recursive/ls2003.mod \
@@ -149,6 +154,8 @@ MODFILES = \
 	kalman_filter_smoother/fs2000_1.mod \
 	kalman_filter_smoother/fs2000_2.mod \
 	kalman_filter_smoother/fs2000a.mod \
+	kalman_filter_smoother/check_variable_dimensions/fs2000.mod \
+	kalman_filter_smoother/check_variable_dimensions/fs2000_ML.mod \
 	second_order/burnside_1.mod \
 	second_order/ds1.mod \
 	second_order/ds2.mod \
@@ -175,6 +182,7 @@ MODFILES = \
 	shock_decomposition/fs2000_est_varlist.mod \
 	stochastic_purely_forward/stochastic_purely_forward.mod \
 	stochastic_purely_forward/stochastic_purely_forward_with_static.mod \
+	forecast/Hansen_exo_det_forecast.mod \
 	gradient/fs2000_numgrad_13.mod \
 	gradient/fs2000_numgrad_15.mod \
 	gradient/fs2000_numgrad_2.mod \
diff --git a/tests/forecast/Hansen_exo_det_forecast.mod b/tests/forecast/Hansen_exo_det_forecast.mod
new file mode 100644
index 0000000000000000000000000000000000000000..22744908a5c8534855ef981ea5e2ce0f3c658677
--- /dev/null
+++ b/tests/forecast/Hansen_exo_det_forecast.mod
@@ -0,0 +1,95 @@
+/*
+* The Hansen model following McCandless, George T. (2008): The ABCs of RBCs, Hardvard University Press, Chapter 6
+*
+* This mod-file tests the correctness of forecasting with exogenous deterministic variables.
+* A forecast starting at the steady state in t=0, where the only shock is a perfectly 
+* anticipated shock in t=8, is equal to the IRF to a 7 period anticipated news shock.
+* Note the timing difference due to the fact that in forecasting. the agent starts at the 
+* steady state at time 0 and has the first endogenous reaction period at t=1 so that the shock at 
+* t=8 is only 7 period anticipated
+
+* This implementation was written by Johannes Pfeifer. Please note that the
+* following copyright notice only applies to this Dynare implementation of the
+* model.
+*/
+
+/*
+ * Copyright (C) 2014 Johannes Pfeifer
+ *
+ * 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/>.
+ */
+
+
+
+var c r y h k a;
+varexo eps_a_surp eps_a_antic;
+varexo_det e_det;
+
+parameters beta delta theta rho_a A_disutil;
+
+beta = 0.99;
+delta = 0.025;
+theta = 0.36;
+rho_a = 0.35;
+A_disutil = 2;
+
+model;
+1/c = beta*((1/c(+1))*(r(+1) +(1-delta)));
+(1-h)*(1-theta)*(y/h) = A_disutil*c;
+c = y +(1-delta)*k(-1) - k;
+y = a*k(-1)^(theta)*h^(1-theta);
+r = theta*(y/k(-1));
+log(a)=rho_a*log(a(-1))+eps_a_surp+eps_a_antic(-7)+e_det;
+end;
+
+steady_state_model;
+a = 1;
+h = (1+(A_disutil/(1-theta))*(1 - (beta*delta*theta)/(1-beta*(1-delta))))^(-1);
+k = h*(theta*a/(1/beta -(1-delta)))^(1/(1-theta));
+y = a*k^(theta)*h^(1-theta);
+c = y-delta*k;
+r =  1/beta - (1-delta);
+end;
+
+steady;
+
+shocks;
+var eps_a_surp; stderr 0;
+var eps_a_antic; stderr 0.01;
+var e_det;
+periods 8;
+values 0.01;
+end;
+
+stoch_simul(irf=40,nomoments, order=1);
+
+% make_ex_;
+
+forecast(periods=40);
+figure
+for ii=1:M_.orig_endo_nbr
+    subplot(3,3,ii)    
+    var_name=deblank(M_.endo_names(ii,:));
+    var_index=strmatch(var_name,deblank(M_.endo_names),'exact');
+    plot(1:40,oo_.dr.ys(var_index)+oo_.irfs.([var_name,'_eps_a_antic']),'b',1:40,... %
+            oo_.forecast.Mean.(var_name),'r--')
+    title(var_name)
+    difference(ii,:)=oo_.dr.ys(var_index)+oo_.irfs.([var_name,'_eps_a_antic'])-oo_.forecast.Mean.(var_name)';
+end
+
+if max(max(abs(difference)))>1e-10
+   error('Forecasts with exogenous deterministic variable is wrong') 
+end
\ No newline at end of file
diff --git a/tests/fs2000/fs2000_mode_compute_8.mod b/tests/fs2000/fs2000_mode_compute_8.mod
index 8ea1ec5786ea128e58e5da4ff1ef3b5ddb83a66d..4f39e10bfed58663ae0ec3e90966d4969f058ec7 100644
--- a/tests/fs2000/fs2000_mode_compute_8.mod
+++ b/tests/fs2000/fs2000_mode_compute_8.mod
@@ -72,4 +72,11 @@ varobs gp_obs gy_obs;
 
 options_.solve_tolf = 1e-12;
 
-estimation(order=1,datafile=fsdat_simul,nobs=192,mode_compute=8,loglinear,mh_replic=0);
+estimation(order=1,datafile=fsdat_simul,nobs=192,mode_compute=8,loglinear,mh_replic=0,optim=(
+'MaxIter',5000,
+'TolFun',1e-4,
+'TolX',1e-4,
+'MaxFunEvals',5000,
+'MaxFunEvalFactor',500,
+'InitialSimplexSize',0.05
+));
diff --git a/tests/kalman_filter_smoother/check_variable_dimensions/fs2000.mod b/tests/kalman_filter_smoother/check_variable_dimensions/fs2000.mod
new file mode 100644
index 0000000000000000000000000000000000000000..f13639d24fb268f7ed63e6e600afe7a1a5a2e3be
--- /dev/null
+++ b/tests/kalman_filter_smoother/check_variable_dimensions/fs2000.mod
@@ -0,0 +1,193 @@
+/*
+ * This file replicates the estimation of the cash in advance model described
+ * Frank Schorfheide (2000): "Loss function-based evaluation of DSGE models",
+ * Journal of Applied Econometrics, 15(6), 645-670.
+ *
+ * The data are in file "fsdat_simul.m", and have been artificially generated.
+ * They are therefore different from the original dataset used by Schorfheide.
+ *
+ * The equations are taken from J. Nason and T. Cogley (1994): "Testing the
+ * implications of long-run neutrality for monetary business cycle models",
+ * Journal of Applied Econometrics, 9, S37-S70.
+ * Note that there is an initial minus sign missing in equation (A1), p. S63.
+ *
+ * This implementation was written by Michel Juillard. Please note that the
+ * following copyright notice only applies to this Dynare implementation of the
+ * model.
+ */
+
+/*
+ * Copyright (C) 2004-2010 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/>.
+ */
+
+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;
+
+alp = 0.33;
+bet = 0.99;
+gam = 0.003;
+mst = 1.011;
+rho = 0.7;
+psi = 0.787;
+del = 0.02;
+
+model;
+dA = exp(gam+e_a);
+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;
+-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
+R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
+1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
+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);
+y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
+gy_obs = dA*y/y(-1);
+gp_obs = (P/P(-1))*m(-1)/dA;
+end;
+
+shocks;
+var e_a; stderr 0.014;
+var e_m; stderr 0.005;
+end;
+
+steady_state_model;
+  dA = exp(gam);
+  gst = 1/dA;
+  m = mst;
+  khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
+  xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
+  nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
+  n  = xist/(nust+xist);
+  P  = xist + nust;
+  k  = khst*n;
+
+  l  = psi*mst*n/( (1-psi)*(1-n) );
+  c  = mst/P;
+  d  = l - mst + 1;
+  y  = k^alp*n^(1-alp)*gst^alp;
+  R  = mst/bet;
+  W  = l/n;
+  ist  = y-c;
+  q  = 1 - d;
+
+  e = 1;
+  
+  gp_obs = m/dA;
+  gy_obs = dA;
+end;
+
+steady;
+
+check;
+
+estimated_params;
+alp, beta_pdf, 0.356, 0.02;
+bet, beta_pdf, 0.993, 0.002;
+gam, normal_pdf, 0.0085, 0.003;
+mst, normal_pdf, 1.0002, 0.007;
+rho, beta_pdf, 0.129, 0.223;
+psi, beta_pdf, 0.65, 0.05;
+del, beta_pdf, 0.01, 0.005;
+stderr e_a, inv_gamma_pdf, 0.035449, inf;
+stderr e_m, inv_gamma_pdf, 0.008862, inf;
+stderr gp_obs, inv_gamma_pdf, 0.001, inf;
+end;
+
+varobs gp_obs gy_obs;
+
+estimation(order=1,datafile='../fsdat_simul', nobs=192, loglinear, mh_replic=2000, mh_nblocks=1, mh_jscale=0.8,forecast=8,smoother,filtered_vars,filter_step_ahead=[1:2],filter_decomposition)  m P c e W R k d y gy_obs;
+
+if size(oo_.PointForecast.deciles.gy_obs,1)~=9
+    error('Number of deciles must be 9')
+end
+
+if size(oo_.PointForecast.deciles.gy_obs,2)~=options_.forecast || ...
+        size(oo_.PointForecast.Mean.gy_obs,1)~=options_.forecast || ...
+        size(oo_.PointForecast.Median.gy_obs,1)~=options_.forecast || ...
+        size(oo_.PointForecast.Var.gy_obs,1)~=options_.forecast || ...
+        size(oo_.PointForecast.HPDinf.gy_obs,1)~=options_.forecast || ...
+        size(oo_.PointForecast.HPDsup.gy_obs,1)~=options_.forecast || ...
+        size(oo_.MeanForecast.deciles.gy_obs,2)~=options_.forecast || ...
+        size(oo_.MeanForecast.Mean.gy_obs,1)~=options_.forecast || ...
+        size(oo_.MeanForecast.Median.gy_obs,1)~=options_.forecast || ...
+        size(oo_.MeanForecast.Var.gy_obs,1)~=options_.forecast || ...
+        size(oo_.MeanForecast.HPDinf.gy_obs,1)~=options_.forecast || ...
+        size(oo_.MeanForecast.HPDsup.gy_obs,1)~=options_.forecast 
+    error('Forecasts have the wrong length')
+end
+
+if size(oo_.UpdatedVariables.deciles.gy_obs,2)~=options_.nobs || ...
+        size(oo_.UpdatedVariables.Mean.gy_obs,1)~=options_.nobs || ...
+        size(oo_.UpdatedVariables.Median.gy_obs,1)~=options_.nobs || ...
+        size(oo_.UpdatedVariables.Var.gy_obs,1)~=options_.nobs || ...
+        size(oo_.UpdatedVariables.HPDinf.gy_obs,1)~=options_.nobs || ...
+        size(oo_.UpdatedVariables.HPDsup.gy_obs,1)~=options_.nobs
+    error('Updated Variables have the wrong length')
+end
+
+if size(oo_.Filtered_Variables_1_step_ahead.deciles.gy_obs,2)~=options_.nobs || ...
+        size(oo_.Filtered_Variables_1_step_ahead.Mean.gy_obs,1)~=options_.nobs || ...
+        size(oo_.Filtered_Variables_1_step_ahead.Median.gy_obs,1)~=options_.nobs || ...
+        size(oo_.Filtered_Variables_1_step_ahead.Var.gy_obs,1)~=options_.nobs || ...
+        size(oo_.Filtered_Variables_1_step_ahead.HPDinf.gy_obs,1)~=options_.nobs || ...
+        size(oo_.Filtered_Variables_1_step_ahead.HPDsup.gy_obs,1)~=options_.nobs
+    error('Filtered_Variables_1_step_ahead have the wrong length')
+end
+
+
+if size(oo_.SmoothedVariables.deciles.gy_obs,2)~=options_.nobs || ...
+        size(oo_.SmoothedVariables.Mean.gy_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedVariables.Median.gy_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedVariables.Var.gy_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedVariables.HPDinf.gy_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedVariables.HPDsup.gy_obs,1)~=options_.nobs
+    error('Smoothed Variables have the wrong length')
+end
+
+if size(oo_.SmoothedShocks.deciles.e_a,2)~=options_.nobs || ...
+        size(oo_.SmoothedShocks.Mean.e_a,1)~=options_.nobs || ...
+        size(oo_.SmoothedShocks.Median.e_a,1)~=options_.nobs || ...
+        size(oo_.SmoothedShocks.Var.e_a,1)~=options_.nobs || ...
+        size(oo_.SmoothedShocks.HPDinf.e_a,1)~=options_.nobs || ...
+        size(oo_.SmoothedShocks.HPDsup.e_a,1)~=options_.nobs
+    error('Smoothed Shocks have the wrong length')
+end
+
+if size(oo_.FilteredVariables.deciles.gy_obs,2)~=options_.nobs || ...
+        size(oo_.FilteredVariables.Mean.gy_obs,1)~=options_.nobs || ...
+        size(oo_.FilteredVariables.Median.gy_obs,1)~=options_.nobs || ...
+        size(oo_.FilteredVariables.Var.gy_obs,1)~=options_.nobs || ...
+        size(oo_.FilteredVariables.HPDinf.gy_obs,1)~=options_.nobs || ...
+        size(oo_.FilteredVariables.HPDsup.gy_obs,1)~=options_.nobs
+    error('Filtered Variables have the wrong length')
+end
+
+if size(oo_.SmoothedMeasurementErrors.deciles.SE_EOBS_gp_obs,2)~=options_.nobs || ...
+        size(oo_.SmoothedMeasurementErrors.Mean.SE_EOBS_gp_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedMeasurementErrors.Median.SE_EOBS_gp_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedMeasurementErrors.Var.SE_EOBS_gp_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedMeasurementErrors.HPDinf.SE_EOBS_gp_obs,1)~=options_.nobs || ...
+        size(oo_.SmoothedMeasurementErrors.HPDsup.SE_EOBS_gp_obs,1)~=options_.nobs
+    error('SmoothedMeasurementErrors have the wrong length')
+end
+
diff --git a/tests/kalman_filter_smoother/check_variable_dimensions/fs2000_ML.mod b/tests/kalman_filter_smoother/check_variable_dimensions/fs2000_ML.mod
new file mode 100644
index 0000000000000000000000000000000000000000..6b396682cbff9ebe9ecf695fa6b12d143494c478
--- /dev/null
+++ b/tests/kalman_filter_smoother/check_variable_dimensions/fs2000_ML.mod
@@ -0,0 +1,161 @@
+/*
+ * This file replicates the estimation of the cash in advance model described
+ * Frank Schorfheide (2000): "Loss function-based evaluation of DSGE models",
+ * Journal of Applied Econometrics, 15(6), 645-670.
+ *
+ * The data are in file "fsdat_simul.m", and have been artificially generated.
+ * They are therefore different from the original dataset used by Schorfheide.
+ *
+ * The equations are taken from J. Nason and T. Cogley (1994): "Testing the
+ * implications of long-run neutrality for monetary business cycle models",
+ * Journal of Applied Econometrics, 9, S37-S70.
+ * Note that there is an initial minus sign missing in equation (A1), p. S63.
+ *
+ * This implementation was written by Michel Juillard. Please note that the
+ * following copyright notice only applies to this Dynare implementation of the
+ * model.
+ */
+
+/*
+ * Copyright (C) 2004-2010 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/>.
+ */
+
+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 theta;
+
+alp = 0.33;
+bet = 0.99;
+gam = 0.003;
+mst = 1.011;
+rho = 0.7;
+psi = 0.787;
+del = 0.02;
+theta=0;
+
+model;
+dA = exp(gam+e_a);
+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;
+-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
+R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
+1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
+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);
+y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
+gy_obs = dA*y/y(-1);
+gp_obs = (P/P(-1))*m(-1)/dA;
+end;
+
+steady_state_model;
+  dA = exp(gam);
+  gst = 1/dA;
+  m = mst;
+  khst = ( (1-gst*bet*(1-del)) / (alp*gst^alp*bet) )^(1/(alp-1));
+  xist = ( ((khst*gst)^alp - (1-gst*(1-del))*khst)/mst )^(-1);
+  nust = psi*mst^2/( (1-alp)*(1-psi)*bet*gst^alp*khst^alp );
+  n  = xist/(nust+xist);
+  P  = xist + nust;
+  k  = khst*n;
+
+  l  = psi*mst*n/( (1-psi)*(1-n) );
+  c  = mst/P;
+  d  = l - mst + 1;
+  y  = k^alp*n^(1-alp)*gst^alp;
+  R  = mst/bet;
+  W  = l/n;
+  ist  = y-c;
+  q  = 1 - d;
+
+  e = 1;
+  
+  gp_obs = m/dA;
+  gy_obs = dA;
+end;
+
+
+shocks;
+var e_a; stderr 0.014;
+var e_m; stderr 0.005;
+end;
+
+varobs gp_obs gy_obs;
+
+steady;
+check;
+
+estimated_params;
+alp, 0.356;
+gam,  0.0085;
+mst, 1.0002;
+rho, 0.129;
+psi, 0.65;
+del,  0.02;
+stderr e_a, 0.035449;
+stderr e_m, 0.008862;
+corr e_m, e_a, 0;
+stderr gp_obs, 0.01;
+end;
+options_.prior_trunc=0;
+estimation(order=1,datafile='../fsdat_simul', nobs=192, loglinear, forecast=8,smoother,filtered_vars,filter_step_ahead=[1,2,4],filter_decomposition,selected_variables_only)  m P c e W R k d y gy_obs;
+
+
+if size(oo_.FilteredVariablesKStepAhead,3)~=(options_.nobs+max(options_.filter_step_ahead)) || ...
+        size(oo_.FilteredVariablesKStepAhead,1)~=(length(options_.filter_step_ahead))
+    error('FilteredVariablesKStepAhead has the wrong length')    
+end
+
+if size(oo_.FilteredVariablesKStepAheadVariances,4)~=(options_.nobs+max(options_.filter_step_ahead)) || ...
+        size(oo_.FilteredVariablesKStepAheadVariances,1)~=(length(options_.filter_step_ahead))
+    error('FilteredVariablesKStepAhead has the wrong length')    
+end
+
+if size(oo_.FilteredVariablesShockDecomposition,4)~=(options_.nobs+max(options_.filter_step_ahead)) || ...
+        size(oo_.FilteredVariablesShockDecomposition,1)~=(length(options_.filter_step_ahead))
+    error('FilteredVariablesShockDecomposition has the wrong length')    
+end
+
+if size(oo_.SmoothedVariables.gy_obs,1)~=options_.nobs
+    error('SmoothedVariables has the wrong length')    
+end
+
+if size(oo_.FilteredVariables.gy_obs,1)~=options_.nobs
+    error('FilteredVariables has the wrong length')    
+end
+
+if size(oo_.UpdatedVariables.gy_obs,1)~=options_.nobs
+    error('UpdatedVariables has the wrong length')    
+end
+
+if size(oo_.SmoothedShocks.e_a,1)~=options_.nobs
+    error('SmoothedShocks has the wrong length')    
+end
+
+if size(oo_.SmoothedMeasurementErrors.gy_obs,1)~=options_.nobs
+    error('SmoothedShocks has the wrong length')    
+end
+
+if size(oo_.forecast.Mean.gy_obs,1)~=options_.forecast || ...
+    size(oo_.forecast.HPDinf.gy_obs,1)~=options_.forecast || ...
+    size(oo_.forecast.HPDsup.gy_obs,1)~=options_.forecast
+    error('Forecasts have the wrong length')    
+end
diff --git a/tests/optimal_policy/osr_example_obj_corr_non_stat_vars.mod b/tests/optimal_policy/osr_example_obj_corr_non_stat_vars.mod
new file mode 100644
index 0000000000000000000000000000000000000000..4720a2566f7c49c7418b379acb59cb6fb2db49f8
--- /dev/null
+++ b/tests/optimal_policy/osr_example_obj_corr_non_stat_vars.mod
@@ -0,0 +1,636 @@
+//This mod-file tests the value of the objective function in the presence of non-stationary variables
+
+Var
+
+
+p_U_Hat            
+
+pi_U_Hat               
+r_Hat              
+r_Gap
+r_Eff
+realrate_U_Hat
+realrate_U_Eff
+realrate_U_Gap     
+
+
+c_U_Gap            
+c_U_Eff
+c_U_Hat
+g_U_Gap            
+g_U_Eff
+g_U_Hat
+
+y_U_Gap            
+y_U_Eff
+y_U_Hat
+
+l_U_Gap             
+l_U_Eff
+l_U_Hat
+
+a_U_Hat            
+
+
+
+p_A_Hat             
+pc_A_Hat           
+
+tt_A_Hat           
+tt_A_Gap
+tt_A_Eff
+
+pi_A_Hat           
+pic_A_Hat         
+c_A_Gap             
+c_A_Eff
+c_A_Hat
+
+g_A_Gap             
+g_A_Eff
+g_A_Hat
+
+realrate_A_Hat      
+
+l_A_Gap             
+l_A_Eff
+l_A_Hat
+
+muW_A_Hat          
+y_A_Gap             
+y_A_Eff
+y_A_Hat
+
+a_A_Hat             
+mc_A_Hat           
+
+tau_A_Hat           
+tau_A_Gap
+tau_A_Eff
+
+Kdebt_A        
+                    
+
+
+
+
+
+p_B_Hat             
+pc_B_Hat            
+
+tt_B_Hat            
+tt_B_Gap
+tt_B_Eff
+
+pi_B_Hat           
+pic_B_Hat          
+c_B_Gap             
+c_B_Eff
+c_B_Hat
+
+g_B_Gap             
+g_B_Eff
+g_B_Hat
+
+realrate_B_Hat      
+
+l_B_Gap             
+l_B_Eff
+l_B_Hat
+
+muW_B_Hat          
+y_B_Gap             
+y_B_Eff
+y_B_Hat
+
+a_B_Hat             
+mc_B_Hat          
+
+tau_B_Hat          
+tau_B_Gap
+tau_B_Eff
+
+Kdebt_B        
+
+
+;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%DECLARATION OF EXOGENOUS VARIABLES%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+Varexo
+
+eps_muW_A       
+eps_a_A         
+
+eps_muW_B       
+eps_a_B         
+
+; 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%DECLARATION OF PARAMETERS%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+parameters
+n               
+alpha           
+beta            
+rho             
+lambdaA         
+lambdaB         
+sigma          
+chi             
+psi             
+
+epsilon         
+muP             
+gamma           
+ell             
+phi_GY          
+phi_caps       
+
+theta_A         
+               
+theta_B         
+                
+phi_A           
+phi_B          
+
+
+%%%%%%
+//Rule Parameters
+
+ruleR_U_y      
+ruleR_U_pi     
+ruleR_U_debt
+
+ruleG_A_y
+ruleG_A_tt
+ruleG_A_debt
+
+
+ruleG_B_y
+ruleG_B_tt
+ruleG_B_debt
+
+
+
+ruleT_A_y
+ruleT_A_tt
+ruleT_A_debt
+
+
+
+ruleT_B_y
+ruleT_B_tt
+ruleT_B_debt
+
+%%%%%%
+
+
+
+rho_a_A         
+rho_a_B	
+rho_muW_A      
+rho_muW_B
+rho_mp          
+
+
+
+r_SS
+
+muW_SS                  
+tau_A_SS                
+DebtOutput_A_SS         
+
+
+tau_B_SS
+DebtOutput_B_SS    
+
+
+;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+%%SET PARAMETER VALUES%%
+%%%%%%CALIBRATION%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%
+n = 0.5; 
+alpha = 0.4;    
+beta = 0.99 ;   
+rho = -log(beta);
+lambdaA = 1-(1-n)*alpha;
+lambdaB = 1-n*alpha;
+sigma = 0.4;   
+chi = 3;    
+psi = 0.4;    
+
+epsilon = 11;  
+muP = 1/(epsilon - 1);
+gamma	= 4.5;
+ell = 11;      
+
+phi_GY = 0.25; 
+phi_caps = alpha*(gamma-(1-alpha)*(-gamma+sigma));
+
+theta_A = 0.75;     
+theta_B = 0.75;     
+phi_A = (1 - theta_A*beta)*(1 - theta_A)/(theta_A*(1 + epsilon*chi)); 
+phi_B = (1 - theta_B*beta)*(1 - theta_B)/(theta_B*(1 + epsilon*chi));  
+
+
+
+
+//Rule Parameters
+
+ruleR_U_y = 0.5;     
+ruleR_U_pi = 1.5;     
+ruleR_U_debt = 0;
+
+
+ruleG_A_y = 0;
+ruleG_A_tt = 0;
+ruleG_A_debt = -0.05;
+
+
+ruleG_B_y = ruleG_A_y;
+ruleG_B_tt = 0;
+ruleG_B_debt = ruleG_A_debt;
+
+
+ruleT_A_y = 0;
+ruleT_A_tt = 0;
+ruleT_A_debt = 0.05;
+
+
+ruleT_B_y = ruleT_A_y;
+ruleT_B_tt = 0;
+ruleT_B_debt = ruleT_A_debt;
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+rho_a_A = 0.85;    
+rho_a_B = 0.85;
+rho_muW_A = 0;
+rho_muW_B = 0;
+rho_mp = 0;      
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%% STEADY STATE VALUES %%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+muW_SS = 1/(ell - 1);
+
+r_SS = log(1/beta);
+
+DebtOutput_A_SS = 4*0.6;
+                      
+DebtOutput_B_SS = 4*0.6; 
+
+
+tau_A_SS = phi_GY + r_SS*DebtOutput_A_SS; 
+tau_B_SS = phi_GY + r_SS*DebtOutput_B_SS; 
+
+
+
+
+
+
+
+model(linear);
+
+
+p_U_Hat = n*p_A_Hat + (1-n)*p_B_Hat; 
+pi_U_Hat = n*pi_A_Hat + (1-n)*pi_B_Hat; 
+
+
+c_U_Gap = c_U_Gap(+1)- sigma*(r_Gap - pi_U_Hat(+1));
+
+
+realrate_U_Gap = realrate_U_Hat - realrate_U_Eff; 
+realrate_U_Eff = ((1 + chi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*(a_U_Hat(+1) - a_U_Hat); 
+
+realrate_U_Hat = r_Hat - pi_U_Hat(+1);
+
+
+r_Eff = ((1 + chi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*(a_U_Hat(+1) - a_U_Hat);
+r_Hat = r_Gap + r_Eff;
+
+
+
+// Interest rate rule
+r_Gap = ruleR_U_y*y_U_Gap(-1) + ruleR_U_pi*pi_U_Hat(-1) + ruleR_U_debt*(n*Kdebt_A(-1) + (1-n)*Kdebt_B(-1));
+
+
+
+
+c_U_Gap = n*c_A_Gap + (1-n)*c_B_Gap; 
+c_U_Eff = n*c_A_Eff + (1-n)*c_B_Eff;
+c_U_Hat = n*c_A_Hat + (1-n)*c_B_Hat;
+
+g_U_Gap = n*g_A_Gap + (1-n)*g_B_Gap; 
+g_U_Eff = n*g_A_Eff + (1-n)*g_B_Eff;
+g_U_Hat = n*g_A_Hat + (1-n)*g_B_Hat;
+
+
+y_U_Gap = n*y_A_Gap + (1-n)*y_B_Gap; 
+y_U_Eff = n*y_A_Eff + (1-n)*y_B_Eff;
+y_U_Hat = n*y_A_Hat + (1-n)*y_B_Hat;
+
+l_U_Gap = n*l_A_Gap + (1-n)*l_B_Gap; 
+l_U_Eff = n*l_A_Eff + (1-n)*l_B_Eff;
+l_U_Hat = n*l_A_Hat + (1-n)*l_B_Hat;
+
+a_U_Hat = n*a_A_Hat + (1-n)*a_B_Hat; 
+
+
+tt_A_Hat = (p_U_Hat - p_A_Hat)/(1-n);                   
+
+pi_A_Hat = p_A_Hat - p_A_Hat(-1); 			
+pic_A_Hat = pc_A_Hat - pc_A_Hat(-1); 		
+
+
+pic_A_Hat = pi_A_Hat + (1-lambdaA)*(tt_A_Hat - tt_A_Hat(-1)); 
+			
+		
+
+c_A_Eff = (((1 + chi)*sigma)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 - alpha)*(1 + chi)*sigma)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_A_Hat - a_U_Hat);
+
+g_A_Eff = (((1 + chi)*psi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 + chi)*psi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_A_Hat - a_U_Hat);
+
+y_A_Eff = (((1 + chi)*(phi_GY*psi + (1 - phi_GY)*sigma))/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 + chi)*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha))))/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_A_Hat - a_U_Hat);
+
+l_A_Eff = y_A_Eff - a_A_Hat;
+
+
+realrate_A_Hat = r_Hat - pic_A_Hat(+1);
+
+
+tt_A_Gap = tt_A_Hat - tt_A_Eff;
+tt_A_Eff = ((1 + chi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*((a_A_Hat - a_U_Hat)/(1-n)); 
+
+
+y_A_Gap = l_A_Gap; 
+
+
+pi_A_Hat = beta*pi_A_Hat(+1)+ phi_A*mc_A_Hat;
+
+mc_A_Hat = tau_A_Gap/(1 - tau_A_SS) +(chi + 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))* y_A_Gap - (phi_GY /((1- phi_GY)*(phi_caps+sigma*(1-alpha))))*g_A_Gap + (1/(sigma*(1- phi_GY))- 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))* y_U_Gap - phi_GY *(1/(sigma*(1 - phi_GY)) - 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))*g_U_Gap;
+
+
+tau_A_Hat = tau_A_Gap + tau_A_Eff;
+tau_A_Eff = - (1 - tau_A_SS)*muW_A_Hat;
+
+
+y_A_Gap = (1- phi_GY)*c_U_Gap + (1 - phi_GY)*(sigma*(1 - alpha) + phi_caps)*(1-n)*tt_A_Gap + phi_GY*g_A_Gap;
+
+
+
+Kdebt_A - ((1 + r_SS)/r_SS)*(tau_A_SS - phi_GY)*r_Hat= (1/beta)*(Kdebt_A(-1) - ((1 + r_SS)/r_SS)*(tau_A_SS - phi_GY)*pi_A_Hat + (phi_GY*g_A_Gap - tau_A_SS*y_A_Gap - tau_A_Gap)) + (1/beta)*(phi_GY*g_A_Eff - tau_A_SS*y_A_Eff + (1 - tau_A_SS)*muW_A_Hat) + (1/beta)*((1 + r_SS)/r_SS)*(tau_A_SS - phi_GY)*alpha*(1-n)*(tt_A_Gap(-1) -(1/(1 + r_SS))*tt_A_Gap) + (1/beta)*((1 + r_SS)/r_SS)*(tau_A_SS - phi_GY)*alpha*(1-n)*(tt_A_Eff(-1) -(1/(1 + r_SS))*tt_A_Eff); 
+
+
+
+//FISCAL RULES
+
+g_A_Gap = ruleG_A_y*(y_A_Gap(-1) - y_U_Gap(-1)) + ruleG_A_tt*tt_A_Gap(-1) + ruleG_A_debt*Kdebt_A(-1); 
+
+tau_A_Gap = ruleT_A_y*(y_A_Gap(-1) - y_U_Gap(-1)) + ruleT_A_tt*tt_A_Gap(-1)+ ruleT_A_debt*Kdebt_A(-1); 
+
+
+c_A_Hat = c_A_Gap + c_A_Eff;
+g_A_Hat = g_A_Gap + g_A_Eff;
+y_A_Hat = y_A_Gap + y_A_Eff;
+l_A_Hat = l_A_Gap + l_A_Eff;
+
+
+
+
+
+
+
+tt_B_Hat = (p_U_Hat - p_B_Hat)/n;                  
+
+pi_B_Hat = p_B_Hat - p_B_Hat(-1); 			
+pic_B_Hat = pc_B_Hat - pc_B_Hat(-1); 		
+
+pic_B_Hat = pi_B_Hat + (1-lambdaB)*(tt_B_Hat - tt_B_Hat(-1)); 
+			
+
+c_B_Eff = (((1 + chi)*sigma)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 - alpha)*(1 + chi)*sigma)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_B_Hat - a_U_Hat);
+
+g_B_Eff = (((1 + chi)*psi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 + chi)*psi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_B_Hat - a_U_Hat);
+
+y_B_Eff = (((1 + chi)*(phi_GY*psi + (1 - phi_GY)*sigma))/(1 + chi*(phi_GY*psi + (1 - phi_GY)*sigma)))*a_U_Hat + (((1 + chi)*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha))))/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*(a_B_Hat - a_U_Hat);
+
+l_B_Eff = y_B_Eff - a_B_Hat;
+
+
+realrate_B_Hat = r_Hat - pic_B_Hat(+1);
+
+
+c_A_Gap = c_B_Gap + sigma*(1 - alpha)*((1-n)*tt_A_Gap-n*(tt_B_Gap));
+
+
+tt_B_Gap = tt_B_Hat - tt_B_Eff;
+tt_B_Eff = ((1 + chi)/(1 + chi*(phi_GY*psi + (1 - phi_GY)*(gamma + (sigma - gamma)*(1 - 2*alpha + alpha*alpha)))))*((a_B_Hat - a_U_Hat)/n); 
+
+
+y_B_Gap = l_B_Gap; //l_B_Gap = y_B_Gap + z_B , up to a first order approximation z_B=0
+
+
+pi_B_Hat = beta*pi_B_Hat(+1)+ phi_B*mc_B_Hat;
+
+mc_B_Hat = tau_B_Gap/(1 - tau_B_SS) +(chi + 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))* y_B_Gap - (phi_GY /((1- phi_GY)*(phi_caps+sigma*(1-alpha))))*g_B_Gap + (1/(sigma*(1- phi_GY))- 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))* y_U_Gap - phi_GY *(1/(sigma*(1 - phi_GY)) - 1/((1- phi_GY)*(phi_caps+sigma*(1-alpha))))*g_U_Gap;
+
+
+tau_B_Hat = tau_B_Gap + tau_B_Eff;
+tau_B_Eff = - (1 - tau_B_SS)*muW_B_Hat;
+
+
+y_B_Gap = (1- phi_GY)*c_U_Gap + (1 - phi_GY)*(sigma*(1 - alpha) + phi_caps)*n*tt_B_Gap + phi_GY*g_B_Gap;
+
+
+Kdebt_B - ((1 + r_SS)/r_SS)*(tau_B_SS - phi_GY)*r_Hat= (1/beta)*(Kdebt_B(-1) - ((1 + r_SS)/r_SS)*(tau_B_SS - phi_GY)*pi_B_Hat + (phi_GY*g_B_Gap - tau_B_SS*y_B_Gap - tau_B_Gap)) + (1/beta)*(phi_GY*g_B_Eff - tau_B_SS*y_B_Eff + (1 - tau_B_SS)*muW_B_Hat) + (1/beta)*((1 + r_SS)/r_SS)*(tau_B_SS - phi_GY)*alpha*n*(tt_B_Gap(-1) -(1/(1 + r_SS))*tt_B_Gap) + (1/beta)*((1 + r_SS)/r_SS)*(tau_B_SS - phi_GY)*alpha*n*(tt_B_Eff(-1) -(1/(1 + r_SS))*tt_B_Eff); 
+
+
+
+
+//FISCAL RULES
+
+g_B_Gap = ruleG_B_y*(y_B_Gap(-1) - y_U_Gap(-1)) + ruleG_B_tt*tt_B_Gap(-1) + ruleG_B_debt*Kdebt_B(-1); // function of domestic inflation since government spending is oriented only to domestic production  
+
+tau_B_Gap = ruleT_B_y*(y_B_Gap(-1) - y_U_Gap(-1)) + ruleT_B_tt*tt_B_Gap(-1) + ruleT_B_debt*Kdebt_B(-1); // function of domenstic inflation(!?)
+
+
+
+c_B_Hat = c_B_Gap + c_B_Eff;
+g_B_Hat = g_B_Gap + g_B_Eff;
+y_B_Hat = y_B_Gap + y_B_Eff;
+l_B_Hat = l_B_Gap + l_B_Eff;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%% Exogenous processes %%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+
+a_A_Hat 	= rho_a_A* a_A_Hat(-1) + eps_a_A;
+a_B_Hat 	= rho_a_B* a_B_Hat(-1) + eps_a_B;
+
+muW_A_Hat 	= rho_muW_A*muW_A_Hat(-1) + eps_muW_A;
+muW_B_Hat	= rho_muW_B*muW_B_Hat(-1) + eps_muW_B;
+
+
+end;
+
+
+
+shocks;
+
+var eps_a_B; stderr 1;
+var eps_a_A; stderr 1;
+
+var eps_muW_B;  stderr 1;
+var eps_muW_A;  stderr 1;
+
+end;
+
+
+steady; 
+//check; //do not use this command under optimal policy!!!
+
+//stoch_simul(order=1, irf=100);
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Optimized Simple Rule (osr)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
+
+
+optim_weights;
+                                                    //for country A
+
+pi_A_Hat (1/2)*n*(epsilon/phi_A);
+c_A_Gap (1/2)*n*(1 - phi_GY)*(1/sigma + (1 - phi_GY)*chi);
+g_A_Gap (1/2)*n*phi_GY*(1/psi + phi_GY*chi);
+tt_A_Gap (1/2)*n*(1 - phi_GY)*(gamma*alpha*(alpha - 2) + 2*phi_caps + (1 - phi_GY)*(phi_caps^2)*chi)*((1-n)^2); 
+
+c_A_Gap, g_A_Gap (1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*chi;
+c_A_Gap, tt_A_Gap (1/2)*(1/2)*n*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*(1-n);
+g_A_Gap, tt_A_Gap (1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*phi_caps*chi*(1-n);
+
+g_A_Gap, c_A_Gap (1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*chi;
+tt_A_Gap, c_A_Gap (1/2)*(1/2)*n*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*(1-n);
+tt_A_Gap, g_A_Gap (1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*phi_caps*chi*(1-n);
+
+
+
+                                                    //now, the same for country B
+pi_B_Hat (1/2)*(1-n)*(epsilon/phi_B);
+c_B_Gap (1/2)*(1-n)*(1 - phi_GY)*(1/sigma + (1 - phi_GY)*chi);
+g_B_Gap (1/2)*(1-n)*phi_GY*(1/psi + phi_GY*chi);
+tt_B_Gap (1/2)*(1-n)*(1 - phi_GY)*(gamma*alpha*(alpha - 2) + 2*phi_caps + (1 - phi_GY)*(phi_caps^2)*chi)*(n^2); 
+
+c_B_Gap, g_B_Gap (1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*chi;
+c_B_Gap, tt_B_Gap (1/2)*(1/2)*(1-n)*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*n;
+g_B_Gap, tt_B_Gap (1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*phi_caps*chi*n;
+
+g_B_Gap, c_B_Gap (1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*chi;
+tt_B_Gap, c_B_Gap (1/2)*(1/2)*(1-n)*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*n;
+tt_B_Gap, g_B_Gap (1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*phi_caps*chi*n;
+
+end;
+
+
+
+osr_params 
+
+
+ruleR_U_y      
+ruleR_U_pi    
+ruleR_U_debt
+
+
+
+
+ruleG_A_y
+ruleG_A_tt
+ruleG_A_debt
+
+
+
+ruleG_B_y
+ruleG_B_tt
+ruleG_B_debt
+
+
+
+ruleT_A_y
+ruleT_A_tt
+ruleT_A_debt
+
+
+
+ruleT_B_y
+ruleT_B_tt
+ruleT_B_debt
+
+;
+
+osr(irf=5,maxit=10000, nograph);
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+asymptotic_loss=((1/2)*n*(epsilon/phi_A))...
+        *oo_.var(strmatch('pi_A_Hat',M_.endo_names,'exact'),strmatch('pi_A_Hat',M_.endo_names,'exact'))+...
+            ((1/2)*n*(1 - phi_GY)*(1/sigma + (1 - phi_GY)*chi))...
+        *oo_.var(strmatch('c_A_Gap',M_.endo_names,'exact'),strmatch('c_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*n*phi_GY*(1/psi + phi_GY*chi))...
+        *oo_.var(strmatch('g_A_Gap',M_.endo_names,'exact'),strmatch('g_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*n*(1 - phi_GY)*(gamma*alpha*(alpha - 2) + 2*phi_caps + (1 - phi_GY)*(phi_caps^2)*chi)*((1-n)^2))...
+        *oo_.var(strmatch('tt_A_Gap',M_.endo_names,'exact'),strmatch('tt_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*chi)...
+        *oo_.var(strmatch('c_A_Gap',M_.endo_names,'exact'),strmatch('g_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*(1-n))...
+        *oo_.var(strmatch('c_A_Gap',M_.endo_names,'exact'),strmatch('tt_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*phi_caps*chi*(1-n))...
+        *oo_.var(strmatch('g_A_Gap',M_.endo_names,'exact'),strmatch('tt_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*chi)...
+        *oo_.var(strmatch('g_A_Gap',M_.endo_names,'exact'),strmatch('c_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*(1-n))...
+        *oo_.var(strmatch('tt_A_Gap',M_.endo_names,'exact'),strmatch('c_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*n*2*phi_GY*(1 - phi_GY)*phi_caps*chi*(1-n))...
+        *oo_.var(strmatch('tt_A_Gap',M_.endo_names,'exact'),strmatch('g_A_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1-n)*(epsilon/phi_B))...
+        *oo_.var(strmatch('pi_B_Hat',M_.endo_names,'exact'),strmatch('pi_B_Hat',M_.endo_names,'exact'))+...
+            ((1/2)*(1-n)*(1 - phi_GY)*(1/sigma + (1 - phi_GY)*chi))...
+        *oo_.var(strmatch('c_B_Gap',M_.endo_names,'exact'),strmatch('c_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1-n)*phi_GY*(1/psi + phi_GY*chi))...
+        *oo_.var(strmatch('g_B_Gap',M_.endo_names,'exact'),strmatch('g_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1-n)*(1 - phi_GY)*(gamma*alpha*(alpha - 2) + 2*phi_caps + (1 - phi_GY)*(phi_caps^2)*chi)*(n^2))...
+        *oo_.var(strmatch('tt_B_Gap',M_.endo_names,'exact'),strmatch('tt_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*chi)...
+        *oo_.var(strmatch('c_B_Gap',M_.endo_names,'exact'),strmatch('g_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*n)...
+        *oo_.var(strmatch('c_B_Gap',M_.endo_names,'exact'),strmatch('tt_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*phi_caps*chi*n)...
+        *oo_.var(strmatch('g_B_Gap',M_.endo_names,'exact'),strmatch('tt_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*chi)...
+        *oo_.var(strmatch('g_B_Gap',M_.endo_names,'exact'),strmatch('c_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*(1 - phi_GY)*(2*alpha + 2*(1 - phi_GY)*phi_caps*chi)*n)...
+        *oo_.var(strmatch('tt_B_Gap',M_.endo_names,'exact'),strmatch('c_B_Gap',M_.endo_names,'exact'))+...
+            ((1/2)*(1/2)*(1-n)*2*phi_GY*(1 - phi_GY)*phi_caps*chi*n)...
+        *oo_.var(strmatch('tt_B_Gap',M_.endo_names,'exact'),strmatch('g_B_Gap',M_.endo_names,'exact'));
+
+if abs(asymptotic_loss-oo_.osr.objective_function)>1e-10
+    error('Objective Function with Non-stationary Variables is wrong')
+end
+        
+        
\ No newline at end of file
diff --git a/tests/optimal_policy/osr_example_objective_correctness.mod b/tests/optimal_policy/osr_example_objective_correctness.mod
new file mode 100644
index 0000000000000000000000000000000000000000..be67fa10a09f7a1e7c04aad721ac37ad5d6da684
--- /dev/null
+++ b/tests/optimal_policy/osr_example_objective_correctness.mod
@@ -0,0 +1,110 @@
+// Example of optimal simple rule
+var y inflation r dummy_var;
+varexo y_ inf_;
+
+parameters delta sigma alpha kappa gammax0 gammac0 gamma_y_ gamma_inf_;
+
+delta =  0.44;
+kappa =  0.18;
+alpha =  0.48;
+sigma = -0.06;
+
+
+model(linear);
+y  = delta * y(-1)  + (1-delta)*y(+1)+sigma *(r - inflation(+1)) + y_; 
+inflation  =   alpha * inflation(-1) + (1-alpha) * inflation(+1) + kappa*y + inf_;
+dummy_var=0.9*dummy_var(-1)+0.01*y;
+r = gammax0*y(-1)+gammac0*inflation(-1)+gamma_y_*y_+gamma_inf_*inf_;
+end;
+
+shocks;
+var y_;
+stderr 0.63;
+var inf_;
+stderr 0.4;
+end;
+
+options_.nograph=1;
+options_.nocorr=1;
+options_.osr.tolf=1e-20;
+osr_params gammax0 gammac0 gamma_y_ gamma_inf_;
+
+
+optim_weights;
+inflation 1;
+y 1;
+dummy_var 1;
+end;
+
+
+gammax0 = 0.2;
+gammac0 = 1.5;
+gamma_y_ = 8;
+gamma_inf_ = 3;
+
+osr;
+%compute objective function manually
+objective=oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('y',M_.endo_names,'exact'))+oo_.var(strmatch('inflation',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'))+oo_.var(strmatch('dummy_var',M_.endo_names,'exact'),strmatch('dummy_var',M_.endo_names,'exact'));
+        
+if abs(oo_.osr.objective_function-objective)>1e-8
+    error('Objective Function is wrong')
+end
+
+%redo computation with covariance specified
+optim_weights;
+inflation 1;
+y 1;
+dummy_var 1;
+y,inflation 0.5;
+end;
+
+osr;
+%compute objective function manually
+objective=oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('y',M_.endo_names,'exact'))+oo_.var(strmatch('inflation',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'))+oo_.var(strmatch('dummy_var',M_.endo_names,'exact'),strmatch('dummy_var',M_.endo_names,'exact'))+0.5*oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'));
+if abs(oo_.osr.objective_function-objective)>1e-8
+    error('Objective Function is wrong')
+end
+
+gammax0=1.35533;
+gammac0=1.39664;
+gamma_y_=16.6667;
+gamma_inf_=9.13199;
+        
+%redo computation with double weight on one covariance 
+optim_weights;
+inflation 1;
+y 1;
+dummy_var 1;
+y,inflation 1;
+end;
+
+osr;
+%compute objective function manually
+objective=oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('y',M_.endo_names,'exact'))+oo_.var(strmatch('inflation',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'))+oo_.var(strmatch('dummy_var',M_.endo_names,'exact'),strmatch('dummy_var',M_.endo_names,'exact'))+1*oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'));
+if abs(oo_.osr.objective_function-objective)>1e-8
+    error('Objective Function is wrong')
+end
+oo_covar_single=oo_;
+
+%redo computation with single weight on both covariances
+
+optim_weights;
+inflation 1;
+y 1;
+dummy_var 1;
+y,inflation 0.5;
+inflation,y 0.5;
+end;
+
+osr;
+%compute objective function manually
+objective=oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('y',M_.endo_names,'exact'))+oo_.var(strmatch('inflation',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'))+oo_.var(strmatch('dummy_var',M_.endo_names,'exact'),strmatch('dummy_var',M_.endo_names,'exact'))+0.5*oo_.var(strmatch('y',M_.endo_names,'exact'),strmatch('inflation',M_.endo_names,'exact'))+0.5*oo_.var(strmatch('inflation',M_.endo_names,'exact'),strmatch('y',M_.endo_names,'exact'));
+if abs(oo_.osr.objective_function-objective)>1e-8
+    error('Objective Function is wrong')
+end
+if abs(oo_.osr.objective_function-oo_covar_single.osr.objective_function)>1e-8
+    error('Objective Function is wrong')
+end
+if max(abs(cell2mat(struct2cell(oo_.osr.optim_params))-cell2mat(struct2cell(oo_covar_single.osr.optim_params))))>1e-5
+    error('Parameters should be identical')
+end
diff --git a/tests/particle/dsge_base2.mod b/tests/particle/dsge_base2.mod
index 9ebb71fef310c6edb064dd3c0463f34b46a451e2..448072aa385fc5016c0a90535a0fabf680df9744 100644
--- a/tests/particle/dsge_base2.mod
+++ b/tests/particle/dsge_base2.mod
@@ -35,26 +35,39 @@ steady;
 //disp(oo_.mean) ;
 
 estimated_params;
-alp, uniform_pdf,,, 0.0001, 0.5;
+alp, uniform_pdf,,, 0.0001, 0.99;
 bet, uniform_pdf,,, 0.0001, 0.99;
 tet, uniform_pdf,,, 0.0001, 1;
 tau, uniform_pdf,,, 0.0001, 100;
 delt, uniform_pdf,,, 0.0001, 0.05;
-rho, uniform_pdf,,, 0.8, 0.99;
+rho, uniform_pdf,,, 0.0001, 0.99;
 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;
 
+//estimated_params_init;
+//alp, 0.4;
+//bet, 0.99;
+//tet, 0.357 ;
+//tau, 50;
+//delt, 0.02;
+//rho, 0.95 ;
+//stderr e_a, .035;
+//stderr y, .0175;//.00158;
+//stderr l, .00312;//.0011;
+//stderr i, .00465;//.000866;
+//end;
+
 estimated_params_init;
 alp, 0.4;
-bet, 0.97;
-tet, 0.357 ;
-tau, 50;
-delt, 0.02;
-rho, 0.9 ;
-stderr e_a, .035;
+bet, 0.98;
+tet, 0.3;
+tau, 30;
+delt, 0.01;
+rho, 0.85;
+stderr e_a, .03;
 stderr y, .0175;//.00158;
 stderr l, .00312;//.0011;
 stderr i, .00465;//.000866;
@@ -68,20 +81,20 @@ varobs y l i ;
 options_.particle.status = 1;
 options_.particle.initialization = 1;
 options_.particle.pruning = 0;
-options_.particle.number_of_particles = 1000 ;
+options_.particle.number_of_particles = 5000 ;
 options_.particle.resampling.status = 'systematic';
 
-//options_.particle.resampling.method1 = 'traditional' ;
+options_.particle.resampling.method1 = 'traditional' ;
 //options_.particle.resampling.method1 = 'residual' ;
-options_.particle.resampling.method1 = 'smooth' ;
+//options_.particle.resampling.method1 = 'smooth' ;
 
-options_.particle.reampling.method2 = 'kitagawa' ;
-//options_.particle.resampling.method2 = 'stratified' ;
+options_.particle.reampling.method2 = 'kitagawa' ;//'stratified' ;
 
-options_.particle.resampling.number_of_partitions = 1;
 options_.particle.resampling.neff_threshold = .5;
+options_.mode_check.neighbourhood_size = .2 ;
+options_.mode_check.number_of_points = 250;
 
-set_dynare_threads('local_state_space_iteration_2',3);
+//set_dynare_threads('local_state_space_iteration_2',3);
 
 options_.particle.algorithm = 'sequential_importance_particle_filter';
 //options_.particle.algorithm = 'auxiliary_particle_filter';
@@ -94,14 +107,14 @@ options_.particle.IS_approximation_method = 'cubature' ;
 //options_.particle.IS_approximation_method = 'unscented' ;
 
 //options_.particle.approximation_method = 'quadrature' ;
-options_.particle.approximation_method = 'cubature' ;
+//options_.particle.approximation_method = 'cubature' ;
 //options_.particle.approximation_method = 'unscented' ;
 //options_.particle.approximation_method = 'MonteCarlo' ;
 
-//options_.mh_posterior_mode_estimation=1 ;
+options_.mh_posterior_mode_estimation=0 ;
 
 // online
-options_.particle.liu_west_delta = 0.9 ;
+options_.particle.liu_west_delta = 0.99 ;
 options_.mode_check_node_number = 250 ;
 
-estimation(datafile=data_risky_perturb2,nograph,order=2,nobs=100,mh_replic=0,mode_compute=7,mode_check);
+estimation(datafile=data_risky_perturb3,order=1,nograph,nobs=100,mh_replic=0,mode_compute=11);
diff --git a/tests/simul/Solow_no_varexo.mod b/tests/simul/Solow_no_varexo.mod
new file mode 100644
index 0000000000000000000000000000000000000000..542fd32584418e166e2abe9d8aacc3b988c3365d
--- /dev/null
+++ b/tests/simul/Solow_no_varexo.mod
@@ -0,0 +1,65 @@
+/*
+ * This file studies the transition to steady state in a simple Solow model with Cobb-Douglass production function
+ *
+ * This implementation was written by Johannes Pfeifer. 
+ * Please note that the following copyright notice only applies to this Dynare 
+ * implementation of the model.
+ */
+
+/*
+ * Copyright (C) 2014 Johannes Pfeifer
+ *
+ * This 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.
+ *
+ * It 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.
+ *
+ * For a copy of the GNU General Public License,
+ * see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+var c k y invest;
+predetermined_variables k;
+parameters s alpha delta n g;
+
+s=0.2;
+alpha=0.3;
+delta=0.1;
+n=0.01;
+g=0.02;
+g_initial=0.02;
+
+model;
+(1+n+g+n*g)*k(+1)=(1-delta)*k+invest;
+invest+c=y;
+c=(1-s)*y;
+y=k^alpha;
+end;
+
+%set initial condition to 90% of steady state value
+initval;
+k=0.9*((delta+n+g+n*g)/s)^(1/(alpha-1));
+y=k^alpha;
+c=(1-s)*y;
+invest=y-c;
+end;
+
+%set terminal condition to steady state value
+endval;
+k=((delta+n+g+n*g)/s)^(1/(alpha-1));
+y=k^alpha;
+c=(1-s)*y;
+invest=y-c;
+end;
+resid(1);
+steady;
+
+simul(periods=200);
+rplot k;
diff --git a/tests/simul/simul_ZLB_purely_forward.mod b/tests/simul/simul_ZLB_purely_forward.mod
new file mode 100644
index 0000000000000000000000000000000000000000..4df56441dccec7eff067b10d239cf62e40f930f1
--- /dev/null
+++ b/tests/simul/simul_ZLB_purely_forward.mod
@@ -0,0 +1,96 @@
+var c, h, pi, w, R, r_e, y, gdp, gdp_hat, k, u, g, c_hat, w_hat, y_hat, h_hat;
+varexo d, z, eta; 
+
+parameters alpha, beta, sigma, gamma, theta, ni, tau_w, phi_p, phi_y;
+
+beta  = 0.997;
+sigma = 2;
+gamma = 25;
+theta = 7.67;
+tau_w = 0.2;
+ni    = 0.28;
+phi_p = 1.5;
+phi_y = 0.125;
+alpha = 0.064;
+
+model;
+
+// log-deviation of _ from its steady state value
+gdp_hat=log(gdp)-log(steady_state(gdp));
+c_hat=log(c)-log(steady_state(c));
+w_hat=log(w)-log(steady_state(w));
+y_hat=log(y)-log(steady_state(y));
+h_hat=log(h)-log(steady_state(h));
+
+// real interest rate
+r_e=1/(beta*d(+1))-1;
+
+//FOC labor
+c^sigma*h^ni=w*(1-tau_w);
+
+//Euler equation 1
+1=beta*d(+1)*(1+R)/(1+pi(+1))*(c/c(+1))^sigma;
+
+//Euler equation 2
+0=1/(1-alpha)*(steady_state(w)/z)*h^alpha-1-gamma/theta*pi*(1+pi)+beta*d(+1)*(c/c(+1))^sigma * y(+1)/y*gamma/theta*pi(+1)*(1+pi(+1));
+
+// Taylor rule with ZLB
+R=max(0,r_e+phi_p*pi+phi_y*gdp_hat);
+
+//output
+y=z*h^(1-alpha);
+
+//aggregate resource constraint
+c=(1-k-eta)*y;
+
+// resource cost of price adjustment
+k=(gamma/2)*(pi^2);
+
+//government purchases
+g=eta*y;
+
+// GDP
+gdp=(1-k)*y;
+
+//utility
+u=(c^(1-sigma))/(1-sigma)-(h^(1+ni))/(1+ni);
+end;
+
+initval;
+z=1;
+d=1;
+pi=0;
+k=(gamma/2)*(pi^2);
+r_e=1/(beta*d)-1;
+eta=0.2;
+h=1;
+y=z*h;
+g=eta*y;
+c=(1-k-eta)*y;
+w=z;
+gdp=(1-k)*y;
+R=r_e;
+end;
+
+steady;
+check;
+
+shocks;
+//5% preference shock
+var d;
+periods 1:10;
+values 1.05;
+
+//technology shock
+var z;
+periods 1:10;
+values 1.05;
+end;
+
+simul(periods=40,maxit=1000);
+
+rplot gdp_hat;
+rplot R;
+if oo_.deterministic_simulation.status~=1
+    error('This model has solution');
+end
\ No newline at end of file
diff --git a/tests/simul/simul_ZLB_purely_forward_no_solution.mod b/tests/simul/simul_ZLB_purely_forward_no_solution.mod
new file mode 100644
index 0000000000000000000000000000000000000000..73d96aa5c6be7848feac67bbb93f62a7a0546f5f
--- /dev/null
+++ b/tests/simul/simul_ZLB_purely_forward_no_solution.mod
@@ -0,0 +1,97 @@
+var c, h, pi, w, R, r_e, y, gdp, gdp_hat, k, u, g, c_hat, w_hat, y_hat, h_hat;
+varexo d, z, eta; 
+
+parameters alpha, beta, sigma, gamma, theta, ni, tau_w, phi_p, phi_y;
+
+beta  = 0.997;
+sigma = 2;
+gamma = 25;
+theta = 7.67;
+tau_w = 0.2;
+ni    = 0.28;
+phi_p = 1.5;
+phi_y = 0.125;
+alpha = 0.064;
+
+model;
+
+// log-deviation of _ from its steady state value
+gdp_hat=log(gdp)-log(steady_state(gdp));
+c_hat=log(c)-log(steady_state(c));
+w_hat=log(w)-log(steady_state(w));
+y_hat=log(y)-log(steady_state(y));
+h_hat=log(h)-log(steady_state(h));
+
+// real interest rate
+r_e=1/(beta*d(+1))-1;
+
+//FOC labor
+c^sigma*h^ni=steady_state(w)*(1-tau_w);
+
+//Euler equation 1
+1=beta*d(+1)*(1+R)/(1+pi(+1))*(c/c(+1))^sigma;
+
+//Euler equation 2
+0=1/(1-alpha)*(steady_state(w)/z)*h^alpha-1-gamma/theta*pi*(1+pi)+beta*d(+1)*(c/c(+1))^sigma * y(+1)/y*gamma/theta*pi(+1)*(1+pi(+1));
+
+// Taylor rule with ZLB
+R=max(0,r_e+phi_p*pi+phi_y*gdp_hat);
+
+//output
+y=z*h^(1-alpha);
+
+//aggregate resource constraint
+c=(1-k-eta)*y;
+
+// resource cost of price adjustment
+k=(gamma/2)*(pi^2);
+
+//government purchases
+g=eta*y;
+
+// GDP
+gdp=(1-k)*y;
+
+//utility
+u=(c^(1-sigma))/(1-sigma)-(h^(1+ni))/(1+ni);
+end;
+
+initval;
+z=1;
+d=1;
+pi=0;
+k=(gamma/2)*(pi^2);
+r_e=1/(beta*d)-1;
+eta=0.2;
+h=1;
+y=z*h;
+g=eta*y;
+c=(1-k-eta)*y;
+w=z;
+gdp=(1-k)*y;
+R=r_e;
+end;
+
+steady;
+check;
+
+shocks;
+//5% preference shock
+var d;
+periods 1:10;
+values 1.05;
+
+//technology shock
+var z;
+periods 1:10;
+values 1.05;
+end;
+
+simul(periods=40,maxit=1000);
+
+rplot gdp_hat;
+rplot R;
+
+if oo_.deterministic_simulation.status==1
+    error('This model has no solution');
+end
\ No newline at end of file