Publications by Thiemo Fetzer

R Function Binding Vectors and Matrices of Variable Length, bug fixed

19.08.2011

Now this is something very geeky, but useful. I had to bind two matrices or vectors together to become a bigger matrix. However, they need not have the same number of rows or even the same row names. The standard cbind() functions require the vectors or matrices to be compatible. The matching is “stupid”, in the sense that it ignores any orde...

1541 sym R (1062 sym/4 pcs)

Microfinance in India: Getting a sense of the geographic distribution

03.09.2011

I am working on a review paper on microfinance in India and use data from the MIX market. Today, I was amazed by how quick I conjured a map of India with the headquarters of the microfinance institutions that report data to the MIX market depicted on that map. Ideally, I would have more geolocation data – but this is hard to come by. But what w...

2017 sym R (369 sym/1 pcs) 2 img

Microfinance Map of India – another go…

30.09.2011

I gave it another go, trying to get a map that looks a bit nicer. This time, I tried to compute something like a density or intensity in a certain area. On the previous map, this was not visible very well. I used ggplot2 and a bit of R code, together with RGoogleMaps to produce the following picture: This map displays the intensity of microfinan...

1265 sym 2 img

Removing Multibyte Characters from Strings

29.01.2012

I was a bit annoyed by the error when loading a dataset that contains multi-byte characters. R basically just chokes on them. I have not really understood the intricacies of this, but it was basically just an annoyance and since I did not really use these characters in the strings containing them, I just wanted to remove them. The easiest solutio...

856 sym

R function: generate a panel data.table or data.frame to fill with data

25.10.2012

I have started to work with R and STATA together. I like running regressions in STATA, but I do graphs and setting up the dataset in R. R clearly has a strong comparative advantage here compared to STATA. I was writing a function that will give me a (balanced) panel-structure in R. It then simply works by joining in the additional data.tables or ...

1215 sym R (859 sym/2 pcs)

Computing Maritime Routes in R

25.03.2013

Thanks to the attention my paper on the cost of Somali piracy has received, a lot of people have approached me to ask how I computed the maritime routes. It is not a very difficult task using R. The key ingredient is a map of the world, that can be rasterized into a grid; all the landmass needs to be assigned an infinite cost of crossing and last...

2255 sym R (495 sym/5 pcs) 2 img

rgeos: TopologyException – found non-noded intersection between..

07.07.2013

I have been having some issues generating spatial unions and intersections using the rgeos package. The package is extremely powerful, as it serves as an R interface to the powerful GEOS engine. However, when working with shapefiles or polygons, quite often you will come across a whole range of errors, typically around topology exceptions. These...

1948 sym R (212 sym/2 pcs) 1 tbl

Classi-Compare of Raster Satellite Images – Before and After

13.08.2013

For my research on the effect of power outages on fertility , we study a period of extensive power rationing that lasted for almost a whole year and affected most of Latin America, but in particular, it affected Colombia. The key difficult was to determine which areas were exposed to the power-outage and the extent to which this was the case. Th...

2131 sym R (2729 sym/2 pcs)

Regressions with Multiple Fixed Effects – Comparing Stata and R

05.04.2014

In my paper on the impact of the recent fracking boom on local economic outcomes, I am estimating models with multiple fixed effects. These fixed effects are useful, because they take out, e.g. industry specific heterogeneity at the county level – or state specific time shocks. The models can take the form: y_{cist} = \alpha_{ci} + b_{st} + \g...

5101 sym R (64 sym/2 pcs) 16 img 1 tbl

Fracking and House Prices on the Marcellus Shale

21.04.2014

Starting last summer I worked on a short project that set out to estimate the potential costs of externalities due to unconventional shale gas production in the Marcellus shale on local house prices using a dataset of roughly 150,000 recently sold houses in Ohio, West Virginia and Pennsylvania. I stopped working on a project that looks at the im...

4168 sym R (311 sym/3 pcs) 8 img