Fixed PAC index for target variable in companion VAR.
parent
8a6d23f471
commit
8b3ba814c7
|
@ -65,18 +65,33 @@ end
|
||||||
pacvalues = DynareModel.params([pacmodel.ec.params; pacmodel.ar.params(:)]);
|
pacvalues = DynareModel.params([pacmodel.ec.params; pacmodel.ar.params(:)]);
|
||||||
|
|
||||||
% Get the indices for the stationary/nonstationary variables in the VAR system.
|
% Get the indices for the stationary/nonstationary variables in the VAR system.
|
||||||
if any(varmodel.nonstationary)
|
id = find(strcmp(DynareModel.endo_names{pacmodel.ec.vars(1)}, varmodel.list_of_variables_in_companion_var));
|
||||||
idns = find(varmodel.nonstationary);
|
|
||||||
if length(idns)<length(varmodel.eqn)
|
if isempty(id)
|
||||||
ids = find(~varmodel.nonstationary);
|
% Find the auxiliary variables if any
|
||||||
|
ad = find(cell2mat(cellfun(@(x) isauxiliary(x, 8), varmodel.list_of_variables_in_companion_var, 'UniformOutput', false)));
|
||||||
|
if isempty(ad)
|
||||||
|
error('Cannot find the trend variable in the Companion VAR/VECM model.')
|
||||||
else
|
else
|
||||||
% All the variables in the system are non stationary.
|
for i=1:length(ad)
|
||||||
ids = [];
|
auxinfo = DynareModel.aux_vars(get_aux_variable_id(varmodel.list_of_variables_in_companion_var{ad(i)}));
|
||||||
|
if isequal(auxinfo.orig_index, pacmodel.ec.vars(1))
|
||||||
|
id = ad(i);
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if isempty(id)
|
||||||
|
error('Cannot find the trend variable in the Companion VAR/VECM model.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if varmodel.nonstationary(id)
|
||||||
|
idns = id;
|
||||||
|
ids = [];
|
||||||
else
|
else
|
||||||
% All the variables in the system are stationary.
|
|
||||||
idns = [];
|
idns = [];
|
||||||
ids = 1:length(varmodel.eqn);
|
ids = id;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Get the value of the discount factor.
|
% Get the value of the discount factor.
|
||||||
|
@ -92,19 +107,27 @@ end
|
||||||
|
|
||||||
% Get h0 and h1 vectors (plus the parameter for the growth neutrality correction).
|
% Get h0 and h1 vectors (plus the parameter for the growth neutrality correction).
|
||||||
if growth_flag
|
if growth_flag
|
||||||
[h0, h1, growthneutrality] = hVectors([pacvalues; beta], varcalib.CompanionMatrix, ids, pacmodel.ec.vars(1), pacmodel.auxmodel);
|
[h0, h1, growthneutrality] = hVectors([pacvalues; beta], varcalib.CompanionMatrix, ids, idns, pacmodel.auxmodel);
|
||||||
else
|
else
|
||||||
[h0, h1] = hVectors([pacvalues; beta], varcalib.CompanionMatrix, ids, pacmodel.ec.vars(1), pacmodel.auxmodel);
|
[h0, h1] = hVectors([pacvalues; beta], varcalib.CompanionMatrix, ids, idns, pacmodel.auxmodel);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Update the parameters related to the stationary components.
|
% Update the parameters related to the stationary components.
|
||||||
if length(h0)
|
if length(h0)
|
||||||
DynareModel.params(pacmodel.h0_param_indices) = h0;
|
DynareModel.params(pacmodel.h0_param_indices) = h0;
|
||||||
|
else
|
||||||
|
if isfield(pacmodel, 'h0_param_indices') && length(pacmodel.h0_param_indices)
|
||||||
|
DynareModel.params(pacmodel.h0_param_indices) = .0;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Update the parameters related to the nonstationary components.
|
% Update the parameters related to the nonstationary components.
|
||||||
if length(h1)
|
if length(h1)
|
||||||
DynareModel.params(pacmodel.h1_param_indices) = h1;
|
DynareModel.params(pacmodel.h1_param_indices) = h1;
|
||||||
|
else
|
||||||
|
if isfield(pacmodel, 'h1_param_indices') && length(pacmodel.h1_param_indices)
|
||||||
|
DynareModel.params(pacmodel.h1_param_indices) = .0;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Update the parameter related to the growth neutrality correction.
|
% Update the parameter related to the growth neutrality correction.
|
||||||
|
|
|
@ -47,6 +47,7 @@ if nargin<2
|
||||||
oo_.var.(var_model_name).CompanionMatrix((i-1)*n+(1:n),(i-2)*n+(1:n)) = eye(n);
|
oo_.var.(var_model_name).CompanionMatrix((i-1)*n+(1:n),(i-2)*n+(1:n)) = eye(n);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
M_.var.(var_model_name).list_of_variables_in_companion_var = M_.endo_names(M_.var.(var_model_name).lhs);
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ if all(~oo_.var.(var_model_name).ec(:))
|
||||||
oo_.var.(var_model_name).CompanionMatrix((i-1)*n+(1:n),(i-2)*n+(1:n)) = eye(n);
|
oo_.var.(var_model_name).CompanionMatrix((i-1)*n+(1:n),(i-2)*n+(1:n)) = eye(n);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
M_.var.(var_model_name).list_of_variables_in_companion_var = M_.endo_names(M_.var.(var_model_name).lhs);
|
||||||
else
|
else
|
||||||
error('You should not use undiff option in this model!')
|
error('You should not use undiff option in this model!')
|
||||||
end
|
end
|
||||||
|
@ -189,6 +191,22 @@ else
|
||||||
oo_.var.(var_model_name).CompanionMatrix(i*n+(1:n),(i-1)*n+(1:n)) = eye(n);
|
oo_.var.(var_model_name).CompanionMatrix(i*n+(1:n),(i-1)*n+(1:n)) = eye(n);
|
||||||
end
|
end
|
||||||
oo_.var.(var_model_name).CompanionMatrix(1:n, p*n+(1:n)) = B(:,:,p+1);
|
oo_.var.(var_model_name).CompanionMatrix(1:n, p*n+(1:n)) = B(:,:,p+1);
|
||||||
|
M_.var.(var_model_name).list_of_variables_in_companion_var = M_.endo_names(M_.var.(var_model_name).lhs);
|
||||||
|
variables_rewritten_in_levels = M_.var.(var_model_name).list_of_variables_in_companion_var(ecm_eqnums_in_auxiliary_model);
|
||||||
|
for i=1:m
|
||||||
|
id = get_aux_variable_id(variables_rewritten_in_levels{i});
|
||||||
|
if id
|
||||||
|
auxinfo = M_.aux_vars(id);
|
||||||
|
if auxinfo.type==8
|
||||||
|
M_.var.(var_model_name).list_of_variables_in_companion_var(ecm_eqnums_in_auxiliary_model(i)) = ...
|
||||||
|
{M_.endo_names{auxinfo.orig_index}};
|
||||||
|
else
|
||||||
|
error('This is a bug. Please contact the Dynare Team.')
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error('This is a bug. Please contact the Dynare Team.')
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
error('It is not possible to cast the VECM model in a companion representation! Use undiff option.')
|
error('It is not possible to cast the VECM model in a companion representation! Use undiff option.')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue