Bayesian estimation error:FZERO cannot continue because user-supplied function_handle

My model worked fine, but there was a problem with Bayesian estimation.

CONVERGENCE NOT ACHIEVED AFTER 20738 ITERATIONS! IMPROVING TOO SLOWLY!

Final value of minus the log posterior (or likelihood):9486.945478

POSTERIOR KERNEL OPTIMIZATION PROBLEM!
(minus) the hessian matrix at the “mode” is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
Warning: The results below are most likely wrong!

In dynare_estimation_1 (line 318)
In dynare_estimation (line 118)
In BG.driver (line 1252)
In dynare (line 278)

MODE CHECK

Fval obtained by the minimization routine (minus the posterior/likelihood)): 9486.945478
Most negative variance -70876390.005596 for parameter 6 (e_muz = 0.000468)
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
FZERO cannot continue because user-supplied function_handle ==> @(rk)solve_rk(delta_p,Fe_p,Le,muk_p,pi_p,qk,R,rk,tauk_p,upsil_p) failed with the error below.

Output argument “tbn_rk” (and possibly others) not assigned a value in the execution with “BG_steadystate>solve_rk” function.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Array indices must be positive integers or logical values.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.447102e-17.

In dyn_first_order_solver (line 297)
In stochastic_solvers (line 251)
In resol (line 119)
In compute_decision_rules (line 34)
In dynare_resolve (line 36)
In dsge_likelihood (line 216)
In mode_check (line 152)
In dynare_estimation_1 (line 325)
In dynare_estimation (line 118)
In BG.driver (line 1252)
In dynare (line 278)

Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.

In dynare_estimation_1 (line 341)
In dynare_estimation (line 118)
In BG.driver (line 1252)
In dynare (line 278)

RESULTS FROM POSTERIOR ESTIMATION
parameters
prior mean mode s.d. prior pstdev

Le_p 2.1100 1.0104 NaN norm 0.4000
bcp_p 0.7000 0.1301 NaN beta 0.1000
bci_p 0.7000 0.3060 NaN beta 0.1000
kappa_p 0.5000 0.9529 NaN beta 0.1000
Fe_p 0.0060 0.0062 NaN beta 0.0020
Fi_p 0.0060 0.0117 NaN beta 0.0020
muk_p 0.4500 0.2455 NaN beta 0.1000
muh_p 0.4500 0.4578 NaN beta 0.1000
ady_p 0.4000 0.7147 NaN norm 0.0500
api_p 1.4000 1.0798 NaN norm 0.1000
rhop_p 0.8500 0.3693 NaN beta 0.1000
Sk_p 2.0000 0.5444 NaN norm 1.0000
Sh_p 2.0000 2.4630 NaN norm 1.0000
sigmaa_p 2.0000 1.7988 NaN norm 0.2500
xiw_p 0.8000 0.8207 NaN beta 0.1000
xip_p 0.8000 0.4916 NaN beta 0.1000
iotap_p 0.7000 0.3713 NaN beta 0.1000
iotaw_p 0.7000 0.5931 NaN beta 0.1000
rhoepsil_p 0.5000 0.5634 NaN beta 0.2000
rhog_p 0.5000 0.0449 NaN beta 0.2000
rhogammae_p 0.5000 0.6572 NaN beta 0.2000
rholambdap_p 0.5000 0.6083 NaN beta 0.2000
rhomuup_p 0.5000 0.4742 NaN beta 0.2000
rhomuz_p 0.5000 0.9999 NaN beta 0.2000
rhonu_p 0.5000 0.6820 NaN beta 0.2000
rhosigmae_p 0.5000 0.7231 NaN beta 0.2000
rhozetai_p 0.5000 0.5133 NaN beta 0.2000
rhozetah_p 0.5000 0.7092 NaN beta 0.2000
rhozetac_p 0.5000 0.2359 NaN beta 0.2000

standard deviation of shocks
prior mean mode s.d. prior pstdev

e_epsil 0.0010 0.0014 NaN invg2 2.0000
e_g 0.0010 0.0025 NaN invg2 2.0000
e_gammae 0.0010 0.0001 NaN invg2 2.0000
e_lambdap 0.0010 0.0010 NaN invg2 2.0000
e_muup 0.0010 0.0018 NaN invg2 2.0000
e_muz 0.0010 0.0005 NaN invg2 2.0000
e_nu 0.0010 0.0007 NaN invg2 2.0000
e_sigmae 0.0010 0.0018 NaN invg2 2.0000
e_xp 0.0010 0.0007 NaN invg2 2.0000
e_zetac 0.0010 0.0013 NaN invg2 2.0000
e_zetah 0.0010 0.0005 NaN invg2 2.0000
e_zetai 0.0010 0.0000 NaN invg2 2.0000
e_qh 0.0100 0.0125 NaN invg2 10.0000

standard deviation of measurement errors
prior mean mode s.d. prior pstdev

shadowbank_obs 0.0100 0.0669 NaN invg2 10.0000

Log data density [Laplace approximation] is NaN.

Error using chol
Matrix must be positive definite with real diagonal.
Error in posterior_sampler_initialization (line 84)
d = chol(vv);
Error in posterior_sampler (line 60)
posterior_sampler_initialization(TargetFun, xparam1, vv, mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation_1 (line 481)
posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation (line 118)
dynare_estimation_1(var_list,dname);
Error in BG.driver (line 1252)
oo_recursive_=dynare_estimation(var_list_);
Error in dynare (line 278)
evalin(‘base’,[fname ‘.driver’]);

Uploading: BG.mod…
BG_param.m (1.9 KB)
BG_steadystate.m (17.8 KB)
BGdata.mat (9.0 KB)

Your mod-file did not upload correctly.
But the error message derives from

if (isempty(idx_ome)) || (idx_ome==1); return;end

in solve_rk. You terminate the function without providing the required output arguments you are requesting. You should initialize all outputs.

Dear Professor jpfeifer, I have uploaded my file once again. So this is the source code for Becard &Gauthier 2023. I am not clear about the specific Settings of the code, can you give me specific suggestions for modification?
Uploading: BG.mod…
BG_steadystate.m (17.8 KB)
BG_param.m (1.9 KB)
BGdata.mat (9.0 KB)

As I wrote, initialize all outputs of the function mentioned.