Statistics and Statistical Programming (Fall 2020)/pset3: Difference between revisions
No edit summary |
Nickmvincent (talk | contribs) |
||
Line 34: | Line 34: | ||
Here's a suggestion for how you might approach this: | Here's a suggestion for how you might approach this: | ||
* (1) Create a new data frame (or tibble) that aggregates stop and search data across sub-groups of `subject_race` per month. This object could include the following columns: | |||
** (a) date as a month/year (should be a date or date-time object) | |||
** (b) race/ethnicity (from the `subject_race` variable) | |||
** (c) number of stops (within the group identified in column b) | |||
** (d) number of searches (within the group identified in column b) | |||
** (e) total number of searches that month/year | |||
** (f) proportion of total searches (within the group identified in column b). (''Note that this will result in a data frame with multiple rows per month/year (as many as one row for each `subject_race` category)''). | |||
* (2) Use `ggplot2` and the [https://ggplot2.tidyverse.org/reference/geom_path.html `geom_line`] layer to generate each of the plots. Note that you'll want to assign `subject_race` as an aesthetic element (`aes`) for some of the plots so that ggplot2 represents each category as a separate line (maybe distinguished by color?). Make sure to incorporate useful titles, axis labels, and legends for each plot you produce. Recall that the R tutorials include examples of using `aes` with `ggplot2`. | |||
=== PC6. Calculate baseline population proportions for relevant race/ethnicity categories === | === PC6. Calculate baseline population proportions for relevant race/ethnicity categories === |
Revision as of 15:49, 6 October 2020
Do police in the United States engage in discriminatory behavior on the basis of race and ethnicity? For this problem set, you will investigate the relationship between traffic stops, vehicle searches and driver attributes (especially race as recorded by police officers conducting traffic stops). Doing so will involve some more advanced data wrangling, visualization, and analysis. We'll use data from The Stanford Open Policing Project (SOPP) that looks at records of traffic stops in Illinois between 2012-2017. The full SOPP dataset for Illinois is about 12 million rows, so I've created a 1% random sample for us to work with here. Overall, the dataset is well-documented and pretty "clean," but there are still a number of features that may be confusing, weird, and/or ill-organized to help answer the questions I've asked you below. Thank goodness you know how to use R to address these issues...
Programming Challenges
PC1. Learn about the data
Review the project overview on the SOPP homepage, the overview of the data, the description of the standardized data, the codebook/notes for the Illinois data from the data_readme.md, as well as any other ancillary materials that you can find that seem likely to help you get oriented with the data.
For the questions below we'll focus on the following measures recorded for each traffic stop in Illinois 2012-2017: `date`, `vehicle_year`, `subject_race`, `subject_sex`, and `search_conducted`.
Record any questions or issues you might notice related to these measures as you review the information about the project and dataset.
PC2. Import, explore, clean
As I mentioned above, the full IL SOPP dataset is over 12 million rows, so I have created a random 1% subset for us to work with in this assignment. That subset lives here (and it's about 26MB). To get started, you'll want to import the data and explore its structure as well as key variables that we'll be focusing on in this analysis (`date`, `vehicle_year`, `subject_race`, `subject_sex`, and `search_conducted`). Inspect a random sample of rows to get a sense of the data. What (if anything) is missing? You may also want to clean/recode some of the key variables. Make sure to explain and justify any data cleanup and/or recoding steps you decide to take.
PC3. Summarize outcome and predictor variables
Calculate and report appropriate summary statistics for the outcome (`search_conducted`) and each of the predictor variables we care about (`date`, `vehicle_year`, `subject_race`, `subject_sex`). Include visual and/or tabular summaries where appropriate. Attempt, when possible, to write efficient/elegant code that avoids unnecessary repetition while also retaining clarity.
PC4. Summarize aggregate relationships between outcome and predictor variables
The outcome variable we care about here is a dichotomous indicator for whether each traffic stop resulted in a police search (of either the driver or the vehicle) being conducted. Summarize the relationship between each of the predictor variables (`date`, `vehicle_year`, `subject_race`, and `subject_sex`) and the outcome variable. For continuous predictors, be sure to include visual summaries. For categorical predictors, focus on providing cross-tabulations that report conditional summary statistics within groups (for example, compare the numbers of searches conducted across the two categories of `subject_sex`).
PC5. Analyze relationships between driver race/ethnicity and vehicle searches over time
Summarize the relationship between the recorded `subject_race` for each traffic stop and the `search_conducted` outcome over the time period covered by the dataset. You may do this in a variety of ways, but at minimum, you should produce the following:
- A plot of the number of stops and searches across the entire sample within each month.
- A plot of the number of stops within each `subject_race` category each month.
- A plot of the number of searches within each `subject_race` category each month.
- A plot of the proportion all searches accounted for within each `subject_race` category each month.
Here's a suggestion for how you might approach this:
- (1) Create a new data frame (or tibble) that aggregates stop and search data across sub-groups of `subject_race` per month. This object could include the following columns:
- (a) date as a month/year (should be a date or date-time object)
- (b) race/ethnicity (from the `subject_race` variable)
- (c) number of stops (within the group identified in column b)
- (d) number of searches (within the group identified in column b)
- (e) total number of searches that month/year
- (f) proportion of total searches (within the group identified in column b). (Note that this will result in a data frame with multiple rows per month/year (as many as one row for each `subject_race` category)).
- (2) Use `ggplot2` and the `geom_line` layer to generate each of the plots. Note that you'll want to assign `subject_race` as an aesthetic element (`aes`) for some of the plots so that ggplot2 represents each category as a separate line (maybe distinguished by color?). Make sure to incorporate useful titles, axis labels, and legends for each plot you produce. Recall that the R tutorials include examples of using `aes` with `ggplot2`.
PC6. Calculate baseline population proportions for relevant race/ethnicity categories
To help interpret the results of the foregoing analysis of the traffic stop data, we should calculate some baseline population proportions of the same race/ethnicity categories in the state of Illinois around the same time that the SOPP data comes from. Luckily, we have access to exactly the data we need to do this via our old friend, the `openintro` library!
Use the `county_complete` dataset from the `openintro` library to calculate the proportions of the Illinois population in 2010 in each of the categories identified in the `subject_race` variable of the traffic stop dataset. Be sure to note and justify any assumptions and/or recoding decisions that you make along the way.
Statistical Questions
SQ1. Interpret the Illinois traffic stop analysis (PCs 3-5)
Return to the questions that motivated this analysis. Based on your results from PCs 3-5, what patterns do you observe in vehicle searches among Illinois drivers between 2012-2017? Specifically, what patterns do you note from your comparisons of stops and searches across the categories identified in the `subject_race` variable? What patterns do you observe when you compare across groups in aggregate (i.e., summed across the entire dataset)? What patterns do you observe in terms of either the numbers or proportions of stops and searches when you compare across groups over time?
SQ2. Contextualize traffic stop data in relation to population data
Consider the results of PCs 3-5 in relation to the results of PC 6. Do the results of PC 6 impact your interpretation of PCs 3-5 in any way? How do you relate the results of the traffic stop and vehicle search analysis to the population baseline proportions?
SQ3. Reflect on the limitations and possible extensions of your analysis
Identify and briefly explain key limitations of the data, your analysis, and the results in relation to the questions and concepts that motivated the exercise. Where possible, what additional information/data or analysis might you suggest in order to overcome these limitations and answer the questions in a more comprehensive or convincing fashion?