2019-01-11 11:47:55 +01:00
|
|
|
function [Y, lhssub, X, startdates, enddates, startidxs, residnames, pbeta, vars] = common_parsing(ds, ast, jsonmodel, overlapping_dates)
|
|
|
|
%function [Y, lhssub, X, startdates, enddates, startidxs, residnames, pbeta, vars] = common_parsing(ds, ast, jsonmodel, 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
|
2018-01-19 14:41:28 +01:00
|
|
|
% jsonmodel [cell array] JSON representation of model block
|
2019-01-11 11:26:13 +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
|
|
|
|
% lhssub [cell array] RHS to subtract from Y
|
|
|
|
% 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
|
|
|
|
% pbeta [cell array] parameter names corresponding to
|
2017-12-13 12:29:42 +01:00
|
|
|
% columns of X
|
2018-01-19 14:41:28 +01:00
|
|
|
% vars [cell array] variable names corresponding to
|
2017-12-13 12:29:42 +01:00
|
|
|
% parameters
|
|
|
|
% surpidxs [vector] indexes in M_.params associated with
|
|
|
|
% columns of X
|
|
|
|
% surconstrainedparams [vector] indexes of parameters that were
|
|
|
|
% constrained
|
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
|
|
|
|
Y = cell(length(ast), 1);
|
|
|
|
lhssub = cell(length(ast), 1);
|
|
|
|
X = cell(length(ast), 1);
|
|
|
|
startdates = cell(length(ast), 1);
|
|
|
|
enddates = cell(length(ast), 1);
|
|
|
|
|
|
|
|
%% Loop over equations
|
|
|
|
neqs = length(ast);
|
|
|
|
for i = 1:neqs
|
|
|
|
%% Parse equation i
|
2019-01-11 17:27:42 +01:00
|
|
|
[Y{i}, lhssub{i}, X{i}] = parse_ols_style_equation(ds, ast{i});
|
2019-01-11 11:26:13 +01:00
|
|
|
|
|
|
|
%% Set start and end dates
|
|
|
|
if overlapping_dates
|
|
|
|
[startdates{i}, enddates{i}] = get_ols_start_end_dates(Y{i}, lhssub{i}, X{i}, jsonmodel{i});
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if overlapping_dates
|
|
|
|
maxfp = max([startdates{:}]);
|
|
|
|
minlp = min([enddates{:}]);
|
|
|
|
for i = 1:neqs
|
|
|
|
Y{i} = Y{i}(maxfp:minlp);
|
|
|
|
X{i} = X{i}(maxfp:minlp);
|
|
|
|
if ~isempty(lhssub{i})
|
|
|
|
lhssub{i} = lhssub{i}(maxfp:minlp);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-12-12 12:13:14 +01:00
|
|
|
end
|