Skip to content
Snippets Groups Projects
Verified Commit 7fedc20a authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Do not return NaNs if a variable is 0 in all periods.

parent 283c2614
Branches
No related tags found
No related merge requests found
......@@ -53,10 +53,14 @@ tdx = find(sum(bsxfun(@eq, p.dates.time, o.dates.time(end,:)),2)==2);
GrowthFactor = p.data(tdx+1:end,:)./p.data(tdx:end-1,:);
CumulatedGrowthFactors = cumprod(GrowthFactor);
isallzeros = all(~p.data) & all(~o.data);
o.data = [o.data; bsxfun(@times,CumulatedGrowthFactors, o.data(end,:))];
o.dates = firstdate(o):firstdate(o)+nobs(o)-1;
o.data(:,isallzeros) = 0;
for i=1:o.vobs
if isempty(o.ops{i})
if noinputname
......@@ -73,7 +77,6 @@ for i=1:o.vobs
end
end
%@test:1
%$ try
%$ ts = dseries([1; 2; 3; 4],dates('1950Q1')) ;
......@@ -95,4 +98,28 @@ end
%$ end
%$
%$ T = all(t);
%@eof:1
\ No newline at end of file
%@eof:1
%@test:2
%$ try
%$ ts = dseries([0 1; 0 2; 0 3; 0 4],dates('1950Q1')) ;
%$ us = dseries([0 3; 0 4; 0 5; 0 6],dates('1950Q3')) ;
%$ ts.chain_(us);
%$ t(1) = 1;
%$ catch
%$ t(1) = 0;
%$ end
%$
%$ if t(1)
%$ t(2) = dassert(ts.freq,4);
%$ t(3) = dassert(ts.init.freq,4);
%$ t(4) = dassert(ts.init.time,[1950, 1]);
%$ t(5) = dassert(ts.vobs,2);
%$ t(6) = dassert(ts.nobs,6);
%$ t(7) = isequal(ts.data(:,2), transpose(1:6));
%$ t(8) = isequal(ts.data(:,1), zeros(6, 1));
%$ t(9) = isequal(ts.dates(end), dates('1951Q2'));
%$ end
%$
%$ T = all(t);
%@eof:2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment