Probably just fixed. The issue was that phi1 and phi2 should be constrained to be zero to one (you can see in this error example that phi2>1). Have uploaded cleaned version of the CDGRR2003 codes.
There was also an minor error in how toolkit handled restrictions across the caliboptions and heteroagentoptions, essentially it would silently fail to do anything if you accidently put the restricition in caliboptions when it was for a GEPriceParamNames. Now it throws error if you try to restrict a parameter that is not one that is actually restrictable. [I accidently put the restriction on ârâ in the caliboptions, when it should be in heteroagentoptions]
It ran successfully. Thank you so much for your hard work.
PS: I noticed the latest VFIToolkit is missing a folder called âOLD_TauchenRouwenhorstâ, which causes an error when the toolkit calls the ârowenhorst.mâ.
I eliminated the old version. Rouwenhorst is still available as discretizeAR1_Rouwenhorst()
which has same input and output shapes and order as all the other discretization commands.
Half on topic half off topic. I was using Claude to build a model the other day. Hilariously it just hard-coded the Tauchen method from scratch (maybe 20 line of code using normcdf()) and I had to overrule and just tell it to use discretizeAR1_Tauchen()
[actually I told it to use discretizeAR1_FarmerToda() instead because that is better, but I just found it amusing that it did a hard-code from scratch instead of using existing routines.]
You should write an agents file that tells claude to look at repo X before writing new routines.
Something along these lines:
Before writing any new MATLAB routine, always search
- Existing repository X
- Built-in functions
for an existing implementation that already performs the required task, or something close to it.
This is especially important for standard numerical routines, helper functions, discretization methods, interpolation utilities, simulation tools, plotting helpers, and general-purpose numerical code.
Examples of routines that should not be reimplemented without first searching the repository or the built-in matlab functions include:
Tauchen or related routines for discretizing AR(1) processes;
Markov-chain simulation utilities;
interpolation routines;
grid-construction utilities such as linspace, logspace, or custom grid builders;
numerical integration or quadrature routines;
sorting.
When a suitable routine exists in repository X, prefer reusing it rather than creating a new duplicate implementation. If the existing routine is almost suitable but needs small extensions, modify or wrap it in a minimal way.
It causes an error because the 46th line of the discretizeAR1_Rouwenhorst still calls another file in the old folder.
Undefined function 'rouwenhorst' for input arguments of type 'double'.
Error in discretizeAR1_Rouwenhorst (line 46)
pi_z=rouwenhorst(znum,p,q);
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in WorkshopModel3 (line 60)
[z_grid,pi_z]=discretizeAR1_Rouwenhorst(0,Params.rho_z,Params.sigma_z_epsilon,n_z);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^