1function trend = lineartrend(o) % --*-- Unitary tests --*--
2
3% Returns a trend centered on zero.
4%
5% INPUTS
6% - o       [dseries]   time series with T observations.
7%
8% OUTPUTS
9% - trend   [double]    T*1 vector, linear trend with mean zero.
10%
11% REMARKS
12% the generic element of the returned argument is trend(i) = i - (n+1)/2.
13
14% Copyright (C) 2017 Dynare Team
15%
16% This file is part of Dynare.
17%
18% Dynare is free software: you can redistribute it and/or modify
19% it under the terms of the GNU General Public License as published by
20% the Free Software Foundation, either version 3 of the License, or
21% (at your option) any later version.
22%
23% Dynare is distributed in the hope that it will be useful,
24% but WITHOUT ANY WARRANTY; without even the implied warranty of
25% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26% GNU General Public License for more details.
27%
28% You should have received a copy of the GNU General Public License
29% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
30
31trend = transpose(1:o.nobs)-.5*(o.nobs+1);
32
33return
34
35%@test:1
36a = dseries(randn(100,3));
37try
38    trend = a.lineartrend;
39    t(1) = 1;
40catch
41    t(1) = 0;
42end
43
44if t(1)
45    t(2) = abs(mean(trend))<1e-12;
46end
47T = all(t);
48%@eof:1