detrend.m 1.33 KB
Newer Older
1 2
function o = detrend(o, model) % --*-- Unitary tests --*--

3 4
% Detrends a dseries object with a polynomial of order model.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
5 6
% INPUTS
% - o       [dseries]   time series to be detrended.
7 8
% - model   [integer]   scalar, order of the fitted polynomial.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
9
% OUTPUTS
10 11 12
% - o       [dseries]   detrended time series.

% Copyright (C) 2014-2017 Dynare Team
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
%
% 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

34 35
o = copy(o);
o.detrend_(model);
36 37 38

%@test:1
%$ % Define a dataset.
39 40
%$ A = ones(3,1);
%$ a = dseries(A);
41 42
%$
%$ try
43 44
%$   b = a.detrend();
%$   t(1) = 1;
45
%$ catch
46
%$   t(1) = 0;
47 48 49
%$ end
%$
%$ if t(1)
50
%$   t(2) = max(max(abs(a.data-A)))<1e-12;
51 52 53
%$ end
%$
%$ T = all(t);
54
%@eof:1