img_8491

For the last two and a half months Claire and I have been living and working in Kitale, a town in Trans Nzoia county, Western Kenya, home to the Kenya headquarters of  Vi Agroforestry.

Vi is an organization founded and supported by a Swedish magazine of the same name. It was founded in the 80’s when a Swedish journalist named Sten Lundgren traveled to Kenya and, struck by the specter of encroaching desertification, wrote an impassioned editorial imploring his countrymen to cease “drowning” each other in flowers and instead “give them a forest!” To no one’s surprise more than Sten’s, donations for trees started flooding in and  Vi Agroforestry (called in Swedish Vi Skogen) began.

First in the arid region of West Pokot–where a forest still grows on land at the boundary between the mutually hostile Turkana and Pokot tribes–Vi’s first employees, a Swedish volunteer and a young Kenyan named William Makokha (who still oversees seed production), began planting trees.

William Makokha in the forest he helped to plant in West Pokot, Kenya.

img_8287

It didn’t take long for Vi’s operation to shift from outright reforestation–with its attendant challenge of land availability–to agroforestry i.e. trees on farms. It was also clear that opportunity lay more in well-watered Trans Nzoia than in West Pokot. Trans Nzoia had been one of the areas designated as “white highlands” during the colonial period, meaning the land was designated for settlement by white British colonists. When independence came, much of the land was redistributed to Kenyans, drawing in farmers eager for land from all over the country. These new settlers found themselves in a landscape denuded by the large-scale agriculture practiced by the colonists.

When Vi was beginning, Trans Nzoia was still relatively deforested, so as the young organization expanded its operations it built tree nurseries around the county and began distributing trees to farmers eager to grow timber and firewood on plots reclaimed from the colonialists’ mono-crop plantations.

As Vi moved toward empowering farmers instead of planting trees on its own, they came in contact with the World Agroforestry Centre (also known as the International Centre for Research in Agroforestry, or ICRAF–an acronym which sticks even to the new name). The impact evaluation I’m working on is an ICRAF project, and Claire’s work is to trace  Vi’s technical knowledge back to its source in scientific research–including ICRAF’s work. So the narrative above comes from oral histories she has collected over the past few months.

Since its early days, Vi has done some remarkable things: they contributed significantly to reforestation in Trans Nzoia, participated in the field-testing of a number of innovative agroforestry practices, developed Kenya’s first carbon credit trading program, and expanded their operations into Tanzania, Uganda and Rwanda.

In addition to providing agricultural advisory services to farmer groups throughout their focal areas, Vi’s headquarters serves as a demonstration area for agroforestry techniques, a tree nursery, and an arboretum dedicated to species indigenous to East Africa.

Tree seedling in the Vi nursery, shaded by trees dedicated to past directors and funders of the organization.

img_8492

As if that weren’t enough they also maintain a garden called the Grove of Peace dedicated to the memory of the victims of the Estonia disaster–a 1994 shipwreck which claimed the lives of 900 people in the Baltic Sea. This garden is the most striking parts of the Vi campus. It is open to the public, and people stroll in throughout the day to walk, eat lunch, pray, and even sing hymns.

Benches in the Grove of Peace, often occupied by Kitale residents on their lunch break.

img_8547

A cow wanders through a trellis in the Grove of Peace. Her milk goes into the morning chai for Vi staff.

img_8502

Claire and I spent the better part of the summer on the back porch of the Vi office, looking down over the peace garden and the arboretum, guarding our lunch from the De Brazza’s monkeys and trying to catch a glimpse of the more reclusive Colobus. It was a wonderful time.

A De Brazza’s monkey scaling the office gutter. These guys  bang on the porch roof in frustration if we get between them and the scraps in the trash can.

img_8445

The Colobus monkeys are harder to spot. They can leap incredible distances, white fringe flying behind them. Just once they came close enough for Claire to get photos.

img_8403

So that’s where we’ve been for the last little while! Claire and I have now moved to Nairobi to be close to the ICRAF office as we write our reports. But we’ll make it back to Vi in Kitale several times before we leave Kenya. We are so grateful to our colleagues there for being so welcoming, and we are glad to get to continue working together as we finish our respective projects.

