Main content

Home

Menu

Loading wiki pages...

View
Wiki Version:
# Crime and COVID-19: Effect of changes in routine activities in Mexico City This project contains the data, materials and publications for a study on the effects of COVID-19-related changes in routine activities on crime in Mexico City, published in Crime Science: - Estévez-Soto, P.R. (2021) Crime and COVID-19: effect of changes in routine activities in Mexico City. *Crime Science*, 10, 15. DOI:[10.1186/s40163-021-00151-y](https://doi.org/10.1186/s40163-021-00151-y) ## Replication The code used in the analysis is contained in the Rmarkdown file: `covid-final-models.Rmd`. The code should run on any modern computer. The file `covid-final-models.pdf` was rendered directly from the Rmarkdown document, and contains the results for all the analyses carried out for the study (however, rendering Rmarkdown requires pandoc and LaTeX, in addition to the rmarkdown R package). The code was run on R 4.0.0 and requires a number of packages beyond base R. These are: - `tidyverse` - `ggthemes` - `knitr` - `tseries` - `fable` - `tseries` - `feasts` - `future` - `cowplot` - `scales` Additionally, the development package `victim` must be installed as well. This can be installed using devtools: `devtools::install_github("prestevez/victim")`. ## Data The data used in the script is available in `data/daily_crime_mobility-2020-07-13.csv`. The 'raw' data are found in `data/`, while the `data_preparation.R` script contains the code used to transform it into daily time series. ## Using docker for replication As the analysis depends on a variety of packages, some of which are in active development, efforts to replicate the analyses contained in the Rmarkdown file can fail if packages with different versions are used. To ensure reproducibility, a [docker](https://docs.docker.com/get-docker/) image is provided in the file `10.17605-OSF.IO-4K9DS.tar.gz`. Docker is a virtualization software that allows running isolated lightweight "virtual machines" called containers. The image in the tar.gz file provided contains a versioned snapshot of the machine used to conduct this study, with all the software and dependencies "frozen" in the versions that were used at the time of the study. Thus, when the `covid-final-models.Rmd` file is rendered using the provided image, there should be no errors due to incompatible, outdated or updated software. The pdf file `covid-final-models.pdf` was rendered using this docker image. To render this file using docker you must first have docker installed and properly set up (see [docker's documentation](https://docs.docker.com/get-started/)). Then download the [`10.17605-OSF.IO-4K9DS.tar.gz`](https://osf.io/htr2j/) file and load it into docker with the following command using a terminal. ```bash # navigate to the directory where # you downloaded the tar file and run: docker load < 10.17605-OSF.IO-4K9DS.tar.gz ``` You can verify that the image was successfully loaded by running: ``` docker image ls ``` You should see an image named `prestevez/r-pres:0.01`. Then, in a clean directory download the files `covid-final-models.Rmd` and `render-pdf-docker.sh` and run the following commands: ``` # make the file executable chmod +x render-pdf-docker.sh # render the pdf using docker ./render-pdf-docker.sh ``` (Alternatively, the command contained in the `render-pdf-docker.sh` file can be copied and pasted to the terminal.) The terminal will display the progress of the rmarkdown rendering process. **Do not close the terminal window** until the process is complete. The process should output a PDF file with the results and it should be identical to the PDF file `covid-final-models.pdf` in the project repository. **Potential bug**: There may be a potential bug in which the final step of the rendering process (building a pdf using latex) is not completed due to a missing dependency in the TeX installation. If this happens, the `covid-final-models.md` or `covid-final-models.tex` contain the results and they can be transformed into pdfs using [pandoc](https://pandoc.org/) or [LaTeX](https://www.latex-project.org/get/), respectively. ## Extending the analysis To extend the analysis to new, more recent data, download the new data sets from [Mexico City's open data portal](https://datos.cdmx.gob.mx/pages/home/) and change the names of the respective new files in the `data_preparation.R`script. The data sets needed are: - *Carpetas de investigación de la PGJ* - *Línea mujeres* - *Afluencia diaria metro* - *Afluencia diaria metrobús* - *Afluencia preliminar en transporte público* Running the data preparation script should create a new `daily_crime_mobility` file that could be used to run new analyses using `covid-final-models.Rmd`.
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.