Bug with GE conditions with fminalgo=5

There is a bug in the code with fminalgo=5 (shooting method). Once the first condition any(p_change>heteroagentoptions.toleranceGEprices) becomes false, Matlab wants to evaluate the second condition GeneralEqmConditions>heteroagentoptions.toleranceGEcondns, but this returns an error

Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL
functions to reduce operands to logical scalar values.

Error in HeteroAgentStationaryEqm_Case1 (line 311)
        while (any(p_change>heteroagentoptions.toleranceGEprices) || GeneralEqmConditions>heteroagentoptions.toleranceGEcondns) && itercounter<heteroagentoptions.maxiter
                                                                     ^^^^^^^^^^^^^^^^^^^^

I suspect that GeneralEqmConditions is a vector while it should be a scalar. I think nonlinear least squares wants that GeneralEqmConditions is a vector, though. Easy fix is to add any or all in the while condition.

UPDATE
I found out more about this problem. I set up the GE weights as a column vector, while it should be a row vector. No need to change the while condition then. I would suggest though to have a check somewhere in the code to make sure heteroagentoptions.GEweights is a row vector.

1 Like

I added check that if heteroagentoptions.multiGEweights is a column vector it gets transposed internally to be a row vector so now as user you can set it up however.

1 Like