latexstatanotepadlogos

Fair warning: this post is off the nerd deep end.I’m going to describe how to use the Notepad++ text editor and the Stata package texdoc to edit Stata and LaTex code from within the same document. So this post will assume a basic level of interest in and knowledge of Stata and LaTex. Here goes!

During my coursework at UIUC I got acquainted with R and was particularly taken with the Knitr package for writing reproducible reports.

Brief discursus on why this matters: reproducible research is a growing preoccupation in the social sciences, especially with recent high-profile spats about p-hacking and reproducibility in the psychology literature. Reproducibility actually encompasses a number of questions, the most obvious being, “if I did the same experiment over again, would I get the same result?” But even before you get to attempting to re-run an experiment (which in economics is tricky, since we don’t exactly work in labs…) there is a lower bar to pass: “if I ran the same code on the same data would I get the same result?” That might seem like an obvious and easy test, but there are a number of documented cases where papers submitted to peer-review journals have failed it. So there is a push within economics to publish the code used in the statistical analysis along with the data and the analysis itself.

Reproducible documents make that task a lot easier. Using a tool like Knitr, you can write a report or paper, including snippets of R so that the code can be edited along with the analysis rather than copying and pasting tables back and forth. This eliminates some possibilities for errors and keeps you from including old tables when the model or the data changes. It also simplifies and organizes the task of providing code and data, because everything is all in one place. Most importantly for the lazy grad student in all of us: it saves a lot of time. Moving to RStudio with Knitr saved me considerable time, because each table was automatically regenerated inside my document any time the code changed.

Which brings me to my major beef with Stata: where’s the equivalent of Knitr? Enter texdoc. This is a Stata package that allows you to write LaTex (the markdown language used to format papers for publication) and Stata code within the same document. This means you can write a report, format it, and run the Stata analysis all in one place, no copying and pasting needed. So…

What You Need:

  1. texdoc and sjlatex Stata packages
  2. Notepad++ text editor
  3. A distribution of LaTex (I used MikTex v. 2.9)

Step 1: Install texdoc and sjlatex

First, to get Stata to allow LaTex code inside your .do files, install texdoc by typing ssc install texdoc into the Stata command line. Then consult the texdoc help file and this paper by Ben Jann for how to include LaTex code inside your .do files.

Next, in order to get LaTex to properly read your Stata output, install sjlatex. Instructions are available here for installing sjlatex and getting your installation of MikTex to find it.

Note: the file “stata.sty” included in the sjlatex package is essential for telling MikTex how to format Stata output. I’m sure there is a more elegant way to do this, but I had to put that file into my LaTex project’s working directory, i.e. the folder where the LaTex pdf files are generated, in order to get MikTex to recognize it.

Now play around with writing LaTex and Stata code, placing LaTex code inside /*tex and tex*/ tags. This will allow you to write a document complete with a LaTex header, sections of text, and a bibliography, while spitting out your Stata output from within the same file.

texdocexample

As you can see above, my LaTex header is treated as a comment (shout-out to Mani at UIUC for his primer on LaTex). So Stata ignores the LaTex, then produces a separate .tex file which you can run MikTex on to produce the final formatted document.

End of story?

Unfortunately no. If you try this out for yourself, you’ll find a few flaws in the workflow, mainly stemming from the limitations of Stata’s native .do file editor. It is just not set up for writing an entire document. It doesn’t have spell-check, it doesn’t wrap text (so a paragraph is one long line), and it will definitely not help you with your LaTex syntax.

So it’s time to ante up and use a real text editor to work with the .texdoc files you’ll be writing with this package. There are two very good options for this task: SublimeText and Notepad++. You can check out how to use SublimeText with Stata here, but I’ll be focusing on Notepad++ because I have a bias for open-source tools, and I already had it installed when I was working this out.

Step 2: Configure Notepad++ to work with Stata

Install Notepad++, then follow the instructions here to install Freidrich Huebler’s extension rundolines. This will allow you to write Stata code in Notepad++ then execute it in Stata.

