Tuesday, July 3, 2012

coding in economics

Well, it's a huge stretch to say that "doing research is writing software", but it is writing code, that's true. And this is a great guide any economist (or any scientist who writes code) should read.

But writing readable code is one thing and writing good, efficient code is another thing, and much more involved than an enumerable list of do's and don't's. More frequently in economics, as we estimate complicated structural models and other computationally intensive things like that, we're going to need to get better at programming, above and beyond simple Stata scripts. Naively writing Matlab code that takes weeks to estimate a model isn't the best way to go about these things in the long run. We should learn C (for example), learn what happens behind the scenes when we write a line of code so we can avoid doing stupidly inefficient things, and learn good algorithms (or at least how they work, so we can use the appropriate pre-existent library for the task.)

I'm as guilty as anyone. And probably these kinds of problems where efficient code is really necessary are still pretty rare, and it's probably hard to know going into it that it will be necessary, so it's still easy to avoid thinking about. But now is a good time to put in the investment. As a profession we seem to have dug ourselves a Stata-lined hole (of infinite despair...) when it comes to regression analysis, let's not also dig ourselves a Matlab-lined hole for structural estimation :)

No comments: