1function o = lead(o, p) % --*-- Unitary tests --*-- 2 3% Returns a lagged time series 4% 5% INPUTS 6% - o [dseries] 7% - p [integer] Number of leads 8% 9% OUTPUTS 10% - o [dseries] 11% 12% EXAMPLE 13% Define a dseries object as follows: 14% 15% >> o = dseries(transpose(1:5)) 16% 17% then o.lag(1) returns 18% 19% | lead(Variable_1,1) 20% 1Y | 2 21% 2Y | 3 22% 3Y | 4 23% 4Y | 5 24% 5Y | NaN 25 26% Copyright (C) 2013-2017 Dynare Team 27% 28% This file is part of Dynare. 29% 30% Dynare is free software: you can redistribute it and/or modify 31% it under the terms of the GNU General Public License as published by 32% the Free Software Foundation, either version 3 of the License, or 33% (at your option) any later version. 34% 35% Dynare is distributed in the hope that it will be useful, 36% but WITHOUT ANY WARRANTY; without even the implied warranty of 37% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38% GNU General Public License for more details. 39% 40% You should have received a copy of the GNU General Public License 41% along with Dynare. If not, see <http://www.gnu.org/licenses/>. 42 43% Set default number of leads 44if nargin<2 45 p = 1; 46end 47 48o = copy(o); 49o.lead_(p); 50 51%@test:1 52%$ try 53%$ data = transpose(1:50); 54%$ ts = dseries(data,'1950Q1'); 55%$ a = ts.lead; 56%$ b = ts.lead.lead; 57%$ c = lead(ts,2); 58%$ t(1) = true; 59%$ catch 60%$ t(1) = false; 61%$ end 62%$ 63%$ if t(1) 64%$ 65%$ DATA = [data(2:end); NaN(1)]; 66%$ t(2) = dassert(a.data, DATA, 1e-15); 67%$ DATA = [data(3:end); NaN(2,1)]; 68%$ t(3) = dassert(b.data, DATA, 1e-15); 69%$ t(4) = dassert(c.data, DATA, 1e-15); 70%$ end 71%$ 72%$ T = all(t); 73%@eof:1