This entry will be the first in a series where we go through all of the Stata exercises in the World Bank’s excellent and free Handbook on Impact Evaluation: Quantitative Methods and Practices written by S. Khandker, G. Koolwal and H. Samad in 2009. The book can be downloaded for free here. The book has a series of chapters (11-16, in fact all of part 2) on Stata exercises designed to prepare the reader to conduct impact evaluations. To make this learning process more affordable this series will take you from installing R to estimating impacts using fuzzy regression discontinuity design. Go to part 1 of the book to read up on the theory and motivation for the techniques we will use in this series. The data files we will use can be downloaded from here.
Go ahead and extract these to a folder you will remember.
To install R go to cran.us.r-project and follow the instructions for your OS.
I highly recommend this environment for working with R. While R can be run completely from the command line, RStudio is much more user friendly and provides an easier transition for users coming from Stata. Go to RStudio and download this free R development environment.
Each of the following sections will follow chapters in the book. I will leave out the exposition and instead focus on the commands. I will present Stata commands first followed by the equivalent expression in R.
The book assumes you are using a PC, I’m using a Mac. They create several folders,
I recommend creating these as well except for the do
and log
folders.
PC:
c:\eval
c:\eval\data
OSX or Linux:
~/eval
~/eval/data
To avoid confusion I will present commands using *NIX style paths. In fact, we could make all of our path statements shorted in R by setting the working directory to the data folder:
setwd('~/eval/data')
I will use the full path in the following code, but if you set your working directory you can use the shorter versions. If you are using Windows use the folder structure above instead.
Stata:
use ~/eval/data/hh_98.dta
R:
library("foreign")
hh_98 = read.dta('~/eval/data/hh_98.dta')
Stata:
save hh_98, replace
R:
save(hh_98, file="~/eval/data/hh_98.RData")
Stata:
exit
R:
quit()
Stata:
exit, clear
R:
quit(save="no")
Even shorter R command:
q("no")
Stata:
help memory
R:
help(Memory)
Even shorter R command:
?Memory
Stata:
search mem
R:
??mem
Next time we will continue with Chapter 11 and begin Working with Data Files.
Quick Links
Legal Stuff
Social Media