Commits (6)
  • Stéphane Adjemian's avatar
    Remove unused output argument. · 2ba2997d
    Stéphane Adjemian authored
    2ba2997d
  • Stéphane Adjemian's avatar
  • Stéphane Adjemian's avatar
    Allow selections of periods or variables with vector of logicals. · 5f829d00
    Stéphane Adjemian authored
    Ref #4.
    
    If ts is a dseries object with T periods and N variables, then we can
    instantiate a new dseries object from ts by extracting periods or
    variables. Periods are selected by passing a vector of logicals with T
    elements. Variables are selected by passing a vector of logicals with
    N elements. If T==N, the convention is to pass a row vector to select
    variables and a colum vector to select periods.
    
    *Example*
    
    >> ts = dseries(randn(10,5), '2000Q1')
    
    ts is a dseries object:
    
           | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5
    2000Q1 | -0.53201   | -1.0642    | 0.39189    | -1.0667    | -0.73417
    2000Q2 | 1.6821     | 1.6035     | -1.2507    | 0.93373    | -0.030814
    2000Q3 | -0.87573   | 1.2347     | -0.94796   | 0.35032    | 0.23235
    2000Q4 | -0.48382   | -0.22963   | -0.74111   | -0.029006  | 0.42639
    2001Q1 | -0.712     | -1.5062    | -0.50782   | 0.18245    | -0.37281
    2001Q2 | -1.1742    | -0.44463   | -0.32058   | -1.5651    | -0.23645
    2001Q3 | -0.19224   | -0.15594   | 0.012469   | -0.084539  | 2.0237
    2001Q4 | -0.27407   | 0.27607    | -3.0292    | 1.6039     | -2.2584
    2002Q1 | 1.5301     | -0.26116   | -0.45701   | 0.098348   | 2.2294
    2002Q2 | -0.24902   | 0.44342    | 1.2424     | 0.041374   | 0.33756
    
    >> ts(mean(ts)>0)
    
    ans is a dseries object:
    
           | Variable_4 | Variable_5
    2000Q1 | -1.0667    | -0.73417
    2000Q2 | 0.93373    | -0.030814
    2000Q3 | 0.35032    | 0.23235
    2000Q4 | -0.029006  | 0.42639
    2001Q1 | 0.18245    | -0.37281
    2001Q2 | -1.5651    | -0.23645
    2001Q3 | -0.084539  | 2.0237
    2001Q4 | 1.6039     | -2.2584
    2002Q1 | 0.098348   | 2.2294
    2002Q2 | 0.041374   | 0.33756
    
    >> ts(ts.dates>=dates('2001Q3'))
    
    ans is a dseries object:
    
           | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5
    2001Q3 | -0.19224   | -0.15594   | 0.012469   | -0.084539  | 2.0237
    2001Q4 | -0.27407   | 0.27607    | -3.0292    | 1.6039     | -2.2584
    2002Q1 | 1.5301     | -0.26116   | -0.45701   | 0.098348   | 2.2294
    2002Q2 | -0.24902   | 0.44342    | 1.2424     | 0.041374   | 0.33756
    5f829d00
  • Stéphane Adjemian's avatar
    Add new comparison methods. · 507ec822
    Stéphane Adjemian authored
    Closes #4.
    
    *Example*
    
    >> a = dseries(randn(4,5),'2000Q1')
    
    a is a dseries object:
    
           | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5
    2000Q1 | 2.4245     | -1.036     | -0.87587   | -0.57001   | -1.6989
    2000Q2 | 0.9594     | 1.8779     | 0.31995    | -1.0257    | 0.6076
    2000Q3 | -0.31577   | 0.9407     | -0.55829   | -0.90875   | -0.1178
    2000Q4 | 0.42862    | 0.78735    | -0.31143   | -0.2099    | 0.69916
    
    >> a.Variable_3>0
    
    ans =
    
      4x1 logical array
    
       0
       1
       0
       0
    
    >> a(a.Variable_3>0)
    
    ans is a dseries object:
    
           | Variable_1 | Variable_2 | Variable_3 | Variable_4 | Variable_5
    2000Q2 | 0.9594     | 1.8779     | 0.31995    | -1.0257    | 0.6076
    507ec822
  • Sébastien Villemot's avatar
    246d66c0
  • Sébastien Villemot's avatar
    CI: bump to Octave 6.3.0 · 5e870858
    Sébastien Villemot authored
    5e870858
