Archives for the ‘Stata’ Category

Program vs. include smackdown

When it comes to defining local macros in a different place from where you use them, you have two options: a do-file you include as needed or an r-class program that you call as needed. I talked about it here and said that a program is a better choice, without any evidence to back up [...]

I switched to Vim

I was looking for an excuse to try something new and I decided to pick on one Notepad++ shortcoming that was handy: the Stata syntax highlighting gets utterly mangled after compound quotes -- `"`like so'"' -- which do sometimes arise, usually in the process of file open/file write.  Vim does not get confused by compound quotes [...]

Calling irregular arguments with syntax anything

The other day I wrote a program that needed to call a file as an argument -- with the full file path. My first pass at it was to capture the argument as usual, with say args input_file. But that would not have worked with file paths that have spaces in them. What might have [...]

Define local macros in one place, use them everywhere

In The Stata Journal Vol. 9, No. 3, 2009 there's a Stata tip (# 77) on re-using macros in multiple do-files, by Jeph Herrin. His solution is to define any local macros in a separate do-file, say locals.do. You can call that do-file with the include command at the top of any do-file that might [...]

Back issues of the Stata Journal

I have this Twitter search saved in my Google Reader. It works OK. One recent tweet by DismalTrader linked to an old Stata Journal article about demand estimation, saved on Scribd. This reminded me that The Stata Journal has a three-year moving wall: anything older than three years prior to the latest issue is available free, [...]

Parenting with Stata

My daughter will be eight days old by the time I'm done writing this. She's on food intake and diaper watch, so among the things we brought home from the hospital was this pink sheet where we were supposed to record full diapers and feeding patterns. Of course we then filled it out, and when [...]

Real FAQ’s

This list at the UNC help desk looks like it really was compiled from questions actually asked. That's always a good thing, so here goes. I hope you find it useful.

Regex tricks with Notepad++ and Statalist

If you haven't heard, the do-file editor in Stata 11 comes with proper syntax highlighting, folding, etc. That means that this post will be obsolete as soon as I upgrade, unless the new do-file editor doesn't do regular expression-based find and replace. No matter. In the meantime, here goes: People often post code on Statalist [...]

Numerics by Stata

Two years ago, three economists at the World Bank -- Michael Lokshin, Zurab Sajaia and Sergiy Radyakin -- cooked up ADePT. That, to my knowledge, was the first successful attempt to use Stata for leveraging econometric research across the world. Think of it this way: a star academic economist builds a theoretical model that explains [...]

My first useful Mata function

Or so I thought. I'm working on a cluster analysis project. There are multiple data sets, they are massive, and there are several variable subsets by which one could plausibly cluster the observations. Agglomerative hierarchical clustering is the way to go when you don't have any notion of how many clusters there should be, but [...]