# Bug in HeteroAgentStationaryEqm\_InfHorz

**URL:** https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672
**Category:** Uncategorized
**Created:** [June 13, 2026, 3:23pm UTC](https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672 "2026-06-13T15:23:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)
#### Post date: [June 13, 2026, 3:23pm UTC](https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672/1 "2026-06-13T15:23:23Z")

</div>

I ran into a small issue using `heteroagentoptions.constrainAtoB` in `HeteroAgentStationaryEqm_InfHorz`.

In this GE solver path, the code checks

```
prod(heteroagentoptions.constrainAtoB)

```

before converting name-based constraints like `{'tau_c'}` into numeric indicator vectors. Since `constrainAtoB` is still a cell array at that point, MATLAB errors with:

```
Error using prod
Invalid data type. First argument must be numeric or logical.

```

This differs from some calibration/estimation paths where name-based constraints are converted before use. A small fix would be to either convert `constrainAtoB` before the `prod(...)` check, or replace that check with something that handles cell arrays, e.g. `~isempty(...)` before conversion.

---

<div class="post-metadata">

### Author: ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)
#### Post date: [June 13, 2026, 5:22pm UTC](https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672/2 "2026-06-13T17:22:39Z")

</div>

Some comments need to be fixed as well

```auto
heteroagentoptions.constrainpositive={}; % names of parameters to constrained to be positive (gets converted to binary-valued vector below)
    heteroagentoptions.constrain0to1={}; % names of parameters to constrained to be positive (gets converted to binary-valued vector below)
    heteroagentoptions.constrainAtoB={}; % names of parameters to constrained to be positive (gets converted to binary-valued vector below)

```

By the way, to generate the error message, just add bounds to r in general equilibrium in the Aiyahari example

---

<div class="post-metadata">

### Author: ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)
#### Post date: [June 14, 2026, 3:21pm UTC](https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672/3 "2026-06-14T15:21:33Z")

</div>

If you try this in the Aiyagari example, you will get an error

```auto
GEPriceParamNames = {'r'};

Params.r = 0.03; % Initial guess, must lie strictly inside the bounds

heteroagentoptions.constrainAtoB = {'r'};
heteroagentoptions.constrainAtoBlimits = [-0.02, 0.08];

```

The error is

```auto
Error using prod
Invalid data type. First argument must be numeric or logical.

```

---

<div class="post-metadata">

### Author: ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)
#### Post date: [June 15, 2026, 4:09am UTC](https://discourse.vfitoolkit.com/t/bug-in-heteroagentstationaryeqm-infhorz/672/4 "2026-06-15T04:09:30Z")

</div>

Should be fixed (bug + comments). Thanks for letting me know.

I built some tests for stationary general eqm commands as part of fixing

> **[vfitoolkitTests/CoreStationaryGeneralEqm at main · vfitoolkit/vfitoolkitTests](https://github.com/vfitoolkit/vfitoolkitTests/tree/main/CoreStationaryGeneralEqm)**
>
> main/CoreStationaryGeneralEqm