Note: This requires some fussing with the code in the programs Huebler provides. Make sure you get the file path to Stata entered correctly, and edit the code so it refers to your version of Stata. I futzed with this for a while before realizing the code pointed to Stata 14.0 and my version is 14.1.

Next, to get Notepad++ to recognize Stata commands and provide syntax highlighting, follow these instructions from Konstantin Golyaev to set Stata code as a user-defined language.

notepadlanguages

Now you can choose Stata as one of the languages. Note that Tex comes pre-installed under “T” in the menu pictured above, so you can toggle between the two languages as you write.

Step 3: Configure Notepad++ to work with LaTex

John Bruer has thorough instructions here for setting up Notepad++ so that you can run LaTex to generate documents and even search back and forth between the final document and the code that produced it.

Note on references: The code in Bruer’s instructions above uses Bibtex to generate references. If you prefer Biber (which is more recent and has more options) you’ll need to substitute biber.exe for bibtex.exe in the pdf_latex.bat file. And again, pay close attention to the paths to the various programs that are being called.

Step 4: Put it all together

Now that Notepad++, Stata and LaTex can all talk to each other, it’s just a matter of settling on a workflow that works for you. I tend to keep three files going in Notepad++ at a time: the .texdoc file, the .tex file, and a master .do file that gets everything started. The master do file just has a few lines of code like this:

clear
cd “example working directory”
set more off
texdoc do example.texdoc
texdoc strip example.texdoc example.do, replace

This sets the working directory, initiates the .texdoc file, and creates a separate .do file with just the Stata code, in case I want to look at or share the code without all the LaTex stuff.

So to run the whole thing, I execute the master .do file, which runs all the code in the .texdoc file, generating both my stripped .do file and a .tex file in the process.

notepaddomaster

Then I click over to the .tex file’s tab and run MikTex using the pdflatex_build command (which I’ve set as keyboard shortcut F8), and there it is: a nicely formatted pdf with paragraphs of text and Stata-generated tables all included.

notepadtex

So that’s that! Using texdoc with Notepad++ you can write reproducible papers and reports and look like a boss doing it. If anyone reading this has any additional improvements or modifications they’ve made, please share them.

 

 

Growing up my heroes were martial. Flying aces, squadron commanders, generals, fighter pilots. Sergeant York, General Patton, Ulysses S. Grant, Hannibal of Carthage, Sun Tzu. The ones I dreamed about most flew planes, steely-eyed men wedded to sleek flying machines dealing death from the air. I had a profusion of inner effigies, models of me at war, reflected back by the pictures in books about dog-fights and bombing runs.

I was in the woods when we declared war on Iraq.

Click here to continue reading at Curator Magazine

They killed the dogs last night. Gunshots and panicked yelps then—for the first time in two months—silence. Now I’m walking two blocks toward the river on the way to the barbershop and there are corpses piled in heaps on the curb awaiting removal.

Calo is unconcerned. He is singing the praises of the neighborhood barber. My hair is thick and shaggy, while Calo’s is buzzed tight; his dense Dominican curls smooth against his head.

“He will make you…zzzt,” he runs his fingers across his scalp, “so good, so cool.”

Dog tongues loll out of dog mouths. The flies, used to the meager pickings on discarded mango pits, are feasting.

“Que…” I search for the right question, “Que es esto?” “What is this?” As if some thing has been here, some single beast, slouching toward the river to die.

Click here to continue reading at Curator Magazine

  • In Thai, one word (tam), suffices for both “make” and “do.” The same is true for the Tajik kardan and the Spanish hacer. English is the only language I’ve yet learned that separates the idea of action from that of creation.
  • When Thais say they are eating, they say they are eating rice. When they say they are hungry, they say they are hungry for rice, whether they plan to eat rice or not. Rice is food. The real food. This linguistic association of the staple with the very concept of food is common. Congolese will often say they have not eaten today if they have not yet eaten manioc.

continue reading at Curator Magazine.

If there is an Oscar for the category, “best glorification of the life of the mind” then Hannah Arendt deserves it. Rarely have the classroom and the writing desk glowed with more fervor on-screen than in Margarethe Von Trotta’s biopic of the acclaimed Jewish political theorist.

