The scripts in this repository can be used to reproduce the results in Mid-quantile mixed graphical models with an application to mass public shootings in the United States by L. Merlo, M. Geraci and L. Petrella.
The code has been parallelized using the following packages:
foreachparalleldoParallel
The post-processed dataset is included in the excel file Mass_Shootings.xlsx in the data folder. The raw data (version 7 - Updated June 2023) can be freely downloaded at www.theviolenceproject.org/mass-shooter-database.The codebook can be found in the main body of the text and more detailed information can be found at www.theviolenceproject.org.
This script contains the functions to run the R scripts in this repository. The main functions are:
QMGMallows to fit the proposed mid-quantile mixed graphical model (QMGM).fit.catallows to estimate the regression parameters of a LASSO-penalized mid-quantile regression.midCDF_estallows to estimate the conditional mid-CDF.
Preliminary step to clean the data and provide a suitable format for the analysis. This script can be used to reproduce Table 1 and Figure 2 of the paper.
- Table 1: Summary statistics of the variables in the sample.
- Figure 2: Number of fatalities per year and number of shootings per year.
This script can be used to reproduce Figures 3 and 4 of the paper.
- Figure 3: Estimated network structures from QMGM7 and MGM.
- Figure 4: Local centrality measures for the MGM and QMGM7 estimated networks.
- Open the
Mass_Shootings_ave.Rscript in RStudio. - At line 75-77, select the grid of quantiles
tau. - Run the script.