2019-01-22 00:57:24 +01:00
|
|
|
function [Y, lhssub, X, startdates, enddates, residnames] = common_parsing(ds, ast, overlapping_dates)
|
|
|
|
%function [Y, lhssub, X, startdates, enddates, residnames] = common_parsing(ds, ast, overlapping_dates)
|
2017-12-12 12:13:14 +01:00
|
|
|
%
|
|
|
|
% Code common to sur.m and pooled_ols.m
|
|
|
|
%
|
|
|
|
% INPUTS
|
2017-12-13 12:29:42 +01:00
|
|
|
% ds [dseries] dataset
|
2019-01-11 11:26:13 +01:00
|
|
|
% ast [cell array] JSON representation of abstract syntax tree
|
2019-01-14 14:56:55 +01:00
|
|
|
% overlapping_dates [boolean] if true, dates are same across equations
|
2017-12-12 12:13:14 +01:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2019-01-11 11:26:13 +01:00
|
|
|
% Y [cell array] dependent variables
|
2019-01-24 11:20:39 +01:00
|
|
|
% lhssub [cell array] RHS subtracted from LHS
|
2019-01-11 11:26:13 +01:00
|
|
|
% X [cell array] regressors
|
2018-01-19 14:41:28 +01:00
|
|
|
% startdates [cell array] first observed period for each
|
2017-12-13 12:29:42 +01:00
|
|
|
% equation
|
2018-01-19 14:41:28 +01:00
|
|
|
% enddates [cell array] last observed period for each
|
2017-12-13 12:29:42 +01:00
|
|
|
% equation
|
|
|
|
% startidxs [vector] rows corresponding to each
|
|
|
|
% equation's observations
|
2018-01-19 14:41:28 +01:00
|
|
|
% residnames [cell array] name of residual in each equation
|
2017-12-12 12:13:14 +01:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
2019-01-11 11:26:13 +01:00
|
|
|
% Copyright (C) 2019 Dynare Team
|
2017-12-12 12:13:14 +01: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/>.
|
|
|
|
|
2019-01-11 11:26:13 +01:00
|
|
|
|
|
|
|
%% Initialize variables
|
2019-01-15 11:05:55 +01:00
|
|
|
neqs = length(ast);
|
|
|
|
Y = cell(neqs, 1);
|
|
|
|
lhssub = cell(neqs, 1);
|
|
|
|
X = cell(neqs, 1);
|
|
|
|
startdates = cell(neqs, 1);
|
|
|
|
enddates = cell(neqs, 1);
|
|
|
|
residnames = cell(neqs, 1);
|
2019-01-11 11:26:13 +01:00
|
|
|
|
|
|
|
%% Loop over equations
|
|
|
|
for i = 1:neqs
|
2019-01-15 11:06:31 +01:00
|
|
|
[Y{i}, lhssub{i}, X{i}, residnames{i}, startdates{i}, enddates{i}] = ...
|
2019-01-22 00:57:24 +01:00
|
|
|
parse_ols_style_equation(ds, ast{i});
|
2019-01-11 11:26:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if overlapping_dates
|
|
|
|
maxfp = max([startdates{:}]);
|
|
|
|
minlp = min([enddates{:}]);
|
|
|
|
for i = 1:neqs
|
|
|
|
Y{i} = Y{i}(maxfp:minlp);
|
2019-01-17 15:15:35 +01:00
|
|
|
if ~isempty(X{i})
|
|
|
|
X{i} = X{i}(maxfp:minlp);
|
|
|
|
end
|
2019-01-11 11:26:13 +01:00
|
|
|
if ~isempty(lhssub{i})
|
|
|
|
lhssub{i} = lhssub{i}(maxfp:minlp);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-12-12 12:13:14 +01:00
|
|
|
end
|