......@@ -3,7 +3,7 @@ variables:
TERM: linux
MATLAB_VERSION: R2021a
OLD_MATLAB_VERSION: R2014a
OCTAVE_VERSION: 6.2.0
OCTAVE_VERSION: 6.3.0
before_script:
- git clone https://git.dynare.org/Dynare/m-unit-tests
......
......@@ -10,4 +10,4 @@
> General Public License for more details.
> A copy of the GNU General Public License is available here
> <http://www.gnu.org/licenses/>.
> <https://www.gnu.org/licenses/>.
......@@ -15,7 +15,7 @@ classdef arima<handle % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
properties
y = []; % dseries object with a single variable.
......
......@@ -2,7 +2,7 @@ function estimate(o, varargin)
% Estimate method for arima class.
% Copyright (C) 2017 Dynare Team
% Copyright © 2017-2021 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -15,7 +15,7 @@ function estimate(o, varargin)
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% Set default values for options.
options.tol = 1e-5;
......@@ -205,17 +205,18 @@ if isequal(linea{1}{1}, 'bic')
o.estimation.information_criteria.Schwarz = linea{2};
end
return
%@test:1
%$ try
%$ y = dseries([0; 0], '1938Q3', 'y')
%$ e = dseries(randn(201,1),'1938Q4','e');
%$ from from 1939Q1 to 1988Q4 do y(t) = .8*y(t-1) - .2*y(t-2) + e(t) - .15*e(t-1)
%$ model = arima(y, '(2,0,1)');
%$ estimate(model);
%$ catch
%$ t(1) = false;
%$ end
%$
%$ T = all(t);
try
y = dseries([0; 0], '1938Q3', 'y')
e = dseries(randn(201,1),'1938Q4','e');
from from 1939Q1 to 1988Q4 do y(t) = .8*y(t-1) - .2*y(t-2) + e(t) - .15*e(t-1)
model = arima(y, '(2,0,1)');
estimate(model);
catch
t(1) = false;
end
T = all(t);
%@eof:1
......@@ -22,7 +22,7 @@ function o = append(o, d) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if isa(d, 'dates')
if ~isequal(length(d), 1)
......
......@@ -22,7 +22,7 @@ function o = append_(o, d) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if isa(d, 'dates')
if ~isequal(length(d), 1)
......
......@@ -21,7 +21,7 @@ function s = char(o) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if length(o)>1
error('dates:char:ArgCheck', 'The input argument must be a dates object with one element!')
......
......@@ -27,7 +27,7 @@ function q = colon(varargin) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% Check the input arguments.
if isequal(nargin, 2)
......
......@@ -21,7 +21,7 @@ function p = copy(o) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
p = dates();
p.freq = o.freq;
......
......@@ -13,7 +13,7 @@ classdef dates<handle % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
properties
freq = []; % Frequency (integer scalar)
......
......@@ -21,6 +21,6 @@ function disp(o)
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
fprintf(['\n' dates4display(o, inputname(1), Inf) '\n\n']);
\ No newline at end of file
......@@ -21,6 +21,6 @@ function display(o)
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
fprintf(['\n' dates4display(o, inputname(1), 5) '\n\n']);
\ No newline at end of file
......@@ -26,7 +26,7 @@ function [m, f] = double(o) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if o.freq==365
error('This method is not implemented for daily frequency.')
......
......@@ -10,7 +10,7 @@ function lastIndex = end(o, k, n) % --*-- Unitary tests --*--
% OUTPUTS
% lastIndex [integer] last dates index
% Copyright (C) 2013-2017 Dynare Team
% Copyright © 2013-2021 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -23,27 +23,29 @@ function lastIndex = end(o, k, n) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
assert(k==1 && n==1, 'dates:end:ArgCheck', 'dates only has one dimension');
lastIndex = o.ndat();
return
%@test:1
%$ % Define a dates object
%$ o = dates('1938Q4'):dates('2015Q4');
%$ q = dates('2015Q4');
%$
%$ % Call the tested routine.
%$ try
%$ p = o(end);
%$ t(1) = true;
%$ catch
%$ t(1) = false;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(p, q);
%$ end
%$
%$ T = all(t);
% Define a dates object
o = dates('1938Q4'):dates('2015Q4');
q = dates('2015Q4');
% Call the tested routine.
try
p = o(end);
t(1) = true;
catch
t(1) = false;
end
if t(1)
t(2) = dassert(p, q);
end
T = all(t);
%@eof:1
\ No newline at end of file
......@@ -22,7 +22,7 @@ function l = eq(varargin) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if varargin{1}.ndat>1 && varargin{2}.ndat>1 && ~isequal(varargin{1}.ndat, varargin{2}.ndat)
l = false;
......
......@@ -22,7 +22,7 @@ function l = ge(varargin) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[o, p] = comparison_arg_checks(varargin{:});
......
......@@ -22,7 +22,7 @@ function l = gt(varargin) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
[o, p] = comparison_arg_checks(varargin{:});
......
......@@ -21,7 +21,7 @@ function o = horzcat(varargin) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if ~all(cellfun(@isdates, varargin))
error('dates:horzcat:ArgCheck', 'All input arguments must be dates objects.')
......
......@@ -22,7 +22,7 @@ function q = intersect(o, p) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if ~isa(o, 'dates') || ~isa(p, 'dates')
error('dates:intersect:ArgCheck','All input arguments must be dates objects!')
......
......@@ -8,7 +8,7 @@ function l = isempty(o) % --*-- Unitary tests --*--
% OUTPUTS
% - l [logical]
% Copyright (C) 2013-2021 Dynare Team
% Copyright © 2013-2021 Dynare Team
%
% This code is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
......@@ -21,22 +21,24 @@ function l = isempty(o) % --*-- Unitary tests --*--
% 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/>.
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
l = isequal(o.ndat(), 0);
return
%@test:1
%$ % Instantiate an empty dates object
%$ d = dates();
%$ % Test if this object is empty
%$ t(1) = isempty(d);
%$ T = all(t);
% Instantiate an empty dates object
d = dates();
% Test if this object is empty
t(1) = isempty(d);
T = all(t);
%@eof:1
%@test:2
%$ % Instantiate an empty dates object
%$ d = dates('1938Q4');
%$ % Test if this object is empty
%$ t(1) = ~isempty(d);
%$ T = all(t);
% Instantiate an empty dates object
d = dates('1938Q4');
% Test if this object is empty
t(1) = ~isempty(d);
T = all(t);
%@eof:2