Fix handling of heteroskedastic_shocks block with several declared periods

Closes: #1791
time-shift
Sébastien Villemot 2021-06-15 12:54:54 +02:00
parent de86089781
commit be38866487
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 18 additions and 19 deletions

View File

@ -32,7 +32,7 @@ function [dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_,
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2020 Dynare Team
% Copyright (C) 2003-2021 Dynare Team
%
% This file is part of Dynare.
%
@ -665,24 +665,23 @@ if options_.heteroskedastic_filter
error(['estimation option conflict: analytic_derivation isn''t available ' ...
'for heteroskedastic_filter'])
end
M_.heteroskedastic_shocks.Qvalue = NaN(M_.exo_nbr,options_.nobs);
M_.heteroskedastic_shocks.Qscale = NaN(M_.exo_nbr,options_.nobs);
xname = fieldnames(M_.heteroskedastic_shocks.Qhet);
for k=1:length(xname)
inx = strcmp(xname{k},M_.exo_names);
isqscale=false;
if isfield(M_.heteroskedastic_shocks.Qhet.(xname{k}),'scale')
M_.heteroskedastic_shocks.Qscale(inx,M_.heteroskedastic_shocks.Qhet.(xname{k}).time_scale)=M_.heteroskedastic_shocks.Qhet.(xname{k}).scale.^2;
isqscale=true;
end
if isfield(M_.heteroskedastic_shocks.Qhet.(xname{k}),'value')
if isqscale && ~isempty(intersect(M_.heteroskedastic_shocks.Qhet.(xname{k}).time_value,M_.heteroskedastic_shocks.Qhet.(xname{k}).time_scale))
fprintf('\ndynare_estimation_init: With the option "heteroskedastic_shocks" you cannot define\n')
fprintf('dynare_estimation_init: the scale and the value for the same shock \n')
fprintf('dynare_estimation_init: in the same period!\n')
error('Scale and value defined for the same shock in the same period with "heteroskedastic_shocks".')
end
M_.heteroskedastic_shocks.Qvalue(inx,M_.heteroskedastic_shocks.Qhet.(xname{k}).time_value)=M_.heteroskedastic_shocks.Qhet.(xname{k}).value.^2;
end
for k=1:length(M_.heteroskedastic_shocks.Qvalue_orig)
v = M_.heteroskedastic_shocks.Qvalue_orig(k);
M_.heteroskedastic_shocks.Qvalue(v.exo_id, v.periods) = v.value^2;
end
for k=1:length(M_.heteroskedastic_shocks.Qscale_orig)
v = M_.heteroskedastic_shocks.Qscale_orig(k);
M_.heteroskedastic_shocks.Qscale(v.exo_id, v.periods) = v.scale^2;
end
if any(any(~isnan(M_.heteroskedastic_shocks.Qvalue) & ~isnan(M_.heteroskedastic_shocks.Qscale)))
fprintf('\ndynare_estimation_init: With the option "heteroskedastic_shocks" you cannot define\n')
fprintf('dynare_estimation_init: the scale and the value for the same shock \n')
fprintf('dynare_estimation_init: in the same period!\n')
error('Scale and value defined for the same shock in the same period with "heteroskedastic_shocks".')
end
end

@ -1 +1 @@
Subproject commit a5d653a5f1046d75c1c3dcd1581e7c9d99f54bb6
Subproject commit 824433aa3f1bd9b5e4f7c395231111242b3c308a