Apply and Practice Activity

Blair Replication Set Up

Introduction

Starting with this Apply and Practice Activity, and continuing in several future Apply and Practice Activities, you are going to replicate the findings of an article by Blair, Judd and Chapleau and published in Psychological Science. The paper is available through Canvas in this Blair Replication Set Up Apply and Practice Activity Assignment. Please read the paper in the coming week.

Background

Before the mid-1970s, criminal courts possessed significant discretion in sentencing, resulting in well-documented racial disparities. Concerns about racial discrimination in the criminal justice system prompted the enactment of laws to limit judges’ discretion and ensure sentencing neutrality. These laws were put into place in many states across the U.S., including Florida, the context for the current study.

In 1979, the Florida Sentencing Study Committee found that ethnic-minority offenders were significantly more likely to receive prison sentences compared to White offenders. To address this bias, sentencing guidelines were implemented in 1983, and a statement of race neutrality in sentencing was added to the Florida Statutes. These guidelines divided noncapital felonies into 10 levels of offense severity, providing judges with a worksheet specifying appropriate sanctions based on the severity of the offense, prior offenses, and other relevant factors. In 1997, the Florida Department of Corrections conducted a study to assess whether race influenced sentencing decisions (prison vs. no prison) and the length of prison sentences for those sentenced to prison. The study concluded that race had no “meaningful” effect on decisions once relevant sentencing factors were taken into account. Therefore, the goal of racial equity, as explicit in the sentencing guidelines law, was deemed to have been met.

However, Blair and colleagues argued that a more subtle form of racial bias, known as “feature-based stereotyping,” might still influence sentencing decisions, even if race itself is not a direct factor. The authors argued that judges may avoid giving different sentences based on racial categories, but they might still be influenced by stereotypes associated with Afrocentric facial features. Afrocentric features encompass physical traits perceived as typical of African Americans, such as dark skin, wide nose, and full lips. Previous research revealed that within a racial category, individuals with more Afrocentric facial features were more likely to be stereotyped with traits associated with Black Americans compared to those with fewer Afrocentric features.

Stereotypes are shared beliefs about social groups that impact judgments through categorization. Afrocentric facial features can lead to feature-based stereotyping within and between racial groups. Unfortunately, people are often unaware of and unable to control feature-based stereotyping. Consequently, both Black and White offenders with more Afrocentric features could potentially receive harsher sentences than those with fewer Afrocentric features, even when legally relevant factors are taken into account. This hypothesis formed the basis for the Blair and colleagues’ paper that we will study.

Please follow the steps below to complete this activity.

Step by step directions

Step 1

Create a Posit Cloud Project.

Let’ set up a new Posit Cloud project. Log into your Posit Cloud account. First, exit out of the foundations project if necessary, and return to Your Workspace. Then, click on the New Project button, then choose New RStudio Project. At the top of the RStudio screen — where it says “Untitled Project” — click to provide the project a name. Call it blair_replication.

In the lower right quadrant of your RStudio session — under the Files tab — create three primary folders in your project.

  1. Right under the Files tab, there is a Folder icon with a green plus — click on this to create a new folder. Enter the folder name data. Click OK.

  2. Create a second folder using the same method — call this one documentation.

  3. Last, create a third folder using the same method — call this one programs.

Step 2

Upload the Blair files to the Posit Cloud blair_replication project.

On Canvas, for the Blair Replication Set Up Apply and Practice Activity Assignment, you were provided with two files (sentence.csv and sentence_codebook.xlsx). Copy these two files onto your desktop. Then upload these two files to folders specified below.

  1. Click on the data folder that you just created. Then, click the Upload button. A box will pop up. Under File to Upload, click Choose File and navigate to the file called sentence.csv. Then click OK. Now, the data frame that we will soon import to R exists in the data folder of your project.
  2. Click on the documentation folder that you just created. Then, click the Upload button. A box will pop up. Under File to Upload, click Choose File and navigate to the file called called sentence_codebook.xlsx. Then click OK.

Step 3

Now we’re ready to start a new Quarto document to perform our analysis (i.e., a Quarto analysis notebook). Click File -> New File -> Quarto Document. A dialog box will pop up — in it, give your new document a Title — Blair Replication Set. Up, then type your name (beside Author). Uncheck the box beside “Use visual markdown editor.” Then click Create Empty Document.

Once the file is created, click File -> Save As, then save your Quarto analysis notebook in the programs folder of the blair_replication project. Name it blair_replication_setup.qmd.

Step 4

Set up your YAML header

