Thursday, September 05, 2013

Modifying Stata library routines

I was recently not understanding why some error messages were being generated by mata's optimize(). I found that it was quite easy to modify the routines to include some debugging print-outs. Broadly we want to create modified routines that mask the existing ones. Here's the basic steps:

  1. Find the mata file (in my case deriv.mata) in the Stata folder, copied it to your own directory, and make changes. 
  2. Turn it into a personal library. See the basic template at -help mata_mlib-.
  3. Have the personal library called instead of the builtin routines. The -mata mlib index- command from the previous step outputted the order in which the libraries are searched for a function.

Enjoy your modified version. When you're all done you can use -mata mlib index- again to get the default ordering.

No comments: