MengLeZhang / crimeMaps-preReg-code

Code used in the protocol for the estimating the effect of crime maps project (https://osf.io/preprints/socarxiv/9zupw/)
0 stars 1 forks source link

Code for Estimating the Effects of Crime Maps (Pre-Registration/Protocol)

Code used in the protocol for the estimating the effect of crime maps project (https://osf.io/preprints/socarxiv/9zupw/). Include code for the supplementary materials.

How to use

The steps are:

  1. Set up the directory structure
  2. Download the raw data public domain data
  3. Run R scripts

Tested under R.4.0.3 and windows 10. Test machine has an i7-4770 CPU with 16GB RAM.M

Folder structure

File directory structure is this:

master folder /// for data and code |-> \code folder //// this folder |-> \code folder\saved cleaned data /// find cleaned outputs here |-> \data /// raw data folder; see data sources

Data sources

The raw data coomes from:

Code to replicate

Run 00-utils.R first to load in dependencies and check file paths. All file paths are relative (to this folder).

The scripts need to create the inferred list of snap points (South Yorkshire only):

To create the inferred list of snaps for the whole of England and Wales comment out lines in 00-utils and makeFile01. See code comments.

To recreate the analysis in supplement, run these additional scripts: