Commit 0899a16d authored by Stéphane Adjemian's avatar Stéphane Adjemian

Fixed indentation.

parent 39f9434d
......@@ -17,7 +17,7 @@ function installx13()
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ~exist('x13.zip','file')
if ( ~isoctave() && verLessThan('matlab', 'R2014b') )
websave('x13.zip', 'http://www.dynare.org/x13/x13.zip');
......
......@@ -17,7 +17,7 @@ function uninstallx13()
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if exist('x13.zip','file')
delete('x13.zip')
end
......
This diff is collapsed.
......@@ -219,6 +219,3 @@ end
%$
%$ T = all(t);
%@eof:1
......@@ -2,10 +2,10 @@ function o = abs(o) % --*-- Unitary tests --*--
% Apply the absolute value to all the variables in a dseries object (without in place modification).
%
% INPUTS
% INPUTS
% - o [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% Copyright (C) 2011-2017 Dynare Team
......@@ -41,7 +41,7 @@ o.abs_;
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(o, q);
%$ t(3) = dassert(p.data, ones(10, 2));
......@@ -63,7 +63,7 @@ o.abs_;
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(length(p.name), 2);
%$ t(3) = dassert(p.name{1},'abs(Variable_1)');
......
......@@ -2,10 +2,10 @@ function o = abs_(o) % --*-- Unitary tests --*--
% Apply the absolute value to all the variables in a dseries object (in place modification).
%
% INPUTS
% INPUTS
% - o [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% Copyright (C) 2017 Dynare Team
......@@ -70,7 +70,7 @@ o.data = abs(o.data);
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(length(o.name), 2);
%$ t(3) = dassert(o.name{1},'abs(Variable_1)');
......
function [o, p] = align(o, p) % --*-- Unitary tests --*--
% If necessay completes dseries object o and p so that they are defined on the same time range
% (in place modification).
%
% INPUTS
% (in place modification).
%
% INPUTS
% - o [dseries]
% - p [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% - p [dseries]
......
function [o, p] = align_(o, p) % --*-- Unitary tests --*--
% If necessay completes dseries object o and p so that they are defined on the same time range
% (in place modification).
%
% INPUTS
% (in place modification).
%
% INPUTS
% - o [dseries]
% - p [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% - p [dseries]
......
function o = baxter_king_filter(o, high_frequency, low_frequency, K) % --*-- Unitary tests --*--
% 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
% 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
% INPUTS
% - o dseries object.
% - high_frequency positive scalar, period length (default value is 6).
% - low_frequency positive scalar, period length (default value is 32).
% - K positive scalar integer, truncation parameter (default value is 12).
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
%
% REMARKS
% This filter use a (symmetric) moving average smoother, so that K observations at the beginning and at the end of the
% 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-2017 Dynare Team
......@@ -65,7 +65,7 @@ o.baxter_king_filter_(high_frequency, low_frequency, K);
%$ % Create a dataset.
%$ e = .2*randn(200,1);
%$ u = randn(200,1);
%$ stochastic_trend = cumsum(e);
%$ stochastic_trend = cumsum(e);
%$ deterministic_trend = .1*transpose(1:200);
%$ x = zeros(200,1);
%$ for i=2:200
......
function o = baxter_king_filter_(o, high_frequency, low_frequency, K) % --*-- Unitary tests --*--
% 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
% 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
% INPUTS
% - o dseries object.
% - high_frequency positive scalar, period length (default value is 6).
% - low_frequency positive scalar, period length (default value is 32).
% - K positive scalar integer, truncation parameter (default value is 12).
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
%
% REMARKS
% This filter use a (symmetric) moving average smoother, so that K observations at the beginning and at the end of the
% 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-2017 Dynare Team
......@@ -55,7 +55,7 @@ if nargin<4 || isempty(K)
end
end
end
% translate periods into frequencies.
hf=2.0*pi/high_frequency;
lf=2.0*pi/low_frequency;
......@@ -86,7 +86,7 @@ tmp = zeros(size(o.data));
% Filtering step.
for t = K+1:nobs(o)-K
tmp(t,:) = weights'*o.data(t-K:t+K,:);
tmp(t,:) = weights'*o.data(t-K:t+K,:);
end
% Update dseries object.
......@@ -105,7 +105,7 @@ end
%$ % Create a dataset.
%$ e = .2*randn(200,1);
%$ u = randn(200,1);
%$ stochastic_trend = cumsum(e);
%$ stochastic_trend = cumsum(e);
%$ deterministic_trend = .1*transpose(1:200);
%$ x = zeros(200,1);
%$ for i=2:200
......
......@@ -2,11 +2,11 @@ function o = center(o, geometric) % --*-- Unitary tests --*--
% Centers dseries object o around its mean (arithmetic or geometric).
%
% INPUTS
% INPUTS
% - o dseries object [mandatory].
% - geometric logical [default is false], if true returns the geometric mean.
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
% Copyright (C) 2016-2017 Dynare Team
......
......@@ -2,11 +2,11 @@ function o = center_(o, geometric) % --*-- Unitary tests --*--
% Centers dseries object o around its mean (arithmetic or geometric).
%
% INPUTS
% INPUTS
% - o dseries object [mandatory].
% - geometric logical [default is false], if true returns the geometric mean.
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
% Copyright (C) 2016-2017 Dynare Team
......
......@@ -2,14 +2,14 @@ function q = chain(o, p) % --*-- Unitary tests --*--
% Chains two dseries objects.
%
% INPUTS
% INPUTS
% - o [dseries]
% - p [dseries]
%
% OUTPUTS
% OUTPUTS
% - q [dseries]
%
% REMARKS
% REMARKS
% The two dseries objects must have common frequency and the same number of variables. Also the
% two samples must overlap.
......
......@@ -27,7 +27,7 @@ p = dseries();
p.data = o.data;
p.name = o.name;
p.tex = o.tex;
p.dates = o.dates;
p.dates = o.dates;
%@test:1
%$ % Define a dates object
......@@ -42,7 +42,7 @@ p.dates = o.dates;
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ o.log_();
%$ t(2) = dassert(p, q);
......
......@@ -49,23 +49,23 @@ end
switch nargin
case 1
% Initialize the output.
o = varargin{1};
% Perform the cumulated sum
if isequal(idx, 1)
o.data = cumprod(o.data);
else
if common_first_period_witout_nan
o.data(idx:end,:) = cumprod(o.data(idx:end,:));
else
o.data = cumprodnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumprod(' o.name{i} ')']};
o.tex(i) = {['\prod_t ' o.tex{i}]};
end
% Initialize the output.
o = varargin{1};
% Perform the cumulated sum
if isequal(idx, 1)
o.data = cumprod(o.data);
else
if common_first_period_witout_nan
o.data(idx:end,:) = cumprod(o.data(idx:end,:));
else
o.data = cumprodnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumprod(' o.name{i} ')']};
o.tex(i) = {['\prod_t ' o.tex{i}]};
end
case 2
if isdseries(varargin{2})
if ~isequal(vobs(varargin{1}), vobs(varargin{2}))
......
......@@ -2,12 +2,12 @@ function o = cumsum(varargin) % --*-- Unitary tests --*--
% Overloads matlab's cumsum function for dseries objects.
%
% INPUTS
% INPUTS
% - o dseries object [mandatory].
% - d dates object [optional]
% - v dseries object with one observation [optional]
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
% Copyright (C) 2013-2017 Dynare Team
......
......@@ -2,12 +2,12 @@ function o = cumsum_(varargin) % --*-- Unitary tests --*--
% Overloads matlab's cumsum function for dseries objects.
%
% INPUTS
% INPUTS
% - o dseries object [mandatory].
% - d dates object [optional]
% - v dseries object with one observation [optional]
%
% OUTPUTS
% OUTPUTS
% - o dseries object.
% Copyright (C) 2013-2017 Dynare Team
......@@ -48,24 +48,24 @@ else
end
switch nargin
case 1
% Initialize the output.
o = varargin{1};
% Perform the cumulated sum
if isequal(idx, 1)
o.data = cumsum(o.data);
else
if common_first_period_witout_nan
o.data(idx:end,:) = cumsum(o.data(idx:end,:));
else
o.data = cumsumnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumsum(' o.name{i} ')']};
o.tex(i) = {['\sum_t ' o.tex{i}]};
end
case 1
% Initialize the output.
o = varargin{1};
% Perform the cumulated sum
if isequal(idx, 1)
o.data = cumsum(o.data);
else
if common_first_period_witout_nan
o.data(idx:end,:) = cumsum(o.data(idx:end,:));
else
o.data = cumsumnan(o.data);
end
end
% Change the name of the variables
for i=1:vobs(o)
o.name(i) = {['cumsum(' o.name{i} ')']};
o.tex(i) = {['\sum_t ' o.tex{i}]};
end
case 2
if isdseries(varargin{2})
if ~isequal(vobs(varargin{1}), vobs(varargin{2}))
......
......@@ -2,11 +2,11 @@ function o = detrend(o, model) % --*-- Unitary tests --*--
% Detrends a dseries object with a polynomial of order model.
%
% INPUTS
% - o [dseries] time series to be detrended.
% INPUTS
% - o [dseries] time series to be detrended.
% - model [integer] scalar, order of the fitted polynomial.
%
% OUTPUTS
% OUTPUTS
% - o [dseries] detrended time series.
% Copyright (C) 2014-2017 Dynare Team
......
......@@ -2,11 +2,11 @@ function o = detrend_(o, model) % --*-- Unitary tests --*--
% Detrends a dseries object with a polynomial of order model.
%
% INPUTS
% - o [dseries] time series to be detrended.
% INPUTS
% - o [dseries] time series to be detrended.
% - model [integer] scalar, order of the fitted polynomial.
%
% OUTPUTS
% OUTPUTS
% - o [dseries] detrended time series.
% Copyright (C) 2014-2017 Dynare Team
......
......@@ -2,10 +2,10 @@ function disp(o)
% Overloads disp method.
%
% INPUTS
% INPUTS
% - o [dseries] Object to be displayed.
%
% OUTPUTS
% OUTPUTS
% None
% Copyright (C) 2011-2017 Dynare Team
......
......@@ -2,13 +2,13 @@ function display(o)
% Overloads display method.
%
% INPUTS
% INPUTS
% - o [dseries] Object to be displayed.
%
% OUTPUTS
% OUTPUTS
% None
%
% REMARKS
% REMARKS
% Contray to the disp method, the whole dseries object is not displayed if the number of
% observations is greater than 40 and if the number of variables is greater than 10.
......
This diff is collapsed.
......@@ -2,12 +2,12 @@ function lastIndex = end(o, k, n)
% Overloads the end method.
%
% INPUTS
% INPUTS
% - o [dseries]
% - k [integer]
% - n [integer]
%
% OUTPUTS
% OUTPUTS
% - lastIndex [integer]
% Copyright (C) 2014-2017 Dynare Team
......
......@@ -2,15 +2,15 @@ function b = eq(o, p) % --*-- Unitary tests --*--
% Overloads eq (==) operator.
%
% INPUTS
% 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.
% 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.
% 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-2017 Dynare Team
%
......
......@@ -2,12 +2,12 @@ function l = exist(o, varname) % --*-- Unitary tests --*--
% Tests if a variable exists in dseries object o.
%
% INPUTS
% INPUTS
% - o [dseries], dseries object.
% - varname [string], name of a variable.
%
% OUTPUTS
% - l [logical], equal to 1 (true) iff varname is a variable in dseries object o.
% OUTPUTS
% - l [logical], equal to 1 (true) iff varname is a variable in dseries object o.
% Copyright (C) 2014 Dynare Team
%
......
......@@ -2,10 +2,10 @@ function o = exp(o) % --*-- Unitary tests --*--
% Apply the exponential to all the variables in a dseries object (without in place modification).
%
% INPUTS
% INPUTS
% - o [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% Copyright (C) 2011-2016 Dynare Team
......@@ -41,7 +41,7 @@ o.exp_();
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(o, q);
%$ t(3) = dassert(p.data, ones(10, 2));
......@@ -63,7 +63,7 @@ o.exp_();
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(length(p.name), 2);
%$ t(3) = dassert(p.name{1},'exp(Variable_1)');
......
......@@ -2,10 +2,10 @@ function o = exp_(o) % --*-- Unitary tests --*--
% Apply the exponential to all the variables in a dseries object (in place modification).
%
% INPUTS
% INPUTS
% - o [dseries]
%
% OUTPUTS
% OUTPUTS
% - o [dseries]
% Copyright (C) 2015-2016 Dynare Team
......@@ -70,7 +70,7 @@ end
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ if t(1)
%$ t(2) = dassert(length(o.name), 2);
%$ t(3) = dassert(o.name{1},'exp(Variable_1)');
......
function p = extract(o, varargin) % --*-- Unitary tests --*--
% Extract some variables from a database.
% Copyright (C) 2012-2017 Dynare Team
%
% This file is part of Dynare.
......@@ -67,8 +67,8 @@ p.data = o.data(:,idVariableName);
p.dates = o.dates;
p.name = o.name(idVariableName);
p.tex = o.tex(idVariableName);
%@test:1
%$ % Define a data set.
%$ A = rand(10,24);
......
......@@ -2,10 +2,10 @@ function d = firstobservedperiod(o) % --*-- Unitary tests --*--
% Returns the first period where all the variables are observed (first period without NaNs).
%
% INPUTS
% INPUTS
% - o [dseries] with N variables and T periods.
%
% OUTPUTS
% OUTPUTS
% - d [dates] First period where the N variables are observed (without NaNs).
% Copyright (C) 2016-2017 Dynare Team
......
......@@ -2,10 +2,10 @@ function f = frequency(o)
% Returns the frequency of a dseries object.
%
% INPUTS
% INPUTS
% - o [dseries]
%
% OUPUTS
% OUPUTS
% - f [integer] 1 (annual), 4 (quarterly), 12 (monthly)
% Copyright (C) 2014-2017 Dynare Team
......
......@@ -2,24 +2,24 @@ function o = horzcat(varargin) % --*-- Unitary tests --*--
% Overloads horzcat method for dseries objects.
%
% INPUTS
% INPUTS
% o o1 dseries object.
% o o2 dseries object.
% o ...
%
% OUTPUTS
% OUTPUTS
% o o dseries object.
%
% EXAMPLE 1
% EXAMPLE 1
% If o1, o2 and o3 are dseries objects the following syntax:
%
%
% o = [o1, o2, o3] ;
%
% defines a dseries object o containing the variables appearing in o1, o2 and o3.
%
% REMARKS
% REMARKS
% o o1, o2, ... must not have common variables.
% Copyright (C) 2011-2017 Dynare Team
%
% This file is part of Dynare.
......@@ -50,72 +50,72 @@ switch nargin
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!')
[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
a = dseries();
end
d_nobs_flag = 0;
if ~isequal(nobs(b),nobs(c))
d_nobs_flag = 1;
b.data = [NaN(firstdate(b)-firstdate(c), vobs(b)); b.data];
end
d_init_flag = 0;
if ~isequal(firstdate(b),firstdate(c))
d_init_flag = 1;
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.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 =