Only test non-zero measurement error covariance entries for positive definiteness
Otherwise, not having measurement error on one variable is not allowed during estimationtime-shift
parent
313ffb5f32
commit
f28a7a62bb
|
@ -210,7 +210,7 @@ H = Model.H;
|
||||||
|
|
||||||
% Test if Q is positive definite.
|
% Test if Q is positive definite.
|
||||||
if ~issquare(Q) || EstimatedParameters.ncx || isfield(EstimatedParameters,'calibrated_covariances')
|
if ~issquare(Q) || EstimatedParameters.ncx || isfield(EstimatedParameters,'calibrated_covariances')
|
||||||
[Q_is_positive_definite, penalty] = ispd(Q);
|
[Q_is_positive_definite, penalty] = ispd(Q(EstimatedParameters.Sigma_e_entries_to_check_for_positive_definiteness,EstimatedParameters.Sigma_e_entries_to_check_for_positive_definiteness));
|
||||||
if ~Q_is_positive_definite
|
if ~Q_is_positive_definite
|
||||||
fval = objective_function_penalty_base+penalty;
|
fval = objective_function_penalty_base+penalty;
|
||||||
exit_flag = 0;
|
exit_flag = 0;
|
||||||
|
@ -231,7 +231,7 @@ end
|
||||||
|
|
||||||
% Test if H is positive definite.
|
% Test if H is positive definite.
|
||||||
if ~issquare(H) || EstimatedParameters.ncn || isfield(EstimatedParameters,'calibrated_covariances_ME')
|
if ~issquare(H) || EstimatedParameters.ncn || isfield(EstimatedParameters,'calibrated_covariances_ME')
|
||||||
[H_is_positive_definite, penalty] = ispd(H);
|
[H_is_positive_definite, penalty] = ispd(H(EstimatedParameters.H_entries_to_check_for_positive_definiteness,EstimatedParameters.H_entries_to_check_for_positive_definiteness));
|
||||||
if ~H_is_positive_definite
|
if ~H_is_positive_definite
|
||||||
fval = objective_function_penalty_base+penalty;
|
fval = objective_function_penalty_base+penalty;
|
||||||
exit_flag = 0;
|
exit_flag = 0;
|
||||||
|
|
|
@ -571,3 +571,28 @@ else
|
||||||
error('The option "prefilter" is inconsistent with the non-zero mean measurement equations in the model.')
|
error('The option "prefilter" is inconsistent with the non-zero mean measurement equations in the model.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
%% get the non-zero rows and columns of Sigma_e and H
|
||||||
|
|
||||||
|
H_non_zero_rows=find(~all(M_.H==0,1));
|
||||||
|
H_non_zero_columns=find(~all(M_.H==0,2));
|
||||||
|
if ~isequal(H_non_zero_rows,H_non_zero_columns')
|
||||||
|
error('Measurement error matrix not symmetric')
|
||||||
|
end
|
||||||
|
if isfield(estim_params_,'nvn_observable_correspondence')
|
||||||
|
estim_params_.H_entries_to_check_for_positive_definiteness=union(H_non_zero_rows,estim_params_.nvn_observable_correspondence(:,1));
|
||||||
|
else
|
||||||
|
estim_params_.H_entries_to_check_for_positive_definiteness=H_non_zero_rows;
|
||||||
|
end
|
||||||
|
|
||||||
|
Sigma_e_non_zero_rows=find(~all(M_.Sigma_e==0,1));
|
||||||
|
Sigma_e_non_zero_columns=find(~all(M_.Sigma_e==0,2));
|
||||||
|
if ~isequal(Sigma_e_non_zero_rows,Sigma_e_non_zero_columns')
|
||||||
|
error('Structual error matrix not symmetric')
|
||||||
|
end
|
||||||
|
if ~isempty(estim_params_.var_exo)
|
||||||
|
estim_params_.Sigma_e_entries_to_check_for_positive_definiteness=union(Sigma_e_non_zero_rows,estim_params_.var_exo(:,1));
|
||||||
|
else
|
||||||
|
estim_params_.Sigma_e_entries_to_check_for_positive_definiteness=Sigma_e_non_zero_rows;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ Q = Model.Sigma_e;
|
||||||
H = Model.H;
|
H = Model.H;
|
||||||
|
|
||||||
if ~issquare(Q) || EstimatedParameters.ncx || isfield(EstimatedParameters,'calibrated_covariances')
|
if ~issquare(Q) || EstimatedParameters.ncx || isfield(EstimatedParameters,'calibrated_covariances')
|
||||||
[Q_is_positive_definite, penalty] = ispd(Q);
|
[Q_is_positive_definite, penalty] = ispd(Q(EstimatedParameters.Sigma_e_entries_to_check_for_positive_definiteness,EstimatedParameters.Sigma_e_entries_to_check_for_positive_definiteness));
|
||||||
if ~Q_is_positive_definite
|
if ~Q_is_positive_definite
|
||||||
fval = objective_function_penalty_base+penalty;
|
fval = objective_function_penalty_base+penalty;
|
||||||
exit_flag = 0;
|
exit_flag = 0;
|
||||||
|
@ -187,7 +187,7 @@ if ~issquare(Q) || EstimatedParameters.ncx || isfield(EstimatedParameters,'calib
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~issquare(H) || EstimatedParameters.ncn || isfield(EstimatedParameters,'calibrated_covariances_ME')
|
if ~issquare(H) || EstimatedParameters.ncn || isfield(EstimatedParameters,'calibrated_covariances_ME')
|
||||||
[H_is_positive_definite, penalty] = ispd(H);
|
[H_is_positive_definite, penalty] = ispd(H(EstimatedParameters.H_entries_to_check_for_positive_definiteness,EstimatedParameters.H_entries_to_check_for_positive_definiteness));
|
||||||
if ~H_is_positive_definite
|
if ~H_is_positive_definite
|
||||||
fval = objective_function_penalty_base+penalty;
|
fval = objective_function_penalty_base+penalty;
|
||||||
exit_flag = 0;
|
exit_flag = 0;
|
||||||
|
|
Loading…
Reference in New Issue