Problem set 5

Due by 11:59 PM on Monday, October 25, 2021

You’ll likely run into some errors when knitting with a modelsummary() table. That’s because the current version of the modelsummary package on CRAN doesn’t include support for robust standard errors from feols() models. You can install the latest version of modelsummary that does have support for robust standard errors by doing this:

  1. Install the remotes package using the Packages panel in RStudio
  2. Run this in your console to install the latest version of modelsummary directly from GitHub: remotes::install_github('vincentarelbundock/modelsummary')

For this problem set, you’ll reproduce the results from one of the papers that you looked at in your threats to validity assignment:

Rafael Di Tella and Ernesto Schargrodsky, “Do Police Reduce Crime? Estimates Using the Allocation of Police Forces After a Terrorist Attack,” American Economic Review 94, no. 1 (March 2004): 115–133, doi:10.1257/000282804322970733.

The full published paper is posted on iCollege under “Content > Validity assignment” (since you used the paper for that assignment). It’s not posted publicly here because of copyright reasons. The data comes from Di Tella and Schargrodsky’s data appendix available at their study’s AER webpage, and I’ve included it in the .zip file for the assignment.

This paper uses difference-in-differences to estimate the causal effect of increased policing on car thefts. Now that you know all about diff-in-diff, you can create their same results!

The answer key from Problem Set 4 (where you also did diff-in-diff) + this example page will be incredibly useful for you:

You’ll be doing all your R work in R Markdown. You can download a zipped file of a pre-made project here:

And as always, if you’re struggling, please talk to me. Work with classmates too (especially for this assignment!). Don’t suffer in silence!

Instructions

  1. If you’re using R on your own computer, download this file, unzip it, and double click on the file named problem-set-5.Rproj: problem-set-5.zip

    You’ll need to make sure you have these packages installed on your computer: tidyverse, haven, broom, fixest, and modelsummary. If you try to load one of those packages with library(tidyverse) or library(haven), etc., and R gives an error that the package is missing, use the “Packages” panel in RStudio to install it.

    (Alternatively, you can open the project named “Problem Set 5” on RStudio.cloud and complete the assignment in your browser without needing to install anything. This link should take you to the project—if it doesn’t, log in and look for the project named “Problem Set 5.”)

  2. Rename the R Markdown file named your-name_problem-set-5.Rmd to something that matches your name and open it in RStudio.

  3. Complete the tasks given in the R Markdown file. There are questions marked in bold. Your job is to answer those questions. You don’t need to put your answers in bold or ALL CAPS or anything, and you can remove the question text if you want.

    Fill out code in the empty chunks provided (you can definitely copy, paste, and adapt from other code in the document or the example page on diff-in-diff—don’t try to write everything from scratch!).

    You’ll need to insert your own code chunks. Rather than typing them by hand (that’s tedious!), use the “Insert” button at the top of the editing window, or press + + I on macOS, or ctrl + alt + I on Windows.

    Remember that you can run an entire chunk by clicking on the green play arrow in the top right corner of the chunk. You can also run lines of code line-by-line if you place your cursor on some R code and press + enter (for macOS users) or ctrl + enter (for Windows users).

    Make sure you run each chunk sequentially. If you run a chunk in the middle of the document without running previous ones, it might not work, since previous chunks might do things that later chunks depend on.

  4. When you’re all done, click on the “Knit” button at the top of the editing window and create an HTML or Word version (or PDF if you’ve installed tinytex) of your document. Upload that file to iCollege.