Merge branch 'rescale_prediction_error_covariance' into 'master'

rescale_prediction_error_covariance

See merge request Dynare/dynare!1698
time-shift
Sébastien Villemot 2020-01-27 17:45:38 +00:00
commit f9e7ede810
2 changed files with 17 additions and 2 deletions

View File

@ -158,6 +158,7 @@ else
LIKK={likk,dlikk};
end
rescale_prediction_error_covariance0=rescale_prediction_error_covariance;
while notsteady && t<=last
s = t-start+1;
if Zflag
@ -175,7 +176,12 @@ while notsteady && t<=last
end
else
if rcond(F)<kalman_tol
badly_conditioned_F = true;
sig=sqrt(diag(F));
if any(diag(F)<kalman_tol) || rcond(F./(sig*sig'))<kalman_tol
badly_conditioned_F = true;
else
rescale_prediction_error_covariance=1;
end
end
end
if badly_conditioned_F
@ -191,6 +197,7 @@ while notsteady && t<=last
if rescale_prediction_error_covariance
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
iF = inv(F./(sig*sig'))./(sig*sig');
rescale_prediction_error_covariance=rescale_prediction_error_covariance0;
else
log_dF = log(det(F));
iF = inv(F);

View File

@ -84,6 +84,7 @@ oldK = Inf;
notsteady = 1;
F_singular = true;
s = 0;
rescale_prediction_error_covariance0=rescale_prediction_error_covariance;
while notsteady && t<=last
s = t-start+1;
@ -110,7 +111,13 @@ while notsteady && t<=last
end
else
if rcond(F)<kalman_tol
badly_conditioned_F = true;
sig=sqrt(diag(F));
if any(diag(F)<kalman_tol) || rcond(F./(sig*sig'))<kalman_tol
badly_conditioned_F = true;
else
rescale_prediction_error_covariance=1;
end
% badly_conditioned_F = true;
end
end
if badly_conditioned_F
@ -126,6 +133,7 @@ while notsteady && t<=last
if rescale_prediction_error_covariance
log_dF = log(det(F./(sig*sig')))+2*sum(log(sig));
iF = inv(F./(sig*sig'))./(sig*sig');
rescale_prediction_error_covariance=rescale_prediction_error_covariance0;
else
log_dF = log(det(F));
iF = inv(F);