In your .qmd file just created, set up your YAML header as you like. You can leave it very simple (just as it is now with the basic set up) or you can explore a bit. Here’s a “go to” set up that I use — but you can modify it as you like. Just remember that all of the instructions must stay between the three dashed lines. The indentations for format: need to be precise — with one tab to begin html and two tabs to begin theme and embed-resources. You’ll get a warning/error notification if something isn’t right. Recall that Quarto has different themes for your report — here, I’ve selected united — but you can choose one you like by perusing the options here.

title: "Blair Replication Set Up"
author: "Kimberly L. Henry"
format: 
  html:
    theme: united
    embed-resources: true
df-print: paged
toc: true
editor: source

Step 5

Install the packages that we will need for this project. Copy and paste the code below into the Console of your RStudio session. The Console is in the lower left quadrant of RStudio. Paste the code right after the > prompt. Click the Return or Enter button on your computer and these will install. Installation will take a few minutes.

packages <- c(
  "tidyverse", "here", "skimr", "scales", "modelr", "labelled", "lubridate", "broom", "performance",
  "viridis", "viridisLite", "RColorBrewer", "ggrepel", "infer", "boot", "gt",
  "ggthemes", "ggtext", "ggdist", "patchwork", "gtsummary", "moderndive", "sjPlot", "modelsummary", 
  "stringr", "pander", "knitr", "GGally", 
  "rvest", "tidymodels", "vip", "purrr",
  "marginaleffects"
)

install.packages(setdiff(packages, rownames(installed.packages())))  

Step 6

Load packages.

Now we need to load the packages that are needed for the first part of this project. Create a first level header called

# Load packages

Then insert a code chunk and load the following packages into the current session.

library(gt)
library(gtsummary)
library(here) 
library(skimr)
library(broom)
library(modelr)
library(labelled)
library(tidyverse)

Once entered, click run on the Load packages code chunk. Now, the packages are ready for you to use.

Step 7

Create a first level header

# Import data

Insert a code chunk, then import the sentence.csv data frame that you just put in your data folder. Call the data frame df().

df <- read_csv(here("data", "sentence.csv"))

Here’s a description of the variables in the data frame:

variable_name label notes
id inmate ID NA
years sentence length in years NA
black race (1 = black, 0 = white) NA
afro rating for afrocentric features inmate photo rated by ~35 CU undergraduate students; raters assigned a single, global assessment of the degree to which each face had features that are typical of African Americans, using a scale from 1 (not at all) to 9 (very much)
primlev seriousness of primary offense based on Florida’s rating system, higher numbers indicate more serious felonies
seclev seriousness of secondary offense based on Florida’s rating system, higher numbers indicate more serious felonies
nsecond number of secondary offenses NA
anysec indicator for any secondary offenses (1 = yes, 0 = no) NA
priorlev seriousness of prior offenses based on Florida’s rating system, higher numbers indicate more serious felonies
nprior number of prior offenses NA
anyprior indicator for any prior offenses (1 = yes, 0 = no) NA
attract rating for attractiveness inmate photo rated by ~35 CU undergraduate students
babyface rating for babyface features inmate photo rated by ~35 CU undergraduate students

Step 8

Create a first level header

# Describe variables

Insert a code chunk, then use the skim() function to describe the variables (i.e., df |> skim()). Take a moment to examine the descriptive statistics. Match the variables up with the description of variables above. Write a few of sentences to describe the descriptive statistics — focus on the variables sentence length in years (years) and afrocentric features (afro). Describe what the variables represent in your own words and describe the descriptive statistics in sentence form. Put these sentences in the white space of your analysis notebook underneath the skim() output.

Step 9

Now that your new Posit Cloud Project is set up, perform the following tasks to share your new blair_replication Posit Cloud Project with your GTA:

  1. At the top of the RStudio screen click on the gear (it’s beside the icon that shows you how much Ram you are using).

  2. Click on Access.

  3. Change Access to All Posit Cloud Users. This will change permissions for just this project.

  4. Copy the address in the address bar, and then submit it as a URL for the Blair Replication Set Up Apply and Practice Activity.

Step 10

Now that you’ve completed all tasks, to help ensure reproducibility, click the down arrow beside the Run button toward the top of your screen then click Restart R and Clear Output. Scroll through your notebook and see that all of the output is now gone. Now, click the down arrow beside the Run button again, then click Restart R and Run All Chunks. Scroll through the file and make sure that everything ran as you would expect. You will find a red bar on the side of a code chunk if an error has occurred. Taking this step ensures that all code chunks are running from top to bottom, in the intended sequence, and producing output that will be reproduced the next time you work on this project.

Now that all code chunks are working as you’d like, click Render. This will create an .html output of your report. Scroll through to make sure everything is correct. The .html output file will be saved along side the corresponding .qmd notebook file.