Links to section notes and relevant files.

These notes (and I) owe a lot to previous GSIs for this class: Fiona Burlig, Kenny Bell, Patrick Baylis, and Dan Hammer.

Section 0: Setting up R

Install R, RStudio, and other relevant programs; resources for R; general suggestions for coding.

pdf

Section 1: Getting started with R

Learning the basics of R: installing and loading packages; loading various data types (haven and readr); basic data summarization and manipulation (introduction to dplyr).

pdf | R script | zip

Section 2: Matrix madness

Vectors, matrices, and general mathematical usage of R.

pdf | R script | zip

Section 3: Functions and loops

Writing your own (OLS) functions, using loops, and running simulations in R.

pdf | R script | zip

Section 4: FWL and model fit

Logical operators, optional arguments to your custom functions, Frisch-Waugh-Lovell (FWL) theorem, omitted variable bias, and measures of fit/overfitting.

pdf | R script | zip

Section 5: Inference and parallelization

Statistical inference via hypothesis testing: t tests and \(F\) tests. Plus simulation and parallelization.

pdf | R script | zip

Section 6: Figures with ggplot2

Creating informative and aesthetically figures using R’s ggplot2—scatter plots, histograms, density plots, and more.

pdf | R script | zip

Section 7: GLS and WLS

Generalized least squares (GLS), weighted least squares (WLS), and more simulations!

pdf | R script | zip

Section 8: OLS in asymptopia

OLS as \(N\) gets (very) big. Also: simulations, coding efficiency, and new ggplot2 techniques.

pdf | R script | zip

Section 9: Standard errors, Vol. I

Calculating standard errors via analytical methods and via the Delta Method. Includes linear and nonlinear combinations of parameters. Plus making prettier tables.

pdf | R script | zip

Section 10: Standard errors, Vol. II

Calculating standard errors in various situations: spherical errors, heteroskedastic errors, temporally correlated errors, spatially correlated errors, clustered errors.

pdf | R script | zip

Section 11: Instrumental variables

Instrumental variables (IV) and two-stage least squares (2SLS). Plus measurement error.

pdf | R script | zip

Section 12: Spatial data

Spatial data. Shapefiles, points data, maps, and—more generally—R as a GIS.

pdf | R script | zip

Section 13: Spatial data, continued

Spatial data. Rasters, geocoding, and mapping in R.

pdf | R script | zip

Section 14: Simultaneous-equation models

Simultaneous equations—theory, identification, estimation, and simulation.

pdf | R script | zip

Supplement 1: LaTeX and knitr

Introductions to and resources for LaTeX and knitr.

pdf