Allow declaration of dates with lowercase frequencies.
parent
f3f985dd37
commit
1d3dc37781
|
@ -60,8 +60,6 @@ function date = dynDate(a,b)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
date = struct;
|
||||
|
||||
date.freq = NaN;
|
||||
|
@ -75,6 +73,7 @@ switch nargin
|
|||
return
|
||||
case 1
|
||||
if ischar(a)% Weekly, Monthly or Quaterly data.
|
||||
a = upper(a);
|
||||
if length(a)>1
|
||||
quaterly = findstr('Q',a);
|
||||
monthly = findstr('M',a);
|
||||
|
@ -154,8 +153,8 @@ end
|
|||
%$ % Define some dates
|
||||
%$ date_1 = 1950;
|
||||
%$ date_2 = '1950Q2';
|
||||
%$ date_3 = '1950M10';
|
||||
%$ date_4 = '1950W50';
|
||||
%$ date_3 = '1950m10';
|
||||
%$ date_4 = '1950w50';
|
||||
%$ date_5 = '1950';
|
||||
%$
|
||||
%$ % Define expected results.
|
||||
|
@ -223,3 +222,19 @@ end
|
|||
%$ end
|
||||
%$ T = all(t);
|
||||
%@eof:3
|
||||
|
||||
%@test:4
|
||||
%$ % Instatiate an empty objects for quaterly, monthly and weekly dates.
|
||||
%$ qq = dynDate('q');
|
||||
%$ mm = dynDate('m');
|
||||
%$ ww = dynDate('w');
|
||||
%$
|
||||
%$ % Check the results.
|
||||
%$ t(1) = dyn_assert(qq.freq,4);
|
||||
%$ t(2) = dyn_assert(mm.freq,12);
|
||||
%$ t(3) = dyn_assert(ww.freq,52);
|
||||
%$ t(4) = dyn_assert(all(isnan(qq.time)),1);
|
||||
%$ t(5) = dyn_assert(all(isnan(mm.time)),1);
|
||||
%$ t(6) = dyn_assert(all(isnan(ww.time)),1);
|
||||
%$ T = all(t);
|
||||
%@eof:4
|
||||
|
|
|
@ -59,7 +59,7 @@ function ts = dynSeries(varargin)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2011, 2012 Dynare Team
|
||||
% Copyright (C) 2011, 2012, 2013 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -76,8 +76,6 @@ function ts = dynSeries(varargin)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
% AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
ts = struct;
|
||||
|
||||
ts.data = [];
|
||||
|
@ -143,26 +141,8 @@ switch nargin
|
|||
% Get the first date and set the frequency.
|
||||
if ~isempty(b)
|
||||
if ischar(b)% Weekly, Monthly or Quaterly data.
|
||||
quaterly = findstr('Q',b);
|
||||
monthly = findstr('M',b);
|
||||
weekly = findstr('W',b);
|
||||
yearly = findstr('Y',b);
|
||||
if ~isempty(quaterly)
|
||||
ts.freq = 4;
|
||||
end
|
||||
if ~isempty(monthly)
|
||||
ts.freq = 12;
|
||||
end
|
||||
if ~isempty(weekly)
|
||||
ts.freq = 52;
|
||||
end
|
||||
if ~isempty(yearly)
|
||||
ts.freq = 1;
|
||||
end
|
||||
if isempty(quaterly) && isempty(monthly) && isempty(weekly) && isempty(yearly)
|
||||
error('dynSeries:: Using a string as a second input argument, I can only handle weekly (W), monthly (M), quaterly (Q) or yearly (Y) data!');
|
||||
end
|
||||
ts.init = dynDate(b);
|
||||
ts.freq = ts.init.freq;
|
||||
elseif isa(b,'dynDate') && ~isempty(b)
|
||||
ts.freq = b.freq;
|
||||
ts.init = b;
|
||||
|
@ -354,7 +334,7 @@ ts.time = ts.init:(ts.init+ts.nobs);
|
|||
%$ t = zeros(7,1);
|
||||
%$
|
||||
%$ try
|
||||
%$ ts = dynSeries([transpose(1:5), transpose(6:10)],'1950Q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
|
||||
%$ ts = dynSeries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
|
||||
%$ t(1) = 1;
|
||||
%$ catch
|
||||
%$ t = 0;
|
||||
|
|
Loading…
Reference in New Issue