Statistical analysis of monthly background checks of gun purchases for the New York Times story What Drives Gun Sales: Terrorism, Obama and Calls for Restrictions.
This script uses the R package seasonal for the seasonal adjustments, which itself uses a program called X-13ARIMA-SEATS. Binaries for this program are available for Windows only, but there is a very helpful compilation guide for Mac OS X. If that doesn't work, try downloading the program from here.
You can either open main.R
in RStudio and run it line by line or run the entire script as a whole on the command-line:
$ R --no-save < main.R
The script creates the PDF plots and CSV files in the out/
folder.
For more explanation of what the script is doing, please read through the comments in main.R.
The source data comes from the FBI's National Instant Criminal Background Check System, and was converted from the original PDF format to CSV using Tabula.
BuzzFeed also released the same dataset on Github last week.
To convert background checks into estimated sales, we relied on a method suggested in the Small Arms Survey by Jurgen Brauer, a professor at Georgia Regents University. Each long gun and handgun check was counted as 1.1 sales. Each multiple-gun check was counted as two sales. Permit checks and other types of checks were omitted. The multiplier is an estimate based on Mr. Brauer's interviews with gun shop owners.
Note: In our computation, we excluded background checks for the "multiple" category in California because they followed an unusual pattern that did not match California gun sales data.