Minimizing the distance between the data and model

Hi I am trying to calibrate omega, sigma_a and sigma_b by minimizing the distance of a set of second moments with respect to the data (GMM). I am sure the model I wrote is correct but I have issue in benchmark_model_run_Mexico.m file so I cannot call the proper results. Could you please tell me whether the codes I wrote is the right way to do that? Second, it does not give me an error but it says

quation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.

exitflag =
1
exitflag =
0

Also, I was expecting the results in MOMS_hp_model and I got the results in below.

MOMS_hp_model
0.00000000000000 + 1338.61275639433i
0.00000000000000 - 0.00898886119437529i
0.00000000000000 - 0.00744518649879554i
0.00000000000000 - 0.00372482891374872i
-24.7058560639534 + 0.00000000000000i
0.00000000000000 - 0.152486798477025i
0.00000000000000 - 0.371917868654176i
0.00000000000000 - 0.0774977355076163i
0.00000000000000 - 0.00295674375382621i
0.00000000000000 - 0.312622813319814i
0.00000000000000 - 0.0759160590140773i
0.00000000000000 - 0.00518807239067139i
0.00000000000000 + 0.0881403577726612i
0.00000000000000 - 0.0126060504437991i
0.00000000000000 - 0.0399092709720994i
0.00000000000000 - 0.0541691455171444i
0.00000000000000 - 0.0734824897003621i
0.00000000000000 - 0.0910792222960299i
0.00000000000000 + 0.118458447462384i
0.00000000000000 + 0.140575614040965i
0.00000000000000 + 0.149113730723083i
0.00000000000000 + 0.148146721050559i

I hope you can have a look and tell me if something is wrong.

Bestbenchmark_model_run_Mexico.m (11.6 KB)

This is a forum for the software Dynare. You are using the SGU codes. I doubt that someone will be able to help you here. In any case, you are missing most of the other files needed to run the codes. Note that complex values often arise from logging or taking the square root of variables that are negative (e.g. already in logs)