Stationary General Eqm: multiple fminalgo

For commands like
HeteroAgentStationaryEqm_Case1_FHorz
you can control which algorithm is being used to solve for general eqm (to minimize the general eqm conditions)

For example
heteroagentoptions.fminalgo=1 is the default, and uses Matlab’s fminsearch()
heteroagentoptions.fminalgo=4 uses CMA-ES which is slow, but very powerful/robust
heteroagentoptions.fminalgo=5 is a shooting-algorithm that requires you to input updating rules, it is fast but requires more work from user
heteroagentoptions.fminalgo=8 uses Matlab’s lsqnonlin(), this is a least-squares residuals algorithm and requires Matlab’s Optimization Toolbox. It is fast, but tends to leave general eqm conditions with values around 1e-4.

There is now also the option of using multiple algorithms. For example maybe you want lsqnonlin() as it is fast, but you know it is not highly accurate so you would also then like to take the answer it gives as the starting point for fminsearch(). That is, you want to do fminalgo=8, and then use the solution as the initial guess for fminalgo=1. There is now a built-in way to do this, namely you set
heteroagentoptions.fminalgo=[8,1]
VFI Toolkit notices that heteroagentoptions.fminalgo is a vector and will do the first element, and then use the solution of this as the starting point while using the second element.

You can also set them to have different tolerances in the obvious way: When using heteroagentoptions.fminalgo with two values, you can also set heteroagentoptions.toleranceGEconds and heteroagentoptions.toleranceGEprices as having two values. Will make it easy to use a rough solution on the first, then accurate on the second.

PS. fminalgo=[8,1] or fminalgo=[8,4] are my personal two favourite combos at the moment. They seem to give a good mix of speed, accuracy, and robustness.

2 Likes

Nice! I note incidentally that lsqnonlin in Matlab allows the user to set bounds for optimization variables, something that fminsearch does not allow for. This can be useful if you know that one of your variable has to be positive (e.g. aggregate capital) and a negative value would return an error (e.g. F_K(K) is not well defined if K<0). I guess the toolkit doe not include the possibility to set bound constraints in GE, correct? Not that I am suggesting it should, just to know…

2 Likes

It is on my to-do list. You can set parameter bounds with the Calibation and GMM Estimation commands. Not yet on General Eqm. It would be nice, but I think it is low priority so is unlikely to happen soon :slight_smile:

1 Like