HomeContact
Archive
Impact Evaluation on a Budget: World Bank Data and R
Jon Page
September 28, 2013
2 min

Table Of Contents

01
Introduction
02
Install R
03
Install R-Studio
04
Overview
05
File Structure
06
Opening a Data Set
07
Save a Data Set
08
Exit the Program
09
Help
10
Conclusion

Introduction

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.

Install R

To install R go to cran.us.r-project and follow the instructions for your OS.

Install R-Studio

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.

Overview

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.

File Structure

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.

Opening a Data Set

Stata:

use ~/eval/data/hh_98.dta

R:

library("foreign")
hh_98 = read.dta('~/eval/data/hh_98.dta')

Save a Data Set

Stata:

save hh_98, replace

R:

save(hh_98, file="~/eval/data/hh_98.RData")

Exit the Program

With prompt to save

Stata:

exit

R:

quit()

Reckless (or confident) version

Stata:

exit, clear

R:

quit(save="no")

Even shorter R command:

q("no")

Help

Strict command requiring the correct command or keyword to be used

Stata:

help memory

R:

help(Memory)

Even shorter R command:

?Memory

Stata:

search mem

R:

??mem

Conclusion

Next time we will continue with Chapter 11 and begin Working with Data Files.


Tags

#r#stata#world-bank-data

Related Posts

R for Impact Evaluation: R and Stata Side-by-side
November 26, 2013
3 min
© 2022, All Rights Reserved.

Quick Links

About UsContact Us

Social Media