From d5a2015dedeb49c31748f6797803af4516a9ce2d Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer <jpfeifer@gmx.de> Date: Wed, 8 Dec 2021 09:38:41 +0100 Subject: [PATCH] mom: gracefully exit if unobserved moments are matched. --- matlab/+mom/run.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/matlab/+mom/run.m b/matlab/+mom/run.m index 370d46ffbb..21a9efa55e 100644 --- a/matlab/+mom/run.m +++ b/matlab/+mom/run.m @@ -454,6 +454,12 @@ options_mom_.mom.mom_nbr = size(M_.matched_moments,1); % Get maximum lag number for autocovariances/autocorrelations options_mom_.ar = max(cellfun(@max,M_.matched_moments(:,2))) - min(cellfun(@min,M_.matched_moments(:,2))); +%check that only observed variables are involved in moments +not_observed_variables=setdiff(oo_.dr.inv_order_var([M_.matched_moments{:,1}]),oo_.dr.obs_var); +if ~isempty(not_observed_variables) + error('\nmethod_of_moments: You specified moments involving %s, but it is not a varobs.',M_.endo_names{oo_.dr.order_var(not_observed_variables)}) +end + % ------------------------------------------------------------------------- % Step 3: Checks and transformations for estimated parameters, priors, and bounds % ------------------------------------------------------------------------- -- GitLab