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
......
......@@ -17,141 +17,141 @@ classdef arima<handle % --*-- Unitary tests --*--
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
properties
y = []; % dseries object with a single variable.
p = []; % Number of lags on the autoregressive part.
d = []; % Order of differenciation.
q = []; % Number of lags on the moving average part.
P = []; % Seasonal component autoregressive part number of lags.
D = []; % Seasonal component order of differenciation.
Q = []; % Seasonal component moving average part number of lags.
S = []; % Seasonal component period.
ar = []; % Autoregressive parameters.
ma = []; % Moving arverage parameters.
AR = []; % Seasonal component autoregressive parameters.
MA = []; % Seasonal component moving average parameters.
ar_std = []; % Autoregressive parameters estimator std.
ma_std = []; % Moving arverage parameters estimator std.
AR_std = []; % Seasonal component autoregressive parameters estimator std.
MA_std = []; % Seasonal component moving average parameters estimator std.
sigma = []; % Standard deviation of the schock.
estimation = []; % Structure gathering informations related to the estimation of the model.
end
properties
y = []; % dseries object with a single variable.
p = []; % Number of lags on the autoregressive part.
d = []; % Order of differenciation.
q = []; % Number of lags on the moving average part.
P = []; % Seasonal component autoregressive part number of lags.
D = []; % Seasonal component order of differenciation.
Q = []; % Seasonal component moving average part number of lags.
S = []; % Seasonal component period.
ar = []; % Autoregressive parameters.
ma = []; % Moving arverage parameters.
AR = []; % Seasonal component autoregressive parameters.
MA = []; % Seasonal component moving average parameters.
ar_std = []; % Autoregressive parameters estimator std.
ma_std = []; % Moving arverage parameters estimator std.
AR_std = []; % Seasonal component autoregressive parameters estimator std.
MA_std = []; % Seasonal component moving average parameters estimator std.
sigma = []; % Standard deviation of the schock.
estimation = []; % Structure gathering informations related to the estimation of the model.
end
methods
methods
function o = arima(y, model)
% Constructor for the arma class.
%
% INPUTS
%
% INPUTS
% - y [dseries] Data.
% - model [string] Specification of the model of the form '(p, d, q)(P,D,Q)S', See X-13ARIMA-SEATS manual.
%
% OUPUTS
% OUPUTS
% - o [arima] ARIMA model object.
nargin
switch nargin
case 0
% Return empty object.
o.y = []; % dseries object with a single variable.
o.p = []; % Number of lags on the autoregressive part.
o.d = []; % Order of differenciation.
o.q = []; % Number of lags on the moving average part.
o.P = []; % Seasonal component autoregressive part number of lags.
o.D = []; % Seasonal component order of differenciation.
o.Q = []; % Seasonal component moving average part number of lags.
o.S = []; % Seasonal component period.
o.ar = []; % Autoregressive parameters.
o.ma = []; % Moving arverage parameters.
o.AR = []; % Seasonal component autoregressive parameters.
o.MA = []; % Seasonal component moving average parameters.
o.ar_std = []; % Autoregressive parameters estimator std.
o.ma_std = []; % Moving arverage parameters estimator std.
o.AR_std = []; % Seasonal component autoregressive parameters estimator std.
o.MA_std = []; % Seasonal component moving average parameters estimator std.
o.sigma = []; % Standard deviation of the schock.
o.estimation = []; % Structure gathering informations related to the estimation of the model.
return
case 2
if ~isdseries(y)
error('arima::WrongInputArguments', 'First input argument must be a dseries object!')
end
if ~ischar(model)
error('arima::WrongInputArguments', 'Second input argument must be a string!')
nargin
switch nargin
case 0
% Return empty object.
o.y = []; % dseries object with a single variable.
o.p = []; % Number of lags on the autoregressive part.
o.d = []; % Order of differenciation.
o.q = []; % Number of lags on the moving average part.
o.P = []; % Seasonal component autoregressive part number of lags.
o.D = []; % Seasonal component order of differenciation.
o.Q = []; % Seasonal component moving average part number of lags.
o.S = []; % Seasonal component period.
o.ar = []; % Autoregressive parameters.
o.ma = []; % Moving arverage parameters.
o.AR = []; % Seasonal component autoregressive parameters.
o.MA = []; % Seasonal component moving average parameters.
o.ar_std = []; % Autoregressive parameters estimator std.
o.ma_std = []; % Moving arverage parameters estimator std.
o.AR_std = []; % Seasonal component autoregressive parameters estimator std.
o.MA_std = []; % Seasonal component moving average parameters estimator std.
o.sigma = []; % Standard deviation of the schock.
o.estimation = []; % Structure gathering informations related to the estimation of the model.
return
case 2
if ~isdseries(y)
error('arima::WrongInputArguments', 'First input argument must be a dseries object!')
end
if ~ischar(model)
error('arima::WrongInputArguments', 'Second input argument must be a string!')
end
o.y = y;
o.estimation = struct();
% Read the description of the ARIMA model.
model = regexprep(model,'(\s)',''); % Removes all spaces.
description = regexp(model, '(\([0-9],[0-9],[0-9]\)([0-9]+)?)', 'tokens');
% First cell is the non seasonal component.
ns_arima = description{1}{1};
ns_arima_specification = regexp(ns_arima, '([0-9]*)', 'tokens');
o.p = str2num(ns_arima_specification{1}{1});
o.d = str2num(ns_arima_specification{2}{1});
o.q = str2num(ns_arima_specification{3}{1});
% Set default values for parameters and estimate std.
if o.p
o.ar = zeros(o.p, 1);
o.ar_std = zeros(o.p, 1);
else
o.ar = [];
o.ar_std = [];
end
if o.q
o.ma = zeros(o.q, 1);
o.ma_std = zeros(o.q, 1);
else
o.ma = [];
o.ma_std = [];
end
% Following cells are the ARIMA models on the seasonal components.
number_of_seasonal_components = length(description)-1;
if number_of_seasonal_components
o.P = zeros(number_of_seasonal_components, 1);
o.D = zeros(number_of_seasonal_components, 1);
o.Q = zeros(number_of_seasonal_components, 1);
o.S = zeros(number_of_seasonal_components, 1);
for i=1:number_of_seasonal_components
s_arima = description{i+1}{1};
s_arima_specification = regexp(s_arima, '([0-9]*)', 'tokens');
if isequal(i, 1) && isequal(length(s_arima_specification), 3)
o.S(i) = y.init.freq;
else
o.S(i) = str2num(s_arima_specification{4}{1});
end
o.P(i) = str2num(s_arima_specification{1}{1});
o.D(i) = str2num(s_arima_specification{2}{1});
o.Q(i) = str2num(s_arima_specification{3}{1});
end
o.y = y;
o.estimation = struct();
% Read the description of the ARIMA model.
model = regexprep(model,'(\s)',''); % Removes all spaces.
description = regexp(model, '(\([0-9],[0-9],[0-9]\)([0-9]+)?)', 'tokens');
% First cell is the non seasonal component.
ns_arima = description{1}{1};
ns_arima_specification = regexp(ns_arima, '([0-9]*)', 'tokens');
o.p = str2num(ns_arima_specification{1}{1});
o.d = str2num(ns_arima_specification{2}{1});
o.q = str2num(ns_arima_specification{3}{1});
% Set default values for parameters and estimate std.
if o.p
o.ar = zeros(o.p, 1);
o.ar_std = zeros(o.p, 1);
end
% Set default values for parameters and estimate std.
o.AR = {};
o.MA = {};
o.AR_std = {};
o.MA_std = {};
for i=1:number_of_seasonal_components
if o.P(i)
o.AR{i} = zeros(o.P(i), 1);
o.AR_std{i} = zeros(o.P(i), 1);
else
o.ar = [];
o.ar_std = [];
o.AR{i} = [];
o.AR_std{i} = [];
end
if o.q
o.ma = zeros(o.q, 1);
o.ma_std = zeros(o.q, 1);
if o.Q(i)
o.MA{i} = zeros(o.Q(i), 1);
o.MA_std{i} = zeros(o.Q(i), 1);
else
o.ma = [];
o.ma_std = [];
end
% Following cells are the ARIMA models on the seasonal components.
number_of_seasonal_components = length(description)-1;
if number_of_seasonal_components
o.P = zeros(number_of_seasonal_components, 1);
o.D = zeros(number_of_seasonal_components, 1);
o.Q = zeros(number_of_seasonal_components, 1);
o.S = zeros(number_of_seasonal_components, 1);
for i=1:number_of_seasonal_components
s_arima = description{i+1}{1};
s_arima_specification = regexp(s_arima, '([0-9]*)', 'tokens');
if isequal(i, 1) && isequal(length(s_arima_specification), 3)
o.S(i) = y.init.freq;
else
o.S(i) = str2num(s_arima_specification{4}{1});
end
o.P(i) = str2num(s_arima_specification{1}{1});
o.D(i) = str2num(s_arima_specification{2}{1});
o.Q(i) = str2num(s_arima_specification{3}{1});
end
end
% Set default values for parameters and estimate std.
o.AR = {};
o.MA = {};
o.AR_std = {};
o.MA_std = {};
for i=1:number_of_seasonal_components
if o.P(i)
o.AR{i} = zeros(o.P(i), 1);
o.AR_std{i} = zeros(o.P(i), 1);
else
o.AR{i} = [];
o.AR_std{i} = [];
end
if o.Q(i)
o.MA{i} = zeros(o.Q(i), 1);
o.MA_std{i} = zeros(o.Q(i), 1);
else
o.MA{i} = [];
o.MA_std{i} = [];
end
o.MA{i} = [];
o.MA_std{i} = [];
end
% Set default value for the size of the innovation.
o.sigma = std(y.data);
otherwise
error('arima::WrongInputArguments', 'Two input argument are mandatory!')
end
% Set default value for the size of the innovation.
o.sigma = std(y.data);
otherwise
error('arima::WrongInputArguments', 'Two input argument are mandatory!')
end
end % arima
end % methods
end % methods
end % classdef
%@test:1
......@@ -162,6 +162,6 @@ end % classdef
%$ catch
%$ t(1) = false;
%$ end
%$
%$
%$ T = all(t);
%@eof:1
......@@ -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