It’s a winning presentation. Barbara Sukowa’s Arendt is a lantern-jawed hero of independent thought, steely-eyed in the face of criticism.

And that criticism is stiff, for Hannah Arendt chooses to center its drama around Arendt’s coverage of the Adolf Eichmann trial and the writing of the subsequent book, Eichmann in Jerusalema period in Arendt’s life when she was embroiled in controversy. The film makes much of this drama, reminding the viewers that what is now familiar in the history of ideas was once too hot to handle.

Click here to continue reading at Curator Magazine.

Graphic from infosthetics.com

As a follow-up to Eric Beinhocker’s The Origin of Wealth, I recently downloaded and read The Atlas of Economic Complexity by Ricardo Hausmann, Cesar Hidalgo et al. It was a good chaser after Beinhocker’s massive introduction to complexity economics. Hausmann and Hidalgo are influenced by the idea that the economy is a complex adaptive system. Therefore they reject the idea that you can easily sum up an economy in a single number like GDP. Instead, they try to analyze all the different products produced in the economy in an attempt to get a grasp on how complex it is rather than just how big it is in dollar terms. Their results are interesting.

Hausmann and Hidalgo assume that the economy is based on productive knowledge–bits of knowledge necessary to make the products that we consume. These units of productive knowledge they call capabilities. They also assume that many products have overlaps in the capabilities needed to make them. So if you make shirts, there is a high probability you can make blouses too. These relationships should show up in a visualization of the product space. Countries that makes shirts will show a tendency to produce products with overlapping capabilities: blouses, pants, etc.

Hausmann and Hidalgo calculate a country’s economic complexity by measuring the diversity of products a country is capable of producing, and by also calculating the ubiquity of the products they do produce. So if a country produces only a few products and those products are ubiquitous throughout the world it is pretty certain the country has a fairly non-complex economy. The amount of capabilities present in that economy must be pretty few. For example, here’s an infographic of the economy of Tajikistan:

Taj exportsAluminum, raw cotton and dried fruit dominate the Tajik economy. And each of these items are ubiquitous enough in the world that it does not take a high degree of scarce knowledge to produce them. On the other hand, here’s Thailand’s exports:

tree_map_export_tha_all_show_2010Notice the increase in the number of products, but also of the kinds of products produced. It takes many more capabilities to produce electronics than it does to produce raw cotton. Here the difference between an emerging economy like Thailand and an underdeveloped economy like Tajikistan is pretty stark.

The interesting thing about the measure of economic complexity is that Hausmann and Hidalgo have found it to be a strong indicator of future economic growth. The economies which are highly complex but with a lower-than-expected current GDP can be expected to grow quickly, while countries that have a high GDP relative to their complexity can be expected to grow slowly, if at all. This gives a new dimension to the “resource curse” hypothesis in that it displays growth based on natural resource exploitation is unsustainable, unless it is invested in expanding other productive capacities.

According to the Atlas of Economic Complexity, the economies whose level of complexity  most predict growth in GDP per capita are China, India and Thailand. Next in the rankings come Belarus, Muldova and Zimbabwe. All of these countries have economies which currently lag behind their potential.

Using GDP instead of GDP per capita, the top slots all go to Sub-Saharan Africa: Uganda, Kenya and Tanzania take the top slots, with Zimbabwe, Madagascar and Senegal following. Though their high levels of population growth keep income per capita down, these will all likely be fast-growing economies over the next decade.

The Atlas of Economic Complexity brings to life the incredible diversity within the world economy. It offers a new metric of development: the Economic Complexity Index, or ECI, which may prove to be a more important indicator than more simplistic metrics like GDP per capita. Time will tell how Hausmann and Ricardo’s predictions turn out. But their approach seems bound to be imitated as development theorists absorb and make use of the insights of complexity science.

For a brief introduction to economic complexity from Cesar Hidalgo himself, check out his talk at TEDx Boston:

And for more cool data visualizations visit the Observatory of Economic Complexity.