ols: modify ols-style estimation routines to account for change in 7be8f10e0e
parent
fe8dfba59d
commit
aceeef876b
|
@ -5,7 +5,7 @@ function [dbase, info] = checkdatabaseforinversion(dbase, DynareModel)
|
|||
% adds auxiliary variables, for lags greater than 1 on endogebnous variables
|
||||
% or lags on the exogenous variables.
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -34,21 +34,21 @@ k = 0;
|
|||
for i = DynareModel.orig_endo_nbr+1:DynareModel.endo_nbr
|
||||
k = k+1;
|
||||
if DynareModel.aux_vars(k).type==1
|
||||
if ismember(deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index,:)), dbase.name)
|
||||
dbase{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).endo_index, :))} = dbase{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :))}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
|
||||
if ismember(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index,:), dbase.name)
|
||||
dbase{DynareModel.endo_names(DynareModel.aux_vars(k).endo_index, :)} = dbase{DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :)}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
|
||||
else
|
||||
error('%s not available in dbase!', deblank(DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :)));
|
||||
error('%s not available in dbase!', DynareModel.endo_names(DynareModel.aux_vars(k).orig_index, :));
|
||||
end
|
||||
elseif DynareModel.aux_vars(k).type==3
|
||||
dbase{deblank(DynareModel.endo_names(DynareModel.aux_vars(k).endo_index,:))} = dbase{deblank(DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :))}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
|
||||
listoflaggedexogenousvariables = vertcat(listoflaggedexogenousvariables, deblank(DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :)));
|
||||
dbase{DynareModel.endo_names(DynareModel.aux_vars(k).endo_index,:)} = dbase{DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :)}.lag(abs(DynareModel.aux_vars(k).orig_lead_lag));
|
||||
listoflaggedexogenousvariables = vertcat(listoflaggedexogenousvariables, DynareModel.exo_names(DynareModel.aux_vars(k).orig_index, :));
|
||||
else
|
||||
warning('Please contact Dynare Team!')
|
||||
end
|
||||
end
|
||||
|
||||
info.endonames = cellstr(DynareModel.endo_names);
|
||||
info.exonames = cellstr(DynareModel.exo_names);
|
||||
info.endonames = DynareModel.endo_names;
|
||||
info.exonames = DynareModel.exo_names;
|
||||
info.computeresiduals = false;
|
||||
|
||||
% Check that all the endogenous variables are defined in dbase.
|
||||
|
|
|
@ -18,7 +18,7 @@ function ds = dyn_ols(ds, fitted_names_dict, eqtags)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -67,9 +67,7 @@ else
|
|||
end
|
||||
|
||||
%% Estimation
|
||||
M_endo_trim = cellstr(M_.endo_names);
|
||||
M_exo_trim = cellstr(M_.exo_names);
|
||||
M_endo_exo_names_trim = [M_endo_trim; M_exo_trim];
|
||||
M_endo_exo_names_trim = [M_.endo_names; M_.exo_names];
|
||||
regex = strjoin(M_endo_exo_names_trim(:,1), '|');
|
||||
mathops = '[\+\*\^\-\/\(\)]';
|
||||
M_param_names_trim = cellfun(@strtrim, num2cell(M_.param_names,2), 'UniformOutput', false);
|
||||
|
@ -77,7 +75,7 @@ for i = 1:length(lhs)
|
|||
%% Construct regression matrices
|
||||
rhs_ = strsplit(rhs{i}, {'+','-','*','/','^','log(','exp(','(',')'});
|
||||
rhs_(cellfun(@(x) all(isstrprop(x, 'digit')), rhs_)) = [];
|
||||
vnames = setdiff(rhs_, cellstr(M_.param_names));
|
||||
vnames = setdiff(rhs_, M_.param_names);
|
||||
if ~isempty(regexp(rhs{i}, ...
|
||||
['(' strjoin(vnames, '\\(\\d+\\)|') '\\(\\d+\\))'], ...
|
||||
'once'))
|
||||
|
@ -85,7 +83,7 @@ for i = 1:length(lhs)
|
|||
lineno{i} ': ' lhs{i} ' = ' rhs{i}]);
|
||||
end
|
||||
|
||||
pnames = intersect(rhs_, cellstr(M_.param_names));
|
||||
pnames = intersect(rhs_, M_.param_names);
|
||||
vnames = cell(1, length(pnames));
|
||||
splitstrings = cell(length(pnames), 1);
|
||||
X = dseries();
|
||||
|
@ -144,7 +142,7 @@ for i = 1:length(lhs)
|
|||
end
|
||||
|
||||
lhssub = getRhsToSubFromLhs(ds, rhs{i}, regex, [splitstrings; pnames]);
|
||||
residuals = setdiff(intersect(rhs_, M_exo_trim), ds.name);
|
||||
residuals = setdiff(intersect(rhs_, M_.exo_names), ds.name);
|
||||
assert(~isempty(residuals), ['No residuals in equation ' num2str(i)]);
|
||||
assert(length(residuals) == 1, ['More than one residual in equation ' num2str(i)]);
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ assert(ischar(rhs), 'The second argument must be a string');
|
|||
assert(ischar(regex), 'The third argument must be a string');
|
||||
assert(iscell(splits), 'The fourth argument must be a cell');
|
||||
|
||||
M_exo_trim = cellstr(M_.exo_names);
|
||||
lhssub = dseries();
|
||||
rhs_ = strsplit(rhs, splits);
|
||||
for j = 1:length(rhs_)
|
||||
|
@ -61,7 +60,7 @@ for j = 1:length(rhs_)
|
|||
lhssub = [lhssub eval(regexprep([minusstr str], regex, 'ds.$&'))];
|
||||
lhssub.rename_(lhssub{lhssub.vobs}.name{:}, [minusstr str]);
|
||||
catch
|
||||
if ~any(strcmp(M_exo_trim, str))
|
||||
if ~any(strcmp(M_.exo_names, str))
|
||||
error(['getRhsToSubFromLhs: problem evaluating ' minusstr str]);
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ function olseqs(ds, varargin)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -44,7 +44,7 @@ for i = 1:length(lhs)
|
|||
%% Construct regression matrices
|
||||
rhs_ = strsplit(rhs{i}, {'+','-','*','/','^','log(','exp(','(',')'});
|
||||
rhs_(cellfun(@(x) all(isstrprop(x, 'digit')), rhs_)) = [];
|
||||
vnames = setdiff(rhs_, cellstr(M_.param_names));
|
||||
vnames = setdiff(rhs_, M_.param_names);
|
||||
regexprnoleads = cell2mat(strcat('(', vnames, {'\(\d+\))|'}));
|
||||
if ~isempty(regexp(rhs{i}, regexprnoleads(1:end-1), 'match'))
|
||||
error(['olseqs: you cannot have leads in equation on line ' ...
|
||||
|
|
|
@ -15,7 +15,7 @@ function pooled_fgls(ds, param_common, param_regex)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% dynare must be run with the option: json=parse
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -45,7 +45,6 @@ kLeye = kron(chol(inv(M_.Sigma_e)), eye(oo_.sur.dof));
|
|||
[q, r] = qr(kLeye*oo_.pooled_fgls.X, 0);
|
||||
oo_.pooled_fgls.beta = r\(q'*kLeye*oo_.pooled_fgls.Y);
|
||||
|
||||
param_names_trim = cellstr(M_.param_names);
|
||||
regexcountries = ['(' strjoin(param_common(1:end),'|') ')'];
|
||||
pbeta = oo_.pooled_fgls.pbeta;
|
||||
assigned_idxs = false(size(pbeta));
|
||||
|
@ -54,14 +53,14 @@ for i = 1:length(param_regex)
|
|||
assigned_idxs = assigned_idxs | beta_idx;
|
||||
value = oo_.pooled_fgls.beta(beta_idx);
|
||||
assert(~isempty(value));
|
||||
M_.params(~cellfun(@isempty, regexp(param_names_trim, ...
|
||||
M_.params(~cellfun(@isempty, regexp(M_.param_names, ...
|
||||
strrep(param_regex{i}, '*', regexcountries)))) = value;
|
||||
end
|
||||
idxs = find(assigned_idxs == 0);
|
||||
values = oo_.pooled_fgls.beta(idxs);
|
||||
names = pbeta(idxs);
|
||||
for i = 1:length(idxs)
|
||||
M_.params(strcmp(param_names_trim, names{i})) = values(i);
|
||||
M_.params(strcmp(M_.param_names, names{i})) = values(i);
|
||||
end
|
||||
|
||||
oo_.pooled_fgls = rmfield(oo_.pooled_fgls, 'X');
|
||||
|
|
|
@ -21,7 +21,7 @@ function pooled_ols(ds, param_common, param_regex, overlapping_dates, save_struc
|
|||
% SPECIAL REQUIREMENTS
|
||||
% dynare must be run with the option: json=compute
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -85,10 +85,8 @@ for i = 1:length(param_regex)
|
|||
end
|
||||
|
||||
%% Find parameters and variable names in every equation & Setup estimation matrices
|
||||
M_exo_names_trim = cellstr(M_.exo_names);
|
||||
M_param_names_trim = cellstr(M_.param_names);
|
||||
[X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpidxs, surconstrainedparams] = ...
|
||||
pooled_sur_common(ds, lhs, rhs, lineno, M_exo_names_trim, M_param_names_trim);
|
||||
pooled_sur_common(ds, lhs, rhs, lineno);
|
||||
|
||||
if overlapping_dates
|
||||
maxfp = max([startdates{:}]);
|
||||
|
@ -141,7 +139,7 @@ for i = 1:length(param_regex)
|
|||
assigned_idxs = assigned_idxs | beta_idx;
|
||||
value = oo_.(save_structure_name).beta(beta_idx);
|
||||
assert(~isempty(value));
|
||||
M_.params(~cellfun(@isempty, regexp(M_param_names_trim, ...
|
||||
M_.params(~cellfun(@isempty, regexp(M_.param_names, ...
|
||||
strrep(param_regex{i}, '*', regexcountries)))) = value;
|
||||
end
|
||||
idxs = find(assigned_idxs == 0);
|
||||
|
@ -149,7 +147,7 @@ values = oo_.(save_structure_name).beta(idxs);
|
|||
names = pbeta(idxs);
|
||||
assert(length(values) == length(names));
|
||||
for i = 1:length(idxs)
|
||||
M_.params(strcmp(M_param_names_trim, names{i})) = values(i);
|
||||
M_.params(strcmp(M_.param_names, names{i})) = values(i);
|
||||
end
|
||||
|
||||
residuals = Y - X * oo_.(save_structure_name).beta;
|
||||
|
@ -160,7 +158,7 @@ for i = 1:length(lhs)
|
|||
oo_.(save_structure_name).resid.(residnames{i}{:}) = residuals(startidxs(i):startidxs(i+1)-1);
|
||||
end
|
||||
oo_.(save_structure_name).varcovar.(['eq' num2str(i)]) = oo_.(save_structure_name).resid.(residnames{i}{:})*oo_.(save_structure_name).resid.(residnames{i}{:})';
|
||||
idx = find(strcmp(residnames{i}{:}, M_exo_names_trim));
|
||||
idx = find(strcmp(residnames{i}{:}, M_.exo_names));
|
||||
M_.Sigma_e(idx, idx) = var(oo_.(save_structure_name).resid.(residnames{i}{:}));
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpidxs, surconstrainedparams] = pooled_sur_common(ds, lhs, rhs, lineno, M_exo_names_trim, M_param_names_trim)
|
||||
%function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpidxs, surconstrainedparams] = pooled_sur_common(ds, lhs, rhs, lineno, M_exo_names_trim, M_param_names_trim)
|
||||
function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpidxs, surconstrainedparams] = pooled_sur_common(ds, lhs, rhs, lineno)
|
||||
%function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpidxs, surconstrainedparams] = pooled_sur_common(ds, lhs, rhs, lineno)
|
||||
%
|
||||
% Code common to sur.m and pooled_ols.m
|
||||
%
|
||||
|
@ -8,8 +8,6 @@ function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpid
|
|||
% lhs [cellstr] LHS of equations
|
||||
% rhs [cellstr] RHS of equations
|
||||
% lineno [cellstr] line number of equations
|
||||
% M_exo_names_trim [cellarr] cellstr(M_.exo_names)
|
||||
% M_param_names_trim [cellarr] cellstr(M_.param_names)
|
||||
%
|
||||
% OUTPUTS
|
||||
% X [matrix] regressors
|
||||
|
@ -33,7 +31,7 @@ function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpid
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -52,7 +50,7 @@ function [X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, surpid
|
|||
|
||||
global M_
|
||||
|
||||
M_endo_exo_names_trim = [cellstr(M_.endo_names); M_exo_names_trim];
|
||||
M_endo_exo_names_trim = [M_.endo_names; M_.exo_names];
|
||||
regex = strjoin(M_endo_exo_names_trim(:,1), '|');
|
||||
mathops = '[\+\*\^\-\/]';
|
||||
params = cell(length(rhs),1);
|
||||
|
@ -70,7 +68,7 @@ surconstrainedparams = [];
|
|||
for i = 1:length(lhs)
|
||||
rhs_ = strsplit(rhs{i}, {'+','-','*','/','^','log(','ln(','log10(','exp(','(',')','diff('});
|
||||
rhs_(cellfun(@(x) all(isstrprop(x, 'digit')), rhs_)) = [];
|
||||
vnames = setdiff(rhs_, M_param_names_trim);
|
||||
vnames = setdiff(rhs_, M_.param_names);
|
||||
if ~isempty(regexp(rhs{i}, ...
|
||||
['(' strjoin(vnames, '\\(\\d+\\)|') '\\(\\d+\\))'], 'once'))
|
||||
error(['pooled_ols: you cannot have leads in equation on line ' ...
|
||||
|
@ -78,7 +76,7 @@ for i = 1:length(lhs)
|
|||
end
|
||||
|
||||
% Find parameters and associated variables
|
||||
pnames = intersect(rhs_, M_param_names_trim);
|
||||
pnames = intersect(rhs_, M_.param_names);
|
||||
pidxs = zeros(length(pnames), 1);
|
||||
vnames = cell(1, length(pnames));
|
||||
splitstrings = cell(length(pnames), 1);
|
||||
|
@ -91,7 +89,7 @@ for i = 1:length(lhs)
|
|||
pbeta = [pbeta; pnames{j}];
|
||||
pidxs(j) = length(pbeta);
|
||||
surpidx = surpidx + 1;
|
||||
surpidxs(surpidx, 1) = find(strcmp(pnames{j}, M_param_names_trim));
|
||||
surpidxs(surpidx, 1) = find(strcmp(pnames{j}, M_.param_names));
|
||||
else
|
||||
pidxs(j) = idx;
|
||||
surconstrainedparams = [surconstrainedparams idx];
|
||||
|
@ -150,7 +148,7 @@ for i = 1:length(lhs)
|
|||
|
||||
lhssub = getRhsToSubFromLhs(ds, rhs{i}, regex, [splitstrings; pnames]);
|
||||
|
||||
residnames{i} = setdiff(intersect(rhs_, M_exo_names_trim), ds.name);
|
||||
residnames{i} = setdiff(intersect(rhs_, M_.exo_names), ds.name);
|
||||
assert(~isempty(residnames{i}), ['No residuals in equation ' num2str(i)]);
|
||||
assert(length(residnames{i}) == 1, ['More than one residual in equation ' num2str(i)]);
|
||||
|
||||
|
|
|
@ -44,14 +44,12 @@ jsonmodel = jsonmodel.model;
|
|||
[lhs, rhs, lineno] = getEquationsByTags(jsonmodel);
|
||||
|
||||
%% Find parameters and variable names in equations and setup estimation matrices
|
||||
M_exo_names_trim = cellstr(M_.exo_names);
|
||||
M_param_names_trim = cellstr(M_.param_names);
|
||||
[X, Y, startdates, enddates, startidxs, residnames, pbeta, vars, pidxs, surconstrainedparams] = ...
|
||||
pooled_sur_common(ds, lhs, rhs, lineno, M_exo_names_trim, M_param_names_trim);
|
||||
pooled_sur_common(ds, lhs, rhs, lineno);
|
||||
|
||||
if size(X, 2) ~= M_.param_nbr
|
||||
warning(['Not all parameters were used in model: ' ...
|
||||
sprintf('%s', strjoin(setdiff(M_param_names_trim, pbeta), ', '))]);
|
||||
sprintf('%s', strjoin(setdiff(M_.param_names, pbeta), ', '))]);
|
||||
end
|
||||
|
||||
%% Force equations to have the same sample range
|
||||
|
|
|
@ -22,7 +22,7 @@ function plot_contributions(equationname, ds1, ds0)
|
|||
% [name='Phillips curve']
|
||||
% pi = beta*pi(1) + slope*y + lam;
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -107,7 +107,7 @@ rhs = rhs{:};
|
|||
% Get variable and parameter names in the equation.
|
||||
rhs_ = strsplit(rhs,{'+','-','*','/','^','log(','exp(','(',')'});
|
||||
rhs_(cellfun(@(x) all(isstrprop(x, 'digit')), rhs_)) = []; % Remove numbers
|
||||
pnames = cellstr(M_.param_names);
|
||||
pnames = M_.param_names;
|
||||
vnames = setdiff(rhs_, pnames);
|
||||
pnames = setdiff(rhs_, vnames);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ end
|
|||
|
||||
%% Estimation
|
||||
[nobs, pidxs, X, Y, m] = sur(ds);
|
||||
pnamesall = cellstr(M_.param_names(pidxs, :));
|
||||
pnamesall = M_.param_names(pidxs);
|
||||
nparams = length(param_names);
|
||||
pidxs = zeros(nparams, 1);
|
||||
for i = 1:nparams
|
||||
|
|
|
@ -34,15 +34,14 @@ assert( ...
|
|||
length(y) == length(M_.endo_names) || ... % when called from static model
|
||||
length(y) == sum(sum(M_.lead_lag_incidence ~= 0)) ... % when called from dynamic model
|
||||
);
|
||||
endo_names = cellstr(M_.endo_names);
|
||||
yidx = zeros(size(endo_names));
|
||||
yidx = zeros(size(M_.endo_names));
|
||||
for i=1:size(M_.var.(name).var_list_,1)
|
||||
yidx = yidx | strcmp(strtrim(M_.var.(name).var_list_(i,:)), endo_names);
|
||||
yidx = yidx | strcmp(strtrim(M_.var.(name).var_list_(i,:)), M_.endo_names);
|
||||
end
|
||||
y = y(yidx,:);
|
||||
|
||||
if nargin == 4
|
||||
fvidx = strcmp(fcv, endo_names);
|
||||
fvidx = strcmp(fcv, M_.endo_names);
|
||||
end
|
||||
|
||||
%% load .mat file
|
||||
|
|
|
@ -12,7 +12,7 @@ function writeVarExpectationFunction(var_model_name, horizon)
|
|||
%
|
||||
% NONE
|
||||
|
||||
% Copyright (C) 2017 Dynare Team
|
||||
% Copyright (C) 2017-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -53,11 +53,10 @@ fprintf(fid, '%%\n%% Created automatically by Dynare on %s\n%%\n\n', datestr(now
|
|||
fprintf(fid, '%%%% Construct y\n');
|
||||
fprintf(fid, 'assert(length(y) == %d);\n', sum(sum(M_.lead_lag_incidence ~= 0)));
|
||||
|
||||
endo_names = cellstr(M_.endo_names);
|
||||
nvars = size(M_.var.(var_model_name).var_list_,1);
|
||||
var_model_order = M_.var.(var_model_name).order;
|
||||
yidx = zeros(nvars, min(var_model_order, 2));
|
||||
% first for order <= 2, drawing variables directly from their endo_names
|
||||
% first for order <= 2, drawing variables directly from their M_.endo_names
|
||||
for i=1:min(var_model_order, 2)
|
||||
if mod(i, 2) == 0
|
||||
ridx = 1;
|
||||
|
@ -65,7 +64,7 @@ for i=1:min(var_model_order, 2)
|
|||
ridx = 2;
|
||||
end
|
||||
for j=1:nvars
|
||||
cidx = strcmp(strtrim(M_.var.(var_model_name).var_list_(j,:)), endo_names)';
|
||||
cidx = strcmp(strtrim(M_.var.(var_model_name).var_list_(j,:)), M_.endo_names)';
|
||||
if ~any(cidx)
|
||||
error([strtrim(M_.var.(var_model_name).var_list_(j,:)) ' not found in the list of endogenous variables']);
|
||||
end
|
||||
|
@ -79,7 +78,7 @@ if var_model_order > 2
|
|||
y1idx = zeros((var_model_order - 2)*nvars, var_model_order - 2);
|
||||
for i=3:var_model_order
|
||||
for j=1:nvars
|
||||
idx = find(strcmp(strtrim(M_.var.(var_model_name).var_list_(j,:)), endo_names));
|
||||
idx = find(strcmp(strtrim(M_.var.(var_model_name).var_list_(j,:)), M_.endo_names));
|
||||
if ~any(idx)
|
||||
error([strtrim(M_.var.(var_model_name).var_list_(j,:)) ' not found in the list of endogenous variables']);
|
||||
end
|
||||
|
|
|
@ -10,15 +10,14 @@ Sigma_e = M_.Sigma_e;
|
|||
|
||||
options_.bnlms.set_dynare_seed_to_default = false;
|
||||
|
||||
M_endo_names_trim = cellstr(M_.endo_names);
|
||||
nparampool = length(M_.params);
|
||||
BETA = zeros(NSIMS, nparampool);
|
||||
for i=1:NSIMS
|
||||
i
|
||||
firstobs = rand(3, length(M_endo_names_trim));
|
||||
firstobs = rand(3, length(M_.endo_names));
|
||||
M_.params = calibrated_values;
|
||||
M_.Sigma_e = Sigma_e;
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_endo_names_trim), 10000);
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000);
|
||||
simdata = simdata(simdata.dates(5001:6000));
|
||||
names=regexp(simdata.name, 'res\w*');
|
||||
idxs = [];
|
||||
|
|
|
@ -22,7 +22,7 @@ model(linear);
|
|||
end;
|
||||
|
||||
% Estimate all parameters
|
||||
%estparams = cellstr(M_.param_names);
|
||||
%estparams = M_.param_names;
|
||||
%estparamsval = M_.params;
|
||||
|
||||
% Estimate demand parameters
|
||||
|
|
|
@ -34,7 +34,7 @@ end;
|
|||
oo_ = simul_backward_model([], 1000, options_, M_, oo_);
|
||||
|
||||
// Put all the simulated data in a dseries object.
|
||||
ds1 = dseries(transpose(oo_.endo_simul), 1900Q1, cellstr(M_.endo_names));
|
||||
ds1 = dseries(transpose(oo_.endo_simul), 1900Q1, M_.endo_names);
|
||||
|
||||
|
||||
// Select a subsample for estimation
|
||||
|
|
|
@ -9,15 +9,14 @@ Sigma_e = M_.Sigma_e;
|
|||
|
||||
options_.bnlms.set_dynare_seed_to_default = false;
|
||||
|
||||
M_endo_names_trim = cellstr(M_.endo_names);
|
||||
nparampool = length(M_.params);
|
||||
BETA = zeros(NSIMS, nparampool);
|
||||
for i=1:NSIMS
|
||||
i
|
||||
firstobs = rand(3, length(M_endo_names_trim));
|
||||
firstobs = rand(3, length(M_.endo_names));
|
||||
M_.params = calibrated_values;
|
||||
M_.Sigma_e = Sigma_e;
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_endo_names_trim), 10000);
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000);
|
||||
simdata = simdata(simdata.dates(5001:6000));
|
||||
names=regexp(simdata.name, 'res\w*');
|
||||
idxs = [];
|
||||
|
|
|
@ -9,15 +9,14 @@ Sigma_e = M_.Sigma_e;
|
|||
|
||||
options_.bnlms.set_dynare_seed_to_default = false;
|
||||
|
||||
M_endo_names_trim = cellstr(M_.endo_names);
|
||||
nparampool = length(M_.params);
|
||||
BETA = zeros(NSIMS, nparampool);
|
||||
for i=1:NSIMS
|
||||
i
|
||||
firstobs = rand(3, length(M_endo_names_trim));
|
||||
firstobs = rand(3, length(M_.endo_names));
|
||||
M_.params = calibrated_values;
|
||||
M_.Sigma_e = Sigma_e;
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_endo_names_trim), 10000);
|
||||
simdata = simul_backward_model(dseries(firstobs, dates('1995Q1'), M_.endo_names), 10000);
|
||||
simdata = simdata(simdata.dates(5001:6000));
|
||||
names=regexp(simdata.name, 'res\w*');
|
||||
idxs = [];
|
||||
|
|
|
@ -73,13 +73,13 @@ exo_names = nv.M_.exo_names;
|
|||
endo_names = nv.M_.endo_names;
|
||||
|
||||
for i = 1:length(exo_names)
|
||||
figure('Name', ['Shock to ' exo_names(i)]);
|
||||
figure('Name', ['Shock to ' exo_names{i}]);
|
||||
for j = 1:length(endo_names)
|
||||
subplot(ridx, cidx, j);
|
||||
hold on
|
||||
title(endo_names(j,:));
|
||||
plot(nv.oo_.irfs.([deblank(endo_names(j,:)) '_' deblank(exo_names(i,:))]));
|
||||
plot(wv.oo_.irfs.([deblank(endo_names(j,:)) '_' deblank(exo_names(i,:))]), '--');
|
||||
title(endo_names{j});
|
||||
plot(nv.oo_.irfs.([endo_names{j} '_' exo_names{i}]));
|
||||
plot(wv.oo_.irfs.([endo_names{j} '_' exo_names{i}]), '--');
|
||||
hold off
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue