It is occasionally useful to create maps where each geographic unit is given equal visual prominence. This is particularly true in economics/political science, where land area can be poorly correlated with the information you’re really trying to depict. For example South Dakota has about twice the land area of Kentucky, but has fewer than one-fifth of the population.

One way to deal with this is a hexagonal tile grid map, and NPR gives good examples of their application to U.S. states. I’ve adapted code to facilitate something similar for Ireland’s 32 counties in Stata. (I was working with 1800s population data, before Northern Ireland existed, so the code is based on the 32 counties.) The images are generated by spmap and maptile, and you can use their in-built options to change the appearance. The map is implemented as what maptile calls a “geography”, and I’ve named this geography eirtile.

The first requirement is installation of both spmap and maptile, both of which are available from the SSC.

Next, click this link to download the eirtile database and coordinate files. These need to be unzipped into the maptile geographies folder, located within your Stata ado folder. For me that’s C:\ado\personal\maptile_geographies though it might be different for you. You may also want to download this 1841 Census population file to replicate the example.

An important requirement is that you have a variable named countyid to link your data to the database coordinates. The ordering is alphabetic, so Antrim is countyid=1 and Wicklow is countyid=32. The code will still run if observations are missing, so it’s not the end of the world if you don’t have data from the six NI counties.

The code below generates the 1840 population image.

insheet using "1841pops.csv", clear names
destring pop, replace ignore(",")
gen pop_per_thousand = round(pop/1000)
sort County
gen countyid = _n
maptile pop_per_thousand, geog(eirtile) geoid(countyid) twopt(title("Population of Irish counties ('000s), 1841")) nq(7)

The first three lines open and clean the data. Lines 4 and 5 generate the necessary countyid variable, which serves as the link between your data and the mapping software. The last line calls maptile, tells it to map the population variable of interest, use eirtile as the geography, and that countyid is the identifier variable. The latter options (twopt and nq) are maptile-specific commands and you should consult that program’s help file for details. This help file also shows you how to change the colours, label the missing data, etc.


I’ve posted before about problems with line widths when exporting tables from Stata. Here is one trick to solve having an excessively wide addnote at the bottom of the table.

Ensuring you have pre-loaded the booktabs package, add the following line to the header of your LaTeX file:

\newcommand{\tabnotes}[2]{\bottomrule \multicolumn{#1}{@{}p{0.70\linewidth}@{}}{\footnotesize #2 }\end{tabular}\end{table}}

This creates a new command (called tabnotes) that takes two arguments: a number of columns, and text. An example is \tabnotes{3}{Hi there} — this will add a note at the bottom of your table, spread over 3 columns of your table, and it will say “Hi there”. If your table has seven columns, change the first argument to 7 instead of 3. You can obviously change what the text says, too. The important thing is that the text will automatically wrap if it is wider than 70% of the width of your text. You can change to any percent you wish by altering the 0.7\linewidth portion of the code above.

An important fact is that you must include \tabnotes inside esttab’s postfoot() option. For example, your might use:

esttab myresult using tab.tex, booktabs replace postfoot("\tabnotes{3}{Hello there, I hope this helps you.}")

Please note that is all one line, your browser likely splits it over several lines.


1. The first recorded person with the name is Saint Enda, who lived on the Aran Islands off the coast of Galway c. 500 AD. Enda comes from Éanna, which means "bird-like".

2. In the year I was born, eighty-one babies in Ireland were named Enda. That put it comfortably in the Top 100 most popular (boys) names, ahead of Jamie but behind Seamus. The equivalently popular boys name in the US in 1987 was Ian. Despite its ancient origins, the popularity of the name is a recent phenomenon: the 1901 Census lists only person in Ireland named Enda. The resuscitation is likely linked to St Enda's School, founded in 1908.

3. Between 2011 and 2017 the Taoiseach (prime minister) of Ireland was named Enda Kenny. Since his rise to national prominence, the popularity of our name has sadly plummeted. Only three children were named Enda in 2016.

4. Discriminating against gay people is a bad thing. In the United States, Employment Non-Discrimination Acts are routinely called ENDAs. Scholarly work has shown that US states with Endas are more innovative.

5. I was once at a wedding with five Endas there. Had we taken a selfie, it would be called an endascope.


On any given day, I will usually be working on only one of several projects in Stata. These projects will often take several years. It should be easy to switch to the folders for these files. For example, to switch to my project on Stamp Duty the command go stamp would be handy.

I wrote a small bit of code to make that happen. You can download go.ado here. Download it, edit it with your own shortcuts, save it to your preferred ado folder, and make it easier to jump to different projects.


When exporting graphics from Stata or Matlab, it's better to select a lossless/vectorized format instead of a rasterized pic. This ensures your image is high-quality and not grainy/pixelated.

Grainy exports

Poor quality, grainy image

Better quality export

Unfortunately, Matlab does not allow lossless PDF exports of pictures with non-standard fonts. (I'm not the first person to notice this problem. I failed to implement Juan Guerrero's suggested solution.) Matlab will export the font in PNG no problem, but your image will appear grainy. If you try to export as a PDF, your fonts will be reverted to something weird. Obviously this doesn't matter if you're happy with the default fonts, but this bug does limit your ability to customize the output.

Thankfully, with the help of the nice people at Inkscape ( there is a workaround.

  1. Install Inkscape
  2. Generate your figure in Matlab
  3. In "Export Setup", change the Font to anything saved on your system. Export as Scalable Vector Graphic (SVG) file
  4. Open the SVG in Inkscape
  5. Save it a lossless PDF as, say, figure7.pdf
  6. Include in your LaTeX document with \includegraphics{figure7}



Usually my exams have a large blank space for students to write their names in.

If, instead, I wanted to generate individualised exams with their names printed in that space, this code will do that for you. It uses the pgffor package to loop over the list of names you provide.

\def\classlist{Enda Hargaden,
George Akerlof,
Joe Stiglitz,
Don Bruce}
\foreach \studentname in \classlist{

Econ 381 Problem Set: \studentname's Copy

\item What is OLS?
\item What's the square root of 25?
\item More questions yadda yadda



Over on Twitter, Gray Kimbrough suggests using colour to indicate statistical significance/p-values instead of the traditional stars. This was part of a broader argument for Powerpoint over Beamer.

I much prefer Beamer to Powerpoint, and I knew it would be very easy to implement coloured cells in regression tables directly from Stata into LaTeX/beamer.

I use the wonderful estout to produce regression tables (and have modified it in the past) so here's how to produce the table above with one extra line in your do-file.

sysuse auto

** This line generates a local named siggreen, defining significance with green opacity
local siggreen "star(\cellcolor{green!10} 0.10 \cellcolor{green!35} 0.05 \cellcolor{green!95} 0.01) nonotes"

** Run a few sample regressions
qui eststo: reg price foreign mpg weight
qui eststo: reg price foreign mpg weight turn
qui eststo: reg price foreign mpg weight turn gear_ratio displacement headroom

** Using esttab, produce the output with Enda's preferred options
esttab using myoutput.tex, replace booktabs nodepvars nomtitle se label ar2 `siggreen' title("Green Regression")

Then, to include that table into your TeX document:


If you want to include this tables in your Beamer slides, see this post.


I've discussed in the past how to indicate statistical significance with colour rather than stars. Another concern people have about using Beamer is that it can be hard to squish results into one slide. In my opinion, that is solved very easily with my tinytable command.


\newcommand{\tinytable}[1]{\textcolor{black}{\tiny \input{#1} }}


\frametitle{Still fascinating, but smaller}

This generates the following:


The economic package includes old commands that are now deprecated within LaTeX. This caused me a problem using the AER bibliography style (aer.bst), and likely causes problems with other BibTeX styles too. My particular problem was with scrartcl refusing to recognise the \bf command rather than the newer \textbf version.

Very specifically, the problem was "Class scrartcl Error: undefined old font command `\bf'."

The fix for this is simple. Just include the following two lines in the preamble of your document.


You could alternatively open up your *.bst file and manually change the code, but the two lines above should fix it.


There has been much hand-wringing about Apple’s low effective tax rates, particularly since the European Commission’s declaration that they know more about the correct implementation of Ireland’s tax laws than Ireland’s own tax authorities. This has focused the public eye on the taxation of multinational corporations in Ireland and elsewhere. There is a problem with the taxation of MNCs, but I argue it is a problem largely attributable to actions in Washington DC, not anywhere else.

Let me explain. The US headline corporate tax rate is 35%. Thus if an American company earns $100 in the United States, the IRS expects that company to pay a total of $35 in taxes. Further, the US corporate tax base is structured on a worldwide income system. So if Starbucks earns $100 in Denmark, the IRS still expects the company to pay a total of $35 in taxes. For example, if Starbucks pays $20 in taxes to Denmark, the residual $15 is due in taxes to the US. (See here for an example of this offsetting rule.)

Continuing with the Denmark example, the amount due to the Danish government must by law account for the fact that a lot of Starbucks’ profitability comes from its intellectual property: its recipes, branding, and so on. That intellectual property is American, not Danish. For the sake of argument, let’s say that 75% of Starbucks’ profitability in Denmark is based on American intellectual property, and the rest is due to shrewd decisions by managers in Copenhagen. (Change these numbers as you see fit, the idea still holds.) Thus although Starbucks will technically book $100 of profit in Denmark, 75% of that is “American profit”, with only 25% attributable to decisions by the Danish operation. Denmark’s corporate tax rate is 22%, so Starbucks will owe 22% of $25 = $5.50 to Denmark. But recall that they booked $100 of gross profits in Denmark so, on the face of it, The Guardian and other such outlets will wail that Starbucks gets away with a tax rate of only 5.5%. How unfair, how unjust, etc.

Of course what The Guardian and The Huffington Post will typically fail to mention is that the IRS expects the residual $29.50 to be paid in the US ($35 less the $5.50 paid in Denmark = $29.50). That is the main reason why newspaper headlines mislead the public. But a further, more substantive issue that is rarely discussed in the media is where the real problem comes in: the United States’ unusual treatment of (unrepatriated) foreign profits.

What is this unusual treatment? Starbucks do not have to pay that tax liability until they redistribute the profits back to the shareholders by way of a dividend payment. So it is perfectly legal, as per the Tax Reform Act of 1986, for Starbucks’ profits to sit in a bank earning interest rather than paying up to the IRS.

Regular US taxpayers have to pay their previous year's taxes by April 15th. Corporations can choose when they pay up, and they are welcome under US tax law to wait many years to do so. They may even hold out in the hope that Congress drops the tax rate -- for example Donald Trump has proposed lowering the corporate tax rate from 35% to 15% -- and end up paying much less than previously thought. Apple is sitting on about $150bn dollars of unrepatriated profits. They’re holding out (completely sensibly, from their perspective) for a law change so when it comes to paying up, they do so at a lower rate. This holding out again makes it appear that companies like Apple's tax liabilities are lower than they actually are. How unfair, how unjust, etc. Yet I don't think I have ever seen a newspaper discuss the intricacies of why an existing US law -- the Tax Reform Act of 1986 -- encourages this perverse behaviour, nor do I predict a flurry of articles heaping praise on Apple or Starbucks when their effective tax rate shoots through the roof when they eventually repatriate back-dated income.

You can also perhaps see why Apple’s low tax payments in Ireland are an issue for Washington, not Dublin.

Finally, all this is relatively moot if we fail to consider the incidence of corporate taxes. Most members of the public understand that taxes on oil are passed onto the consumer, at least in part. However, the same logic has yet to penetrate the public consciousness on corporate taxes. If you tax a corporation, the workers and customers of that corporation cannot magically wave a moral wand and avoid the economic repercussions of the tax. Some of that tax will inevitably be passed onto consumers, some onto workers, some onto shareholders, etc.

Exactly how the tax is split between groups is a tricky thing to statistically disentangle. However, recent research suggests that about 30% of corporate taxes in the US are passed onto the corporation's employees; and excellent work by German economists suggests that over there perhaps as much as 80% is passed onto workers. The clamour for increased taxation of multinationals almost never considers this reality. I have never seen it mentioned in newspapers that if large multinationals are successfully dodging taxes, it is almost certain that their consumers and workers also benefit from this.

To be clear: I like The Guardian; the Tax Reform Act was a considerable improvement overall; and corporations should pay the tax rates that are demanded of them by law. However the depiction of corporate taxation in the media routinely overlooks mandatory deductions for intellectual property, the deferral of unrepatriated foreign earnings, and the crucial issue of incidence/who actually pays the corporate tax.

Debate on the topic suffers as a result.

Scroll to Top