From a8c04e3ed5f2ca8c394a4a5e78817cb18f154d17 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 19 Mar 2014 21:43:23 +0100 Subject: [PATCH] Filter out more pathological cases in osr1.m --- matlab/osr1.m | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/matlab/osr1.m b/matlab/osr1.m index deba95945..a8d393148 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -51,7 +51,15 @@ if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0 end if M_.maximum_lead == 0 - error ('Backward or static model: no point in using OSR') ; + error ('OSR: Backward or static model: no point in using OSR') ; +end + +if any(any(isinf(weights))) + error ('OSR: At least one of the optim_weights is infinite.') ; +end + +if any(isnan(M_.params(i_params))) + error ('OSR: At least one of the initial parameter values for osr_params is NaN') ; end exe =zeros(M_.exo_nbr,1); @@ -61,6 +69,8 @@ oo_.dr = set_state_space(oo_.dr,M_,options_); np = size(i_params,1); t0 = M_.params(i_params); + + inv_order_var = oo_.dr.inv_order_var; H0 = 1e-4*eye(np); @@ -75,6 +85,12 @@ if info~=0 else fprintf('\nOSR: Initial value of the objective function: %g \n\n',loss); end +if isinf(loss) + fprintf('\nOSR: The initial value of the objective function is infinite.\n'); + fprintf('\nOSR: Check whether the unconditional variance of a target variable is infinite\n'); + fprintf('\nOSR: due to the presence of a unit root.\n'); + error('OSR: Initial likelihood is infinite') +end %%do actual optimization [f,p]=csminwel1('osr_obj',t0,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,i_params,...