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

Fixed bug (incorrect results) in backcast method.

parent 923eadce
Branches
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ function q = backcast(o, p, diff) % --*-- Unitary tests --*--
% The two dseries objects must have common frequency and the same number of variables. Also the
% two samples must overlap.
% Copyright (C) 2019 Dynare Team
% Copyright © 2019-2020 Dynare Team
%
% This file is part of Dynare.
%
......
function o = backcast_(o, p, diff) % --*-- Unitary tests --*--
% Copyright (C) 2019 Dynare Team
% Copyright © 2019-2020 Dynare Team
%
% This file is part of Dynare.
%
......@@ -43,11 +43,11 @@ idp = find(o.dates(1)==p.dates);
if diff
FirstDifference = p.data(2:idp,:)-p.data(1:idp-1,:);
CumulatedDifferences = rcumsum(FirstDifference);
o.data = [bsxfun(@minus, o.data(1:end), CumulatedDifferences); o.data];
o.data = [bsxfun(@minus, o.data(1), CumulatedDifferences); o.data];
else
GrowthFactor = p.data(2:idp,:)./p.data(1:idp-1,:);
CumulatedGrowthFactors = rcumprod(GrowthFactor);
o.data = [bsxfun(@rdivide, o.data(1:end), CumulatedGrowthFactors); o.data];
o.data = [bsxfun(@rdivide, o.data(1), CumulatedGrowthFactors); o.data];
end
o.dates = firstdate(p):lastdate(o);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment