Tuesday, March 30, 2010

Mathematica and Dynamic Penn Effect

Over at VOX, there is an interesting article about revising real income data at the country level, and the author suggested that estimating a dynamic Penn effect might help with better estimates.

I was struck by how easy it would be to replicate figure 2 of the article using Mathematica given the program's ability to access certain data sources using build in functions - CountryData in this case. In particular, modifying an example from a Mathematica web seminar, I have some not-very-elegant but working code:

Y2 = 2005; Y1 = 1993
ListPlot[Tooltip
[
{Log[Extract[CountryData[#, {"GDPPerCapita", {Y2, Y2}}], {1, 2}]] -
Log[Extract[CountryData[#, {"GDPPerCapita", {Y1,Y1}}], {1, 2}]],
Log[Extract[CountryData[#, {"PriceIndex", {Y2,Y2}}], {1, 2}]] -
Log[Extract[CountryData[#, {"PriceIndex", {Y1,Y1}}], {1, 2}]]
},
CountryData[#, "Name"]
]
& /@ CountryData["Countries"],
Frame -> True,
FrameLabel -> {"Difference in Log GDP per Capita", "Difference in Log Price Level Index"},
PlotRange -> {-.6,1}]

Running the code generate the scatter plot above, with tooltips indicating the countries. There should also be a way to use Manipulate[] to make the plot dynamic and show the results over different time periods.

It is interesting that corresponding chart above (12 years, from 1993 to 2005) looks somewhat different than the one from the article. The summary of the sources used by Mathematica is here, and the most recently available data appears to be 2006.

The graphs below illustrate the relationship over the periods of 7 years (1993 to 2000) and 2 years (1993 to 1995) While the data point has become more scattered over time, the relationship appear quite stable.

1993 to 1995


1993 to 2000






Why have developing-country data on real incomes been revised so much? [VOX]