2013-10-18 17:38:43 +02:00
function ts = dseries ( varargin) % --*-- Unitary tests --*--
2011-08-11 22:47:46 +02:00
%@info:
2013-10-18 17:38:43 +02:00
%! @deftypefn {Function File} {@var{ts} =} dseries (@var{a},@var{b},@var{c},@var{d})
%! @anchor{dseries}
2011-08-11 22:47:46 +02:00
%! @sp 1
%! Constructor for the Dynare time series class.
%! @sp 2
%! @strong{Inputs}
2012-12-05 14:52:08 +01:00
%! @sp 2
2013-10-18 17:38:43 +02:00
%! If @code{nargin==0} then an empty dseries object is created. The object can be populated with data subsequently using the overloaded subsref method.
2012-12-05 14:52:08 +01:00
%! @sp 2
2014-04-30 15:44:30 +02:00
%! If @code{nargin==1} and if the input argument is a @ref{dates} object, then a dseries object without data is created. This object can be populated with the overload subsref method.
2012-12-05 14:52:08 +01:00
%! @sp 2
2013-10-18 17:38:43 +02:00
%! If @code{nargin==1} and if the input argument is a string for the name of a csv, m or mat file containing data, then a dseries object is created from these data.
2012-12-05 14:52:08 +01:00
%! @sp 2
%! If @code{nargin>1}:
2011-08-11 22:47:46 +02:00
%! @sp 1
%! @table @ @var
%! @item a
%! T*1 vector or T*N matrix of data.
%! @item b
2012-12-05 14:52:08 +01:00
%! Initial date. For Quaterly, Monthly or Weekly data, b must be a string. For yearly data or if the frequence is not defined b must be an integer.
2011-08-11 22:47:46 +02:00
%! @item c
2014-03-26 11:39:52 +01:00
%! N*1 cell array of strings or N*q array of strings. Names of the N time series.
2011-08-11 22:47:46 +02:00
%! @item d
2014-03-26 11:39:52 +01:00
%! N*1 cell array of strings or N*p array of characters. TeX names of the N time series.
2011-08-11 22:47:46 +02:00
%! @end table
2012-12-05 14:52:08 +01:00
%! @sp 2
2011-08-11 22:47:46 +02:00
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item ts
%! Dynare time series object.
%! @end table
2012-12-05 14:52:08 +01:00
%! @sp 2
2011-08-11 22:47:46 +02:00
%! @strong{Properties}
%! @sp 1
%! The constructor defines the following properties:
%! @sp 1
%! @table @ @var
%! @item data
%! Array of doubles (nobs*vobs).
%! @item nobs
%! Scalar integer, the number of observations.
%! @item vobs
%! Scalar integer, the number of variables.
%! @item name
2012-12-05 14:52:08 +01:00
%! Cell array of strings, names of the variables.
2011-08-11 22:47:46 +02:00
%! @item tex
2012-12-05 14:52:08 +01:00
%! Cell array of strings, tex names of the variables.
2011-08-11 22:47:46 +02:00
%! @item freq
%! Scalar integer, the frequency of the time series. @var{freq} is equal to 1 if data are on a yearly basis or if
%! frequency is unspecified. @var{freq} is equal to 4 if data are on a quaterly basis. @var{freq} is equal to
%! 12 if data are on a monthly basis. @var{freq} is equal to 52 if data are on a weekly basis.
%! @item init
2014-04-30 15:44:30 +02:00
%! @ref{dates} object, initial date of the dataset.
2011-08-11 22:47:46 +02:00
%! @end table
%! @end deftypefn
%@eod:
2013-06-12 16:42:09 +02:00
% Copyright (C) 2011-2013 Dynare Team
2011-08-11 22:47:46 +02:00
%
% 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/>.
2014-06-08 16:52:41 +02:00
if nargin > 0 && ischar ( varargin { 1 } ) && isequal ( varargin { 1 } , ' initialize' )
2014-05-14 12:36:06 +02:00
ts = struct ;
ts . data = [ ] ;
ts . nobs = 0 ;
ts . vobs = 0 ;
ts . name = { } ;
ts . tex = { } ;
ts . dates = dates ( ) ;
2014-05-14 15:54:15 +02:00
ts = class ( ts , ' dseries' ) ;
assignin ( ' base' , ' emptydseriesobject' , ts ) ;
return
2014-05-14 12:36:06 +02:00
end
2011-08-11 22:47:46 +02:00
2014-05-14 15:54:15 +02:00
ts = evalin ( ' base' , ' emptydseriesobject' ) ;
2011-08-11 22:47:46 +02:00
switch nargin
case 0
2013-10-18 17:38:43 +02:00
% Create an empty dseries object.
2011-08-11 22:47:46 +02:00
return
2012-11-26 15:05:14 +01:00
case 1
2013-11-06 22:43:43 +01:00
if isdates ( varargin { 1 } )
2013-10-16 13:09:11 +02:00
switch length ( varargin { 1 } )
case 0
2013-11-06 17:41:11 +01:00
error ( [ ' dseries::dseries: Input ' inputname ( 1 ) ' (identified as a dates object) must be non empty!' ] )
2013-10-16 13:09:11 +02:00
case 1
2013-10-18 17:38:43 +02:00
% Create an empty dseries object with an initial date.
2014-06-09 11:41:16 +02:00
ts . dates = varargin { 1 } ;
2013-10-16 13:09:11 +02:00
otherwise
2014-03-22 11:23:46 +01:00
% A range of dates is passed to the constructor
ts . dates = varargin { 1 } ;
2012-11-26 15:05:14 +01:00
end
2012-12-03 15:51:03 +01:00
return
2012-11-26 15:05:14 +01:00
elseif ischar ( varargin { 1 } )
2013-10-18 17:38:43 +02:00
% Create a dseries object loading data in a file (*.csv, *.m, *.mat).
2013-07-03 10:59:50 +02:00
if isempty ( varargin { 1 } )
2013-10-18 17:38:43 +02:00
error ( ' dseries:: Wrong calling sequence! Input argument cannot be an empty string.' )
2013-07-03 10:59:50 +02:00
elseif check_file_extension ( varargin { 1 } , ' m' )
2013-03-16 00:29:56 +01:00
[ freq , init , data , varlist , tex ] = load_m_file_data ( varargin { 1 } ) ;
2012-11-26 15:05:14 +01:00
elseif check_file_extension ( varargin { 1 } , ' mat' )
2013-03-16 00:29:56 +01:00
[ freq , init , data , varlist , tex ] = load_mat_file_data ( varargin { 1 } ) ;
2012-11-26 15:05:14 +01:00
elseif check_file_extension ( varargin { 1 } , ' csv' )
[ freq , init , data , varlist ] = load_csv_file_data ( varargin { 1 } ) ;
2013-03-16 00:29:56 +01:00
tex = [ ] ;
2013-09-11 17:19:54 +02:00
elseif check_file_extension ( varargin { 1 } , ' xls' ) || check_file_extension ( varargin { 1 } , ' xlsx' )
2013-11-29 17:47:53 +01:00
if isglobalinbase ( ' options_' )
2013-09-11 17:19:54 +02:00
% Check that the object is instantiated within a dynare session so that options_ global structure exists.
2013-10-18 17:38:43 +02:00
% Should provide latter a mechanism to pass range and sheet to dseries constructor...
2013-09-11 17:19:54 +02:00
range = evalin ( ' base' , ' options_.xls_range' ) ;
sheet = evalin ( ' base' , ' options_.xls_sheet' ) ;
else
% By default only the (whole) first sheet is loaded.
range = [ ] ;
sheet = [ ] ;
end
[ freq , init , data , varlist ] = load_xls_file_data ( varargin { 1 } , sheet , range ) ;
tex = [ ] ;
2012-11-26 15:05:14 +01:00
else
2013-10-18 17:38:43 +02:00
error ( [ ' dseries:: I' ' m not able to load data from ' inputname ( 1 ) ' !' ] )
2012-11-26 15:05:14 +01:00
end
2012-12-03 15:51:03 +01:00
ts . data = data ;
ts . name = varlist ;
ts . vobs = length ( varlist ) ;
2013-03-15 16:40:20 +01:00
ts . nobs = size ( data , 1 ) ;
2014-06-09 11:41:16 +02:00
ts . dates = init : init + ( ts . nobs - 1 ) ;
2013-03-16 00:29:56 +01:00
if isempty ( tex )
2013-11-22 17:55:57 +01:00
ts . tex = name2tex ( varlist ) ;
2013-03-16 00:29:56 +01:00
else
2013-07-05 12:38:32 +02:00
ts . tex = tex ;
2013-03-15 16:40:20 +01:00
end
2013-07-05 12:38:32 +02:00
elseif isnumeric ( varargin { 1 } ) && isequal ( ndims ( varargin { 1 } ) , 2 )
ts . data = varargin { 1 } ;
[ ts . nobs , ts . vobs ] = size ( ts . data ) ;
ts . name = default_name ( ts . vobs ) ;
2013-11-22 17:55:57 +01:00
ts . tex = name2tex ( ts . name ) ;
2014-06-09 11:41:16 +02:00
ts . dates = dates ( 1 , 1 ) : dates ( 1 , 1 ) + ( ts . nobs - 1 ) ;
2012-11-26 15:05:14 +01:00
end
2012-12-05 14:52:08 +01:00
case { 2 , 3 , 4 }
2014-06-19 17:59:19 +02:00
if isequal ( nargin , 2 ) && ischar ( varargin { 1 } ) && isdates ( varargin { 2 } )
% Instantiate dseries object with a data file and force the initial date to be as given by the second input argument.
ds = dseries ( varargin { 1 } ) ;
ts = dseries ( ds . data , varargin { 2 } , ds . name , ds . tex ) ;
return
end
2012-12-03 15:51:03 +01:00
a = varargin { 1 } ;
b = varargin { 2 } ;
if nargin < 4
2013-03-15 16:40:20 +01:00
d = { } ;
2012-12-03 15:51:03 +01:00
else
d = varargin { 4 } ;
2014-03-27 18:25:46 +01:00
if ~ iscell ( d ) && ~ isempty ( d )
2014-03-26 11:39:52 +01:00
d = cellstr ( d ) ;
end
2012-12-03 15:51:03 +01:00
end
if nargin < 3
2013-03-15 16:40:20 +01:00
c = { } ;
2012-12-03 15:51:03 +01:00
else
c = varargin { 3 } ;
2014-03-27 18:25:46 +01:00
if ~ iscell ( c ) && ~ isempty ( c )
2014-03-26 11:39:52 +01:00
c = cellstr ( c ) ;
end
2011-08-11 22:47:46 +02:00
end
% Get data, number of observations and number of variables.
ts . data = a ;
ts . nobs = size ( a , 1 ) ;
ts . vobs = size ( a , 2 ) ;
% Get the first date and set the frequency.
2013-10-16 13:09:11 +02:00
if isempty ( b )
2014-06-09 11:41:16 +02:00
init = dates ( 1 , 1 ) ;
2014-03-22 11:23:46 +01:00
elseif ( isdates ( b ) && isequal ( length ( b ) , 1 ) )
2014-06-09 11:41:16 +02:00
init = b ;
2014-03-22 11:23:46 +01:00
elseif isdate ( b ) % Weekly, Monthly, Quaterly or Annual data (string).
2014-06-09 11:41:16 +02:00
init = dates ( b ) ;
2014-03-22 11:23:46 +01:00
elseif ( isnumeric ( b ) && isscalar ( b ) && isint ( b ) ) % Yearly data.
2014-06-09 11:41:16 +02:00
init = dates ( [ num2str ( b ) ' Y' ] ) ;
2014-03-22 11:23:46 +01:00
elseif isdates ( b ) % Range of dates
2014-06-09 11:41:16 +02:00
init = b ( 1 ) ;
2014-03-22 11:23:46 +01:00
if ts . nobs > 1 && ~ isequal ( b . ndat , ts . nobs )
message = ' dseries::dseries: If second input is a range, its number of elements must match ' ;
message = char ( message , ' the number of rows in the first input, unless the first input' ) ;
message = char ( message , ' has only one row.' ) ;
skipline ( )
disp ( message ) ;
error ( ' ' ) ;
elseif isequal ( ts . nobs , 1 )
ts . data = repmat ( ts . data , b . ndat , 1 ) ;
ts . nobs = b . ndat ;
2011-08-11 22:47:46 +02:00
end
2014-03-22 11:23:46 +01:00
ts . dates = b ;
elseif ( isnumeric ( b ) && isint ( b ) ) % Range of yearly dates.
message = ' dseries::dseries: Not implemented! If you need to define a range of years' ;
message = char ( message , ' you have to pass a dates object as the second input argument.' ) ;
disp ( message )
error ( ' ' )
else
error ( ' dseries::dseries: Wrong calling sequence!' ) ;
2011-08-11 22:47:46 +02:00
end
% Get the names of the variables.
if ~ isempty ( c )
2012-12-03 15:51:03 +01:00
if ts . vobs == length ( c )
for i = 1 : ts . vobs
2014-06-09 11:41:16 +02:00
ts . name = vertcat ( ts . name , c ( i ) ) ;
2012-12-03 15:51:03 +01:00
end
2011-08-11 22:47:46 +02:00
else
2013-10-18 17:38:43 +02:00
error ( ' dseries::dseries: The number of declared names does not match the number of variables!' )
2011-08-11 22:47:46 +02:00
end
else
2013-07-05 12:38:32 +02:00
ts . name = default_name ( ts . vobs ) ;
2011-08-11 22:47:46 +02:00
end
if ~ isempty ( d )
2012-12-03 15:51:03 +01:00
if ts . vobs == length ( d )
for i = 1 : ts . vobs
ts . tex = vertcat ( ts . tex , d ( i ) ) ;
end
2011-08-11 22:47:46 +02:00
else
2013-10-18 17:38:43 +02:00
error ( ' dseries::dseries: The number of declared tex names does not match the number of variables!' )
2011-08-11 22:47:46 +02:00
end
else
2013-07-05 12:38:32 +02:00
ts . tex = name2tex ( ts . name ) ;
2011-08-11 22:47:46 +02:00
end
otherwise
2013-10-18 17:38:43 +02:00
error ( ' dseries::dseries: Can' ' t instantiate the class, wrong calling sequence!' )
2011-08-11 22:47:46 +02:00
end
2014-03-22 11:23:46 +01:00
if isempty ( ts . dates )
2014-06-09 11:41:16 +02:00
ts . dates = init : init + ( ts . nobs - 1 ) ;
2014-03-22 11:23:46 +01:00
end
2011-08-11 22:47:46 +02:00
%@test:1
2013-10-18 17:38:43 +02:00
%$ % Test if we can instantiate an empty dseries object.
2012-11-12 11:05:00 +01:00
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries();
2012-11-12 11:05:00 +01:00
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
2012-11-12 11:07:41 +01:00
%$
2012-11-12 11:05:00 +01:00
%$ T = all(t);
%@eof:1
%@test:2
2012-12-03 15:51:03 +01:00
%$ t = zeros(4,1);
%$
%$ try
2013-10-16 13:09:11 +02:00
%$ aa = dates('1938M11');
2013-10-18 17:38:43 +02:00
%$ ts = dseries(aa);
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,12);
%$ t(3) = dyn_assert(ts.init.freq,12);
%$ t(4) = dyn_assert(ts.init.time,[1938, 11]);
%$ end
%$
%$ T = all(t);
%@eof:2
%@test:3
%$ t = zeros(6,1);
%$
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data.m');
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1994, 3]);
%$ t(5) = dyn_assert(ts.vobs,2);
%$ t(6) = dyn_assert(ts.nobs,100);
%$ end
%$
%$ T = all(t);
%@eof:3
%@test:4
%$ t = zeros(6,1);
%$
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data.mat');
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1994, 3]);
%$ t(5) = dyn_assert(ts.vobs,2);
%$ t(6) = dyn_assert(ts.nobs,100);
%$ end
%$
2011-08-11 22:47:46 +02:00
%$ T = all(t);
2012-12-03 15:51:03 +01:00
%@eof:4
%@test:5
2013-03-15 16:40:20 +01:00
%$ t = zeros(8,1);
2012-12-03 15:51:03 +01:00
%$
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data.csv');
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1990, 1]);
%$ t(5) = dyn_assert(ts.vobs,4);
%$ t(6) = dyn_assert(ts.nobs,4);
2013-03-15 16:40:20 +01:00
%$ t(7) = dyn_assert(ts.name,{'azert';'yuiop';'qsdfg';'jklm'});
%$ t(8) = dyn_assert(ts.tex,{'azert';'yuiop';'qsdfg';'jklm'});
2012-12-03 15:51:03 +01:00
%$ end
%$
%$ T = all(t);
%@eof:5
%@test:6
2013-03-15 16:40:20 +01:00
%$ t = zeros(8,1);
2012-12-03 15:51:03 +01:00
%$
2013-03-19 22:49:23 +01:00
%$ %try
2013-10-18 17:38:43 +02:00
%$ ts = dseries(transpose(1:5),[]);
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
2013-03-19 22:49:23 +01:00
%$ %catch
%$ % t = 0;
%$ %end
2012-12-03 15:51:03 +01:00
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,1);
%$ t(3) = dyn_assert(ts.init.freq,1);
%$ t(4) = dyn_assert(ts.init.time,[1, 1]);
%$ t(5) = dyn_assert(ts.vobs,1);
%$ t(6) = dyn_assert(ts.nobs,5);
2013-03-19 22:49:23 +01:00
%$ t(7) = dyn_assert(ts.name,{'Variable_1'});
%$ t(8) = dyn_assert(ts.tex,{'Variable\\_1'});
2012-12-03 15:51:03 +01:00
%$ end
%$
%$ T = all(t);
%@eof:6
%@test:7
2013-03-15 16:40:20 +01:00
%$ t = zeros(8,1);
2012-12-03 15:51:03 +01:00
%$
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries(transpose(1:5),'1950Q1');
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1950, 1]);
%$ t(5) = dyn_assert(ts.vobs,1);
%$ t(6) = dyn_assert(ts.nobs,5);
2013-03-19 22:49:23 +01:00
%$ t(7) = dyn_assert(ts.name,{'Variable_1'});
%$ t(8) = dyn_assert(ts.tex,{'Variable\\_1'});
2012-12-03 15:51:03 +01:00
%$ end
%$
%$ T = all(t);
%@eof:7
%@test:8
2013-03-15 16:40:20 +01:00
%$ t = zeros(8,1);
2012-12-03 15:51:03 +01:00
%$
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries([transpose(1:5), transpose(6:10)],'1950q1',{'Output'; 'Consumption'}, {'Y_t'; 'C_t'});
2012-12-03 15:51:03 +01:00
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1950, 1]);
%$ t(5) = dyn_assert(ts.vobs,2);
%$ t(6) = dyn_assert(ts.nobs,5);
2013-03-15 16:40:20 +01:00
%$ t(7) = dyn_assert(ts.name,{'Output'; 'Consumption'});
%$ t(8) = dyn_assert(ts.tex,{'Y_t'; 'C_t'});
2012-12-03 15:51:03 +01:00
%$ end
%$
%$ T = all(t);
%@eof:8
2013-09-11 17:21:26 +02:00
%@test:9
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data-1.xls');
2013-09-11 17:21:26 +02:00
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1990, 1]);
%$ t(5) = dyn_assert(ts.vobs,3);
%$ t(6) = dyn_assert(ts.nobs,5);
%$ t(7) = dyn_assert(ts.name,{'GDP';'Consumption';'CPI'});
%$ t(8) = dyn_assert(ts.tex,{'GDP';'Consumption';'CPI'});
%$ end
%$
%$ T = all(t);
%@eof:9
%@test:10
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data-2.xls');
2013-09-11 17:21:26 +02:00
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1990, 1]);
%$ t(5) = dyn_assert(ts.vobs,3);
%$ t(6) = dyn_assert(ts.nobs,5);
%$ t(7) = dyn_assert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
2013-11-29 18:10:47 +01:00
%$ t(8) = dyn_assert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
2013-09-11 17:21:26 +02:00
%$ end
%$
%$ T = all(t);
%@eof:10
%@test:11
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data-3.xls');
2013-09-11 17:21:26 +02:00
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts.freq,1);
%$ t(3) = dyn_assert(ts.init.freq,1);
%$ t(4) = dyn_assert(ts.init.time,[1, 1]);
%$ t(5) = dyn_assert(ts.vobs,3);
%$ t(6) = dyn_assert(ts.nobs,5);
%$ t(7) = dyn_assert(ts.name,{'Variable_1';'Variable_2';'Variable_3'});
2013-11-29 18:10:47 +01:00
%$ t(8) = dyn_assert(ts.tex,{'Variable\\_1';'Variable\\_2';'Variable\\_3'});
2013-09-11 17:21:26 +02:00
%$ end
%$
%$ T = all(t);
%@eof:11
%@test:12
%$ try
2013-10-18 17:38:43 +02:00
%$ ts = dseries('dynseries_test_data-4.xls');
2013-09-11 17:21:26 +02:00
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dyn_assert(ts.freq,1);
%$ t(3) = dyn_assert(ts.init.freq,1);
%$ t(4) = dyn_assert(ts.init.time,[1, 1]);
%$ t(5) = dyn_assert(ts.vobs,3);
%$ t(6) = dyn_assert(ts.nobs,5);
%$ t(7) = dyn_assert(ts.name,{'GDP';'Consumption';'CPI'});
%$ t(8) = dyn_assert(ts.tex,{'GDP';'Consumption';'CPI'});
%$ end
%$
%$ T = all(t);
2014-03-22 11:23:46 +01:00
%@eof:12
%@test:13
%$ t = zeros(6,1);
%$
%$ try
%$ ts = dseries(transpose(1:4),dates('1990Q1'):dates('1990Q4'));
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1990, 1]);
%$ t(5) = dyn_assert(ts.vobs,1);
%$ t(6) = dyn_assert(ts.nobs,4);
%$ end
%$
%$ T = all(t);
%@eof:13
%@test:14
%$ t = zeros(7,1);
%$
%$ try
%$ ts = dseries([1, 2],dates('1990Q1'):dates('1990Q4'));
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts.freq,4);
%$ t(3) = dyn_assert(ts.init.freq,4);
%$ t(4) = dyn_assert(ts.init.time,[1990, 1]);
%$ t(5) = dyn_assert(ts.vobs,2);
%$ t(6) = dyn_assert(ts.nobs,4);
%$ t(7) = dyn_assert(ts.data, [ones(4,1), 2*ones(4,1)]);
%$ end
%$
%$ T = all(t);
%@eof:14
%@test:15
%$ try
%$ ts = dseries([1; 2],dates('1990Q1'):dates('1990Q4'));
%$ t = 0;
%$ catch
%$ t = 1;
%$ end
%$
%$ T = all(t);
%@eof:15